Commit ab152c2f authored by Alex Neundorf's avatar Alex Neundorf

-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
parent 36039f2a
......@@ -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/>
......
......@@ -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();
}
......
......@@ -90,6 +90,7 @@ private:
QCursor mSouthCursor;
QCursor mDragCursor;
QFont mScaleFont;
bool mAlwaysOnTopLayer;
bool mClicked;
bool mLeftToRight;
int mOffset;
......
......@@ -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>
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