]> sigrok.org Git - pulseview.git/commitdiff
Settings: Prettify the settings dialog
authorSoeren Apel <redacted>
Wed, 8 Mar 2017 21:53:51 +0000 (22:53 +0100)
committerUwe Hermann <redacted>
Sun, 12 Mar 2017 14:42:12 +0000 (15:42 +0100)
pv/dialogs/settings.cpp
pv/dialogs/settings.hpp

index eb9e88b6755ddc2813d08d66f3fd208be7f6cd21..c29d80b68f9ddc7d434041e4ef915f92f14c8470 100644 (file)
@@ -24,7 +24,7 @@
 #include <QDialogButtonBox>
 #include <QFormLayout>
 #include <QGroupBox>
-#include <QTabWidget>
+#include <QHBoxLayout>
 #include <QVBoxLayout>
 
 namespace pv {
@@ -33,24 +33,51 @@ namespace dialogs {
 Settings::Settings(QWidget *parent) :
        QDialog(parent, nullptr)
 {
-       QTabWidget *tab_stack = new QTabWidget(this);
-       tab_stack->addTab(get_view_settings_form(tab_stack), tr("&Views"));
+       const int icon_size = 64;
+
+       page_list = new QListWidget;
+       page_list->setViewMode(QListView::IconMode);
+       page_list->setIconSize(QSize(icon_size, icon_size));
+       page_list->setMovement(QListView::Static);
+       page_list->setMaximumWidth(icon_size + icon_size/2);
+       page_list->setSpacing(12);
+
+       pages = new QStackedWidget;
+       create_pages();
+
+       QHBoxLayout *tab_layout = new QHBoxLayout;
+       tab_layout->addWidget(page_list);
+       tab_layout->addWidget(pages, Qt::AlignLeft);
 
        QDialogButtonBox *button_box = new QDialogButtonBox(
                QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
 
        QVBoxLayout* root_layout = new QVBoxLayout(this);
-       root_layout->addWidget(tab_stack);
+       root_layout->addLayout(tab_layout);
        root_layout->addWidget(button_box);
 
        connect(button_box, SIGNAL(accepted()), this, SLOT(accept()));
        connect(button_box, SIGNAL(rejected()), this, SLOT(reject()));
+       connect(page_list, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
+               this, SLOT(on_page_changed(QListWidgetItem*, QListWidgetItem*)));
 
        // Start to record changes
        GlobalSettings settings;
        settings.start_tracking();
 }
 
+void Settings::create_pages()
+{
+       // View page
+       pages->addWidget(get_view_settings_form(pages));
+
+       QListWidgetItem *viewButton = new QListWidgetItem(page_list);
+       viewButton->setIcon(QIcon(":/icons/sigrok-logo-notext.svg"));
+       viewButton->setText(tr("Views"));
+       viewButton->setTextAlignment(Qt::AlignHCenter);
+       viewButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+}
+
 QWidget *Settings::get_view_settings_form(QWidget *parent) const
 {
        GlobalSettings settings;
@@ -94,6 +121,14 @@ void Settings::reject()
        QDialog::reject();
 }
 
+void Settings::on_page_changed(QListWidgetItem *current, QListWidgetItem *previous)
+{
+       if (!current)
+               current = previous;
+
+       pages->setCurrentIndex(page_list->row(current));
+}
+
 void Settings::on_view_alwaysZoomToFit_changed(int state)
 {
        GlobalSettings settings;
index 20c4f91552b184d004ed61642f8d96e13b950c04..913da27ead3d94ef34ffa74c38fd6b82ce505642 100644 (file)
@@ -21,6 +21,8 @@
 #define PULSEVIEW_PV_SETTINGS_HPP
 
 #include <QDialog>
+#include <QListWidget>
+#include <QStackedWidget>
 
 namespace pv {
 namespace dialogs {
@@ -32,14 +34,21 @@ class Settings : public QDialog
 public:
        Settings(QWidget *parent = 0);
 
+       void create_pages();
+
        QWidget *get_view_settings_form(QWidget *parent) const;
 
        void accept();
        void reject();
 
 private Q_SLOTS:
+       void on_page_changed(QListWidgetItem *current, QListWidgetItem *previous);
        void on_view_alwaysZoomToFit_changed(int state);
        void on_view_colouredBG_changed(int state);
+
+private:
+       QListWidget *page_list;
+       QStackedWidget *pages;
 };
 
 } // namespace dialogs