keepassxc/src/gui/osutils/OSUtilsBase.h
Janek Bevendorff dad4ad68f3 Improve macOS platform integration (backport).
- 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)

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 #5349
2021-01-31 12:18:58 +01:00

74 lines
1.9 KiB
C++

/*
* Copyright (C) 2020 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_OSUTILSBASE_H
#define KEEPASSXC_OSUTILSBASE_H
#include <QObject>
#include <QPointer>
/**
* Abstract base class for generic OS-specific functionality
* which can be reasonably expected to be available on all platforms.
*/
class OSUtilsBase : public QObject
{
Q_OBJECT
public:
/**
* @return OS dark mode enabled.
*/
virtual bool isDarkMode() const = 0;
/**
* @return OS task / menu bar is dark.
*/
virtual bool isStatusBarDark() const = 0;
/**
* @return KeePassXC set to launch at system startup (autostart).
*/
virtual bool isLaunchAtStartupEnabled() const = 0;
/**
* @param enable Add or remove KeePassXC from system autostart.
*/
virtual void setLaunchAtStartup(bool enable) = 0;
/**
* @return OS caps lock enabled.
*/
virtual bool isCapslockEnabled() = 0;
signals:
/**
* Indicates platform UI theme change (light mode to dark mode).
*/
void interfaceThemeChanged();
/*
* Indicates a change in the tray / statusbar theme.
*/
void statusbarThemeChanged();
protected:
explicit OSUtilsBase(QObject* parent = nullptr);
virtual ~OSUtilsBase();
};
#endif // KEEPASSXC_OSUTILSBASE_H