mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-03 10:34:14 +02:00
464d516537
Adds a ProjectUsageTracker (sources/project/) that accumulates how
long a project has been the active tab, using QElapsedTimer so the
value is computed on demand rather than via polling. It's hosted on
ProjectPropertiesHandler per that class's own stated design intent
("all new properties should be managed by this class").
The accumulated time is persisted as a new <usage time_spent="N"
enabled="true|false"/> element, a sibling of <properties> in the
project XML, written/read by new QETProject::writeUsageXml()/
readUsageXml(). It rides along on the existing autosave path for
free, since writeBackup() already serializes the full project via
toXml().
QETDiagramEditor::subWindowActivated() now pauses every open
project's tracker except the one whose tab just became current, so
switching between several open projects keeps each project's tracked
time isolated.
Surfaced in the existing Project Properties "Général" page: a
"Temps passé sur ce projet" display, a "Réinitialiser" button, and
an opt-out checkbox ("uniquement enregistré localement dans ce
fichier" - this is local-only, never transmitted anywhere).
Verified beyond compiling: full CMake build, then an actual runtime
session confirming the saved XML's time_spent value, that closing
and reopening the project round-trips and resumes timing, that the
reset button works, and - the key correctness check - that with two
projects open, the inactive one's time_spent stays frozen while the
active one accumulates real elapsed time, over the same interval.
See discussion #576.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
180 lines
4.7 KiB
C++
180 lines
4.7 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 PROJECTCONFIGPAGES_H
|
|
#define PROJECTCONFIGPAGES_H
|
|
#include "configpage.h"
|
|
|
|
class QLabel;
|
|
class QLineEdit;
|
|
class QCheckBox;
|
|
class QPushButton;
|
|
class QETProject;
|
|
class BorderPropertiesWidget;
|
|
class ConductorPropertiesWidget;
|
|
class DiagramContextWidget;
|
|
class ReportPropertieWidget;
|
|
class XRefPropertiesWidget;
|
|
class SelectAutonumW;
|
|
class FolioAutonumberingW;
|
|
class FormulaAutonumberingW;
|
|
class AutoNumberingManagementW;
|
|
|
|
/**
|
|
@brief The ProjectConfigPage class
|
|
This class, derived from ConfigPage,
|
|
aims at providing the basic skeleton for a project configuration page.
|
|
*/
|
|
class ProjectConfigPage : public ConfigPage {
|
|
Q_OBJECT
|
|
// Constructor, destructor
|
|
public:
|
|
ProjectConfigPage(QETProject *, QWidget * = nullptr);
|
|
~ProjectConfigPage() override;
|
|
private:
|
|
ProjectConfigPage(const ProjectConfigPage &);
|
|
|
|
// methods
|
|
public:
|
|
virtual QETProject *project() const;
|
|
virtual QETProject *setProject(QETProject *project, bool = true);
|
|
void applyConf() override;
|
|
/**
|
|
Apply configuration to the project after user input. This method is
|
|
automatically called when the ConfigDialog is validated, and only if the
|
|
project is both non-zero and not read-only.
|
|
*/
|
|
virtual void applyProjectConf() = 0;
|
|
|
|
protected:
|
|
virtual void init();
|
|
/**
|
|
Use this pure virtual method to initialize your page widgets.
|
|
*/
|
|
virtual void initWidgets() = 0;
|
|
/**
|
|
Use this pure virtual method to initialize your page layout. This method is
|
|
always called after initWidgets().
|
|
*/
|
|
virtual void initLayout() = 0;
|
|
/**
|
|
Use this pure virtual method to fill widgets with project values.
|
|
*/
|
|
virtual void readValuesFromProject() = 0;
|
|
/**
|
|
Use this pure virtual method to adjust the "read only" state of your page
|
|
widgets according to the currently edited project.
|
|
*/
|
|
virtual void adjustReadOnly() = 0;
|
|
|
|
// attributes
|
|
protected:
|
|
QETProject *m_project; ///< Currently edited project
|
|
};
|
|
|
|
/**
|
|
This page enables users to configure the main properties of a project.
|
|
*/
|
|
class ProjectMainConfigPage : public ProjectConfigPage {
|
|
Q_OBJECT
|
|
// Constructor, destructor
|
|
public:
|
|
ProjectMainConfigPage(QETProject *, QWidget * = nullptr);
|
|
~ProjectMainConfigPage() override;
|
|
private:
|
|
ProjectMainConfigPage(const ProjectMainConfigPage &);
|
|
|
|
// methods
|
|
public:
|
|
QString title() const override;
|
|
QIcon icon() const override;
|
|
void applyProjectConf() override;
|
|
QString projectTitle() const;
|
|
|
|
protected:
|
|
void initWidgets() override;
|
|
void initLayout() override;
|
|
void readValuesFromProject() override;
|
|
void adjustReadOnly() override;
|
|
|
|
private slots:
|
|
void resetUsageTracker();
|
|
|
|
// attributes
|
|
protected:
|
|
QLabel *title_label_;
|
|
QLineEdit *title_value_;
|
|
QLabel *title_information_;
|
|
QLabel *project_variables_label_;
|
|
DiagramContextWidget *project_variables_;
|
|
QLabel *usage_label_;
|
|
QLabel *usage_value_;
|
|
QCheckBox *usage_enabled_cb_;
|
|
QPushButton *usage_reset_pb_;
|
|
};
|
|
|
|
class ProjectAutoNumConfigPage : public ProjectConfigPage {
|
|
Q_OBJECT
|
|
|
|
//Methods
|
|
public:
|
|
ProjectAutoNumConfigPage (QETProject *project,
|
|
QWidget *parent = nullptr);
|
|
|
|
QString title() const override;
|
|
QIcon icon() const override;
|
|
void applyProjectConf() override;
|
|
virtual void changeToTab(int);
|
|
protected:
|
|
void initWidgets() override;
|
|
void initLayout() override {}
|
|
void readValuesFromProject() override;
|
|
void adjustReadOnly() override;
|
|
private:
|
|
void buildConnections();
|
|
private slots:
|
|
void updateContextConductor(const QString&);//conductor
|
|
void saveContextConductor();
|
|
void removeContextConductor();
|
|
void updateContextFolio(const QString&);//folio
|
|
void saveContextFolio();
|
|
void removeContextFolio();
|
|
void updateContextElement(const QString&);//element
|
|
void saveContextElement();
|
|
void removeContextElement();
|
|
|
|
void applyAutoNum();
|
|
void applyManagement();
|
|
|
|
signals:
|
|
void setAutoNum(QString);
|
|
void setAutoNum(int,int);
|
|
void saveCurrentTbp();
|
|
void loadSavedTbp();
|
|
|
|
//Attributes
|
|
private:
|
|
SelectAutonumW *m_saw_conductor;
|
|
SelectAutonumW *m_saw_folio;
|
|
SelectAutonumW *m_saw_element;
|
|
FolioAutonumberingW *m_faw;
|
|
AutoNumberingManagementW *m_amw;
|
|
|
|
};
|
|
|
|
#endif
|