Skip to content

Commit

Permalink
Separate icons for dark and light themes (#154)
Browse files Browse the repository at this point in the history
This is necessary when the high-contrast system themes are in use, where a light theme exists, in which case our white icons are invisible on the white background.
  • Loading branch information
jakrams authored May 4, 2023
1 parent 3e1f82e commit f6a4fb0
Show file tree
Hide file tree
Showing 88 changed files with 1,091 additions and 119 deletions.
36 changes: 23 additions & 13 deletions ArrtSource/App/AppWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ArrtAppWindow::ArrtAppWindow()
{
SettingsDlg dlg(m_storageAccount.get(), m_arrAclient.get(), this);
dlg.exec(); });
act->setIcon(QIcon(":/ArrtApplication/Icons/settings.svg"));
act->setIcon(QIcon::fromTheme("settings"));
}

// help menu
Expand All @@ -83,9 +83,9 @@ ArrtAppWindow::ArrtAppWindow()

// set up toolbutton menu for model actions
{
m_clearModelsAction = new QAction(QIcon(":/ArrtApplication/Icons/remove.svg"), "Remove all models");
m_loadFromStorageAction = new QAction(QIcon(":/ArrtApplication/Icons/upload.svg"), "Load from storage...");
m_loadWithUrlAction = new QAction(QIcon(":/ArrtApplication/Icons/model.svg"), "Load with URL...");
m_clearModelsAction = new QAction(QIcon::fromTheme("remove"), "Remove all models");
m_loadFromStorageAction = new QAction(QIcon::fromTheme("upload"), "Load from storage...");
m_loadWithUrlAction = new QAction(QIcon::fromTheme("model"), "Load with URL...");

RenderingTab->ModelsToolbutton->addAction(m_loadFromStorageAction);
RenderingTab->ModelsToolbutton->addAction(m_loadWithUrlAction);
Expand Down Expand Up @@ -409,11 +409,11 @@ void ArrtAppWindow::OnUpdateStatusBar()

if (state.IsConnectionActive())
{
RenderingTab->EditSessionButton->setIcon(QIcon(":/ArrtApplication/Icons/stop.svg"));
RenderingTab->EditSessionButton->setIcon(QIcon::fromTheme("stop"));
}
else
{
RenderingTab->EditSessionButton->setIcon(QIcon(":/ArrtApplication/Icons/start.svg"));
RenderingTab->EditSessionButton->setIcon(QIcon::fromTheme("start"));
}

float fModelLoad = m_arrSession->GetModelLoadingProgress();
Expand Down Expand Up @@ -505,18 +505,28 @@ void ArrtAppWindow::CheckForNewVersion()

void ArrtAppWindow::OnCheckForNewVersionResult(QString latestVersion)
{
const QString currentVersion(ARRT_VERSION);

if (latestVersion.startsWith('v', Qt::CaseInsensitive))
{
latestVersion = latestVersion.mid(1);
}

if (currentVersion != latestVersion)
QStringList numbers = latestVersion.split('.', Qt::SkipEmptyParts);

if (numbers.size() != 3)
goto ask;

if (numbers[0].toUInt() > ARRT_VERSION_MAJOR)
goto ask;
if (numbers[1].toUInt() > ARRT_VERSION_MINOR)
goto ask;
if (numbers[2].toUInt() > ARRT_VERSION_PATCH)
goto ask;

return;

ask:
if (QMessageBox::question(this, "New Version Available", QString("ARRT version %1 is now available.\n\nDo you want to open the GitHub release page?").arg(latestVersion), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
{
if (QMessageBox::question(this, "New Version Available", QString("ARRT version %1 is now available.\n\nDo you want to open the GitHub release page?").arg(latestVersion), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
{
QDesktopServices::openUrl(QUrl("https://github.com/Azure/azure-remote-rendering-asset-tool/releases"));
}
QDesktopServices::openUrl(QUrl("https://github.com/Azure/azure-remote-rendering-asset-tool/releases"));
}
}
3 changes: 1 addition & 2 deletions ArrtSource/App/LogWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
<string>Clear Log</string>
</property>
<property name="icon">
<iconset resource="../Resources/ArrtApplication.qrc">
<normaloff>:/ArrtApplication/Icons/remove.svg</normaloff>:/ArrtApplication/Icons/remove.svg</iconset>
<iconset theme="remove"/>
</property>
</widget>
</item>
Expand Down
6 changes: 6 additions & 0 deletions ArrtSource/App/SettingsDlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@
<property name="text">
<string> + </string>
</property>
<property name="icon">
<iconset theme="new"/>
</property>
</widget>
</item>
<item>
Expand All @@ -262,6 +265,9 @@
<property name="text">
<string> X </string>
</property>
<property name="icon">
<iconset theme="remove"/>
</property>
</widget>
</item>
<item>
Expand Down
18 changes: 17 additions & 1 deletion ArrtSource/ArrtMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,28 @@ class ArrtStyle : public QProxyStyle

static void SetStyleSheet(QApplication* /*app*/)
{
// need to have any thing active, even if it's one that doesn't exist
QIcon::setThemeName("none");

if (IsHighContrastOn())
{
// if high contrast mode is enabled, we just don't use a custom theme
if (QApplication::palette().window().color().lightness() < 150)
{
// use icons from the dark theme
QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << ":theme-dark");
}
else
{
// use icons from the light theme
QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << ":theme-light");
}

// if high contrast mode is enabled, we just don't use custom colors
return;
}

QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << ":theme-dark");

QApplication::setStyle(new ArrtStyle());
QPalette palette;

Expand Down
8 changes: 7 additions & 1 deletion ArrtSource/ArrtVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

// Version information which is going to be exposed in the output executable

#define ARRT_VERSION "2.3.12"
#define STR2(s) #s
#define STR(s) STR2(s)

#define ARRT_VERSION_MAJOR 2
#define ARRT_VERSION_MINOR 3
#define ARRT_VERSION_PATCH 12
#define ARRT_VERSION STR(ARRT_VERSION_MAJOR) "." STR(ARRT_VERSION_MINOR) "." STR(ARRT_VERSION_PATCH)

#define VER_COMPANY "Microsoft Corporation"
#define VER_PRODUCTNAME "Azure Remote Rendering Toolkit"
Expand Down
8 changes: 4 additions & 4 deletions ArrtSource/Conversion/UI/ConversionTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ void ArrtAppWindow::UpdateConversionsList()
{
case ConversionStatus::New:
{
item->setIcon(QIcon(":/ArrtApplication/Icons/conversion.svg"));
item->setIcon(QIcon::fromTheme("conversion"));
text = "<new conversion>";
break;
}
case ConversionStatus::Running:
{
const uint64_t duration = QDateTime::currentSecsSinceEpoch() - conv.m_startConversionTime;
item->setIcon(QIcon(":/ArrtApplication/Icons/conversion_running.svg"));
item->setIcon(QIcon::fromTheme("conversion_running"));
text += QString(" (running) [%1]").arg(SecToString(duration));
break;
}
case ConversionStatus::Finished:
{
const uint64_t duration = conv.m_endConversionTime - conv.m_startConversionTime;
item->setIcon(QIcon(":/ArrtApplication/Icons/conversion_succeeded.svg"));
item->setIcon(QIcon::fromTheme("conversion_succeeded"));
text += QString(" (succeeded)");

if (duration > 0)
Expand All @@ -80,7 +80,7 @@ void ArrtAppWindow::UpdateConversionsList()
case ConversionStatus::Failed:
{
const uint64_t duration = conv.m_endConversionTime - conv.m_startConversionTime;
item->setIcon(QIcon(":/ArrtApplication/Icons/conversion_failed.svg"));
item->setIcon(QIcon::fromTheme("conversion_failed"));
text += QString(" (failed)");

if (duration > 0)
Expand Down
15 changes: 7 additions & 8 deletions ArrtSource/Rendering/UI/RenderingWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
<string>Session...</string>
</property>
<property name="icon">
<iconset resource="../../Resources/ArrtApplication.qrc">
<normaloff>:/ArrtApplication/Icons/start.svg</normaloff>:/ArrtApplication/Icons/start.svg</iconset>
<iconset theme="start"/>
</property>
</widget>
</item>
Expand All @@ -46,8 +45,8 @@
<string>Model</string>
</property>
<property name="icon">
<iconset resource="../../Resources/ArrtApplication.qrc">
<normaloff>:/ArrtApplication/Icons/model.svg</normaloff>:/ArrtApplication/Icons/model.svg</iconset>
<iconset theme="model">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
Expand Down Expand Up @@ -102,8 +101,8 @@
<string>Camera...</string>
</property>
<property name="icon">
<iconset resource="../../Resources/ArrtApplication.qrc">
<normaloff>:/ArrtApplication/Icons/settings.svg</normaloff>:/ArrtApplication/Icons/settings.svg</iconset>
<iconset theme="settings">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
Expand All @@ -113,8 +112,8 @@
<string>Inspect...</string>
</property>
<property name="icon">
<iconset resource="../../Resources/ArrtApplication.qrc">
<normaloff>:/ArrtApplication/Icons/inspector.svg</normaloff>:/ArrtApplication/Icons/inspector.svg</iconset>
<iconset theme="inspector">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
Expand Down
13 changes: 3 additions & 10 deletions ArrtSource/Rendering/UI/StartSessionDlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@
<property name="text">
<string>Extend Now</string>
</property>
<property name="icon">
<iconset resource="../../Resources/ArrtApplication.qrc">
<normaloff>:/ArrtApplication/Icons/extendtime.svg</normaloff>:/ArrtApplication/Icons/extendtime.svg</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
Expand Down Expand Up @@ -192,8 +188,7 @@
<string>Auto Extend</string>
</property>
<property name="icon">
<iconset resource="../../Resources/ArrtApplication.qrc">
<normaloff>:/ArrtApplication/Icons/autoextendtime.svg</normaloff>:/ArrtApplication/Icons/autoextendtime.svg</iconset>
<iconset theme="autoextendtime"/>
</property>
</widget>
</item>
Expand Down Expand Up @@ -253,8 +248,7 @@
<string>Start</string>
</property>
<property name="icon">
<iconset resource="../../Resources/ArrtApplication.qrc">
<normaloff>:/ArrtApplication/Icons/start.svg</normaloff>:/ArrtApplication/Icons/start.svg</iconset>
<iconset theme="start"/>
</property>
<property name="default">
<bool>true</bool>
Expand All @@ -267,8 +261,7 @@
<string>Stop</string>
</property>
<property name="icon">
<iconset resource="../../Resources/ArrtApplication.qrc">
<normaloff>:/ArrtApplication/Icons/stop.svg</normaloff>:/ArrtApplication/Icons/stop.svg</iconset>
<iconset theme="stop"/>
</property>
</widget>
</item>
Expand Down
102 changes: 48 additions & 54 deletions ArrtSource/Resources/ArrtApplication.qrc
Original file line number Diff line number Diff line change
@@ -1,57 +1,51 @@
<RCC>
<qresource prefix="/ArrtApplication">
<file>Icons/conversion.svg</file>
<file>Icons/critical.svg</file>
<file>Icons/debug.svg</file>
<file>Icons/details.svg</file>
<file>Icons/directory.svg</file>
<file>Icons/directorymode.svg</file>
<file>Icons/error.svg</file>
<file>Icons/info.svg</file>
<file>Icons/log.svg</file>
<file>Icons/model.svg</file>
<file>Icons/rendering.svg</file>
<file>Icons/settings.svg</file>
<file>Icons/simple.svg</file>
<file>Icons/start.svg</file>
<file>Icons/stop.svg</file>
<file>Icons/warning.svg</file>
<file>Icons/inspector.svg</file>
<file>Icons/new.svg</file>
<file>Icons/upload.svg</file>
<file>Icons/autoextendtime.svg</file>
<file>Icons/extendtime.svg</file>
<file>Icons/parentdir.svg</file>
<file>Icons/remove.svg</file>
<file>Icons/conversion_canceled.svg</file>
<file>Icons/conversion_failed.svg</file>
<file>Icons/conversion_running.svg</file>
<file>Icons/conversion_succeeded.svg</file>
<file>Icons/collapse.svg</file>
<file>Icons/expand.svg</file>
<file>Icons/newfolder.svg</file>
<file>Icons/showblobs.svg</file>
<file>Icons/expanded.svg</file>
<file>Icons/notexpanded.svg</file>
<file>Icons/session_connected.svg</file>
<file>Icons/session_connecting.svg</file>
<file>Icons/session_error.svg</file>
<file>Icons/session_expired.svg</file>
<file>Icons/session_not_active.svg</file>
<file>Icons/session_ready.svg</file>
<file>Icons/session_starting.svg</file>
<file>Icons/session_stop_requested.svg</file>
<file>Icons/session_stopped.svg</file>
<file>Icons/refresh.svg</file>
<file>Icons/back.svg</file>
<file>Icons/remoterendering.png</file>
<file>Icons/more_actions.svg</file>
<file>Icons/arrow_down.svg</file>
<file>Icons/arrow_left.svg</file>
<file>Icons/arrow_right.svg</file>
<file>Icons/arrow_up.svg</file>
<file>Icons/materials.svg</file>
<file>Icons/stats.svg</file>
<file>Icons/scene.svg</file>
<qresource prefix="/">
<file>theme-dark/model.svg</file>
<file>theme-dark/remove.svg</file>
<file>theme-dark/upload.svg</file>
<file>theme-dark/settings.svg</file>
<file>theme-dark/inspector.svg</file>
<file>theme-dark/directory.svg</file>
<file>theme-dark/newfolder.svg</file>
<file>theme-dark/autoextendtime.svg</file>
<file>theme-dark/remoterendering.png</file>
<file>theme-dark/refresh.svg</file>
<file>theme-dark/new.svg</file>
<file>theme-dark/start.svg</file>
<file>theme-dark/stop.svg</file>
<file>theme-dark/conversion.svg</file>
<file>theme-dark/conversion_failed.svg</file>
<file>theme-dark/conversion_running.svg</file>
<file>theme-dark/conversion_succeeded.svg</file>
<file>theme-dark/debug.svg</file>
<file>theme-dark/info.svg</file>
<file>theme-dark/warning.svg</file>
<file>theme-dark/critical.svg</file>
<file>theme-dark/error.svg</file>
<file>theme-dark/session_error.svg</file>

<file>theme-light/model.svg</file>
<file>theme-light/remove.svg</file>
<file>theme-light/upload.svg</file>
<file>theme-light/settings.svg</file>
<file>theme-light/inspector.svg</file>
<file>theme-light/directory.svg</file>
<file>theme-light/newfolder.svg</file>
<file>theme-light/autoextendtime.svg</file>
<file>theme-light/remoterendering.png</file>
<file>theme-light/refresh.svg</file>
<file>theme-light/new.svg</file>
<file>theme-light/start.svg</file>
<file>theme-light/stop.svg</file>
<file>theme-light/conversion.svg</file>
<file>theme-light/conversion_failed.svg</file>
<file>theme-light/conversion_running.svg</file>
<file>theme-light/conversion_succeeded.svg</file>
<file>theme-light/debug.svg</file>
<file>theme-light/info.svg</file>
<file>theme-light/warning.svg</file>
<file>theme-light/critical.svg</file>
<file>theme-light/error.svg</file>
<file>theme-light/session_error.svg</file>
</qresource>
</RCC>
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit f6a4fb0

Please sign in to comment.