[Kstars-devel] KDE/kdeedu/kstars/kstars
Jason Harris
kstars at 30doradus.org
Tue Apr 17 09:15:48 CEST 2007
SVN commit 654880 by harris:
Action fixes: we can no longer refer to actions with sender()->objectName()
Instead, you can query action names like so:
if ( sender() == actionCollection()->action("actionNameString")
Thanks, Jasem, for reminding me about this (this fixes the
non-functional toolbar buttons, as well as some menu actions)
CCMAIL: kstars-devel at kde.org
M +8 -7 fovdialog.cpp
M +23 -24 kstarsactions.cpp
M +2 -1 opscatalog.cpp
M +2 -1 opssolarsystem.cpp
--- trunk/KDE/kdeedu/kstars/kstars/fovdialog.cpp #654879:654880
@@ -25,6 +25,7 @@
#include <QTextStream>
#include <QPaintEvent>
+#include <kactioncollection.h>
#include <klocale.h>
#include <kdebug.h>
#include <kpushbutton.h>
@@ -250,16 +251,16 @@
}
void NewFOV::slotComputeFOV() {
- //DEBUG
- kDebug() << ":" << sender()->objectName() << ":" << endl;
- if ( sender()->objectName() == QString( "ComputeEyeFOV" ) ) kDebug() << "A" << endl;
- if ( sender()->objectName() == QString( "ComputeEyeFOV" ) && ui->TLength1->value() > 0.0 ) kDebug() << "B" << endl;
+ KStars *ks = (KStars*)(parent()->parent());
- if ( sender()->objectName() == QString( "ComputeEyeFOV" ) && ui->TLength1->value() > 0.0 )
+ if ( sender() == ks->actionCollection()->action( "ComputeEyeFOV" ) ) kDebug() << "A" << endl;
+ if ( sender() == ks->actionCollection()->action( "ComputeEyeFOV" ) && ui->TLength1->value() > 0.0 ) kDebug() << "B" << endl;
+
+ if ( sender() == ks->actionCollection()->action( "ComputeEyeFOV" ) && ui->TLength1->value() > 0.0 )
ui->FOVEdit->setText( KGlobal::locale()->formatNumber( ui->EyeFOV->value() * ui->EyeLength->value() / ui->TLength1->value() ) );
- else if ( sender()->objectName() == QString( "ComputeCameraFOV" ) && ui->TLength2->value() > 0.0 )
+ else if ( sender() == ks->actionCollection()->action( "ComputeCameraFOV" ) && ui->TLength2->value() > 0.0 )
ui->FOVEdit->setText( KGlobal::locale()->formatNumber( ui->ChipSize->value() * 3438.0 / ui->TLength2->value() ) );
- else if ( sender()->objectName() == QString( "ComputeHPBW" ) && ui->RTDiameter->value() > 0.0 && ui->WaveLength->value() > 0.0 ) {
+ else if ( sender() == ks->actionCollection()->action( "ComputeHPBW" ) && ui->RTDiameter->value() > 0.0 && ui->WaveLength->value() > 0.0 ) {
ui->FOVEdit->setText( KGlobal::locale()->formatNumber( 34.34 * 1.2 * ui->WaveLength->value() / ui->RTDiameter->value() ) );
// Beam width for an antenna is usually a circle on the sky.
ui->ShapeBox->setCurrentIndex(4);
--- trunk/KDE/kdeedu/kstars/kstars/kstarsactions.cpp #654879:654880
@@ -98,23 +98,23 @@
void KStars::slotViewToolBar() {
KToggleAction *a = (KToggleAction*)sender();
- if ( a->objectName() == QString( "show_stars" ) ) {
+ if ( a == actionCollection()->action( "show_stars" ) ) {
Options::setShowStars( a->isChecked() );
- } else if ( a->objectName() == QString( "show_deepsky" ) ) {
+ } else if ( a == actionCollection()->action( "show_deepsky" ) ) {
Options::setShowDeepSky( a->isChecked() );
- } else if ( a->objectName() == QString( "show_planets" ) ) {
+ } else if ( a == actionCollection()->action( "show_planets" ) ) {
Options::setShowPlanets( a->isChecked() );
- } else if ( a->objectName() == QString( "show_clines" ) ) {
+ } else if ( a == actionCollection()->action( "show_clines" ) ) {
Options::setShowCLines( a->isChecked() );
- } else if ( a->objectName() == QString( "show_cnames" ) ) {
+ } else if ( a == actionCollection()->action( "show_cnames" ) ) {
Options::setShowCNames( a->isChecked() );
- } else if ( a->objectName() == QString( "show_cbounds" ) ) {
+ } else if ( a == actionCollection()->action( "show_cbounds" ) ) {
Options::setShowCBounds( a->isChecked() );
- } else if ( a->objectName() == QString( "show_mw" ) ) {
+ } else if ( a == actionCollection()->action( "show_mw" ) ) {
Options::setShowMilkyWay( a->isChecked() );
- } else if ( a->objectName() == QString( "show_grid" ) ) {
+ } else if ( a == actionCollection()->action( "show_grid" ) ) {
Options::setShowGrid( a->isChecked() );
- } else if ( a->objectName() == QString( "show_horizon" ) ) {
+ } else if ( a == actionCollection()->action( "show_horizon" ) ) {
Options::setShowGround( a->isChecked() );
}
@@ -640,17 +640,16 @@
//Pointing
void KStars::slotPointFocus() {
- QString sentFrom( sender()->objectName() );
- if ( sentFrom == "zenith" )
+ if ( sender() == actionCollection()->action("zenith") )
map()->invokeKey( Qt::Key_Z );
- else if ( sentFrom == "north" )
+ else if ( sender() == actionCollection()->action("north") )
map()->invokeKey( Qt::Key_N );
- else if ( sentFrom == "east" )
+ else if ( sender() == actionCollection()->action("east") )
map()->invokeKey( Qt::Key_E );
- else if ( sentFrom == "south" )
+ else if ( sender() == actionCollection()->action("south") )
map()->invokeKey( Qt::Key_S );
- else if ( sentFrom == "west" )
+ else if ( sender() == actionCollection()->action("west") )
map()->invokeKey( Qt::Key_W );
}
@@ -970,25 +969,25 @@
//toggle display of GUI Items on/off
void KStars::slotShowGUIItem( bool show ) {
//Toolbars
- if ( sender()->objectName() == QString( "show_mainToolBar" ) ) {
+ if ( sender() == actionCollection()->action( "show_mainToolBar" ) ) {
Options::setShowMainToolBar( show );
if ( show ) toolBar("kstarsToolBar")->show();
else toolBar("kstarsToolBar")->hide();
}
- if ( sender()->objectName() == QString( "show_viewToolBar" ) ) {
+ if ( sender() == actionCollection()->action( "show_viewToolBar" ) ) {
Options::setShowViewToolBar( show );
if ( show ) toolBar( "viewToolBar" )->show();
else toolBar( "viewToolBar" )->hide();
}
- if ( sender()->objectName() == QString( "show_statusBar" ) ) {
+ if ( sender() == actionCollection()->action( "show_statusBar" ) ) {
Options::setShowStatusBar( show );
if ( show ) statusBar()->show();
else statusBar()->hide();
}
- if ( sender()->objectName() == QString( "show_sbAzAlt" ) ) {
+ if ( sender() == actionCollection()->action( "show_sbAzAlt" ) ) {
Options::setShowAltAzField( show );
if ( show ) {
//To preserve the order (AzAlt before RADec), we have to remove
@@ -1011,7 +1010,7 @@
}
}
- if ( sender()->objectName() == QString( "show_sbRADec" ) ) {
+ if ( sender() == actionCollection()->action( "show_sbRADec" ) ) {
Options::setShowRADecField( show );
if ( show ) {
QString s = "000d 00m 00s, +00d 00\' 00\""; //only need this to set the width
@@ -1027,13 +1026,13 @@
//InfoBoxes: we only change options here; these are also connected to slots in
//InfoBoxes that actually toggle the display.
- if ( sender()->objectName() == QString( "show_boxes" ) )
+ if ( sender() == actionCollection()->action( "show_boxes" ) )
Options::setShowInfoBoxes( show );
- if ( sender()->objectName() == QString( "show_time_box" ) )
+ if ( sender() == actionCollection()->action( "show_time_box" ) )
Options::setShowTimeBox( show );
- if ( sender()->objectName() == QString( "show_location_box" ) )
+ if ( sender() == actionCollection()->action( "show_location_box" ) )
Options::setShowGeoBox( show );
- if ( sender()->objectName() == QString( "show_focus_box" ) )
+ if ( sender() == actionCollection()->action( "show_focus_box" ) )
Options::setShowFocusBox( show );
}
--- trunk/KDE/kdeedu/kstars/kstars/opscatalog.cpp #654879:654880
@@ -20,6 +20,7 @@
#include <QTextStream>
#include <kfiledialog.h>
+#include <kactioncollection.h>
#include "opscatalog.h"
#include "Options.h"
@@ -90,7 +91,7 @@
void OpsCatalog::updateDisplay() {
//Modify display according to settings in the CatalogList
- if ( sender()->objectName() == QString( "CatalogList" ) )
+ if ( sender() == ksw->actionCollection()->action( "CatalogList" ) )
Options::setShowDeepSky( true );
Options::setShowMessier( showMessier->checkState() );
--- trunk/KDE/kdeedu/kstars/kstars/opssolarsystem.cpp #654879:654880
@@ -16,6 +16,7 @@
***************************************************************************/
#include <qcheckbox.h>
#include <qlabel.h>
+#include <kactioncollection.h>
#include <kpushbutton.h>
#include "opssolarsystem.h"
#include "kstars.h"
@@ -58,7 +59,7 @@
void OpsSolarSystem::slotSelectPlanets() {
bool b=true;
- if ( sender()->objectName() == QString( "showNonePlanets" ) ) b = false;
+ if ( sender() == ksw->actionCollection()->action( "showNonePlanets" ) ) b = false;
kcfg_ShowSun->setChecked( b );
kcfg_ShowMoon->setChecked( b );
More information about the Kstars-devel
mailing list