Commit 617a01bd authored by Mathias Soeken's avatar Mathias Soeken

* Fix indention

 * Hide close action in menu when disabling the systemtray

svn path=/trunk/KDE/kdegraphics/kruler/; revision=1014319
parent c7a8dc44
......@@ -75,6 +75,7 @@ KLineal::KLineal( QWidget *parent )
: QWidget( parent ),
mDragging( false ),
mShortEdgeLen( 70 ),
mCloseAction( 0 ),
mLenMenu( 0 ), // INFO This member could be eventually deleted
// since if mFullScreenAction is initialized
// mLenMenu should have been, too.
......@@ -87,7 +88,6 @@ KLineal::KLineal( QWidget *parent )
mCloseButton( 0 ),
mTrayIcon( 0 )
{
firstCreate = true;
KWindowSystem::setType( winId(), NET::Override ); // or NET::Normal
KWindowSystem::setState( winId(), NET::KeepAbove );
......@@ -249,27 +249,28 @@ KLineal::KLineal( QWidget *parent )
KLineal::~KLineal()
{
delete mTrayIcon;
delete mTrayIcon;
}
void KLineal::createSystemTray()
{
if( firstCreate)
{
KAction *closeAction = KStandardAction::close( this, SLOT( slotClose() ), this );
mActionCollection->addAction( "close", closeAction );
mMenu->addAction( closeAction );
mCloseButton = new QToolButton( this );
mCloseButton->setIcon( closeAction->icon() );
mCloseButton->setToolTip( closeAction->text().remove( '&' ) );
connect( mCloseButton, SIGNAL( clicked() ), this, SLOT( slotClose() ) );
firstCreate = false;
}
if(!mTrayIcon) {
mTrayIcon = new KRulerSystemTray( KIcon( "kruler" ), this,mActionCollection );
mTrayIcon->setCategory(Experimental::KNotificationItem::ApplicationStatus);
}
if ( !mCloseAction ) {
mCloseAction = KStandardAction::close( this, SLOT( slotClose() ), this );
mActionCollection->addAction( "close", mCloseAction );
mMenu->addAction( mCloseAction );
mCloseButton = new QToolButton( this );
mCloseButton->setIcon( mCloseAction->icon() );
mCloseButton->setToolTip( mCloseAction->text().remove( '&' ) );
connect( mCloseButton, SIGNAL( clicked() ), this, SLOT( slotClose() ) );
} else {
mCloseAction->setVisible( true );
}
if ( !mTrayIcon ) {
mTrayIcon = new KRulerSystemTray( KIcon( "kruler" ), this, mActionCollection );
mTrayIcon->setCategory( Experimental::KNotificationItem::ApplicationStatus );
}
}
......@@ -636,31 +637,34 @@ void KLineal::slotPreferences()
advancedConfig.setupUi( advancedConfigWidget );
dialog->addPage( advancedConfigWidget, i18n( "Advanced" ), "preferences-other" );
connect(dialog, SIGNAL(settingsChanged(const QString&)), SLOT(loadConfig()));
connect( dialog, SIGNAL( settingsChanged( const QString& ) ), SLOT( loadConfig() ) );
dialog->exec();
delete dialog;
}
void KLineal::loadConfig()
{
mColor = RulerSettings::self()->bgColor();
mScaleFont = RulerSettings::self()->scaleFont();
saveSettings();
mColor = RulerSettings::self()->bgColor();
mScaleFont = RulerSettings::self()->scaleFont();
saveSettings();
if ( RulerSettings::self()->trayIcon() ) {
if ( !mTrayIcon ) {
createSystemTray();
//need to adjust button
adjustButtons();
}
if ( RulerSettings::self()->trayIcon() ) {
if ( !mTrayIcon ) {
createSystemTray();
//need to adjust button
adjustButtons();
}
else {
if ( mTrayIcon ) {
delete mTrayIcon;
mTrayIcon = 0;
}
} else {
if ( mTrayIcon ) {
delete mTrayIcon;
mTrayIcon = 0;
}
repaint();
if ( mCloseAction ) {
mCloseAction->setVisible( false );
}
}
repaint();
}
......
......@@ -54,7 +54,7 @@ protected:
void enterEvent( QEvent *e );
void leaveEvent( QEvent *e );
void createSystemTray();
void createSystemTray();
private:
KAction* addAction( KMenu *menu, KIcon icon, const QString& text,
......@@ -75,6 +75,7 @@ private:
int mLongEdgeLen;
int mShortEdgeLen;
KMenu *mMenu;
QAction *mCloseAction;
KMenu *mLenMenu;
QAction *mFullScreenAction;
QAction *mScaleDirectionAction;
......@@ -96,9 +97,8 @@ private:
int mOpacity;
QToolButton *mBtnRotateLeft, *mBtnRotateRight;
QToolButton *mCloseButton;
KRulerSystemTray *mTrayIcon;
KRulerSystemTray *mTrayIcon;
bool firstCreate;
public slots:
void setOrientation( int );
void setNorth();
......@@ -128,6 +128,6 @@ public slots:
void saveSettings();
void slotClose();
void slotQuit();
void loadConfig();
void loadConfig();
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment