From ab221b9e60acd087a298b8f6b35574b79bbad929 Mon Sep 17 00:00:00 2001 From: sniperbeamer Date: Thu, 3 Sep 2009 17:35:46 +0000 Subject: [PATCH] Add option to show the application window always on top git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@340 b624d157-de02-0410-bad0-e51aec6abb33 --- changelog | 4 +++- src/KpxConfig.h | 2 ++ src/dialogs/SettingsDlg.cpp | 2 ++ src/forms/SettingsDlg.ui | 7 +++++++ src/mainwindow.cpp | 10 ++++++++++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index d8bb1c4..e25a60a 100644 --- a/changelog +++ b/changelog @@ -1,8 +1,10 @@ ---------------------------- - 0.4.1 (2009-08-XX) + 0.4.1 (2009-09-XX) ---------------------------- - Added initial documentation (by Jussi Sainio) - Added and improved many translations +- Added ability to drag'n'drop fields (username, password, ...) to other applications +- Added option to show the application window always on top - Seperate columns settings between normal and search results view - Interrupt auto-type if the focused window changed meanwhile - Reduced height of password generator dialog (Bug #2831504) diff --git a/src/KpxConfig.h b/src/KpxConfig.h index d159ab1..45ff3ec 100644 --- a/src/KpxConfig.h +++ b/src/KpxConfig.h @@ -64,6 +64,7 @@ public: bool hidePasswords(){return settings.value("UI/HidePasswords",true).toBool();} bool hideUsernames(){return settings.value("UI/HideUsernames",true).toBool();} QByteArray hSplitterPos(){return settings.value("UI/HSplitterPos").toByteArray();} + bool alwaysOnTop(){return settings.value("UI/AlwaysOnTop",false).toBool();} IntegrPluginType integrPlugin(){return stringToIntegrPluginType(settings.value("Options/IntegrPlugin").toString());} QString lastFile(){return settings.value("Options/LastFile").toString();} QString lastKeyLocation(){return settings.value("Options/LastKeyLocation").toString();} @@ -135,6 +136,7 @@ public: void setHidePasswords(bool value){settings.setValue("UI/HidePasswords",value);} void setHideUsernames(bool value){settings.setValue("UI/HideUsernames",value);} void setHSplitterPos(const QByteArray& value){settings.setValue("UI/HSplitterPos",value);} + void setAlwaysOnTop(bool value){settings.setValue("UI/AlwaysOnTop",value);} void setIntegrPlugin(IntegrPluginType value){settings.setValue("Options/IntegrPlugin",integrPluginTypeToString(value));} void setLastFile(const QString& value){settings.setValue("Options/LastFile",value);} void setLastKeyLocation(const QString& value){settings.setValue("Options/LastKeyLocation",value);} diff --git a/src/dialogs/SettingsDlg.cpp b/src/dialogs/SettingsDlg.cpp index c0e3b37..584e944 100644 --- a/src/dialogs/SettingsDlg.cpp +++ b/src/dialogs/SettingsDlg.cpp @@ -106,6 +106,7 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog) } //Appearance + CheckBox_AlwaysOnTop->setChecked(config->alwaysOnTop()); QPixmap *pxt=new QPixmap(pixmTextColor->width(),pixmTextColor->height()); pxt->fill(config->bannerTextColor()); pixmTextColor->clear(); @@ -252,6 +253,7 @@ void CSettingsDlg::apply(){ config->setAutoSaveChange(CheckBox_AutoSaveChange->isChecked()); //Appearence + config->setAlwaysOnTop(CheckBox_AlwaysOnTop->isChecked()); config->setBannerColor1(color1); config->setBannerColor2(color2); config->setBannerTextColor(textcolor); diff --git a/src/forms/SettingsDlg.ui b/src/forms/SettingsDlg.ui index d84b4cc..210b252 100644 --- a/src/forms/SettingsDlg.ui +++ b/src/forms/SettingsDlg.ui @@ -649,6 +649,13 @@ QListView::item { + + + + Show window always on top + + + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 86bc747..b4075d8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -84,6 +84,8 @@ KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,bool ArgMin,bool Arg //statusBar()->addWidget(StatusBarSelection,85); statusBar()->setVisible(config->showStatusbar()); setStatusBarMsg(StatusBarReady); + if (config->alwaysOnTop()) + setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); NormalCentralWidget=QMainWindow::centralWidget(); LockedCentralWidget=new QWidget(this); @@ -1114,6 +1116,7 @@ void KeepassMainWindow::showEvent(QShowEvent* event){ void KeepassMainWindow::OnExtrasSettings(){ QString oldLang = config->language(); + bool oldAlwaysOnTop = config->alwaysOnTop(); CSettingsDlg dlg(this); dlg.exec(); if (config->language() != oldLang){ @@ -1130,6 +1133,13 @@ void KeepassMainWindow::OnExtrasSettings(){ EntryView->setAlternatingRowColors(config->alternatingRowColors()); SysTray->setVisible(config->showSysTrayIcon()); menuBookmarks->menuAction()->setVisible(config->featureBookmarks()); + if (config->alwaysOnTop() != oldAlwaysOnTop) { + if (config->alwaysOnTop()) + setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); + else + setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint); + show(); + } EventOccurred = true; if (config->lockOnInactivity() && config->lockAfterSec()!=0 && !inactivityTimer->isActive()){