From 35fc439d0970a12d3b44b7be13012cc36cd39277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Deckert?= Date: Fri, 19 Dec 2014 14:15:02 +0100 Subject: [PATCH] add tray support patch to KeePassX ebuild --- app-admin/keepassx/Manifest | 2 + app-admin/keepassx/files/tray.patch | 274 ++++++++++++++++++ .../keepassx-2.0_alpha20140908-r1.ebuild | 44 +++ 3 files changed, 320 insertions(+) create mode 100644 app-admin/keepassx/files/tray.patch create mode 100644 app-admin/keepassx/keepassx-2.0_alpha20140908-r1.ebuild diff --git a/app-admin/keepassx/Manifest b/app-admin/keepassx/Manifest index 440006b..463e32e 100644 --- a/app-admin/keepassx/Manifest +++ b/app-admin/keepassx/Manifest @@ -1 +1,3 @@ +AUX tray.patch 9101 SHA256 082189d6ca322195b9c43a52f5a5b09050cb73fbcc5548a8c0e59bbb6d981430 SHA512 68b71763184b2f0820fa528d44a32f57f10166ff06458eae7208e3399932b806a1eb0310a42bfa16107e9e6c4e641d3224694c9563f183119786ce7134998a0c WHIRLPOOL 970fdc6c8f24eb95cf6a9b6d98a155f0d2f5a1bb9670fbef200be1dd74977188b076fda5b99993acb63577a3dd6793627bf14dda8ec915214f90e2c6530a5faa +EBUILD keepassx-2.0_alpha20140908-r1.ebuild 1151 SHA256 e6115f97f4f4f8364dfa5953b2f2b8df92e15134dee763be27f5dafd369c52b5 SHA512 2a3a536990cad078a27fa44a775779c10a570014450bad0c68735125652c3e1701abaeb6f684d92404528056d0dd3cb655bbc0daa43320575a7ce42169b710dc WHIRLPOOL 09d1d50a089b1e6ed1ec862caeff61a3387be63d90cf475ac9c1971801222b6dc3945090c621dc44898958efc18ec47ea25de10ef775ca7c74938577a6cdc55b EBUILD keepassx-2.0_alpha20140908.ebuild 1120 SHA256 4fcf59070802144970f4c7be826c0252d94c1940c8a5696873f82732b198341a SHA512 74670de2ee4ca1c76b6b6eaa35bbb50dad24d394cb7c4ab9b549d6bf8e51a84192ec374eb62fb46bb4e0705ced967d1f992b8ac55564c4f2e17c15f6b2f67080 WHIRLPOOL 2b1dbc3d8b37d4ee43e8cd5f0c61064fb4a0d63bc1a92a09409b80475992266fa6a6dd61dba0128e8fb095b92b015478b935a3a076c40a93d4ed5b97b8a1b47e diff --git a/app-admin/keepassx/files/tray.patch b/app-admin/keepassx/files/tray.patch new file mode 100644 index 0000000..81ceee6 --- /dev/null +++ b/app-admin/keepassx/files/tray.patch @@ -0,0 +1,274 @@ +From 4cdb9a645d8af65ea37e3af41e668540f8a1b30c Mon Sep 17 00:00:00 2001 +From: Felix Geyer +Date: Sun, 2 Nov 2014 10:15:44 +0100 +Subject: [PATCH] Add an option to display a tray icon. + +Also implement "Minimize to tray" functionality. +--- + src/core/Config.cpp | 2 ++ + src/gui/MainWindow.cpp | 73 ++++++++++++++++++++++++++++++++++++++++ + src/gui/MainWindow.h | 7 ++++ + src/gui/SettingsWidget.cpp | 9 +++++ + src/gui/SettingsWidgetGeneral.ui | 19 ++++++++++- + src/main.cpp | 2 ++ + 6 files changed, 111 insertions(+), 1 deletion(-) + +diff --git a/src/core/Config.cpp b/src/core/Config.cpp +index d47541e..03b5129 100644 +--- a/src/core/Config.cpp ++++ b/src/core/Config.cpp +@@ -104,6 +104,8 @@ void Config::init(const QString& fileName) + m_defaults.insert("security/passwordscleartext", false); + m_defaults.insert("security/autotypeask", true); + m_defaults.insert("GUI/Language", "system"); ++ m_defaults.insert("GUI/ShowTrayIcon", false); ++ m_defaults.insert("GUI/MinimizeToTray", false); + } + + Config* Config::instance() +diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp +index 48baa4c..dd77989 100644 +--- a/src/gui/MainWindow.cpp ++++ b/src/gui/MainWindow.cpp +@@ -33,6 +33,7 @@ const QString MainWindow::BaseWindowTitle = "KeePassX"; + + MainWindow::MainWindow() + : m_ui(new Ui::MainWindow()) ++ , m_trayIcon(Q_NULLPTR) + { + m_ui->setupUi(this); + +@@ -201,6 +202,8 @@ MainWindow::MainWindow() + + m_actionMultiplexer.connect(m_ui->actionSearch, SIGNAL(triggered()), + SLOT(toggleSearch())); ++ ++ updateTrayIcon(); + } + + MainWindow::~MainWindow() +@@ -429,12 +432,26 @@ void MainWindow::closeEvent(QCloseEvent* event) + saveWindowInformation(); + + event->accept(); ++ QApplication::quit(); + } + else { + event->ignore(); + } + } + ++void MainWindow::changeEvent(QEvent *event) ++{ ++ if ((event->type() == QEvent::WindowStateChange) && isMinimized() ++ && isTrayIconEnabled() && config()->get("GUI/MinimizeToTray").toBool()) ++ { ++ event->ignore(); ++ hide(); ++ } ++ else { ++ QMainWindow::changeEvent(event); ++ } ++} ++ + void MainWindow::saveWindowInformation() + { + config()->set("GUI/MainWindowGeometry", saveGeometry()); +@@ -467,6 +484,35 @@ bool MainWindow::saveLastDatabases() + return accept; + } + ++void MainWindow::updateTrayIcon() ++{ ++ if (isTrayIconEnabled()) { ++ if (!m_trayIcon) { ++ m_trayIcon = new QSystemTrayIcon(filePath()->applicationIcon(), this); ++ ++ QMenu* menu = new QMenu(this); ++ ++ QAction* actionToggle = new QAction(tr("Toggle window"), menu); ++ menu->addAction(actionToggle); ++ ++ menu->addAction(m_ui->actionQuit); ++ ++ connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), ++ SLOT(trayIconTriggered(QSystemTrayIcon::ActivationReason))); ++ connect(actionToggle, SIGNAL(triggered()), SLOT(toggleWindow())); ++ ++ m_trayIcon->setContextMenu(menu); ++ m_trayIcon->show(); ++ } ++ } ++ else { ++ if (m_trayIcon) { ++ delete m_trayIcon; ++ m_trayIcon = Q_NULLPTR; ++ } ++ } ++} ++ + void MainWindow::showEntryContextMenu(const QPoint& globalPos) + { + m_ui->menuEntries->popup(globalPos); +@@ -511,4 +557,31 @@ void MainWindow::applySettingsChanges() + else { + m_inactivityTimer->deactivate(); + } ++ ++ updateTrayIcon(); ++} ++ ++void MainWindow::trayIconTriggered(QSystemTrayIcon::ActivationReason reason) ++{ ++ if (reason == QSystemTrayIcon::Trigger) { ++ toggleWindow(); ++ } ++} ++ ++void MainWindow::toggleWindow() ++{ ++ if (QApplication::activeWindow() == this) { ++ hide(); ++ } ++ else { ++ show(); ++ raise(); ++ activateWindow(); ++ } ++} ++ ++bool MainWindow::isTrayIconEnabled() const ++{ ++ return config()->get("GUI/ShowTrayIcon").toBool() ++ && QSystemTrayIcon::isSystemTrayAvailable(); + } +diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h +index e904426..b966703 100644 +--- a/src/gui/MainWindow.h ++++ b/src/gui/MainWindow.h +@@ -20,6 +20,7 @@ + + #include + #include ++#include + + #include "core/SignalMultiplexer.h" + #include "gui/DatabaseWidget.h" +@@ -44,6 +45,7 @@ public Q_SLOTS: + + protected: + void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE; ++ void changeEvent(QEvent* event) Q_DECL_OVERRIDE; + + private Q_SLOTS: + void setMenuActionState(DatabaseWidget::Mode mode = DatabaseWidget::None); +@@ -61,6 +63,8 @@ private Q_SLOTS: + void saveToolbarState(bool value); + void rememberOpenDatabases(const QString& filePath); + void applySettingsChanges(); ++ void trayIconTriggered(QSystemTrayIcon::ActivationReason reason); ++ void toggleWindow(); + + private: + static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0); +@@ -69,6 +73,8 @@ private Q_SLOTS: + + void saveWindowInformation(); + bool saveLastDatabases(); ++ void updateTrayIcon(); ++ bool isTrayIconEnabled() const; + + const QScopedPointer m_ui; + SignalMultiplexer m_actionMultiplexer; +@@ -78,6 +84,7 @@ private Q_SLOTS: + QStringList m_openDatabases; + InactivityTimer* m_inactivityTimer; + int m_countDefaultAttributes; ++ QSystemTrayIcon* m_trayIcon; + + Q_DISABLE_COPY(MainWindow) + }; +diff --git a/src/gui/SettingsWidget.cpp b/src/gui/SettingsWidget.cpp +index 929db37..a7863ea 100644 +--- a/src/gui/SettingsWidget.cpp ++++ b/src/gui/SettingsWidget.cpp +@@ -47,6 +47,8 @@ SettingsWidget::SettingsWidget(QWidget* parent) + + connect(m_generalUi->autoSaveAfterEveryChangeCheckBox, SIGNAL(toggled(bool)), + this, SLOT(enableAutoSaveOnExit(bool))); ++ connect(m_generalUi->systrayShowCheckBox, SIGNAL(toggled(bool)), ++ m_generalUi->systrayMinimizeToTrayCheckBox, SLOT(setEnabled(bool))); + + connect(m_secUi->clearClipboardCheckBox, SIGNAL(toggled(bool)), + m_secUi->clearClipboardSpinBox, SLOT(setEnabled(bool))); +@@ -80,6 +82,9 @@ void SettingsWidget::loadSettings() + m_generalUi->languageComboBox->setCurrentIndex(defaultIndex); + } + ++ m_generalUi->systrayShowCheckBox->setChecked(config()->get("GUI/ShowTrayIcon").toBool()); ++ m_generalUi->systrayMinimizeToTrayCheckBox->setChecked(config()->get("GUI/MinimizeToTray").toBool()); ++ + if (autoType()->isAvailable()) { + m_globalAutoTypeKey = static_cast(config()->get("GlobalAutoTypeKey").toInt()); + m_globalAutoTypeModifiers = static_cast(config()->get("GlobalAutoTypeModifiers").toInt()); +@@ -118,6 +123,10 @@ void SettingsWidget::saveSettings() + m_generalUi->autoTypeEntryTitleMatchCheckBox->isChecked()); + int currentLangIndex = m_generalUi->languageComboBox->currentIndex(); + config()->set("GUI/Language", m_generalUi->languageComboBox->itemData(currentLangIndex).toString()); ++ ++ config()->set("GUI/ShowTrayIcon", m_generalUi->systrayShowCheckBox->isChecked()); ++ config()->set("GUI/MinimizeToTray", m_generalUi->systrayMinimizeToTrayCheckBox->isChecked()); ++ + if (autoType()->isAvailable()) { + config()->set("GlobalAutoTypeKey", m_generalUi->autoTypeShortcutWidget->key()); + config()->set("GlobalAutoTypeModifiers", +diff --git a/src/gui/SettingsWidgetGeneral.ui b/src/gui/SettingsWidgetGeneral.ui +index f3dc079..cbad7e5 100644 +--- a/src/gui/SettingsWidgetGeneral.ui ++++ b/src/gui/SettingsWidgetGeneral.ui +@@ -7,7 +7,7 @@ + 0 + 0 + 456 +- 288 ++ 340 + + + +@@ -96,6 +96,23 @@ + + + ++ ++ ++ ++ Show a system tray icon ++ ++ ++ ++ ++ ++ ++ false ++ ++ ++ Hide window to system tray when minimized ++ ++ ++ + + + +diff --git a/src/main.cpp b/src/main.cpp +index b9659e4..2bdef5b 100644 +--- a/src/main.cpp ++++ b/src/main.cpp +@@ -39,6 +39,8 @@ int main(int argc, char** argv) + // don't set organizationName as that changes the return value of + // QDesktopServices::storageLocation(QDesktopServices::DataLocation) + ++ QApplication::setQuitOnLastWindowClosed(false); ++ + if (!Crypto::init()) { + QString error = QCoreApplication::translate("Main", + "Fatal error while testing the cryptographic functions."); diff --git a/app-admin/keepassx/keepassx-2.0_alpha20140908-r1.ebuild b/app-admin/keepassx/keepassx-2.0_alpha20140908-r1.ebuild new file mode 100644 index 0000000..885b7e2 --- /dev/null +++ b/app-admin/keepassx/keepassx-2.0_alpha20140908-r1.ebuild @@ -0,0 +1,44 @@ +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-admin/keepassx/keepassx-2.0_alpha6.ebuild,v 1.1 2014/04/15 12:02:27 polynomial-c Exp $ + +EAPI=5 + +inherit git-2 cmake-utils + +EGIT_REPO_URI="https://github.com/kylemanna/keepassx" +##EGIT_PROJECT="xbmc-pvr-addons${PVRADDONS_EGIT_PROJECT:-}.git" +EGIT_COMMIT="b7fd29b8aa5c2df1ce413baffe5c40d2b7c146d2" +EGIT_BRANCH="yubikey" + +DESCRIPTION="Qt password manager compatible with its Win32 and Pocket PC versions" +HOMEPAGE="http://www.keepassx.org/" + +LICENSE="|| ( GPL-2 GPL-3 ) BSD GPL-2 LGPL-2.1 LGPL-3+ CC0-1.0 public-domain || ( LGPL-2.1 GPL-3 )" +SLOT="0" +KEYWORDS="~amd64 ~ppc ~x86 ~amd64-linux ~x86-linux" +IUSE="test yubikey" + +DEPEND=" + dev-libs/libgcrypt:0= + dev-qt/qtcore:4 + dev-qt/qtdbus:4 + dev-qt/qtgui:4 + dev-qt/qttest:4 + sys-libs/zlib + x11-libs/libX11 + x11-libs/libXtst + yubikey? ( sys-auth/libyubikey + sys-auth/ykpers ) +" +RDEPEND="${DEPEND}" + +DOCS=(CHANGELOG) + +src_configure() { + epatch ${FILESDIR}/tray.patch + local mycmakeargs=( + $(cmake-utils_use_with test TESTS) + ) + cmake-utils_src_configure +}