Commit 0ad89bfa authored by Mathias Soeken's avatar Mathias Soeken

Close button when in tray icon mode. This can be configured to be visible...

Close button when in tray icon mode. This can be configured to be visible independent from the other 
tool buttons.

svn path=/trunk/KDE/kdegraphics/kruler/; revision=923733
parent 4527708d
TODO TODO
* non-model preferences dialog, so that you can see the result when * non-model preferences dialog, so that you can see the result when
you change the color you change the color
* show/hide tray icon (and close action) when configuring tray icon
* move tray icon to another page in configuration dialog * move tray icon to another page in configuration dialog
* move some actions to tray icon context menu * move some actions to tray icon context menu
* close button (visible on hover) on the lineal * show/hide tray icon (and close action) when configuring tray icon
DONE DONE
* Center scale * Center scale
...@@ -13,4 +12,4 @@ DONE ...@@ -13,4 +12,4 @@ DONE
* Store last orientation and scale direction * Store last orientation and scale direction
* Store scale offset * Store scale offset
* Relative scale (percent). Then ignoring offset? * Relative scale (percent). Then ignoring offset?
* close button (visible on hover) on the lineal
...@@ -48,6 +48,13 @@ ...@@ -48,6 +48,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1" >
<widget class="QCheckBox" name="kcfg_CloseButtonVisible" >
<property name="text" >
<string>Show close button</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<layoutfunction spacing="KDialog::spacingHint" margin="KDialog::marginHint" /> <layoutfunction spacing="KDialog::spacingHint" margin="KDialog::marginHint" />
...@@ -67,5 +74,22 @@ ...@@ -67,5 +74,22 @@
<tabstop>kcfg_BgColor</tabstop> <tabstop>kcfg_BgColor</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections>
<connection>
<sender>kcfg_TrayIcon</sender>
<signal>toggled(bool)</signal>
<receiver>kcfg_CloseButtonVisible</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>172</x>
<y>100</y>
</hint>
<hint type="destinationlabel" >
<x>183</x>
<y>127</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>
...@@ -79,7 +79,8 @@ KLineal::KLineal( QWidget *parent ) ...@@ -79,7 +79,8 @@ KLineal::KLineal( QWidget *parent )
mCenterOriginAction( 0 ), mCenterOriginAction( 0 ),
mOffsetAction( 0 ), mOffsetAction( 0 ),
mClicked( false ), mClicked( false ),
mActionCollection( 0 ) mActionCollection( 0 ),
mCloseButton( 0 )
{ {
KWindowSystem::setType( winId(), NET::Override ); // or NET::Normal KWindowSystem::setType( winId(), NET::Override ); // or NET::Normal
KWindowSystem::setState( winId(), NET::KeepAbove ); KWindowSystem::setState( winId(), NET::KeepAbove );
...@@ -121,7 +122,6 @@ KLineal::KLineal( QWidget *parent ) ...@@ -121,7 +122,6 @@ KLineal::KLineal( QWidget *parent )
mLabel->setWhatsThis( i18n( "This is the current distance measured in pixels." ) ); mLabel->setWhatsThis( i18n( "This is the current distance measured in pixels." ) );
mColorLabel = new QAutoSizeLabel( this ); mColorLabel = new QAutoSizeLabel( this );
mColorLabel->setAutoFillBackground( true ); mColorLabel->setAutoFillBackground( true );
mColorLabel->hide();
QFont colorFont( KGlobalSettings::fixedFont().family(), 10 ); QFont colorFont( KGlobalSettings::fixedFont().family(), 10 );
colorFont.setPixelSize( 10 ); colorFont.setPixelSize( 10 );
mColorLabel->setFont( colorFont ); mColorLabel->setFont( colorFont );
...@@ -132,17 +132,13 @@ KLineal::KLineal( QWidget *parent ) ...@@ -132,17 +132,13 @@ KLineal::KLineal( QWidget *parent )
"little square at the end of the line cursor." ) ); "little square at the end of the line cursor." ) );
mBtnRotateLeft = new QToolButton( this ); mBtnRotateLeft = new QToolButton( this );
mBtnRotateLeft->setGeometry( mLongEdgeLen / 2 - 28, 5, 26, 26 );
mBtnRotateLeft->setIcon( KIcon( "object-rotate-left" ) ); mBtnRotateLeft->setIcon( KIcon( "object-rotate-left" ) );
mBtnRotateLeft->setToolTip( i18n( "Turn Left" ) ); mBtnRotateLeft->setToolTip( i18n( "Turn Left" ) );
mBtnRotateLeft->hide();
connect( mBtnRotateLeft, SIGNAL( clicked() ), this, SLOT( turnLeft() ) ); connect( mBtnRotateLeft, SIGNAL( clicked() ), this, SLOT( turnLeft() ) );
mBtnRotateRight = new QToolButton( this ); mBtnRotateRight = new QToolButton( this );
mBtnRotateRight->setGeometry( mLongEdgeLen / 2 + 2, 5, 26, 26 );
mBtnRotateRight->setIcon( KIcon( "object-rotate-right" ) ); mBtnRotateRight->setIcon( KIcon( "object-rotate-right" ) );
mBtnRotateRight->setToolTip( i18n( "Turn Right" ) ); mBtnRotateRight->setToolTip( i18n( "Turn Right" ) );
mBtnRotateRight->hide();
connect( mBtnRotateRight, SIGNAL( clicked() ), this, SLOT( turnRight() ) ); connect( mBtnRotateRight, SIGNAL( clicked() ), this, SLOT( turnRight() ) );
resize( QSize( mLongEdgeLen, mShortEdgeLen ) ); resize( QSize( mLongEdgeLen, mShortEdgeLen ) );
...@@ -232,6 +228,11 @@ KLineal::KLineal( QWidget *parent ) ...@@ -232,6 +228,11 @@ KLineal::KLineal( QWidget *parent )
KAction *closeAction = KStandardAction::close( this, SLOT( slotClose() ), this ); KAction *closeAction = KStandardAction::close( this, SLOT( slotClose() ), this );
mActionCollection->addAction( "close", closeAction ); mActionCollection->addAction( "close", closeAction );
mMenu->addAction( closeAction ); mMenu->addAction( closeAction );
mCloseButton = new QToolButton( this );
mCloseButton->setIcon( closeAction->icon() );
mCloseButton->setToolTip( closeAction->text().replace( '&', QString() ) );
connect( mCloseButton, SIGNAL( clicked() ), this, SLOT( slotClose() ) );
} }
KAction *quit = KStandardAction::quit( kapp, SLOT( quit() ), this ); KAction *quit = KStandardAction::quit( kapp, SLOT( quit() ), this );
...@@ -243,6 +244,7 @@ KLineal::KLineal( QWidget *parent ) ...@@ -243,6 +244,7 @@ KLineal::KLineal( QWidget *parent )
mLastClickPos = geometry().topLeft() + QPoint( width() / 2, height() / 2 ); mLastClickPos = geometry().topLeft() + QPoint( width() / 2, height() / 2 );
hideLabel();
setOrientation( mOrientation ); setOrientation( mOrientation );
if ( RulerSettings::self()->trayIcon() ) { if ( RulerSettings::self()->trayIcon() ) {
...@@ -413,7 +415,7 @@ void KLineal::setOrientation( int inOrientation ) ...@@ -413,7 +415,7 @@ void KLineal::setOrientation( int inOrientation )
break; break;
} }
adjustRotateButtons(); adjustButtons();
if ( mLenMenu && mFullScreenAction ) { if ( mLenMenu && mFullScreenAction ) {
mFullScreenAction->setText( mOrientation % 2 ? i18n( "&Full Screen Height" ) : i18n( "&Full Screen Width" ) ); mFullScreenAction->setText( mOrientation % 2 ? i18n( "&Full Screen Height" ) : i18n( "&Full Screen Width" ) );
...@@ -480,7 +482,7 @@ void KLineal::reLength( int percentOfScreen ) ...@@ -480,7 +482,7 @@ void KLineal::reLength( int percentOfScreen )
move( x(), 10 ); move( x(), 10 );
} }
adjustRotateButtons(); adjustButtons();
saveSettings(); saveSettings();
} }
...@@ -507,7 +509,7 @@ void KLineal::reLengthAbsolute( int length ) ...@@ -507,7 +509,7 @@ void KLineal::reLengthAbsolute( int length )
move( x(), 10 ); move( x(), 10 );
} }
adjustRotateButtons(); adjustButtons();
saveSettings(); saveSettings();
} }
...@@ -612,6 +614,7 @@ void KLineal::slotPreferences() ...@@ -612,6 +614,7 @@ void KLineal::slotPreferences()
Ui::ConfigAppearance appearanceConfig; Ui::ConfigAppearance appearanceConfig;
QWidget *appearanceConfigWidget = new QWidget( dialog ); QWidget *appearanceConfigWidget = new QWidget( dialog );
appearanceConfig.setupUi( appearanceConfigWidget ); appearanceConfig.setupUi( appearanceConfigWidget );
appearanceConfig.kcfg_CloseButtonVisible->setEnabled( appearanceConfig.kcfg_TrayIcon->isChecked() );
dialog->addPage( appearanceConfigWidget, i18n( "Appearance" ), "preferences-desktop-default-applications" ); dialog->addPage( appearanceConfigWidget, i18n( "Appearance" ), "preferences-desktop-default-applications" );
dialog->exec(); dialog->exec();
...@@ -698,6 +701,9 @@ void KLineal::showLabel() ...@@ -698,6 +701,9 @@ void KLineal::showLabel()
mBtnRotateLeft->show(); mBtnRotateLeft->show();
mBtnRotateRight->show(); mBtnRotateRight->show();
} }
if ( mCloseButton && RulerSettings::self()->closeButtonVisible() ) {
mCloseButton->show();
}
} }
/** /**
...@@ -709,6 +715,9 @@ void KLineal::hideLabel() ...@@ -709,6 +715,9 @@ void KLineal::hideLabel()
mColorLabel->hide(); mColorLabel->hide();
mBtnRotateLeft->hide(); mBtnRotateLeft->hide();
mBtnRotateRight->hide(); mBtnRotateRight->hide();
if ( mCloseButton ) {
mCloseButton->hide();
}
} }
/** /**
...@@ -741,29 +750,41 @@ void KLineal::adjustLabel() ...@@ -741,29 +750,41 @@ void KLineal::adjustLabel()
} }
/** /**
* Updates the position of the rotation buttons * Updates the position of the tool buttons
*/ */
void KLineal::adjustRotateButtons() void KLineal::adjustButtons()
{ {
switch( mOrientation ) { switch( mOrientation ) {
case North: case North:
mBtnRotateLeft->move( mLongEdgeLen / 2 - 28, height() - 31 ); mBtnRotateLeft->move( mLongEdgeLen / 2 - 28, height() - 31 );
mBtnRotateRight->move( mLongEdgeLen / 2 + 2, height() - 31 ); mBtnRotateRight->move( mLongEdgeLen / 2 + 2, height() - 31 );
if ( mCloseButton ) {
mCloseButton->move( width() - 31, height() - 31 );
}
break; break;
case South: case South:
mBtnRotateLeft->move( mLongEdgeLen / 2 - 28, 5 ); mBtnRotateLeft->move( mLongEdgeLen / 2 - 28, 5 );
mBtnRotateRight->move( mLongEdgeLen / 2 + 2, 5 ); mBtnRotateRight->move( mLongEdgeLen / 2 + 2, 5 );
if ( mCloseButton ) {
mCloseButton->move( width() - 31, 5 );
}
break; break;
case East: case East:
mBtnRotateLeft->move( 5, mLongEdgeLen / 2 - 28 ); mBtnRotateLeft->move( 5, mLongEdgeLen / 2 - 28 );
mBtnRotateRight->move( 5, mLongEdgeLen / 2 + 2 ); mBtnRotateRight->move( 5, mLongEdgeLen / 2 + 2 );
if ( mCloseButton ) {
mCloseButton->move( 5, height() - 31 );
}
break; break;
case West: case West:
mBtnRotateLeft->move( width() - 31, mLongEdgeLen / 2 - 28 ); mBtnRotateLeft->move( width() - 31, mLongEdgeLen / 2 - 28 );
mBtnRotateRight->move( width() - 31, mLongEdgeLen / 2 + 2 ); mBtnRotateRight->move( width() - 31, mLongEdgeLen / 2 + 2 );
if ( mCloseButton ) {
mCloseButton->move( width() - 31, height() - 31 );
}
break; break;
} }
} }
......
...@@ -92,6 +92,7 @@ private: ...@@ -92,6 +92,7 @@ private:
KActionCollection *mActionCollection; KActionCollection *mActionCollection;
int mOpacity; int mOpacity;
QToolButton *mBtnRotateLeft, *mBtnRotateRight; QToolButton *mBtnRotateLeft, *mBtnRotateRight;
QToolButton *mCloseButton;
public slots: public slots:
void setOrientation( int ); void setOrientation( int );
...@@ -105,7 +106,7 @@ public slots: ...@@ -105,7 +106,7 @@ public slots:
void hideLabel(); void hideLabel();
void showLabel(); void showLabel();
void adjustLabel(); void adjustLabel();
void adjustRotateButtons(); void adjustButtons();
void setShortLength(); void setShortLength();
void setMediumLength(); void setMediumLength();
void setTallLength(); void setTallLength();
......
...@@ -42,7 +42,11 @@ ...@@ -42,7 +42,11 @@
<default>255</default> <default>255</default>
</entry> </entry>
<entry name="RotateButtonsVisible" type="Bool"> <entry name="RotateButtonsVisible" type="Bool">
<label>Are the rotate buttons visible?</label> <label>Are the rotate buttons visible</label>
<default>false</default>
</entry>
<entry name="CloseButtonVisible" type="Bool">
<label>Is the close button visible</label>
<default>false</default> <default>false</default>
</entry> </entry>
</group> </group>
......
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