Files
qelectrotech-source-mirror/sources/ui/configpage/configpages.h
T
Kellermorph 8b59bcb992 Give new projects the terminal labelling of the settings
The labelling of the terminals is a setting of the project, so that the
same file draws the same way on every machine which opens it. A new
project has to start with something, though, and that is now a default
of the application: Configure QElectroTech > New project, on the sheet
tab, the same group box with the same two choices the project
properties use -- what it saves is only what a new project starts with.

Off unless the settings say otherwise, so a new project draws the whole
label in one field, as it always did, and a project saved after that
keeps its own choice (readTerminalLabelSplitXml()).

The settings key starts with "diagrameditor/default", the prefix of the
new-project part of a configuration profile, so the choice travels with
the other defaults of a new project.

The project gets the setting in its own properties and nowhere else: the
page of the new sheets does not offer it, and the tests say so.
2026-10-23 14:50:58 +02:00

161 lines
5.1 KiB
C++

/*
Copyright 2006-2026 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_PAGES_H
#define CONFIG_PAGES_H
#include "configpage.h"
#include "../projectpropertiesdialog.h"
#include "../titleblockpropertieswidget.h"
#include "../autoNum/numerotationcontext.h"
#include <QDialog>
#include <QtWidgets>
class BorderPropertiesWidget;
class ConductorPropertiesWidget;
class TitleBlockPropertiesWidget;
class ExportPropertiesWidget;
class ReportPropertieWidget;
class XRefPropertiesWidget;
class GuidesPropertiesWidget;
class QETProject;
class TitleBlockProperties;
class SelectAutonumW;
/**
@brief The NewDiagramPage class
This configuration page enables users to define the properties of new
diagrams to come.
*/
class NewDiagramPage : public ConfigPage {
Q_OBJECT
// constructors, destructor
public:
NewDiagramPage(QETProject *project = nullptr,
QWidget * = nullptr,
ProjectPropertiesDialog *teste = nullptr);
~NewDiagramPage() override;
private:
NewDiagramPage(const NewDiagramPage &);
bool eventFilter(QObject *obj, QEvent *event) override;
public slots:
void changeToAutoFolioTab();
void setFolioAutonum(QString);
void saveCurrentTbp();
void loadSavedTbp();
// methods
public:
void applyConf() override;
QString title() const override;
QIcon icon() const override;
// attributes
private:
ProjectPropertiesDialog *ppd_;
QETProject *m_project; ///< Project to edit properties
BorderPropertiesWidget *bpw; ///< Widget to edit default diagram dimensions
TitleBlockPropertiesWidget *ipw; ///< Widget to edit default title block properties
ConductorPropertiesWidget *m_cpw; ///< Widget to edit default conductor properties
ReportPropertieWidget *rpw; ///< Widget to edit default report label
XRefPropertiesWidget *xrefpw; ///< Widget to edit default xref properties
GuidesPropertiesWidget *m_gpw; ///< Widget to edit guides
//How a new project's terminals draw their label, the application's
//default (Configure QElectroTech > New project). Per project it is
//a project property (project properties > General), so these are
//only built for the application's defaults, without a project.
QGroupBox *m_terminal_label_gb = nullptr;
QRadioButton *m_terminal_label_combined_rb = nullptr;
QRadioButton *m_terminal_label_split_rb = nullptr;
QLabel *m_terminal_label_help = nullptr;
TitleBlockProperties savedTbp; ///< Used to save current TBP and retrieve later
QTabWidget *m_tab_widget; ///< Main tab widget (stored for later access)
// auto-numbering tab data
struct AutoNumTab {
SelectAutonumW *widget = nullptr;
QHash<QString, NumerotationContext> contexts;
QString prefix;
/// When set, this tab keeps one single rule, always saved
/// and read under this name: there is no visible combo box
/// to name a rule with (see SelectAutonumW::
/// setSingleRuleMode). The cable numbering works that way.
QString fixed_name;
};
AutoNumTab m_autonum_conductor;
AutoNumTab m_autonum_element;
AutoNumTab m_autonum_folio;
AutoNumTab m_autonum_cable;
void initAutoNumTab(AutoNumTab &tab, SelectAutonumW *w, const QString &prefix);
void loadAutoNumTab(AutoNumTab &tab, QSettings &settings);
void saveAutoNumContext(AutoNumTab &tab);
void removeAutoNumContext(AutoNumTab &tab);
void persistAutonumSettings();
static bool isPlaceholder(QComboBox *combo, const QString &name);
};
/**
@brief The ExportConfigPage class
This configuration page enables users to set default export options.
*/
class ExportConfigPage : public ConfigPage {
Q_OBJECT
// constructors, destructor
public:
ExportConfigPage(QWidget * = nullptr);
~ExportConfigPage() override;
private:
ExportConfigPage(const ExportConfigPage &);
// methods
public:
void applyConf() override;
QString title() const override;
QIcon icon() const override;
// attributes
public:
ExportPropertiesWidget *epw;
};
/**
@brief The PrintConfigPage class
This configuration page enables users to set default printing options.
*/
class PrintConfigPage : public ConfigPage {
Q_OBJECT
// constructors, destructor
public:
PrintConfigPage(QWidget * = nullptr);
~PrintConfigPage() override;
private:
PrintConfigPage(const PrintConfigPage &);
// methods
public:
void applyConf() override;
QString title() const override;
QIcon icon() const override;
// attributes
public:
ExportPropertiesWidget *epw;
};
#endif