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)
|
if(UNIX AND NOT APPLE)
|
||||||
install(DIRECTORY icons/application/ DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor
|
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
|
install(DIRECTORY icons/application/ DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor
|
||||||
FILES_MATCHING PATTERN "application-x-keepassx.png" PATTERN "application-x-keepassx.svgz")
|
FILES_MATCHING PATTERN "application-x-keepassx.png" PATTERN "application-x-keepassx.svgz")
|
||||||
install(FILES linux/keepassx.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
|
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");
|
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)
|
QIcon FilePath::icon(const QString& category, const QString& name, bool fromTheme)
|
||||||
{
|
{
|
||||||
QString combinedName = category + "/" + name;
|
QString combinedName = category + "/" + name;
|
||||||
|
@ -28,6 +28,8 @@ public:
|
|||||||
QString dataPath(const QString& name);
|
QString dataPath(const QString& name);
|
||||||
QString pluginPath(const QString& name);
|
QString pluginPath(const QString& name);
|
||||||
QIcon applicationIcon();
|
QIcon applicationIcon();
|
||||||
|
QIcon trayIconLocked();
|
||||||
|
QIcon trayIconUnlocked();
|
||||||
QIcon icon(const QString& category, const QString& name, bool fromTheme = true);
|
QIcon icon(const QString& category, const QString& name, bool fromTheme = true);
|
||||||
QIcon onOffIcon(const QString& category, const QString& name);
|
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(closeRequest()), SLOT(closeDatabaseFromSender()));
|
||||||
connect(dbStruct.dbWidget, SIGNAL(databaseChanged(Database*)), SLOT(changeDatabase(Database*)));
|
connect(dbStruct.dbWidget, SIGNAL(databaseChanged(Database*)), SLOT(changeDatabase(Database*)));
|
||||||
connect(dbStruct.dbWidget, SIGNAL(unlockedDatabase()), SLOT(updateTabNameFromDbWidgetSender()));
|
connect(dbStruct.dbWidget, SIGNAL(unlockedDatabase()), SLOT(updateTabNameFromDbWidgetSender()));
|
||||||
|
connect(dbStruct.dbWidget, SIGNAL(unlockedDatabase()), SLOT(emitDatabaseUnlockedFromDbWidgetSender()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseWidget* DatabaseTabWidget::currentDatabaseWidget()
|
DatabaseWidget* DatabaseTabWidget::currentDatabaseWidget()
|
||||||
@ -706,6 +707,8 @@ void DatabaseTabWidget::lockDatabases()
|
|||||||
dbWidget->lock();
|
dbWidget->lock();
|
||||||
// database has changed so we can't use the db variable anymore
|
// database has changed so we can't use the db variable anymore
|
||||||
updateTabName(dbWidget->database());
|
updateTabName(dbWidget->database());
|
||||||
|
|
||||||
|
Q_EMIT databaseLocked(dbWidget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,6 +767,11 @@ void DatabaseTabWidget::emitActivateDatabaseChanged()
|
|||||||
Q_EMIT activateDatabaseChanged(currentDatabaseWidget());
|
Q_EMIT activateDatabaseChanged(currentDatabaseWidget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseTabWidget::emitDatabaseUnlockedFromDbWidgetSender()
|
||||||
|
{
|
||||||
|
Q_EMIT databaseUnlocked(static_cast<DatabaseWidget*>(sender()));
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseTabWidget::connectDatabase(Database* newDb, Database* oldDb)
|
void DatabaseTabWidget::connectDatabase(Database* newDb, Database* oldDb)
|
||||||
{
|
{
|
||||||
if (oldDb) {
|
if (oldDb) {
|
||||||
|
@ -80,6 +80,8 @@ Q_SIGNALS:
|
|||||||
void tabNameChanged();
|
void tabNameChanged();
|
||||||
void databaseWithFileClosed(QString filePath);
|
void databaseWithFileClosed(QString filePath);
|
||||||
void activateDatabaseChanged(DatabaseWidget* dbWidget);
|
void activateDatabaseChanged(DatabaseWidget* dbWidget);
|
||||||
|
void databaseLocked(DatabaseWidget* dbWidget);
|
||||||
|
void databaseUnlocked(DatabaseWidget* dbWidget);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void updateTabName(Database* db);
|
void updateTabName(Database* db);
|
||||||
@ -89,6 +91,7 @@ private Q_SLOTS:
|
|||||||
void toggleTabbar();
|
void toggleTabbar();
|
||||||
void changeDatabase(Database* newDb);
|
void changeDatabase(Database* newDb);
|
||||||
void emitActivateDatabaseChanged();
|
void emitActivateDatabaseChanged();
|
||||||
|
void emitDatabaseUnlockedFromDbWidgetSender();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool saveDatabase(Database* db);
|
bool saveDatabase(Database* db);
|
||||||
|
@ -658,6 +658,7 @@ void DatabaseWidget::openDatabase(bool accepted)
|
|||||||
if (accepted) {
|
if (accepted) {
|
||||||
replaceDatabase(static_cast<DatabaseOpenWidget*>(sender())->database());
|
replaceDatabase(static_cast<DatabaseOpenWidget*>(sender())->database());
|
||||||
setCurrentWidget(m_mainWidget);
|
setCurrentWidget(m_mainWidget);
|
||||||
|
Q_EMIT unlockedDatabase();
|
||||||
|
|
||||||
// We won't need those anymore and KeePass1OpenWidget closes
|
// We won't need those anymore and KeePass1OpenWidget closes
|
||||||
// the file in its dtor.
|
// the file in its dtor.
|
||||||
|
@ -185,6 +185,10 @@ MainWindow::MainWindow()
|
|||||||
SLOT(databaseTabChanged(int)));
|
SLOT(databaseTabChanged(int)));
|
||||||
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)),
|
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)),
|
||||||
SLOT(setMenuActionState()));
|
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(setMenuActionState()));
|
||||||
connect(m_ui->stackedWidget, SIGNAL(currentChanged(int)), SLOT(updateWindowTitle()));
|
connect(m_ui->stackedWidget, SIGNAL(currentChanged(int)), SLOT(updateWindowTitle()));
|
||||||
connect(m_ui->settingsWidget, SIGNAL(editFinished(bool)), SLOT(switchToDatabases()));
|
connect(m_ui->settingsWidget, SIGNAL(editFinished(bool)), SLOT(switchToDatabases()));
|
||||||
@ -486,6 +490,11 @@ void MainWindow::switchToSettings()
|
|||||||
m_ui->stackedWidget->setCurrentIndex(1);
|
m_ui->stackedWidget->setCurrentIndex(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::databaseStatusChanged(DatabaseWidget *)
|
||||||
|
{
|
||||||
|
updateTrayIcon();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::databaseTabChanged(int tabIndex)
|
void MainWindow::databaseTabChanged(int tabIndex)
|
||||||
{
|
{
|
||||||
if (tabIndex != -1 && m_ui->stackedWidget->currentIndex() == 2) {
|
if (tabIndex != -1 && m_ui->stackedWidget->currentIndex() == 2) {
|
||||||
@ -573,7 +582,7 @@ void MainWindow::updateTrayIcon()
|
|||||||
{
|
{
|
||||||
if (isTrayIconEnabled()) {
|
if (isTrayIconEnabled()) {
|
||||||
if (!m_trayIcon) {
|
if (!m_trayIcon) {
|
||||||
m_trayIcon = new QSystemTrayIcon(filePath()->applicationIcon(), this);
|
m_trayIcon = new QSystemTrayIcon(this);
|
||||||
|
|
||||||
QMenu* menu = new QMenu(this);
|
QMenu* menu = new QMenu(this);
|
||||||
|
|
||||||
@ -587,8 +596,15 @@ void MainWindow::updateTrayIcon()
|
|||||||
connect(actionToggle, SIGNAL(triggered()), SLOT(toggleWindow()));
|
connect(actionToggle, SIGNAL(triggered()), SLOT(toggleWindow()));
|
||||||
|
|
||||||
m_trayIcon->setContextMenu(menu);
|
m_trayIcon->setContextMenu(menu);
|
||||||
|
m_trayIcon->setIcon(filePath()->applicationIcon());
|
||||||
m_trayIcon->show();
|
m_trayIcon->show();
|
||||||
}
|
}
|
||||||
|
if (m_ui->tabWidget->hasLockableDatabases()) {
|
||||||
|
m_trayIcon->setIcon(filePath()->trayIconUnlocked());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_trayIcon->setIcon(filePath()->trayIconLocked());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (m_trayIcon) {
|
if (m_trayIcon) {
|
||||||
|
@ -54,6 +54,7 @@ private Q_SLOTS:
|
|||||||
void showAboutDialog();
|
void showAboutDialog();
|
||||||
void switchToDatabases();
|
void switchToDatabases();
|
||||||
void switchToSettings();
|
void switchToSettings();
|
||||||
|
void databaseStatusChanged(DatabaseWidget *dbWidget);
|
||||||
void databaseTabChanged(int tabIndex);
|
void databaseTabChanged(int tabIndex);
|
||||||
void openRecentDatabase(QAction* action);
|
void openRecentDatabase(QAction* action);
|
||||||
void clearLastDatabases();
|
void clearLastDatabases();
|
||||||
|