Add initial preferences page for Start
This commit is contained in:
@@ -33,6 +33,8 @@
|
||||
#include <Gui/Language/Translator.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/WidgetFactory.h>
|
||||
#include "DlgStartPreferencesImp.h"
|
||||
|
||||
|
||||
#include <gsl/pointers>
|
||||
@@ -124,5 +126,9 @@ PyMOD_INIT_FUNC(StartGui)
|
||||
loadStartResource();
|
||||
Base::Console().Log("done\n");
|
||||
|
||||
// register preferences pages
|
||||
new Gui::PrefPageProducer<StartGui::DlgStartPreferencesImp>(
|
||||
QT_TRANSLATE_NOOP("QObject", "Start"));
|
||||
|
||||
PyMOD_Return(mod);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,10 @@ set(StartGui_LIBS
|
||||
FreeCADGui
|
||||
)
|
||||
|
||||
set(StartGui_UIC_SRCS
|
||||
DlgStartPreferences.ui
|
||||
)
|
||||
|
||||
set(Start_TR_QRC ${CMAKE_CURRENT_BINARY_DIR}/Resources/Start_translation.qrc)
|
||||
qt_find_and_add_translation(QM_SRCS "Resources/translations/*_*.ts"
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Resources/translations)
|
||||
@@ -54,6 +58,8 @@ qt_add_resources(Start_QRC_SRCS Resources/Start.qrc ${Start_TR_QRC})
|
||||
SET(StartGui_SRCS
|
||||
${Start_QRC_SRCS}
|
||||
${StartGui_UIC_SRCS}
|
||||
DlgStartPreferencesImp.cpp
|
||||
DlgStartPreferencesImp.h
|
||||
AppStartGui.cpp
|
||||
FileCardDelegate.cpp
|
||||
FileCardDelegate.h
|
||||
|
||||
145
src/Mod/Start/Gui/DlgStartPreferences.ui
Normal file
145
src/Mod/Start/Gui/DlgStartPreferences.ui
Normal file
@@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DlgStartPreferences</class>
|
||||
<widget class="QWidget" name="DlgStartPreferences">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>537</width>
|
||||
<height>766</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>General</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBoxContents">
|
||||
<property name="title">
|
||||
<string>Contents</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelCustomFolder">
|
||||
<property name="text">
|
||||
<string>Show additional folder contents</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxShowExamples">
|
||||
<property name="toolTip">
|
||||
<string>If you want the examples to show on the first page</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ShowExamples</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Start</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::PrefFileChooser" name="fileChooserCustomFolder" native="true">
|
||||
<property name="toolTip">
|
||||
<string>An optional custom folder to be displayed at the bottom of the first page.
|
||||
By using ";;" to separate paths, you can add several folders here</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CustomFolder</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Start</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Show examples folder contents</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBoxOptions">
|
||||
<property name="title">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxCloseAfterLoading">
|
||||
<property name="toolTip">
|
||||
<string>If checked, will automatically close the Start page when FreeCAD launches</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>closeStart</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Start</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Close start page after loading</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::FileChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Gui/FileDialog.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefFileChooser</class>
|
||||
<extends>Gui::FileChooser</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
84
src/Mod/Start/Gui/DlgStartPreferencesImp.cpp
Normal file
84
src/Mod/Start/Gui/DlgStartPreferencesImp.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <Gui/Application.h>
|
||||
|
||||
#include "DlgStartPreferencesImp.h"
|
||||
#include "ui_DlgStartPreferences.h"
|
||||
|
||||
|
||||
using namespace StartGui;
|
||||
|
||||
/**
|
||||
* Constructs a DlgStartPreferencesImp which is a child of 'parent'
|
||||
*/
|
||||
DlgStartPreferencesImp::DlgStartPreferencesImp(QWidget* parent)
|
||||
: PreferencePage(parent)
|
||||
, ui(new Ui_DlgStartPreferences)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgStartPreferencesImp::~DlgStartPreferencesImp()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
|
||||
void DlgStartPreferencesImp::saveSettings()
|
||||
{
|
||||
ui->fileChooserCustomFolder->onSave();
|
||||
ui->checkBoxShowExamples->onSave();
|
||||
ui->checkBoxCloseAfterLoading->onSave();
|
||||
}
|
||||
|
||||
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());
|
||||
// QString startWbName = QLatin1String(start.c_str());
|
||||
|
||||
ui->fileChooserCustomFolder->onRestore();
|
||||
ui->checkBoxShowExamples->onRestore();
|
||||
ui->checkBoxCloseAfterLoading->onRestore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgStartPreferencesImp::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_DlgStartPreferencesImp.cpp"
|
||||
52
src/Mod/Start/Gui/DlgStartPreferencesImp.h
Normal file
52
src/Mod/Start/Gui/DlgStartPreferencesImp.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef STARTGUI_DLGSTARTPREFERENCESIMP_H
|
||||
#define STARTGUI_DLGSTARTPREFERENCESIMP_H
|
||||
|
||||
#include <memory>
|
||||
#include <Gui/PropertyPage.h>
|
||||
|
||||
|
||||
class Ui_DlgStartPreferences;
|
||||
namespace StartGui
|
||||
{
|
||||
class DlgStartPreferencesImp: public Gui::Dialog::PreferencePage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DlgStartPreferencesImp(QWidget* parent = nullptr);
|
||||
~DlgStartPreferencesImp() override;
|
||||
|
||||
protected:
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
void changeEvent(QEvent* e) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgStartPreferences> ui;
|
||||
};
|
||||
|
||||
} // namespace StartGui
|
||||
|
||||
#endif // STARTGUI_DLGSTARTPREFERENCESIMP_H
|
||||
Reference in New Issue
Block a user