mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Refactored the ConfigDialog class to make it more generic.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@1877 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
1539628f24
commit
7a587a7d36
@ -16,6 +16,7 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "configdialog.h"
|
||||
#include "configpages.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
/**
|
||||
@ -23,9 +24,6 @@
|
||||
@param parent QWidget parent
|
||||
*/
|
||||
ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
|
||||
|
||||
setWindowTitle(tr("Configurer QElectroTech", "window title"));
|
||||
|
||||
// liste des pages
|
||||
pages_list = new QListWidget();
|
||||
pages_list -> setViewMode(QListView::IconMode);
|
||||
@ -37,11 +35,6 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
|
||||
|
||||
// pages
|
||||
pages_widget = new QStackedWidget();
|
||||
addPage(new GeneralConfigurationPage());
|
||||
addPage(new NewDiagramPage());
|
||||
addPage(new ExportConfigPage());
|
||||
addPage(new PrintConfigPage());
|
||||
buildPagesList();
|
||||
|
||||
// boutons
|
||||
buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
|
||||
@ -80,12 +73,19 @@ void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previou
|
||||
void ConfigDialog::buildPagesList() {
|
||||
pages_list -> clear();
|
||||
foreach(ConfigPage *page, pages) {
|
||||
addPageToList(page);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Add the \a page ConfigPage to this configuration dialog.
|
||||
*/
|
||||
void ConfigDialog::addPageToList(ConfigPage *page) {
|
||||
QListWidgetItem *new_button = new QListWidgetItem(pages_list);
|
||||
new_button -> setIcon(page -> icon());
|
||||
new_button -> setText(page -> title());
|
||||
new_button -> setTextAlignment(Qt::AlignHCenter);
|
||||
new_button -> setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,4 +105,5 @@ void ConfigDialog::addPage(ConfigPage *page) {
|
||||
if (!page || pages.contains(page)) return;
|
||||
pages << page;
|
||||
pages_widget -> addWidget(page);
|
||||
addPageToList(page);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
#ifndef CONFIG_DIALOG_H
|
||||
#define CONFIG_DIALOG_H
|
||||
#include <QDialog>
|
||||
#include "configpages.h"
|
||||
class ConfigPage;
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
class QStackedWidget;
|
||||
@ -45,6 +45,7 @@ class ConfigDialog : public QDialog {
|
||||
|
||||
private:
|
||||
void buildPagesList();
|
||||
void addPageToList(ConfigPage *);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "qetapp.h"
|
||||
#include "aboutqet.h"
|
||||
#include "configdialog.h"
|
||||
#include "configpages.h"
|
||||
#include "qetdiagrameditor.h"
|
||||
#include "qetelementeditor.h"
|
||||
#include "elementscollectionitem.h"
|
||||
@ -1144,6 +1145,12 @@ void QETApp::configureQET() {
|
||||
|
||||
// cree le dialogue
|
||||
ConfigDialog cd;
|
||||
cd.setWindowTitle(tr("Configurer QElectroTech", "window title"));
|
||||
cd.addPage(new GeneralConfigurationPage());
|
||||
cd.addPage(new NewDiagramPage());
|
||||
cd.addPage(new ExportConfigPage());
|
||||
cd.addPage(new PrintConfigPage());
|
||||
|
||||
|
||||
// associe le dialogue a un eventuel widget parent
|
||||
if (parent_widget) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user