Commit e60fde5c authored by Laurent Montel's avatar Laurent Montel 😁

Fix show/hide close button when we show/hide systemtray

svn path=/trunk/KDE/kdegraphics/kruler/; revision=935472
parent e2111bbe
......@@ -227,16 +227,8 @@ KLineal::KLineal( QWidget *parent )
mMenu->addSeparator();
mMenu->addMenu( ( new KHelpMenu( this, KGlobal::mainComponent().aboutData(), true ) )->menu() );
mMenu->addSeparator();
if ( RulerSettings::self()->trayIcon() ) {
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() ) );
createSystemTray();
}
KAction *quit = KStandardAction::quit( kapp, SLOT( quit() ), this );
......@@ -251,16 +243,27 @@ KLineal::KLineal( QWidget *parent )
hideLabel();
setOrientation( mOrientation );
if ( RulerSettings::self()->trayIcon() ) {
mTrayIcon = new KSystemTrayIcon( KIcon( "kruler" ), this );
mTrayIcon->show();
}
}
KLineal::~KLineal()
{
}
void KLineal::createSystemTray()
{
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() ) );
mTrayIcon = new KSystemTrayIcon( KIcon( "kruler" ), this );
mTrayIcon->show();
}
KAction* KLineal::addAction( KMenu *menu, KIcon icon, const QString& text,
const QObject* receiver, const char* member,
const QKeySequence &shortcut, const QString& name )
......@@ -632,10 +635,15 @@ void KLineal::slotPreferences()
repaint();
saveSettings();
delete dialog;
if ( RulerSettings::self()->trayIcon() ) {
if ( !mTrayIcon )
mTrayIcon = new KSystemTrayIcon( KIcon( "kruler" ), this );
mTrayIcon->show();
if ( !mTrayIcon ) {
createSystemTray();
//need to adjust button
adjustButtons();
}
else
mTrayIcon->show();
}
else {
if ( mTrayIcon ) {
......
......@@ -54,6 +54,8 @@ protected:
void enterEvent( QEvent *e );
void leaveEvent( QEvent *e );
void createSystemTray();
private:
KAction* addAction( KMenu *menu, KIcon icon, const QString& text,
const QObject* receiver, const char* member,
......
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