Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/set theme #374

Merged
merged 32 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
41e7858
first test for setting the icon color according to theme
thoellt Aug 8, 2023
78d0eaa
Merge branch 'feature/menubar_refactor' into feature/look_and_feel_macos
thoellt Aug 8, 2023
71e12a1
Merge branch 'master' into feature/look_and_feel_macos
thoellt Aug 8, 2023
74865d0
Adds theme changer in settings
thoellt Aug 9, 2023
977b146
adds image resources for settings buttons
thoellt Aug 9, 2023
90f9046
Adds interactive theme update examples for two startpage widgets
thoellt Aug 10, 2023
d1b91cf
removes mac calls from windows build
thoellt Aug 10, 2023
578c521
adds theme change for widgetActionLabel
thoellt Aug 10, 2023
e2017d4
updates updateCustomStyle to correctly capture hovered labels
thoellt Aug 10, 2023
30bb948
adds dynamic theme to groupsAction
thoellt Aug 10, 2023
6704662
updates group section header for more native look on macOS
thoellt Aug 10, 2023
c24aab2
more dynamic theming for the frontpage
thoellt Aug 10, 2023
4c612db
uses apps textcolor directly in several places instead of windowcolor
thoellt Aug 11, 2023
84b4b9d
Adds possibility to set WidgetAction icon by name
thoellt Aug 11, 2023
95a6535
Replaces straight-forward icon setters in classes derived from Widget…
thoellt Aug 11, 2023
d66f1de
Merge branch 'master' into feature/set_theme
thoellt Aug 30, 2023
e776752
uses style sheet instead of backgroundRole for start page background
thoellt Aug 30, 2023
cc88e37
Use ads repolish to update widgets recursively from main window on th…
thoellt Aug 30, 2023
eebf7cd
update some icons in dockWidget and Title on theme change
thoellt Aug 30, 2023
a310576
Changes background
thoellt Aug 30, 2023
94cd7ea
Fixes some issues on the startpage introduced by new theme change
thoellt Aug 30, 2023
63443e7
Update GroupsAction.cpp (#376)
ThomasKroes Sep 1, 2023
30551a1
Merge branch 'master' into feature/set_theme
thoellt Sep 25, 2023
c1755ff
Merge branch 'master' into feature/set_theme
thoellt Sep 26, 2023
440ac5d
Forces light theme on macOS until all icons can be drawn for the dark…
thoellt Oct 5, 2023
484d3ad
Removes objective C files from non-apple generators
thoellt Oct 5, 2023
ac6edaf
Merge branch 'master' into feature/set_theme
thoellt Oct 9, 2023
d2d7303
Merge branch 'master' into feature/set_theme
thoellt Oct 9, 2023
e799438
Reimplements missing ads::internal function
thoellt Oct 9, 2023
bcd164e
Adjust splash screen shadow on macOS to be more in line with system …
thoellt Oct 9, 2023
0109527
temporary disables non-solid FA fonts, to avoid broken icons
thoellt Oct 9, 2023
2853a6b
enable macOS theming
thoellt Oct 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion HDPS/cmake/CMakeHdpsSourcesPublic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,13 @@ set(PUBLIC_UTIL_HEADERS
src/util/NumericalRange.h
)

if(APPLE)
set(PUBLIC_UTIL_HEADERS
${PUBLIC_UTIL_HEADERS}
src/util/MacThemeHelper.h
)
endif()

set(PUBLIC_UTIL_SOURCES
src/util/Miscellaneous.cpp
src/util/FileUtil.cpp
Expand Down Expand Up @@ -489,6 +496,13 @@ set(PUBLIC_UTIL_SOURCES
src/util/NumericalRange.cpp
)

if(APPLE)
set(PUBLIC_UTIL_SOURCES
${PUBLIC_UTIL_SOURCES}
src/util/MacThemeHelper.mm
)
endif()

set(PUBLIC_UTIL_FILES
${PUBLIC_UTIL_HEADERS}
${PUBLIC_UTIL_SOURCES}
Expand Down Expand Up @@ -641,13 +655,15 @@ set(PUBLIC_GLOBAL_SETTINGS_HEADERS
src/ParametersSettingsAction.h
src/MiscellaneousSettingsAction.h
src/TasksSettingsAction.h
src/ApplicationSettingsAction.h
)

set(PUBLIC_GLOBAL_SETTINGS_SOURCES
src/GlobalSettingsGroupAction.cpp
src/ParametersSettingsAction.cpp
src/MiscellaneousSettingsAction.cpp
src/TasksSettingsAction.cpp
src/ApplicationSettingsAction.cpp
)

set(PUBLIC_GLOBAL_SETTINGS_FILES
Expand Down Expand Up @@ -804,4 +820,4 @@ source_group(Project FILES ${PUBLIC_PROJECT_FILES})
source_group(Model\\Actions FILES ${PUBLIC_ACTIONS_MODEL_FILES})
source_group(Model\\DataHierarchy FILES ${PUBLIC_DATA_HIERARCHY_MODEL_FILES})
source_group(GlobalSettings FILES ${PUBLIC_GLOBAL_SETTINGS_FILES})
source_group(Task FILES ${PUBLIC_TASK_FILES})
source_group(Task FILES ${PUBLIC_TASK_FILES})
5 changes: 5 additions & 0 deletions HDPS/res/ResourcesCore.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
<file alias="StartPageBackground">images/StartPageBackground.png</file>
<file alias="SplashScreenBackground">images/SplashScreenBackground.png</file>
</qresource>
<qresource prefix="/Buttons">
<file alias="ModeDark">images/buttons/ModeDark.png</file>
<file alias="ModeLight">images/buttons/ModeLight.png</file>
<file alias="ModeSystem">images/buttons/ModeSystem.png</file>
</qresource>
<qresource prefix="/">
<file>shaders/Quad.vert</file>
<file>shaders/DensityCompute.vert</file>
Expand Down
Binary file modified HDPS/res/images/StartPageBackground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added HDPS/res/images/buttons/ModeDark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added HDPS/res/images/buttons/ModeLight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added HDPS/res/images/buttons/ModeSystem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions HDPS/src/AbstractSettingsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ParametersSettingsAction.h"
#include "MiscellaneousSettingsAction.h"
#include "TasksSettingsAction.h"
#include "ApplicationSettingsAction.h"

namespace hdps
{
Expand Down Expand Up @@ -49,6 +50,7 @@ class AbstractSettingsManager : public AbstractManager
virtual ParametersSettingsAction& getParametersSettings() = 0;
virtual MiscellaneousSettingsAction& getMiscellaneousSettings() = 0;
virtual TasksSettingsAction& getTasksSettingsAction() = 0;
virtual ApplicationSettingsAction& getApplicationSettings() = 0;
};

}
8 changes: 4 additions & 4 deletions HDPS/src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ Application::Application(int& argc, char** argv) :
_startupProjectMetaAction(nullptr)
{
_iconFonts.add(QSharedPointer<IconFont>(new FontAwesome(5, 14, {
":/IconFonts/FontAwesomeBrandsRegular-5.14.otf",
":/IconFonts/FontAwesomeRegular-5.14.otf",
//":/IconFonts/FontAwesomeBrandsRegular-5.14.otf",
//":/IconFonts/FontAwesomeRegular-5.14.otf",
":/IconFonts/FontAwesomeSolid-5.14.otf"
}, true)));

_iconFonts.add(QSharedPointer<IconFont>(new FontAwesome(6, 4, {
":/IconFonts/FontAwesomeBrandsRegular-6.4.otf",
":/IconFonts/FontAwesomeRegular-6.4.otf",
//":/IconFonts/FontAwesomeBrandsRegular-6.4.otf",
//":/IconFonts/FontAwesomeRegular-6.4.otf",
":/IconFonts/FontAwesomeSolid-6.4.otf"
})));

Expand Down
63 changes: 63 additions & 0 deletions HDPS/src/ApplicationSettingsAction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// A corresponding LICENSE file is located in the root directory of this source tree
// Copyright (C) 2023 BioVault (Biomedical Visual Analytics Unit LUMC - TU Delft)

#include "ApplicationSettingsAction.h"
#include "Application.h"

#ifdef Q_OS_MACX
#include "util/MacThemeHelper.h"
#endif // Q_OS_MACX

namespace hdps
{

ApplicationSettingsAction::ApplicationSettingsAction(QObject* parent) :
GlobalSettingsGroupAction(parent, "Application"),
_appearanceOptionAction(nullptr)
{
setShowLabels(true);

bool themesAvailable = false;

#ifdef Q_OS_MACX
themesAvailable = macDarkThemeAvailable();
// Temporary no option is provided, instead we fix for the light theme.
// While changing the theme works, there is still a number of icons that do not work on dark theme.
//macSetToLightTheme();
#endif // Q_OS_MACX

if( themesAvailable )
{
_appearanceOptionAction = new gui::OptionAction(this, "Appearance", QStringList({"System", "Dark", "Light"}), "System");
_appearanceOptionAction->setDefaultWidgetFlags(gui::OptionAction::HorizontalButtons);
_appearanceOptionAction->setSettingsPrefix(getSettingsPrefix() + "AppearanceOption");

addAction(_appearanceOptionAction);

const auto appearanceOptionCurrentIndexChanged = [this](const QString& currentText) -> void {
//qDebug() << "Changing Appearance to " << currentText << ".";
if(currentText == "System")
{
#ifdef Q_OS_MACX
macSetToAutoTheme();
#endif // Q_OS_MACX
}
else if(currentText == "Dark")
{
#ifdef Q_OS_MACX
macSetToDarkTheme();
#endif // Q_OS_MACX
}
else if(currentText == "Light")
{
#ifdef Q_OS_MACX
macSetToLightTheme();
#endif // Q_OS_MACX
}
};
connect(_appearanceOptionAction, &gui::OptionAction::currentTextChanged, this, appearanceOptionCurrentIndexChanged);
}
}

}
40 changes: 40 additions & 0 deletions HDPS/src/ApplicationSettingsAction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// A corresponding LICENSE file is located in the root directory of this source tree
// Copyright (C) 2023 BioVault (Biomedical Visual Analytics Unit LUMC - TU Delft)

#pragma once

#include "GlobalSettingsGroupAction.h"

#include "actions/OptionAction.h"

namespace hdps
{

/**
* Application global settings action class
*
* Action class which groups all global settings for the application
*
* @author Thomas Kroes
* @author Thomas Höllt
*/
class ApplicationSettingsAction final : public GlobalSettingsGroupAction
{
public:

/**
* Constructor
* @param parent Pointer to parent object
*/
ApplicationSettingsAction(QObject* parent);

public: // Action getters

gui::OptionAction* getAppearanceOptionAction() { return _appearanceOptionAction; }

private:
gui::OptionAction* _appearanceOptionAction; /** Options for dark, light, or system appearance */
};

}
2 changes: 1 addition & 1 deletion HDPS/src/ParametersSettingsAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ParametersSettingsAction::ParametersSettingsAction(QObject* parent) :

connect(&_expertModeAction, &ToggleAction::toggled, this, updateExpertModeActionTooltip);

_expertModeAction.setIcon(Application::getIconFont("FontAwesome").getIcon("user-graduate"));
_expertModeAction.setIconByName("user-graduate");
}

}
2 changes: 1 addition & 1 deletion HDPS/src/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Plugin::Plugin(const PluginFactory* factory) :
_guiNameAction.setConnectionPermissionsToForceNone();

_destroyAction.setToolTip(QString("Remove %1").arg(getGuiName()));
_destroyAction.setIcon(Application::getIconFont("FontAwesome").getIcon("trash"));
_destroyAction.setIconByName("trash");
_destroyAction.setConfigurationFlag(WidgetAction::ConfigurationFlag::VisibleInMenu);
_destroyAction.setConfigurationFlag(WidgetAction::ConfigurationFlag::InternalUseOnly);
_destroyAction.setConnectionPermissionsToForceNone();
Expand Down
2 changes: 1 addition & 1 deletion HDPS/src/PluginFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ std::uint16_t PluginFactory::getNumberOfDatasetsForType(const Datasets& datasets

}

}
}
6 changes: 3 additions & 3 deletions HDPS/src/ViewPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ ViewPlugin::ViewPlugin(const PluginFactory* factory) :
_widget.addAction(&_isolateAction);
_widget.addAction(&_helpAction);

_editorAction.setIcon(Application::getIconFont("FontAwesome").getIcon("cog"));
_editorAction.setIconByName("cog");
_editorAction.setShortcut(tr("F12"));
_editorAction.setShortcutContext(Qt::WidgetWithChildrenShortcut);
_editorAction.setConfigurationFlag(WidgetAction::ConfigurationFlag::VisibleInMenu);
_editorAction.setConfigurationFlag(WidgetAction::ConfigurationFlag::InternalUseOnly);
_editorAction.setConnectionPermissionsToForceNone();

_screenshotAction.setIcon(Application::getIconFont("FontAwesome").getIcon("camera"));
_screenshotAction.setIconByName("camera");
_screenshotAction.setShortcut(tr("F2"));
_screenshotAction.setShortcutContext(Qt::WidgetWithChildrenShortcut);
_screenshotAction.setConfigurationFlag(WidgetAction::ConfigurationFlag::VisibleInMenu);
_screenshotAction.setConfigurationFlag(WidgetAction::ConfigurationFlag::InternalUseOnly);
_screenshotAction.setConnectionPermissionsToForceNone();

_isolateAction.setIcon(Application::getIconFont("FontAwesome").getIcon("crosshairs"));
_isolateAction.setIconByName("crosshairs");
_isolateAction.setShortcut(tr("F3"));
_isolateAction.setShortcutContext(Qt::WidgetWithChildrenShortcut);
_isolateAction.setConfigurationFlag(WidgetAction::ConfigurationFlag::VisibleInMenu);
Expand Down
2 changes: 1 addition & 1 deletion HDPS/src/Workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void Workspace::initialize()
_descriptionAction.setPlaceHolderString("Enter workspace description here...");
_descriptionAction.setClearable(true);

_tagsAction.setIcon(Application::getIconFont("FontAwesome").getIcon("tag"));
_tagsAction.setIconByName("tag");
_tagsAction.setCategory("Tag");

_commentsAction.setPlaceHolderString("Enter workspace comments here...");
Expand Down
2 changes: 1 addition & 1 deletion HDPS/src/actions/ColorMapAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ColorMapAction::ColorMapAction(QObject* parent, const QString& title, const Colo
_customColorMapGroupAction(this, "Custom color map"),
_settingsAction(*this, "Settings")
{
setIcon(Application::getIconFont("FontAwesome").getIcon("paint-roller"));
setIconByName("paint-roller");
setDefaultWidgetFlags(WidgetFlag::Default);

initialize(colorMap);
Expand Down
12 changes: 6 additions & 6 deletions HDPS/src/actions/ColorMapEditor1DAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ColorMapEditor1DAction::ColorMapEditor1DAction(QObject* parent, const QString& t
_colorMapImage(colorMapImageSize, QImage::Format::Format_ARGB32_Premultiplied)
{
setText("1D custom color map");
setIcon(Application::getIconFont("FontAwesome").getIcon("chart-line"));
setIconByName("chart-line");

addNode(QPointF(0.0f, 0.0f), Qt::black);
addNode(QPointF(1.0f, 1.0f), Qt::white);
Expand Down Expand Up @@ -248,11 +248,11 @@ ColorMapEditor1DAction::Widget::Widget(QWidget* parent, ColorMapEditor1DAction*

auto& fontAwesome = Application::getIconFont("FontAwesome");

_goToFirstNodeAction.setIcon(fontAwesome.getIcon("angle-double-left"));
_goToPreviousNodeAction.setIcon(fontAwesome.getIcon("angle-left"));
_goToNextNodeAction.setIcon(fontAwesome.getIcon("angle-right"));
_goToLastNodeAction.setIcon(fontAwesome.getIcon("angle-double-right"));
_removeNodeAction.setIcon(fontAwesome.getIcon("trash"));
_goToFirstNodeAction.setIconByName("angle-double-left");
_goToPreviousNodeAction.setIconByName("angle-left");
_goToNextNodeAction.setIconByName("angle-right");
_goToLastNodeAction.setIconByName("angle-double-right");
_removeNodeAction.setIconByName("trash");

auto layout = new QVBoxLayout();
auto toolbarLayout = new QHBoxLayout();
Expand Down
2 changes: 1 addition & 1 deletion HDPS/src/actions/ColorMapSettingsAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ColorMapSettingsAction::ColorMapSettingsAction(ColorMapAction& colorMapAction, c
_colorMapAction(colorMapAction)
{
setText("Settings");
setIcon(Application::getIconFont("FontAwesome").getIcon("sliders-h"));
setIconByName("sliders-h");
}

ColorMapSettingsAction::Widget::Widget(QWidget* parent, ColorMapSettingsAction* colorMapSettingsAction, const std::int32_t& widgetFlags) :
Expand Down
2 changes: 1 addition & 1 deletion HDPS/src/actions/DatasetPickerAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DatasetPickerAction::DatasetPickerAction(QObject* parent, const QString& title,
_eventListener()
{
setText(title);
setIcon(Application::getIconFont("FontAwesome").getIcon("database"));
setIconByName("database");
setToolTip("Pick a dataset");
setCustomModel(&_datasetsModel);
setPlaceHolderString("--choose dataset--");
Expand Down
2 changes: 1 addition & 1 deletion HDPS/src/actions/DirectoryPickerAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ DirectoryPickerAction::DirectoryPickerAction(QObject* parent, const QString& tit

// Configure pick action
_pickAction.setDefaultWidgetFlags(TriggerAction::Icon);
_pickAction.setIcon(Application::getIconFont("FontAwesome").getIcon("folder"));
_pickAction.setIconByName("folder");
_pickAction.setToolTip("Click to choose a directory");

// Disable trailing action
Expand Down
2 changes: 1 addition & 1 deletion HDPS/src/actions/FilePickerAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ FilePickerAction::FilePickerAction(QObject* parent, const QString& title, const
_filePathAction.setCompleter(&_completer);

_pickAction.setDefaultWidgetFlags(TriggerAction::Icon);
_pickAction.setIcon(Application::getIconFont("FontAwesome").getIcon("folder-open"));
_pickAction.setIconByName("folder-open");

const auto updatePickActionToolTip = [this]() -> void {
_pickAction.setToolTip(QString("Click to browse for %1").arg(getFileType().toLower()));
Expand Down
14 changes: 12 additions & 2 deletions HDPS/src/actions/GroupSectionTreeItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <QDebug>
#include <QMenu>
#include <QResizeEvent>
#include <QOperatingSystemVersion>

//#define GROUP_SECTION_TREE_ITEM_VERBOSE

Expand Down Expand Up @@ -62,7 +63,12 @@ GroupSectionTreeItem::PushButton::PushButton(QTreeWidgetItem* treeWidgetItem, Gr
_overlayLayout(),
_iconLabel()
{
setFixedHeight(22);
auto isMacOS = QOperatingSystemVersion::currentType() == QOperatingSystemVersion::MacOS;

// on macOS the buttons look extremely squished and foreign with fixed height
if(!isMacOS) {
setFixedHeight(22);
}

// Get reference to the Font Awesome icon font
auto& fontAwesome = Application::getIconFont("FontAwesome");
Expand All @@ -75,7 +81,11 @@ GroupSectionTreeItem::PushButton::PushButton(QTreeWidgetItem* treeWidgetItem, Gr
_overlayLayout.addStretch(1);

_iconLabel.setAlignment(Qt::AlignCenter);
_iconLabel.setFont(fontAwesome.getFont(7));
if(isMacOS) {
_iconLabel.setFont(fontAwesome.getFont());
} else {
_iconLabel.setFont(fontAwesome.getFont(7));
}

// Install event filter to synchronize overlay widget size with push button size
installEventFilter(this);
Expand Down
Loading
Loading