Gui: Add Std_ReloadStyleSheet command

This adds a command that will reload currently active stylesheet - a must have for stylesheet developers
This commit is contained in:
Kacper Donat
2024-05-12 15:42:36 +02:00
committed by Chris Hennes
parent ba9240a3f2
commit b231bbb0ca
2 changed files with 29 additions and 0 deletions

View File

@@ -2188,6 +2188,7 @@ void Application::setStyleSheet(const QString& qssFile, bool tiledBackground)
}
mw->setProperty("fc_currentStyleSheet", qssFile);
mw->setProperty("fc_tiledBackground", tiledBackground);
if (!qssFile.isEmpty()) {
// Search for stylesheet in user-defined search paths.

View File

@@ -952,6 +952,33 @@ bool StdCmdUserEditMode::isActive()
return true;
}
//===========================================================================
// Std_ReloadStylesheet
//===========================================================================
DEF_STD_CMD(StdCmdReloadStyleSheet)
StdCmdReloadStyleSheet::StdCmdReloadStyleSheet()
: Command("Std_ReloadStyleSheet")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("&Reload stylesheet");
sToolTipText = QT_TR_NOOP("Reloads the current stylesheet");
sWhatsThis = "Std_ReloadStyleSheet";
sStatusTip = QT_TR_NOOP("Reloads the current stylesheet");
sPixmap = "view-refresh";
sWhatsThis = "Std_ReloadStyleSheet";
}
void StdCmdReloadStyleSheet::activated(int iMsg)
{
auto mw = getMainWindow();
auto qssFile = mw->property("fc_currentStyleSheet").toString();
auto tiledBackground = mw->property("fc_tiledBackground").toBool();
Gui::Application::Instance->setStyleSheet(qssFile, tiledBackground);
}
namespace Gui {
void CreateStdCommands()
@@ -983,6 +1010,7 @@ void CreateStdCommands()
rcCmdMgr.addCommand(new StdCmdTextDocument());
rcCmdMgr.addCommand(new StdCmdUnitsCalculator());
rcCmdMgr.addCommand(new StdCmdUserEditMode());
rcCmdMgr.addCommand(new StdCmdReloadStyleSheet());
//rcCmdMgr.addCommand(new StdCmdMeasurementSimple());
//rcCmdMgr.addCommand(new StdCmdDownloadOnlineHelp());
//rcCmdMgr.addCommand(new StdCmdDescription());