mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-06-29 00:47:32 -04:00
Handle OSX Finder events
This commit is contained in:
parent
3bc3bfb15e
commit
679398be00
4 changed files with 85 additions and 1 deletions
|
@ -18,6 +18,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
|
||||||
configure_file( config-keepassx.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepassx.h )
|
configure_file( config-keepassx.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepassx.h )
|
||||||
|
|
||||||
set(keepassx_SOURCES
|
set(keepassx_SOURCES
|
||||||
|
core/KeePassApp.cpp
|
||||||
core/Config.cpp
|
core/Config.cpp
|
||||||
core/Database.cpp
|
core/Database.cpp
|
||||||
core/DatabaseIcons.cpp
|
core/DatabaseIcons.cpp
|
||||||
|
@ -86,6 +87,7 @@ set(keepassx_SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
set(keepassx_MOC
|
set(keepassx_MOC
|
||||||
|
core/KeePassApp.h
|
||||||
core/Database.h
|
core/Database.h
|
||||||
core/Entry.h
|
core/Entry.h
|
||||||
core/EntryAttachments.h
|
core/EntryAttachments.h
|
||||||
|
|
47
src/core/KeePassApp.cpp
Normal file
47
src/core/KeePassApp.cpp
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2012 Tobias Tangemann
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 or (at your option)
|
||||||
|
* version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "KeePassApp.h"
|
||||||
|
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
#include <QtGui/QFileOpenEvent>
|
||||||
|
|
||||||
|
KeePassApp::KeePassApp(int &argc, char **argv) :
|
||||||
|
QApplication(argc, argv),
|
||||||
|
mainWindow(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (QApplication::event(event));
|
||||||
|
}
|
33
src/core/KeePassApp.h
Normal file
33
src/core/KeePassApp.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2012 Tobias Tangemann
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 or (at your option)
|
||||||
|
* version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QtGui/QApplication>
|
||||||
|
#include "gui/MainWindow.h"
|
||||||
|
|
||||||
|
class KeePassApp : public QApplication
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
MainWindow *mainWindow;
|
||||||
|
|
||||||
|
public:
|
||||||
|
KeePassApp(int &argc, char **argv);
|
||||||
|
~KeePassApp();
|
||||||
|
|
||||||
|
void setMainWindow(MainWindow *mainWindow);
|
||||||
|
bool event(QEvent *event);
|
||||||
|
};
|
|
@ -21,12 +21,13 @@
|
||||||
|
|
||||||
#include "crypto/Crypto.h"
|
#include "crypto/Crypto.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
#include "core/KeePassApp.h"
|
||||||
#include "keys/CompositeKey.h"
|
#include "keys/CompositeKey.h"
|
||||||
#include "keys/PasswordKey.h"
|
#include "keys/PasswordKey.h"
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
KeePassApp app(argc, argv);
|
||||||
// don't set applicationName or organizationName as that changes
|
// don't set applicationName or organizationName as that changes
|
||||||
// QDesktopServices::storageLocation()
|
// QDesktopServices::storageLocation()
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow mainWindow;
|
MainWindow mainWindow;
|
||||||
|
app.setMainWindow(&mainWindow);
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
|
||||||
if (!filename.isEmpty()) {
|
if (!filename.isEmpty()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue