##// END OF EJS Templates
Implements method to register a widget in the dialog
Alexandre Leroux -
r428:236a0bfac326
parent child
Show More
@@ -1,27 +1,34
1 #ifndef SCIQLOP_SQPSETTINGSDIALOG_H
1 #ifndef SCIQLOP_SQPSETTINGSDIALOG_H
2 #define SCIQLOP_SQPSETTINGSDIALOG_H
2 #define SCIQLOP_SQPSETTINGSDIALOG_H
3
3
4 #include "Settings/ISqpSettingsBindable.h"
4 #include "Settings/ISqpSettingsBindable.h"
5
5
6 #include <QDialog>
6 #include <QDialog>
7
7
8 namespace Ui {
8 namespace Ui {
9 class SqpSettingsDialog;
9 class SqpSettingsDialog;
10 } // Ui
10 } // Ui
11
11
12 /**
12 /**
13 * @brief The SqpSettingsDialog class represents the dialog in which the parameters of SciQlop are
13 * @brief The SqpSettingsDialog class represents the dialog in which the parameters of SciQlop are
14 * set
14 * set
15 */
15 */
16 class SqpSettingsDialog : public QDialog {
16 class SqpSettingsDialog : public QDialog {
17 Q_OBJECT
17 Q_OBJECT
18
18
19 public:
19 public:
20 explicit SqpSettingsDialog(QWidget *parent = 0);
20 explicit SqpSettingsDialog(QWidget *parent = 0);
21 virtual ~SqpSettingsDialog() noexcept;
21 virtual ~SqpSettingsDialog() noexcept;
22
22
23 /**
24 * Registers a widget into the dialog
25 * @param name the name under which the widget will appear in the dialog
26 * @param widget the widget to register
27 */
28 void registerWidget(const QString &name, QWidget *widget) noexcept;
29
23 private:
30 private:
24 Ui::SqpSettingsDialog *ui;
31 Ui::SqpSettingsDialog *ui;
25 };
32 };
26
33
27 #endif // SCIQLOP_SQPSETTINGSDIALOG_H
34 #endif // SCIQLOP_SQPSETTINGSDIALOG_H
@@ -1,17 +1,29
1 #include "Settings/SqpSettingsDialog.h"
1 #include "Settings/SqpSettingsDialog.h"
2 #include "ui_SqpSettingsDialog.h"
2 #include "ui_SqpSettingsDialog.h"
3
3
4 SqpSettingsDialog::SqpSettingsDialog(QWidget *parent)
4 SqpSettingsDialog::SqpSettingsDialog(QWidget *parent)
5 : QDialog{parent}, ui{new Ui::SqpSettingsDialog}
5 : QDialog{parent}, ui{new Ui::SqpSettingsDialog}
6 {
6 {
7 ui->setupUi(this);
7 ui->setupUi(this);
8
8
9 // Connection to change the current page to the selection of an entry in the list
9 // Connection to change the current page to the selection of an entry in the list
10 connect(ui->listWidget, &QListWidget::currentRowChanged, ui->stackedWidget,
10 connect(ui->listWidget, &QListWidget::currentRowChanged, ui->stackedWidget,
11 &QStackedWidget::setCurrentIndex);
11 &QStackedWidget::setCurrentIndex);
12 }
12 }
13
13
14 SqpSettingsDialog::~SqpSettingsDialog() noexcept
14 SqpSettingsDialog::~SqpSettingsDialog() noexcept
15 {
15 {
16 delete ui;
16 delete ui;
17 }
17 }
18 void SqpSettingsDialog::registerWidget(const QString &name, QWidget *widget) noexcept
19 {
20 auto newItem = new QListWidgetItem{ui->listWidget};
21 newItem->setText(name);
22
23 ui->stackedWidget->addWidget(widget);
24
25 // Selects widget if it's the first in the dialog
26 if (ui->listWidget->count() == 1) {
27 ui->listWidget->setCurrentItem(newItem);
28 }
29 }
General Comments 0
You need to be logged in to leave comments. Login now