mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
- Allow switching between themes without restart (except classic) - Rework icon loading and recolouring logic to react to theme changes - Automatically react to light/dark theme change - Remove explicit selection of monochrome tray icon variant (selected automatically now) - Update theme background colours for Big Sur - Update application icon to match Big Sur HIG The tray icon doesn't respond perfectly to theme changes yet on Big Sur, since we need different icons for dark and light theme and cannot simply let the OS recolour the icon for us (we do that, too, but only as an additional fallback). At the moment, there is no signal to listen to that would allow this. This patch adds a few generic methods to OSUtils for detecting and communicating theme changes, which are only stubs for Windows and Linux at the moment and need to be implemented in future commits. Fixes #4933 Fixes #5349
99 lines
2.8 KiB
C++
99 lines
2.8 KiB
C++
/*
|
|
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
|
|
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
|
|
*
|
|
* 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_MACUTILS_H
|
|
#define KEEPASSXC_MACUTILS_H
|
|
|
|
#include "AppKit.h"
|
|
#include "gui/osutils/OSUtilsBase.h"
|
|
#include <Carbon/Carbon.h>
|
|
|
|
#include <QColor>
|
|
#include <QPointer>
|
|
#include <QScopedPointer>
|
|
#include <qwindowdefs.h>
|
|
|
|
class MacUtils : public OSUtilsBase
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
static MacUtils* instance();
|
|
|
|
bool isDarkMode() const override;
|
|
bool isStatusBarDark() const override;
|
|
bool isLaunchAtStartupEnabled() const override;
|
|
void setLaunchAtStartup(bool enable) override;
|
|
bool isCapslockEnabled() override;
|
|
|
|
WId activeWindow();
|
|
bool raiseWindow(WId pid);
|
|
bool raiseLastActiveWindow();
|
|
bool raiseOwnWindow();
|
|
bool hideOwnWindow();
|
|
bool isHidden();
|
|
bool enableAccessibility();
|
|
bool enableScreenRecording();
|
|
void toggleForegroundApp(bool foreground);
|
|
|
|
void registerNativeEventFilter() override;
|
|
|
|
bool registerGlobalShortcut(const QString& name,
|
|
Qt::Key key,
|
|
Qt::KeyboardModifiers modifiers,
|
|
QString* error = nullptr) override;
|
|
bool unregisterGlobalShortcut(const QString& name) override;
|
|
|
|
uint16 qtToNativeKeyCode(Qt::Key key);
|
|
CGEventFlags qtToNativeModifiers(Qt::KeyboardModifiers modifiers, bool native);
|
|
|
|
signals:
|
|
void lockDatabases();
|
|
|
|
protected:
|
|
explicit MacUtils(QObject* parent = nullptr);
|
|
~MacUtils() override;
|
|
|
|
private:
|
|
QString getLaunchAgentFilename() const;
|
|
static OSStatus hotkeyHandler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
|
|
|
QScopedPointer<AppKit> m_appkit;
|
|
static QPointer<MacUtils> m_instance;
|
|
|
|
struct globalShortcut
|
|
{
|
|
EventHotKeyRef hotkeyRef;
|
|
EventHotKeyID hotkeyId;
|
|
uint16 nativeKeyCode;
|
|
CGEventFlags nativeModifiers;
|
|
};
|
|
|
|
int m_nextShortcutId = 1;
|
|
QHash<QString, QSharedPointer<globalShortcut>> m_globalShortcuts;
|
|
|
|
Q_DISABLE_COPY(MacUtils)
|
|
};
|
|
|
|
inline MacUtils* macUtils()
|
|
{
|
|
return MacUtils::instance();
|
|
}
|
|
|
|
#endif // KEEPASSXC_MACUTILS_H
|