Skip to content

Commit

Permalink
Add code to check for current palette being a dark theme
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew J. Milner <[email protected]>
  • Loading branch information
matterhorn103 committed Jan 18, 2024
1 parent 350d18d commit ce8eb4c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions avogadro/qtgui/toolplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
******************************************************************************/

#include "toolplugin.h"
#include <QtGui/QPalette>

namespace Avogadro::QtGui {

Expand Down Expand Up @@ -58,4 +59,14 @@ bool ToolPlugin::handleCommand(const QString& command,

ToolPluginFactory::~ToolPluginFactory() {}

// Method suggested by Qt to determine if theme is dark pre Qt6.5
static bool shouldApplyDarkFrame()

Check notice

Code scanning / CodeQL

Unused static function Note

Static function shouldApplyDarkFrame is unreachable
{
const QPalette defaultPalette;
return defaultPalette.color(QPalette::WindowText).lightness()
> defaultPalette.color(QPalette::Window).lightness();
}

bool ToolPlugin::darkTheme = shouldApplyDarkFrame();

} // namespace Avogadro::QtGui
3 changes: 3 additions & 0 deletions avogadro/qtgui/toolplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class AVOGADROQTGUI_EXPORT ToolPlugin : public QObject
{
Q_OBJECT

private:
static bool darkTheme;

public:
explicit ToolPlugin(QObject* parent = nullptr);
~ToolPlugin() override;
Expand Down

0 comments on commit ce8eb4c

Please sign in to comment.