-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the use of UnlockDatabaseDialog without AutoType. Switch browse…
…r to use UnlockDatabaseDialog.
- Loading branch information
varjolintu
committed
May 8, 2018
1 parent
aae6d09
commit cd4a59e
Showing
10 changed files
with
250 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (C) 2012 Felix Geyer <[email protected]> | ||
* Copyright (C) 2017 KeePassXC Team <[email protected]> | ||
* | ||
* 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 "BrowserUtils.h" | ||
#include <QApplication> | ||
|
||
BrowserUtils* BrowserUtils::m_instance = nullptr; | ||
|
||
#ifndef Q_OS_MAC | ||
BrowserUtils::BrowserUtils(QObject* parent) : QObject(parent) | ||
{ | ||
|
||
} | ||
|
||
BrowserUtils::~BrowserUtils() | ||
{ | ||
|
||
} | ||
#endif | ||
|
||
BrowserUtils* BrowserUtils::instance() | ||
{ | ||
if (!m_instance) { | ||
m_instance = new BrowserUtils(qApp); | ||
} | ||
|
||
return m_instance; | ||
} | ||
|
||
void BrowserUtils::raiseWindow() | ||
{ | ||
#if defined(Q_OS_MAC) | ||
raiseOwnWindow(); | ||
#endif | ||
} | ||
|
||
#ifndef Q_OS_MAC | ||
bool BrowserUtils::raiseOwnWindow() | ||
{ | ||
return false; | ||
} | ||
|
||
bool BrowserUtils::raiseLastActiveWindow() | ||
{ | ||
return false; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) 2012 Felix Geyer <[email protected]> | ||
* Copyright (C) 2017 KeePassXC Team <[email protected]> | ||
* | ||
* 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/>. | ||
*/ | ||
|
||
#ifndef KEEPASSXC_BROWSERUTILS_H | ||
#define KEEPASSXC_BROWSERUTILS_H | ||
|
||
#include <QObject> | ||
|
||
class BrowserUtils : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
static BrowserUtils* instance(); | ||
static void createTestInstance(); | ||
|
||
public slots: | ||
virtual void raiseWindow(); | ||
virtual bool raiseLastActiveWindow(); | ||
virtual bool raiseOwnWindow(); | ||
#if defined(Q_OS_MAC) | ||
virtual bool activateProcess(pid_t pid); | ||
#endif | ||
|
||
private: | ||
explicit BrowserUtils(QObject* parent = nullptr); | ||
~BrowserUtils(); | ||
|
||
static BrowserUtils* m_instance; | ||
void* self; | ||
|
||
Q_DISABLE_COPY(BrowserUtils) | ||
}; | ||
|
||
inline BrowserUtils* browserUtils() | ||
{ | ||
return BrowserUtils::instance(); | ||
} | ||
|
||
#endif // KEEPASSXC_BROWSERUTILS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (C) 2016 Lennart Glauer <[email protected]> | ||
* Copyright (C) 2017 KeePassXC Team <[email protected]> | ||
* | ||
* 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 "BrowserUtils.h" | ||
#import <AppKit/AppKit.h> | ||
|
||
@interface AppKitImpl : NSObject | ||
@property (strong) NSRunningApplication *lastActiveApplication; | ||
@end | ||
|
||
@implementation AppKitImpl | ||
|
||
BrowserUtils::BrowserUtils(QObject* parent) | ||
{ | ||
self = [[AppKitImpl alloc] init]; | ||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:static_cast<id>(self) | ||
selector:@selector(didDeactivateApplicationObserver:) | ||
name:NSWorkspaceDidDeactivateApplicationNotification | ||
object:nil]; | ||
} | ||
|
||
BrowserUtils::~BrowserUtils() | ||
{ | ||
[[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:static_cast<id>(self)]; | ||
[static_cast<id>(self) dealloc]; | ||
} | ||
|
||
- (pid_t) ownProcessId | ||
{ | ||
return [NSProcessInfo processInfo].processIdentifier; | ||
} | ||
|
||
- (void) didDeactivateApplicationObserver:(NSNotification *) notification | ||
{ | ||
NSDictionary *userInfo = notification.userInfo; | ||
NSRunningApplication *app = userInfo[NSWorkspaceApplicationKey]; | ||
|
||
if (app.processIdentifier != [self ownProcessId]) { | ||
self.lastActiveApplication = app; | ||
} | ||
} | ||
|
||
bool BrowserUtils::raiseOwnWindow() | ||
{ | ||
pid_t pid = [static_cast<id>(self) ownProcessId]; | ||
return activateProcess(pid); | ||
} | ||
|
||
bool BrowserUtils::raiseLastActiveWindow() | ||
{ | ||
pid_t pid = [static_cast<id>(self) lastActiveApplication].processIdentifier; | ||
return activateProcess(pid); | ||
} | ||
|
||
bool BrowserUtils::activateProcess(pid_t pid) | ||
{ | ||
NSRunningApplication* app = [NSRunningApplication runningApplicationWithProcessIdentifier:pid]; | ||
return app && [app activateWithOptions:static_cast<NSApplicationActivationOptions>(NSApplicationActivateIgnoringOtherApps)]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.