summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Neundorf <[email protected]>2016-05-29 23:48:59 +0200
committerAlex Neundorf <[email protected]>2016-05-29 23:48:59 +0200
commitab152c2f7ee07cd3eb8f10b902ebeff1b4b6e182 (patch)
tree374d1d06f4f0d2a4bd887fc7a33143606d9785c0
parent36039f2a30218d15d676529594776170de862e8f (diff)
-add option to stay "always on top" #317463
There is now a new option "Always on top" for kruler, which defaults to true, so by default it is now always on top. The patch is based on the patch by Manuel Galiu (attached to the bug report). Alex
-rw-r--r--cfg_advanced.ui10
-rw-r--r--klineal.cpp13
-rw-r--r--klineal.h1
-rw-r--r--kruler.kcfg4
4 files changed, 26 insertions, 2 deletions
diff --git a/cfg_advanced.ui b/cfg_advanced.ui
index 43fca0b..3c61ef8 100644
--- a/cfg_advanced.ui
+++ b/cfg_advanced.ui
@@ -27,6 +27,16 @@
</property>
</widget>
</item>
+ <item row="2" column="1" >
+ <widget class="QCheckBox" name="kcfg_AlwaysOnTop" >
+ <property name="toolTip" >
+ <string>If this option is enabled, the window is being kept above other windows.</string>
+ </property>
+ <property name="text" >
+ <string>Always on top</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
diff --git a/klineal.cpp b/klineal.cpp
index bf9677b..1a3ba8b 100644
--- a/klineal.cpp
+++ b/klineal.cpp
@@ -98,7 +98,6 @@ KLineal::KLineal( QWidget *parent )
KWindowSystem::setType( winId(), NET::Override ); // or NET::Normal
KWindowSystem::setState( winId(), NET::KeepAbove );
- setWindowFlags( Qt::FramelessWindowHint );
setWindowTitle( i18nc( "@title:window", "KRuler" ) );
setMinimumSize( 60, 60 );
@@ -126,6 +125,7 @@ KLineal::KLineal( QWidget *parent )
mLeftToRight = RulerSettings::self()->leftToRight();
mOffset = RulerSettings::self()->offset();
mRelativeScale = RulerSettings::self()->relativeScale();
+ mAlwaysOnTopLayer = RulerSettings::self()->alwaysOnTop();
mLabel = new QAutoSizeLabel( this );
mLabel->setGeometry( 0, height() - 12, 32, 12 );
@@ -241,6 +241,9 @@ KLineal::KLineal( QWidget *parent )
mLastClickPos = geometry().topLeft() + QPoint( width() / 2, height() / 2 );
+ setWindowFlags( mAlwaysOnTopLayer ? Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint
+ : Qt::FramelessWindowHint );
+
hideLabel();
setOrientation( mOrientation );
@@ -631,7 +634,7 @@ void KLineal::slotPreferences()
dialog->addPage( appearanceConfigWidget, i18n( "Appearance" ), QStringLiteral( "preferences-desktop-default-applications" ) );
#ifdef KRULER_HAVE_X11
- // Advanced page only contains "Native moving" setting, disable when not running on X11
+ // Advanced page only contains the "Native moving" and "Always on top" settings, disable when not running on X11
if ( QX11Info::isPlatformX11() ) {
Ui::ConfigAdvanced advancedConfig;
QWidget *advancedConfigWidget = new QWidget( dialog );
@@ -649,8 +652,12 @@ void KLineal::loadConfig()
{
mColor = RulerSettings::self()->bgColor();
mScaleFont = RulerSettings::self()->scaleFont();
+ mAlwaysOnTopLayer = RulerSettings::self()->alwaysOnTop();
saveSettings();
+ setWindowFlags( mAlwaysOnTopLayer ? Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint
+ : Qt::FramelessWindowHint );
+
if ( RulerSettings::self()->trayIcon() ) {
if ( !mTrayIcon ) {
createSystemTray();
@@ -665,6 +672,7 @@ void KLineal::loadConfig()
mCloseAction->setVisible( false );
}
}
+ show();
repaint();
}
@@ -693,6 +701,7 @@ void KLineal::saveSettings()
RulerSettings::self()->setLeftToRight( mLeftToRight );
RulerSettings::self()->setOffset( mOffset );
RulerSettings::self()->setRelativeScale( mRelativeScale );
+ RulerSettings::self()->setAlwaysOnTop( mAlwaysOnTopLayer );
RulerSettings::self()->save();
}
diff --git a/klineal.h b/klineal.h
index 3fcc35a..ef75632 100644
--- a/klineal.h
+++ b/klineal.h
@@ -90,6 +90,7 @@ private:
QCursor mSouthCursor;
QCursor mDragCursor;
QFont mScaleFont;
+ bool mAlwaysOnTopLayer;
bool mClicked;
bool mLeftToRight;
int mOffset;
diff --git a/kruler.kcfg b/kruler.kcfg
index 61427ec..c51ae61 100644
--- a/kruler.kcfg
+++ b/kruler.kcfg
@@ -52,5 +52,9 @@
<label>Is native moving (possibly wobbling windows) active</label>
<default>false</default>
</entry>
+ <entry name="AlwaysOnTop" type="Bool">
+ <label>Is always on top</label>
+ <default>true</default>
+ </entry>
</group>
</kcfg>