StartPage implement custom CSS preference
This commit is contained in:
@@ -99,6 +99,7 @@ PyMOD_INIT_FUNC(StartGui)
|
||||
|
||||
// register preferences pages
|
||||
new Gui::PrefPageProducer<StartGui::DlgStartPreferencesImp> (QT_TRANSLATE_NOOP("QObject", "Start"));
|
||||
new Gui::PrefPageProducer<StartGui::DlgStartPreferencesAdvancedImp> (QT_TRANSLATE_NOOP("QObject", "Start"));
|
||||
|
||||
// instantiating the commands
|
||||
CreateStartCommands();
|
||||
|
||||
@@ -14,6 +14,7 @@ set(StartGui_LIBS
|
||||
|
||||
set(StartGui_UIC_SRCS
|
||||
DlgStartPreferences.ui
|
||||
DlgStartPreferencesAdvanced.ui
|
||||
)
|
||||
|
||||
set (Start_TR_QRC ${CMAKE_CURRENT_BINARY_DIR}/Resources/Start_translation.qrc)
|
||||
@@ -26,6 +27,7 @@ SET(StartGui_SRCS
|
||||
${Start_QRC_SRCS}
|
||||
${StartGui_UIC_SRCS}
|
||||
DlgStartPreferences.ui
|
||||
DlgStartPreferencesAdvanced.ui
|
||||
DlgStartPreferencesImp.cpp
|
||||
DlgStartPreferencesImp.h
|
||||
AppStartGui.cpp
|
||||
|
||||
@@ -11,31 +11,9 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Start page options</string>
|
||||
<string>General</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Start page template</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="Gui::PrefFileChooser" name="fileChooser_1" native="true">
|
||||
<property name="toolTip">
|
||||
<string>An optional HTML template that will be used instead of the default start page.</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Template</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Start</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
|
||||
87
src/Mod/Start/Gui/DlgStartPreferencesAdvanced.ui
Normal file
87
src/Mod/Start/Gui/DlgStartPreferencesAdvanced.ui
Normal file
File diff suppressed because one or more lines are too long
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "DlgStartPreferencesImp.h"
|
||||
#include "ui_DlgStartPreferences.h"
|
||||
#include "ui_DlgStartPreferencesAdvanced.h"
|
||||
|
||||
|
||||
using namespace StartGui;
|
||||
@@ -33,9 +34,9 @@ using namespace StartGui;
|
||||
/**
|
||||
* Constructs a DlgStartPreferencesImp which is a child of 'parent'
|
||||
*/
|
||||
DlgStartPreferencesImp::DlgStartPreferencesImp( QWidget* parent )
|
||||
: PreferencePage( parent )
|
||||
, ui(new Ui_DlgStartPreferences)
|
||||
DlgStartPreferencesImp::DlgStartPreferencesImp(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgStartPreferences)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -55,8 +56,10 @@ DlgStartPreferencesImp::DlgStartPreferencesImp( QWidget* parent )
|
||||
menuText[text] = it;
|
||||
}
|
||||
|
||||
{ // add special workbench to selection
|
||||
QPixmap px = Gui::Application::Instance->workbenchIcon(QString::fromLatin1("NoneWorkbench"));
|
||||
// add special workbench to selection
|
||||
{
|
||||
QPixmap px =
|
||||
Gui::Application::Instance->workbenchIcon(QString::fromLatin1("NoneWorkbench"));
|
||||
QString key = QString::fromLatin1("<last>");
|
||||
QString value = QString::fromLatin1("$LastModule");
|
||||
if (px.isNull()) {
|
||||
@@ -69,12 +72,13 @@ DlgStartPreferencesImp::DlgStartPreferencesImp( QWidget* parent )
|
||||
|
||||
for (QMap<QString, QString>::Iterator it = menuText.begin(); it != menuText.end(); ++it) {
|
||||
QPixmap px = Gui::Application::Instance->workbenchIcon(it.value());
|
||||
if (px.isNull())
|
||||
if (px.isNull()) {
|
||||
ui->AutoloadModuleCombo->addItem(it.key(), QVariant(it.value()));
|
||||
else
|
||||
}
|
||||
else {
|
||||
ui->AutoloadModuleCombo->addItem(px, it.key(), QVariant(it.value()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,8 +91,9 @@ void DlgStartPreferencesImp::saveSettings()
|
||||
int index = ui->AutoloadModuleCombo->currentIndex();
|
||||
QVariant data = ui->AutoloadModuleCombo->itemData(index);
|
||||
QString startWbName = data.toString();
|
||||
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Start")->
|
||||
SetASCII("AutoloadModule", startWbName.toLatin1());
|
||||
App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Start")
|
||||
->SetASCII("AutoloadModule", startWbName.toLatin1());
|
||||
ui->colorButton_1->onSave();
|
||||
ui->colorButton_2->onSave();
|
||||
ui->colorButton_3->onSave();
|
||||
@@ -96,7 +101,6 @@ void DlgStartPreferencesImp::saveSettings()
|
||||
ui->colorButton_5->onSave();
|
||||
ui->colorButton_6->onSave();
|
||||
ui->colorButton_7->onSave();
|
||||
ui->fileChooser_1->onSave();
|
||||
ui->fileChooser_2->onSave();
|
||||
ui->fileChooser_3->onSave();
|
||||
ui->radioButton_1->onSave();
|
||||
@@ -118,8 +122,9 @@ void DlgStartPreferencesImp::saveSettings()
|
||||
void DlgStartPreferencesImp::loadSettings()
|
||||
{
|
||||
std::string start = App::Application::Config()["StartWorkbench"];
|
||||
start = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Start")->
|
||||
GetASCII("AutoloadModule", start.c_str());
|
||||
start = App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Start")
|
||||
->GetASCII("AutoloadModule", start.c_str());
|
||||
QString startWbName = QLatin1String(start.c_str());
|
||||
ui->AutoloadModuleCombo->setCurrentIndex(ui->AutoloadModuleCombo->findData(startWbName));
|
||||
ui->colorButton_1->onRestore();
|
||||
@@ -129,7 +134,6 @@ void DlgStartPreferencesImp::loadSettings()
|
||||
ui->colorButton_5->onRestore();
|
||||
ui->colorButton_6->onRestore();
|
||||
ui->colorButton_7->onRestore();
|
||||
ui->fileChooser_1->onRestore();
|
||||
ui->fileChooser_2->onRestore();
|
||||
ui->fileChooser_3->onRestore();
|
||||
ui->radioButton_1->onRestore();
|
||||
@@ -151,7 +155,48 @@ void DlgStartPreferencesImp::loadSettings()
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgStartPreferencesImp::changeEvent(QEvent *ev)
|
||||
void DlgStartPreferencesImp::changeEvent(QEvent* ev)
|
||||
{
|
||||
if (ev->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
else {
|
||||
Gui::Dialog::PreferencePage::changeEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a DlgStartPreferencesAdvancedImp which is a child of 'parent'
|
||||
*/
|
||||
DlgStartPreferencesAdvancedImp::DlgStartPreferencesAdvancedImp(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgStartPreferencesAdvanced)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgStartPreferencesAdvancedImp::~DlgStartPreferencesAdvancedImp() = default;
|
||||
|
||||
void DlgStartPreferencesAdvancedImp::saveSettings()
|
||||
{
|
||||
ui->templateFileChooser->onSave();
|
||||
ui->customCSSTextEdit->onSave();
|
||||
}
|
||||
|
||||
void DlgStartPreferencesAdvancedImp::loadSettings()
|
||||
{
|
||||
ui->templateFileChooser->onRestore();
|
||||
ui->customCSSTextEdit->onRestore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgStartPreferencesAdvancedImp::changeEvent(QEvent* ev)
|
||||
{
|
||||
if (ev->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
|
||||
@@ -23,29 +23,48 @@
|
||||
#ifndef STARTGUI_DLGSTARTPREFERENCESIMP_H
|
||||
#define STARTGUI_DLGSTARTPREFERENCESIMP_H
|
||||
|
||||
#include <memory>
|
||||
#include <Gui/PropertyPage.h>
|
||||
#include <memory>
|
||||
|
||||
|
||||
class Ui_DlgStartPreferences;
|
||||
namespace StartGui {
|
||||
class DlgStartPreferencesImp : public Gui::Dialog::PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
class Ui_DlgStartPreferencesAdvanced;
|
||||
namespace StartGui
|
||||
{
|
||||
class DlgStartPreferencesImp: public Gui::Dialog::PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgStartPreferencesImp( QWidget* parent = nullptr );
|
||||
~DlgStartPreferencesImp() override;
|
||||
public:
|
||||
explicit DlgStartPreferencesImp(QWidget* parent = nullptr);
|
||||
~DlgStartPreferencesImp() override;
|
||||
|
||||
protected:
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
void changeEvent(QEvent *e) override;
|
||||
protected:
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgStartPreferences> ui;
|
||||
};
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgStartPreferences> ui;
|
||||
};
|
||||
|
||||
} // namespace StartGui
|
||||
class DlgStartPreferencesAdvancedImp: public Gui::Dialog::PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
#endif // STARTGUI_DLGSTARTPREFERENCESIMP_H
|
||||
public:
|
||||
explicit DlgStartPreferencesAdvancedImp(QWidget* parent = nullptr);
|
||||
~DlgStartPreferencesAdvancedImp() override;
|
||||
|
||||
protected:
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgStartPreferencesAdvanced> ui;
|
||||
};
|
||||
|
||||
}// namespace StartGui
|
||||
|
||||
#endif// STARTGUI_DLGSTARTPREFERENCESIMP_H
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<script>JS</script>
|
||||
<style>
|
||||
CSS
|
||||
DEFAULT_CSS
|
||||
CUSTOM_CSS
|
||||
</style>
|
||||
<!--QSS-->
|
||||
</head>
|
||||
|
||||
@@ -352,7 +352,8 @@ def handle():
|
||||
with open(css_filename, 'r') as f:
|
||||
CSS = f.read()
|
||||
HTML = HTML.replace("JS",JS)
|
||||
HTML = HTML.replace("CSS",CSS)
|
||||
HTML = HTML.replace("DEFAULT_CSS",CSS)
|
||||
HTML = HTML.replace("CUSTOM_CSS",FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetString("CustomCSS","").replace("\n",""))
|
||||
|
||||
# set the language
|
||||
|
||||
|
||||
Reference in New Issue
Block a user