mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Use a signal to connect to a slot in main window.
Coding style fixes. http://gitorious.org/keepassx/keepassx/merge_requests/10
This commit is contained in:
parent
679398be00
commit
d445bf1ecd
@ -17,12 +17,10 @@
|
||||
|
||||
#include "KeePassApp.h"
|
||||
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QFileOpenEvent>
|
||||
|
||||
KeePassApp::KeePassApp(int &argc, char **argv) :
|
||||
QApplication(argc, argv),
|
||||
mainWindow(NULL)
|
||||
KeePassApp::KeePassApp(int& argc, char** argv)
|
||||
: QApplication(argc, argv)
|
||||
{
|
||||
}
|
||||
|
||||
@ -30,18 +28,13 @@ KeePassApp::~KeePassApp()
|
||||
{
|
||||
}
|
||||
|
||||
void KeePassApp::setMainWindow(MainWindow *mainWindow)
|
||||
{
|
||||
this->mainWindow = mainWindow;
|
||||
}
|
||||
|
||||
bool KeePassApp::event(QEvent *event)
|
||||
{
|
||||
// Handle Apple QFileOpenEvent from finder (double click on .kdbx file)
|
||||
if (event->type() == QEvent::FileOpen && mainWindow) {
|
||||
mainWindow->openDatabase(static_cast<QFileOpenEvent*>(event)->file(), QString(), QString());
|
||||
return true;
|
||||
}
|
||||
// Handle Apple QFileOpenEvent from finder (double click on .kdbx file)
|
||||
if (event->type() == QEvent::FileOpen) {
|
||||
Q_EMIT openDatabase(static_cast<QFileOpenEvent*>(event)->file());
|
||||
return true;
|
||||
}
|
||||
|
||||
return (QApplication::event(event));
|
||||
}
|
@ -20,14 +20,14 @@
|
||||
|
||||
class KeePassApp : public QApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
MainWindow *mainWindow;
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KeePassApp(int &argc, char **argv);
|
||||
~KeePassApp();
|
||||
KeePassApp(int& argc, char** argv);
|
||||
~KeePassApp();
|
||||
|
||||
void setMainWindow(MainWindow *mainWindow);
|
||||
bool event(QEvent *event);
|
||||
bool event(QEvent *event);
|
||||
|
||||
Q_SIGNALS:
|
||||
void openDatabase(const QString& filename);
|
||||
};
|
@ -33,7 +33,10 @@ class MainWindow : public QMainWindow
|
||||
public:
|
||||
MainWindow();
|
||||
~MainWindow();
|
||||
void openDatabase(const QString& fileName, const QString& pw, const QString& keyFile);
|
||||
|
||||
public Q_SLOTS:
|
||||
void openDatabase(const QString& fileName, const QString& pw = QString(),
|
||||
const QString& keyFile = QString());
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
@ -51,9 +51,10 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
MainWindow mainWindow;
|
||||
app.setMainWindow(&mainWindow);
|
||||
mainWindow.show();
|
||||
|
||||
QObject::connect(&app, SIGNAL(openDatabase(QString)), &mainWindow, SLOT(openDatabase(QString)));
|
||||
|
||||
if (!filename.isEmpty()) {
|
||||
mainWindow.openDatabase(filename, password, QString());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user