mirror of
https://github.com/deskflow/deskflow.git
synced 2026-07-04 21:04:59 +08:00
refactor: move logExpanded to Settings
newkey: gui/logExpanded <= General/logExpanded remove logExpanded AppConfig
This commit is contained in:
parent
2a53d4f187
commit
698fd3f83c
@ -15,7 +15,7 @@
|
||||
#include "dialogs/SettingsDialog.h"
|
||||
|
||||
#include "base/String.h"
|
||||
#include "common/constants.h"
|
||||
#include "common/Settings.h"
|
||||
#include "gui/Logger.h"
|
||||
#include "gui/config/ConfigScopes.h"
|
||||
#include "gui/constants.h"
|
||||
@ -226,7 +226,7 @@ void MainWindow::setupControls()
|
||||
|
||||
// Setup the log toggle, set its initial state to closed
|
||||
ui->btnToggleLog->setStyleSheet(kStyleFlatButton);
|
||||
if (m_appConfig.logExpanded()) {
|
||||
if (Settings::value(Settings::Gui::LogExpanded).toBool()) {
|
||||
ui->btnToggleLog->setArrowType(Qt::DownArrow);
|
||||
ui->textLog->setVisible(true);
|
||||
ui->btnToggleLog->click();
|
||||
@ -361,14 +361,12 @@ void MainWindow::toggleLogVisible(bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
ui->btnToggleLog->setArrowType(Qt::DownArrow);
|
||||
ui->textLog->setVisible(true);
|
||||
m_appConfig.setLogExpanded(true);
|
||||
} else {
|
||||
ui->btnToggleLog->setArrowType(Qt::RightArrow);
|
||||
m_expandedSize = size();
|
||||
ui->textLog->setVisible(false);
|
||||
m_appConfig.setLogExpanded(false);
|
||||
}
|
||||
ui->textLog->setVisible(visible);
|
||||
Settings::setValue(Settings::Gui::LogExpanded, visible);
|
||||
// 1 ms delay is to make sure we have left the function before calling updateSize
|
||||
QTimer::singleShot(1, this, &MainWindow::updateSize);
|
||||
}
|
||||
@ -516,7 +514,7 @@ void MainWindow::resetCore()
|
||||
|
||||
void MainWindow::updateSize()
|
||||
{
|
||||
if (m_appConfig.logExpanded()) {
|
||||
if (Settings::value(Settings::Gui::LogExpanded).toBool()) {
|
||||
setMaximumHeight(16777215);
|
||||
setMaximumWidth(16777215);
|
||||
resize(m_expandedSize);
|
||||
|
||||
@ -73,6 +73,10 @@ QVariant Settings::defaultValue(const QString &key)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (key == Gui::LogExpanded) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@ -101,11 +105,11 @@ void Settings::setScope(bool systemScope)
|
||||
const bool wasWritable = instance()->m_settings->isWritable();
|
||||
|
||||
QSettings userSettings(Settings::UserSettingFile, QSettings::IniFormat);
|
||||
userSettings.setValue(Settings::Core::Scope, systemScope);
|
||||
userSettings.setValue(Core::Scope, systemScope);
|
||||
userSettings.sync();
|
||||
|
||||
QSettings systemSettings(Settings::SystemSettingFile, QSettings::IniFormat);
|
||||
systemSettings.setValue(Settings::Core::Scope, systemScope);
|
||||
systemSettings.setValue(Core::Scope, systemScope);
|
||||
systemSettings.sync();
|
||||
|
||||
instance()->initSettings();
|
||||
|
||||
@ -34,6 +34,10 @@ public:
|
||||
{
|
||||
inline static const auto Scope = QStringLiteral("core/loadFromSystemScope");
|
||||
};
|
||||
struct Gui
|
||||
{
|
||||
inline static const auto LogExpanded = QStringLiteral("gui/logExpanded");
|
||||
};
|
||||
|
||||
static Settings *instance();
|
||||
static void setSettingFile(const QString &settingsFile = QString());
|
||||
@ -63,5 +67,10 @@ private:
|
||||
|
||||
QSettings *m_settings = nullptr;
|
||||
QString m_portableSettingsFile = QStringLiteral("%1.conf").arg(kAppName);
|
||||
inline static const QStringList m_validKeys = {Settings::Core::Scope};
|
||||
// clang-format off
|
||||
inline static const QStringList m_validKeys = {
|
||||
Core::Scope
|
||||
, Gui::LogExpanded
|
||||
};
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
@ -95,6 +95,7 @@ add_library(${target} STATIC
|
||||
|
||||
target_link_libraries(
|
||||
${target}
|
||||
common
|
||||
platform
|
||||
Qt6::Core
|
||||
Qt6::Widgets
|
||||
|
||||
@ -77,7 +77,7 @@ const char *const AppConfig::m_SettingsName[] = {
|
||||
"", // 41 = Show dev thanks, obsolete
|
||||
"showCloseReminder",
|
||||
"enableUpdateCheck",
|
||||
"logExpanded",
|
||||
"", // 44, Moved to deskflow settings.
|
||||
"colorfulIcon",
|
||||
"requireClientCerts",
|
||||
};
|
||||
@ -143,7 +143,6 @@ void AppConfig::recallFromCurrentScope()
|
||||
m_MainWindowSize = getFromCurrentScope<QSize>(kMainWindowSize, [](const QVariant &v) { return v.toSize(); });
|
||||
m_ShowCloseReminder = getFromCurrentScope(kShowCloseReminder, m_ShowCloseReminder).toBool();
|
||||
m_EnableUpdateCheck = getFromCurrentScope<bool>(kEnableUpdateCheck, [](const QVariant &v) { return v.toBool(); });
|
||||
m_logExpanded = getFromCurrentScope(kLogExpanded, m_logExpanded).toBool();
|
||||
m_colorfulTrayIcon = getFromCurrentScope(kColorfulIcon, m_colorfulTrayIcon).toBool();
|
||||
}
|
||||
|
||||
@ -200,7 +199,6 @@ void AppConfig::commit()
|
||||
setInCurrentScope(kMainWindowPosition, m_MainWindowPosition);
|
||||
setInCurrentScope(kShowCloseReminder, m_ShowCloseReminder);
|
||||
setInCurrentScope(kEnableUpdateCheck, m_EnableUpdateCheck);
|
||||
setInCurrentScope(kLogExpanded, m_logExpanded);
|
||||
setInCurrentScope(kColorfulIcon, m_colorfulTrayIcon);
|
||||
setInCurrentScope(kRequireClientCert, m_RequireClientCert);
|
||||
}
|
||||
@ -574,11 +572,6 @@ std::optional<bool> AppConfig::enableUpdateCheck() const
|
||||
return m_EnableUpdateCheck;
|
||||
}
|
||||
|
||||
bool AppConfig::logExpanded() const
|
||||
{
|
||||
return m_logExpanded;
|
||||
}
|
||||
|
||||
bool AppConfig::colorfulTrayIcon() const
|
||||
{
|
||||
return m_colorfulTrayIcon;
|
||||
@ -756,13 +749,6 @@ void AppConfig::setEnableUpdateCheck(bool value)
|
||||
m_EnableUpdateCheck = value;
|
||||
}
|
||||
|
||||
void AppConfig::setLogExpanded(bool expanded)
|
||||
{
|
||||
if (expanded == m_logExpanded)
|
||||
return;
|
||||
m_logExpanded = expanded;
|
||||
}
|
||||
|
||||
void AppConfig::setColorfulTrayIcon(bool colorful)
|
||||
{
|
||||
if (colorful == m_colorfulTrayIcon)
|
||||
|
||||
@ -99,7 +99,7 @@ private:
|
||||
// 41 = show dev thanks, obsolete
|
||||
kShowCloseReminder = 42,
|
||||
kEnableUpdateCheck = 43,
|
||||
kLogExpanded = 44,
|
||||
// 44 = LogExpanded, Moved to deskflow settings
|
||||
kColorfulIcon = 45,
|
||||
kRequireClientCert = 46
|
||||
};
|
||||
@ -175,7 +175,6 @@ public:
|
||||
std::optional<QPoint> mainWindowPosition() const;
|
||||
bool showCloseReminder() const;
|
||||
std::optional<bool> enableUpdateCheck() const;
|
||||
bool logExpanded() const;
|
||||
bool colorfulTrayIcon() const;
|
||||
|
||||
//
|
||||
@ -216,7 +215,6 @@ public:
|
||||
void setMainWindowPosition(const QPoint &position);
|
||||
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.
|
||||
@ -321,7 +319,6 @@ private:
|
||||
bool m_LoadFromSystemScope = false;
|
||||
bool m_ShowCloseReminder = true;
|
||||
std::optional<bool> m_EnableUpdateCheck;
|
||||
bool m_logExpanded = true;
|
||||
bool m_colorfulTrayIcon = false;
|
||||
bool m_RequireClientCert = true;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user