Add DBus support: control keepassxc on desktop events (load database when log in, close all databases when log out)

This commit is contained in:
Didier Fabert 2017-02-10 15:42:18 +01:00 committed by thez3ro
parent 46c58b3202
commit e560650bf3
No known key found for this signature in database
GPG key ID: F628F9E41DD7C073
9 changed files with 226 additions and 1 deletions

View file

@ -64,6 +64,13 @@
#include "gui/SettingsWidget.h"
#include "gui/PasswordGeneratorWidget.h"
#ifdef WITH_XC_DBUS
#if defined(Q_OS_LINUX)
#include <QtDBus>
#include "gui/MainWindowAdaptor.h"
#endif
#endif
#ifdef WITH_XC_HTTP
class HttpPlugin: public ISettingsPage
{
@ -168,6 +175,16 @@ MainWindow::MainWindow()
, m_appExiting(false)
{
m_ui->setupUi(this);
#ifdef WITH_XC_DBUS
#if defined(Q_OS_LINUX)
new MainWindowAdaptor(this);
QDBusConnection dbus = QDBusConnection::sessionBus();
dbus.registerObject("/keepassxc", this);
dbus.registerService("org.keepassxc.MainWindow");
#else
qWarning("DBus is not available on this system");
#endif
#endif
setAcceptDrops(true);
@ -1123,3 +1140,8 @@ void MainWindow::dropEvent(QDropEvent* event)
}
}
}
void MainWindow::closeAllDatabases()
{
m_ui->tabWidget->closeAllDatabases();
}