feat: Allow users to pick mono color (based on isDarkMode) or colorful icon
This commit is contained in:
@ -32,6 +32,7 @@
|
||||
#include "gui/diagnostic.h"
|
||||
#include "gui/messages.h"
|
||||
#include "gui/string_utils.h"
|
||||
#include "gui/style_utils.h"
|
||||
#include "gui/styles.h"
|
||||
#include "gui/tls/TlsFingerprint.h"
|
||||
#include "platform/wayland.h"
|
||||
@ -66,12 +67,9 @@ using CoreMode = CoreProcess::Mode;
|
||||
using CoreConnectionState = CoreProcess::ConnectionState;
|
||||
using CoreProcessState = CoreProcess::ProcessState;
|
||||
|
||||
const auto kIconFile = ":/icons/128x128/tray.png";
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
const auto kColorfulIconFile = ":/icons/128x128/tray.png";
|
||||
const auto kLightIconFile = ":/icons/128x128/tray-light.png";
|
||||
const auto kDarkIconFile = ":/icons/128x128/tray-dark.png";
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
|
||||
: ui{std::make_unique<Ui::MainWindow>()},
|
||||
@ -673,6 +671,7 @@ void MainWindow::applyConfig()
|
||||
ui->lineHostname->setText(m_AppConfig.serverHostname());
|
||||
ui->lineClientIp->setText(m_ServerConfig.getClientAddress());
|
||||
updateLocalFingerprint();
|
||||
setIcon();
|
||||
}
|
||||
|
||||
void MainWindow::saveSettings()
|
||||
@ -687,12 +686,16 @@ void MainWindow::saveSettings()
|
||||
|
||||
void MainWindow::setIcon()
|
||||
{
|
||||
QIcon icon;
|
||||
#ifdef Q_OS_MAC
|
||||
icon.addFile(kDarkIconFile);
|
||||
icon.setIsMask(true);
|
||||
QIcon icon;
|
||||
if (appConfig().colorfulTrayIcon())
|
||||
icon.addFile(kColorfulIconFile);
|
||||
else {
|
||||
icon.addFile(kDarkIconFile);
|
||||
icon.setIsMask(true);
|
||||
}
|
||||
#else
|
||||
QIcon icon(kIconFile);
|
||||
QIcon icon(appConfig().colorfulTrayIcon() ? kColorfulIconFile : isDarkMode() ? kDarkIconFile : kLightIconFile);
|
||||
#endif
|
||||
m_trayIcon->setIcon(icon);
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
#include "gui/core/CoreProcess.h"
|
||||
#include "gui/messages.h"
|
||||
#include "gui/style_utils.h"
|
||||
#include "gui/tls/TlsCertificate.h"
|
||||
#include "gui/tls/TlsUtility.h"
|
||||
#include "gui/validators/ScreenNameValidator.h"
|
||||
@ -197,6 +198,7 @@ void SettingsDialog::accept()
|
||||
m_appConfig.setEnableService(ui->m_pCheckBoxServiceEnabled->isChecked());
|
||||
m_appConfig.setCloseToTray(ui->m_pCheckBoxCloseToTray->isChecked());
|
||||
m_appConfig.setInvertConnection(ui->m_pInvertConnection->isChecked());
|
||||
m_appConfig.setColorfulTrayIcon(ui->rb_icon_colorful->isChecked());
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
@ -242,6 +244,16 @@ void SettingsDialog::loadFromConfig()
|
||||
|
||||
ui->m_pInvertConnection->setChecked(m_appConfig.invertConnection());
|
||||
|
||||
if (m_appConfig.colorfulTrayIcon())
|
||||
ui->rb_icon_colorful->setChecked(true);
|
||||
else
|
||||
ui->rb_icon_mono->setChecked(true);
|
||||
|
||||
ui->rb_icon_mono->setIcon(
|
||||
isDarkMode() ? QIcon(QStringLiteral(":/icons/128x128/tray-dark.png"))
|
||||
: QIcon(QStringLiteral(":/icons/128x128/tray-light.png"))
|
||||
);
|
||||
|
||||
updateTlsControls();
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>550</width>
|
||||
<height>625</height>
|
||||
<height>652</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -160,6 +160,39 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Tray icon style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_icon_colorful">
|
||||
<property name="text">
|
||||
<string>Colorful</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../res/deskflow.qrc">
|
||||
<normaloff>:/icons/128x128/tray.png</normaloff>:/icons/128x128/tray.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_icon_mono">
|
||||
<property name="text">
|
||||
<string>Monocolor</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../res/deskflow.qrc">
|
||||
<normaloff>:/icons/128x128/tray-dark.png</normaloff>:/icons/128x128/tray-dark.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -761,7 +794,9 @@
|
||||
<tabstop>m_pRadioSystemScope</tabstop>
|
||||
<tabstop>m_pComboElevate</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../res/deskflow.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>m_pButtonBox</sender>
|
||||
|
||||
@ -592,6 +592,11 @@ bool AppConfig::logExpanded() const
|
||||
return m_logExpanded;
|
||||
}
|
||||
|
||||
bool AppConfig::colorfulTrayIcon() const
|
||||
{
|
||||
return m_colorfulTrayIcon;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// End getters
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -772,6 +777,13 @@ void AppConfig::setLogExpanded(bool expanded)
|
||||
m_logExpanded = expanded;
|
||||
}
|
||||
|
||||
void AppConfig::setColorfulTrayIcon(bool colorful)
|
||||
{
|
||||
if (colorful == m_colorfulTrayIcon)
|
||||
return;
|
||||
m_colorfulTrayIcon = colorful;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// End setters
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -110,6 +110,7 @@ private:
|
||||
kShowCloseReminder = 42,
|
||||
kEnableUpdateCheck = 43,
|
||||
kLogExpanded = 44,
|
||||
kColorIcon = 45
|
||||
};
|
||||
|
||||
public:
|
||||
@ -185,6 +186,7 @@ public:
|
||||
bool showCloseReminder() const;
|
||||
std::optional<bool> enableUpdateCheck() const;
|
||||
bool logExpanded() const;
|
||||
bool colorfulTrayIcon() const;
|
||||
|
||||
//
|
||||
// Setters (overrides)
|
||||
@ -226,6 +228,7 @@ public:
|
||||
void setShowCloseReminder(bool show);
|
||||
void setEnableUpdateCheck(bool value);
|
||||
void setLogExpanded(bool expanded);
|
||||
void setColorfulTrayIcon(bool color);
|
||||
|
||||
/// @brief Sets the user preference to load from SystemScope.
|
||||
/// @param [in] value
|
||||
@ -332,6 +335,7 @@ private:
|
||||
bool m_ShowCloseReminder = true;
|
||||
std::optional<bool> m_EnableUpdateCheck;
|
||||
bool m_logExpanded = true;
|
||||
bool m_colorfulTrayIcon = false;
|
||||
|
||||
/**
|
||||
* @brief Flag is set when any TLS is setting is changed, and is reset
|
||||
|
||||
Reference in New Issue
Block a user