Merge pull request #46 from keepassxreboot/feature/trayicon-#37
Show locked tray icon when database is locked
@ -21,7 +21,7 @@ install(FILES ${DATABASE_ICONS} DESTINATION ${DATA_INSTALL_DIR}/icons/database)
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
install(DIRECTORY icons/application/ DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor
|
||||
FILES_MATCHING PATTERN "keepassx.png" PATTERN "keepassx.svgz")
|
||||
FILES_MATCHING PATTERN "keepassx*.png" PATTERN "keepassx*.svgz")
|
||||
install(DIRECTORY icons/application/ DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor
|
||||
FILES_MATCHING PATTERN "application-x-keepassx.png" PATTERN "application-x-keepassx.svgz")
|
||||
install(FILES linux/keepassx.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
|
||||
|
BIN
share/icons/application/128x128/apps/keepassx-locked.png
Normal file
After Width: | Height: | Size: 9.4 KiB |
BIN
share/icons/application/16x16/apps/keepassx-locked.png
Normal file
After Width: | Height: | Size: 895 B |
BIN
share/icons/application/24x24/apps/keepassx-locked.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
share/icons/application/256x256/apps/keepassx-locked.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
share/icons/application/32x32/apps/keepassx-locked.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
share/icons/application/48x48/apps/keepassx-locked.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
share/icons/application/64x64/apps/keepassx-locked.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
share/icons/application/scalable/apps/keepassx-locked.svgz
Normal file
@ -90,6 +90,16 @@ QIcon FilePath::applicationIcon()
|
||||
return icon("apps", "keepassx");
|
||||
}
|
||||
|
||||
QIcon FilePath::trayIconLocked()
|
||||
{
|
||||
return icon("apps", "keepassx-locked");
|
||||
}
|
||||
|
||||
QIcon FilePath::trayIconUnlocked()
|
||||
{
|
||||
return applicationIcon();
|
||||
}
|
||||
|
||||
QIcon FilePath::icon(const QString& category, const QString& name, bool fromTheme)
|
||||
{
|
||||
QString combinedName = category + "/" + name;
|
||||
|
@ -28,6 +28,8 @@ public:
|
||||
QString dataPath(const QString& name);
|
||||
QString pluginPath(const QString& name);
|
||||
QIcon applicationIcon();
|
||||
QIcon trayIconLocked();
|
||||
QIcon trayIconUnlocked();
|
||||
QIcon icon(const QString& category, const QString& name, bool fromTheme = true);
|
||||
QIcon onOffIcon(const QString& category, const QString& name);
|
||||
|
||||
|
@ -610,6 +610,7 @@ void DatabaseTabWidget::insertDatabase(Database* db, const DatabaseManagerStruct
|
||||
connect(dbStruct.dbWidget, SIGNAL(closeRequest()), SLOT(closeDatabaseFromSender()));
|
||||
connect(dbStruct.dbWidget, SIGNAL(databaseChanged(Database*)), SLOT(changeDatabase(Database*)));
|
||||
connect(dbStruct.dbWidget, SIGNAL(unlockedDatabase()), SLOT(updateTabNameFromDbWidgetSender()));
|
||||
connect(dbStruct.dbWidget, SIGNAL(unlockedDatabase()), SLOT(emitDatabaseUnlockedFromDbWidgetSender()));
|
||||
}
|
||||
|
||||
DatabaseWidget* DatabaseTabWidget::currentDatabaseWidget()
|
||||
@ -706,6 +707,8 @@ void DatabaseTabWidget::lockDatabases()
|
||||
dbWidget->lock();
|
||||
// database has changed so we can't use the db variable anymore
|
||||
updateTabName(dbWidget->database());
|
||||
|
||||
Q_EMIT databaseLocked(dbWidget);
|
||||
}
|
||||
}
|
||||
|
||||
@ -764,6 +767,11 @@ void DatabaseTabWidget::emitActivateDatabaseChanged()
|
||||
Q_EMIT activateDatabaseChanged(currentDatabaseWidget());
|
||||
}
|
||||
|
||||
void DatabaseTabWidget::emitDatabaseUnlockedFromDbWidgetSender()
|
||||
{
|
||||
Q_EMIT databaseUnlocked(static_cast<DatabaseWidget*>(sender()));
|
||||
}
|
||||
|
||||
void DatabaseTabWidget::connectDatabase(Database* newDb, Database* oldDb)
|
||||
{
|
||||
if (oldDb) {
|
||||
|
@ -80,6 +80,8 @@ Q_SIGNALS:
|
||||
void tabNameChanged();
|
||||
void databaseWithFileClosed(QString filePath);
|
||||
void activateDatabaseChanged(DatabaseWidget* dbWidget);
|
||||
void databaseLocked(DatabaseWidget* dbWidget);
|
||||
void databaseUnlocked(DatabaseWidget* dbWidget);
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateTabName(Database* db);
|
||||
@ -89,6 +91,7 @@ private Q_SLOTS:
|
||||
void toggleTabbar();
|
||||
void changeDatabase(Database* newDb);
|
||||
void emitActivateDatabaseChanged();
|
||||
void emitDatabaseUnlockedFromDbWidgetSender();
|
||||
|
||||
private:
|
||||
bool saveDatabase(Database* db);
|
||||
|
@ -658,6 +658,7 @@ void DatabaseWidget::openDatabase(bool accepted)
|
||||
if (accepted) {
|
||||
replaceDatabase(static_cast<DatabaseOpenWidget*>(sender())->database());
|
||||
setCurrentWidget(m_mainWidget);
|
||||
Q_EMIT unlockedDatabase();
|
||||
|
||||
// We won't need those anymore and KeePass1OpenWidget closes
|
||||
// the file in its dtor.
|
||||
|
@ -185,6 +185,10 @@ MainWindow::MainWindow()
|
||||
SLOT(databaseTabChanged(int)));
|
||||
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)),
|
||||
SLOT(setMenuActionState()));
|
||||
connect(m_ui->tabWidget, SIGNAL(databaseLocked(DatabaseWidget*)),
|
||||
SLOT(databaseStatusChanged(DatabaseWidget*)));
|
||||
connect(m_ui->tabWidget, SIGNAL(databaseUnlocked(DatabaseWidget*)),
|
||||
SLOT(databaseStatusChanged(DatabaseWidget*)));
|
||||
connect(m_ui->stackedWidget, SIGNAL(currentChanged(int)), SLOT(setMenuActionState()));
|
||||
connect(m_ui->stackedWidget, SIGNAL(currentChanged(int)), SLOT(updateWindowTitle()));
|
||||
connect(m_ui->settingsWidget, SIGNAL(editFinished(bool)), SLOT(switchToDatabases()));
|
||||
@ -486,6 +490,11 @@ void MainWindow::switchToSettings()
|
||||
m_ui->stackedWidget->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
void MainWindow::databaseStatusChanged(DatabaseWidget *)
|
||||
{
|
||||
updateTrayIcon();
|
||||
}
|
||||
|
||||
void MainWindow::databaseTabChanged(int tabIndex)
|
||||
{
|
||||
if (tabIndex != -1 && m_ui->stackedWidget->currentIndex() == 2) {
|
||||
@ -573,7 +582,7 @@ void MainWindow::updateTrayIcon()
|
||||
{
|
||||
if (isTrayIconEnabled()) {
|
||||
if (!m_trayIcon) {
|
||||
m_trayIcon = new QSystemTrayIcon(filePath()->applicationIcon(), this);
|
||||
m_trayIcon = new QSystemTrayIcon(this);
|
||||
|
||||
QMenu* menu = new QMenu(this);
|
||||
|
||||
@ -587,8 +596,15 @@ void MainWindow::updateTrayIcon()
|
||||
connect(actionToggle, SIGNAL(triggered()), SLOT(toggleWindow()));
|
||||
|
||||
m_trayIcon->setContextMenu(menu);
|
||||
m_trayIcon->setIcon(filePath()->applicationIcon());
|
||||
m_trayIcon->show();
|
||||
}
|
||||
if (m_ui->tabWidget->hasLockableDatabases()) {
|
||||
m_trayIcon->setIcon(filePath()->trayIconUnlocked());
|
||||
}
|
||||
else {
|
||||
m_trayIcon->setIcon(filePath()->trayIconLocked());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m_trayIcon) {
|
||||
|
@ -54,6 +54,7 @@ private Q_SLOTS:
|
||||
void showAboutDialog();
|
||||
void switchToDatabases();
|
||||
void switchToSettings();
|
||||
void databaseStatusChanged(DatabaseWidget *dbWidget);
|
||||
void databaseTabChanged(int tabIndex);
|
||||
void openRecentDatabase(QAction* action);
|
||||
void clearLastDatabases();
|
||||
|