From: Soeren Apel Date: Wed, 8 Mar 2017 21:53:51 +0000 (+0100) Subject: Settings: Prettify the settings dialog X-Git-Tag: pulseview-0.4.0~156 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b14db788ee3483eed195c1e73a1ab85ea8c41e47;p=pulseview.git Settings: Prettify the settings dialog --- diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index eb9e88b6..c29d80b6 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include 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; diff --git a/pv/dialogs/settings.hpp b/pv/dialogs/settings.hpp index 20c4f915..913da27e 100644 --- a/pv/dialogs/settings.hpp +++ b/pv/dialogs/settings.hpp @@ -21,6 +21,8 @@ #define PULSEVIEW_PV_SETTINGS_HPP #include +#include +#include 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