Allow to set custom suffix to window title

This is to allow users to differentiate qbt instances when there are multiple running.
PR #20429.
Closes #17905.
This commit is contained in:
Chocobo1
2024-02-27 12:41:12 +08:00
committed by GitHub
parent 364bcf73ee
commit 46e8ee50c8
13 changed files with 98 additions and 27 deletions

View File

@@ -226,6 +226,7 @@ namespace
Application::Application(int &argc, char **argv)
: BaseApplication(argc, argv)
, m_commandLineArgs(parseCommandLine(Application::arguments()))
, m_storeInstanceName(SETTINGS_KEY(u"InstanceName"_s))
, m_storeFileLoggerEnabled(FILELOGGER_SETTINGS_KEY(u"Enabled"_s))
, m_storeFileLoggerBackup(FILELOGGER_SETTINGS_KEY(u"Backup"_s))
, m_storeFileLoggerDeleteOld(FILELOGGER_SETTINGS_KEY(u"DeleteOld"_s))
@@ -360,6 +361,23 @@ const QBtCommandLineParameters &Application::commandLineArgs() const
return m_commandLineArgs;
}
QString Application::instanceName() const
{
return m_storeInstanceName;
}
void Application::setInstanceName(const QString &name)
{
if (name == instanceName())
return;
m_storeInstanceName = name;
#ifndef DISABLE_GUI
if (MainWindow *mw = mainWindow())
mw->setTitleSuffix(name);
#endif
}
int Application::memoryWorkingSetLimit() const
{
return m_storeMemoryWorkingSetLimit.get(512);
@@ -880,7 +898,8 @@ int Application::exec()
const WindowState windowState = (m_startupProgressDialog->windowState() & Qt::WindowMinimized)
? WindowState::Minimized : WindowState::Normal;
#endif
m_window = new MainWindow(this, windowState);
m_window = new MainWindow(this, windowState, instanceName());
delete m_startupProgressDialog;
#endif // DISABLE_GUI

View File

@@ -105,6 +105,9 @@ public:
bool callMainInstance();
const QBtCommandLineParameters &commandLineArgs() const;
QString instanceName() const override;
void setInstanceName(const QString &name) override;
// FileLogger properties
bool isFileLoggerEnabled() const override;
void setFileLoggerEnabled(bool value) override;
@@ -194,6 +197,7 @@ private:
QList<QBtCommandLineParameters> m_paramsQueue;
SettingValue<QString> m_storeInstanceName;
SettingValue<bool> m_storeFileLoggerEnabled;
SettingValue<bool> m_storeFileLoggerBackup;
SettingValue<bool> m_storeFileLoggerDeleteOld;