Merge pull request #10520 from qewer33/startpage-quickstart-open
StartPage: Add custom CSS option, re-organize preferences and further fixes
This commit is contained in:
@@ -101,7 +101,8 @@ PyMOD_INIT_FUNC(StartGui)
|
||||
|
||||
// clang-format off
|
||||
// register preferences pages
|
||||
new Gui::PrefPageProducer<StartGui::DlgStartPreferencesImp>(QT_TRANSLATE_NOOP("QObject", "Start"));
|
||||
new Gui::PrefPageProducer<StartGui::DlgStartPreferencesImp> (QT_TRANSLATE_NOOP("QObject", "Start"));
|
||||
new Gui::PrefPageProducer<StartGui::DlgStartPreferencesAdvancedImp> (QT_TRANSLATE_NOOP("QObject", "Start"));
|
||||
// clang-format on
|
||||
|
||||
// instantiating the commands
|
||||
|
||||
@@ -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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
90
src/Mod/Start/Gui/DlgStartPreferencesAdvanced.ui
Normal file
90
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;
|
||||
@@ -90,28 +91,26 @@ void DlgStartPreferencesImp::saveSettings()
|
||||
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();
|
||||
ui->colorButton_4->onSave();
|
||||
ui->colorButton_5->onSave();
|
||||
ui->colorButton_6->onSave();
|
||||
ui->backgroundColorButton->onSave();
|
||||
ui->backgroundTextColorButton->onSave();
|
||||
ui->pageBackgroundColorButton->onSave();
|
||||
ui->pageTextColorButton->onSave();
|
||||
ui->boxBackgroundColorButton->onSave();
|
||||
ui->linkColorButton->onSave();
|
||||
ui->colorButton_7->onSave();
|
||||
ui->fileChooser_1->onSave();
|
||||
ui->fileChooser_2->onSave();
|
||||
ui->fileChooser_3->onSave();
|
||||
ui->backgroundImageFileChooser->onSave();
|
||||
ui->showAdditionalFolderFileChooser->onSave();
|
||||
ui->radioButton_1->onSave();
|
||||
ui->radioButton_2->onSave();
|
||||
ui->checkBox->onSave();
|
||||
ui->checkBox_1->onSave();
|
||||
ui->checkBox_2->onSave();
|
||||
ui->checkBox_3->onSave();
|
||||
ui->checkBox_4->onSave();
|
||||
ui->checkBox_5->onSave();
|
||||
ui->checkBox_6->onSave();
|
||||
ui->checkBox_7->onSave();
|
||||
ui->lineEdit->onSave();
|
||||
ui->spinBox->onSave();
|
||||
ui->showNotepadCheckBox->onSave();
|
||||
ui->showExamplesCheckBox->onSave();
|
||||
ui->closeStartCheckBox->onSave();
|
||||
ui->closeAndSwitchCheckBox->onSave();
|
||||
ui->showForumCheckBox->onSave();
|
||||
ui->useStyleSheetCheckBox->onSave();
|
||||
ui->showTipsCheckBox->onSave();
|
||||
ui->fontLineEdit->onSave();
|
||||
ui->fontSizeSpinBox->onSave();
|
||||
ui->showFileThumbnailIconsCheckBox->onSave();
|
||||
ui->fileThumbnailIconSizeSpinBox->onSave();
|
||||
}
|
||||
@@ -124,28 +123,26 @@ void DlgStartPreferencesImp::loadSettings()
|
||||
->GetASCII("AutoloadModule", start.c_str());
|
||||
QString startWbName = QLatin1String(start.c_str());
|
||||
ui->AutoloadModuleCombo->setCurrentIndex(ui->AutoloadModuleCombo->findData(startWbName));
|
||||
ui->colorButton_1->onRestore();
|
||||
ui->colorButton_2->onRestore();
|
||||
ui->colorButton_3->onRestore();
|
||||
ui->colorButton_4->onRestore();
|
||||
ui->colorButton_5->onRestore();
|
||||
ui->colorButton_6->onRestore();
|
||||
ui->backgroundColorButton->onRestore();
|
||||
ui->backgroundTextColorButton->onRestore();
|
||||
ui->pageBackgroundColorButton->onRestore();
|
||||
ui->pageTextColorButton->onRestore();
|
||||
ui->boxBackgroundColorButton->onRestore();
|
||||
ui->linkColorButton->onRestore();
|
||||
ui->colorButton_7->onRestore();
|
||||
ui->fileChooser_1->onRestore();
|
||||
ui->fileChooser_2->onRestore();
|
||||
ui->fileChooser_3->onRestore();
|
||||
ui->backgroundImageFileChooser->onRestore();
|
||||
ui->showAdditionalFolderFileChooser->onRestore();
|
||||
ui->radioButton_1->onRestore();
|
||||
ui->radioButton_2->onRestore();
|
||||
ui->checkBox->onRestore();
|
||||
ui->checkBox_1->onRestore();
|
||||
ui->checkBox_2->onRestore();
|
||||
ui->checkBox_3->onRestore();
|
||||
ui->checkBox_4->onRestore();
|
||||
ui->checkBox_5->onRestore();
|
||||
ui->checkBox_6->onRestore();
|
||||
ui->checkBox_7->onRestore();
|
||||
ui->lineEdit->onRestore();
|
||||
ui->spinBox->onRestore();
|
||||
ui->showNotepadCheckBox->onRestore();
|
||||
ui->showExamplesCheckBox->onRestore();
|
||||
ui->closeStartCheckBox->onRestore();
|
||||
ui->closeAndSwitchCheckBox->onRestore();
|
||||
ui->showForumCheckBox->onRestore();
|
||||
ui->useStyleSheetCheckBox->onRestore();
|
||||
ui->showTipsCheckBox->onRestore();
|
||||
ui->fontLineEdit->onRestore();
|
||||
ui->fontSizeSpinBox->onRestore();
|
||||
ui->showFileThumbnailIconsCheckBox->onRestore();
|
||||
ui->fileThumbnailIconSizeSpinBox->onRestore();
|
||||
}
|
||||
@@ -163,4 +160,45 @@ void DlgStartPreferencesImp::changeEvent(QEvent* 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);
|
||||
}
|
||||
else {
|
||||
Gui::Dialog::PreferencePage::changeEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgStartPreferencesImp.cpp"
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
|
||||
class Ui_DlgStartPreferences;
|
||||
class Ui_DlgStartPreferencesAdvanced;
|
||||
namespace StartGui
|
||||
{
|
||||
class DlgStartPreferencesImp: public Gui::Dialog::PreferencePage
|
||||
@@ -47,6 +48,23 @@ private:
|
||||
std::unique_ptr<Ui_DlgStartPreferences> ui;
|
||||
};
|
||||
|
||||
class DlgStartPreferencesAdvancedImp: public Gui::Dialog::PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
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
|
||||
|
||||
@@ -27,7 +27,7 @@ SET(StartPage_ImageResources
|
||||
images/new_file_thumbnail.svg
|
||||
images/icon_settings.png
|
||||
images/new_empty_file.png
|
||||
images/new_import_file.png
|
||||
images/new_open_file.png
|
||||
images/new_parametric_part.png
|
||||
images/new_csg_part.png
|
||||
images/new_2d_draft.png
|
||||
|
||||
@@ -29,10 +29,12 @@ template_name = str(template)
|
||||
if template_name == "empty_file":
|
||||
FreeCADGui.runCommand("Std_New")
|
||||
StartPage.postStart()
|
||||
elif template_name == "import_file":
|
||||
FreeCADGui.runCommand("Std_New")
|
||||
StartPage.postStart()
|
||||
FreeCADGui.runCommand("Std_Import")
|
||||
elif template_name == "open_file":
|
||||
previous_doc = FreeCADGui.ActiveDocument
|
||||
FreeCADGui.runCommand("Std_Open")
|
||||
# workaround to not run postStart() if user cancels the Open dialog
|
||||
if FreeCADGui.ActiveDocument != previous_doc:
|
||||
StartPage.postStart()
|
||||
elif template_name == "parametric_part":
|
||||
FreeCADGui.runCommand("Std_New")
|
||||
FreeCADGui.activateWorkbench("PartDesignWorkbench")
|
||||
|
||||
@@ -24,7 +24,6 @@ body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
OVERFLOW
|
||||
a,
|
||||
a:link,
|
||||
a:visited {
|
||||
@@ -44,6 +43,10 @@ h2 {
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
img, a {
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
@@ -73,7 +76,7 @@ h2 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: TEXTCOLOR;
|
||||
font-size: 1.3em;
|
||||
font-size: 1.4em;
|
||||
margin-left: 25px;
|
||||
font-weight: bold;
|
||||
}
|
||||
@@ -113,7 +116,7 @@ ul.tabs {
|
||||
position: absolute;
|
||||
top: 2em;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
transform: translateX(calc(-50% - 1em));
|
||||
}
|
||||
|
||||
ul.tabs li {
|
||||
@@ -130,7 +133,6 @@ ul.tabs li a {
|
||||
text-decoration: none;
|
||||
outline: 0;
|
||||
font-size: 1.3em;
|
||||
transition: 100ms;
|
||||
}
|
||||
|
||||
ul.tabs li a img {
|
||||
@@ -186,6 +188,7 @@ ul.icons {
|
||||
width: 130px;
|
||||
height: THUMBCARDSIZE;
|
||||
background: BOXCOLOR;
|
||||
border: solid 2px BOXCOLOR;
|
||||
border-radius: 8px;
|
||||
margin: 10px;
|
||||
word-wrap: break-word;
|
||||
@@ -233,6 +236,7 @@ a .caption:visited {
|
||||
width: 18em;
|
||||
height: 5em;
|
||||
background: BOXCOLOR;
|
||||
border: solid 2px BOXCOLOR;
|
||||
border-radius: 8px;
|
||||
margin: 10px;
|
||||
word-wrap: break-word;
|
||||
|
||||
@@ -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>
|
||||
@@ -34,7 +35,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://blog.freecad.org/" title="T_BLOG_TOOLTIP">
|
||||
<a href="https://blog.freecad.org/" title="T_TOOLTIP_BLOG">
|
||||
<img src="IMAGE_SRC_ICON_BLOG" alt="blog">
|
||||
T_BLOG
|
||||
</a>
|
||||
|
||||
@@ -266,9 +266,9 @@ def build_new_file_card(template):
|
||||
TranslationTexts.T_TEMPLATE_EMPTYFILE_NAME,
|
||||
TranslationTexts.T_TEMPLATE_EMPTYFILE_DESC,
|
||||
],
|
||||
"import_file": [
|
||||
TranslationTexts.T_TEMPLATE_IMPORTFILE_NAME,
|
||||
TranslationTexts.T_TEMPLATE_IMPORTFILE_DESC,
|
||||
"open_file": [
|
||||
TranslationTexts.T_TEMPLATE_OPENFILE_NAME,
|
||||
TranslationTexts.T_TEMPLATE_OPENFILE_DESC,
|
||||
],
|
||||
"parametric_part": [
|
||||
TranslationTexts.T_TEMPLATE_PARAMETRICPART_NAME,
|
||||
@@ -286,7 +286,7 @@ def build_new_file_card(template):
|
||||
}
|
||||
|
||||
if template not in templates:
|
||||
return
|
||||
return ""
|
||||
|
||||
image = "file:///" + os.path.join(
|
||||
os.path.join(FreeCAD.getResourceDir(), "Mod", "Start", "StartPage"),
|
||||
@@ -378,7 +378,13 @@ 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
|
||||
|
||||
@@ -496,7 +502,7 @@ def handle():
|
||||
SECTION_NEW_FILE = "<h2>" + TranslationTexts.T_NEWFILE + "</h2>"
|
||||
SECTION_NEW_FILE += "<ul>"
|
||||
SECTION_NEW_FILE += build_new_file_card("empty_file")
|
||||
SECTION_NEW_FILE += build_new_file_card("import_file")
|
||||
SECTION_NEW_FILE += build_new_file_card("open_file")
|
||||
SECTION_NEW_FILE += build_new_file_card("parametric_part")
|
||||
# SECTION_NEW_FILE += build_new_file_card("csg_part")
|
||||
SECTION_NEW_FILE += build_new_file_card("2d_draft")
|
||||
@@ -731,9 +737,6 @@ def handle():
|
||||
BOXCOLOR = gethexcolor(p.GetUnsigned("BoxColor", 3722305023))
|
||||
TEXTCOLOR = gethexcolor(p.GetUnsigned("PageTextColor", 255))
|
||||
BGTCOLOR = gethexcolor(p.GetUnsigned("BackgroundTextColor", 1600086015))
|
||||
OVERFLOW = (
|
||||
"" if p.GetBool("ShowScrollBars", True) else "body::-webkit-scrollbar {display: none;}"
|
||||
)
|
||||
SHADOW = "#888888"
|
||||
if QtGui.QColor(BASECOLOR).valueF() < 0.5: # dark page - we need to make darker shadows
|
||||
SHADOW = "#000000"
|
||||
@@ -750,7 +753,6 @@ def handle():
|
||||
HTML = HTML.replace("SHADOW", SHADOW)
|
||||
HTML = HTML.replace("FONTFAMILY", FONTFAMILY)
|
||||
HTML = HTML.replace("FONTSIZE", str(FONTSIZE) + "px")
|
||||
HTML = HTML.replace("OVERFLOW", OVERFLOW)
|
||||
|
||||
# enable web access if permitted
|
||||
|
||||
|
||||
@@ -41,12 +41,12 @@ T_DOCUMENTS = translate("StartPage", "Documents")
|
||||
T_HELP = translate("StartPage", "Help")
|
||||
T_ACTIVITY = translate("StartPage", "Activity")
|
||||
T_BLOG = translate("StartPage", "Blog")
|
||||
T_BLOG_TOOLTIP = translate("StartPage", "Link to the FreeCAD blog")
|
||||
T_TOOLTIP_BLOG = translate("StartPage", "Link to the FreeCAD blog")
|
||||
T_NEWFILE = translate("StartPage", "New file")
|
||||
T_TEMPLATE_EMPTYFILE_NAME = translate("StartPage", "Empty File")
|
||||
T_TEMPLATE_EMPTYFILE_DESC = translate("StartPage", "Create an empty FreeCAD file")
|
||||
T_TEMPLATE_IMPORTFILE_NAME = translate("StartPage", "Import File")
|
||||
T_TEMPLATE_IMPORTFILE_DESC = translate("StartPage", "Work on an existing CAD file or 3D model")
|
||||
T_TEMPLATE_OPENFILE_NAME = translate("StartPage", "Open File")
|
||||
T_TEMPLATE_OPENFILE_DESC = translate("StartPage", "Open an existing CAD file or 3D model")
|
||||
T_TEMPLATE_PARAMETRICPART_NAME = translate("StartPage", "Standard Part")
|
||||
T_TEMPLATE_PARAMETRICPART_DESC = translate(
|
||||
"StartPage", "Create a part with the Part Design workbench"
|
||||
|
||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Reference in New Issue
Block a user