From: Soeren Apel Date: Thu, 9 Mar 2017 18:38:20 +0000 (+0100) Subject: Integrate the about dialog into the settings dialog X-Git-Tag: pulseview-0.4.0~155 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4e4d72b22a81d1f2d8daee1093ac45264a0a1e2d;p=pulseview.git Integrate the about dialog into the settings dialog --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 547c7c12..f4325bf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,7 +230,6 @@ set(pulseview_SOURCES pv/devices/hardwaredevice.cpp pv/devices/inputfile.cpp pv/devices/sessionfile.cpp - pv/dialogs/about.cpp pv/dialogs/connect.cpp pv/dialogs/inputoutputoptions.cpp pv/dialogs/settings.cpp @@ -295,7 +294,6 @@ set(pulseview_HEADERS pv/data/logic.hpp pv/data/logicsegment.hpp pv/data/signalbase.hpp - pv/dialogs/about.hpp pv/dialogs/connect.hpp pv/dialogs/inputoutputoptions.hpp pv/dialogs/settings.hpp @@ -343,10 +341,6 @@ set(pulseview_HEADERS pv/widgets/wellarray.hpp ) -set(pulseview_FORMS - pv/dialogs/about.ui -) - set(pulseview_RESOURCES pulseview.qrc ) @@ -393,14 +387,12 @@ endif() if(Qt5Core_FOUND) qt5_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS}) - qt5_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS}) qt5_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) else() # Workaround for QTBUG-22829: -DBOOST_NEXT_PRIOR_HPP_INCLUDED. # https://bugreports.qt.io/browse/QTBUG-22829 qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS} OPTIONS -DBOOST_NEXT_PRIOR_HPP_INCLUDED) - qt4_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS}) qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES}) include(${QT_USE_FILE}) endif() @@ -484,14 +476,12 @@ if(ANDROID) add_library(${PROJECT_NAME} SHARED ${pulseview_SOURCES} ${pulseview_HEADERS_MOC} - ${pulseview_FORMS_HEADERS} ${pulseview_RESOURCES_RCC} ) else() add_executable(${PROJECT_NAME} ${pulseview_SOURCES} ${pulseview_HEADERS_MOC} - ${pulseview_FORMS_HEADERS} ${pulseview_RESOURCES_RCC} ) endif() diff --git a/README b/README index ccc7d051..613ecc5c 100644 --- a/README +++ b/README @@ -44,6 +44,13 @@ is to be interpreted as Copyright (C) 2010,2011,2012,2013 Contributor Name +Icons authors and licenses +-------------------------- + +icons/information.svg: Bobarino + https://en.wikipedia.org/wiki/File:Information.svg + + Mailing list ------------ diff --git a/icons/information.svg b/icons/information.svg new file mode 100644 index 00000000..3a43f112 --- /dev/null +++ b/icons/information.svg @@ -0,0 +1,252 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pulseview.qrc b/pulseview.qrc index cc524b09..b259281c 100644 --- a/pulseview.qrc +++ b/pulseview.qrc @@ -2,6 +2,7 @@ icons/add-decoder.svg icons/application-exit.png + icons/channels.svg icons/configure.png icons/decoder-delete.svg icons/decoder-hidden.svg @@ -9,7 +10,7 @@ icons/document-new.png icons/document-open.png icons/document-save-as.png - icons/channels.svg + icons/information.svg icons/menu.svg icons/sigrok-logo-notext.png icons/sigrok-logo-notext.svg diff --git a/pv/dialogs/about.cpp b/pv/dialogs/about.cpp deleted file mode 100644 index dbe7d9b8..00000000 --- a/pv/dialogs/about.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2012 Joel Holdsworth - * - * This program 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. - * - * This program 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 this program; if not, see . - */ - -#ifdef ENABLE_DECODE -#include -#endif - -#include - -#include "about.hpp" -#include - -#include - -using std::shared_ptr; -using sigrok::Context; - -namespace pv { -namespace dialogs { - -About::About(shared_ptr context, QWidget *parent) : - QDialog(parent), - ui(new Ui::About) -{ -#ifdef ENABLE_DECODE - struct srd_decoder *dec; -#endif - - QString s; - - ui->setupUi(this); - - /* Setup the version field */ - ui->versionInfo->setText(tr("%1 %2
%3
%4") - .arg(QApplication::applicationName(), - QApplication::applicationVersion(), - tr("GNU GPL, version 3 or later"), - QApplication::organizationDomain())); - ui->versionInfo->setOpenExternalLinks(true); - - s.append(""); - - /* Set up the supported field */ - s.append(""); - for (auto entry : context->drivers()) { - s.append(QString("") - .arg(QString::fromUtf8(entry.first.c_str()), - QString::fromUtf8(entry.second->long_name().c_str()))); - } - - s.append(""); - for (auto entry : context->input_formats()) { - s.append(QString("") - .arg(QString::fromUtf8(entry.first.c_str()), - QString::fromUtf8(entry.second->description().c_str()))); - } - - s.append(""); - for (auto entry : context->output_formats()) { - s.append(QString("") - .arg(QString::fromUtf8(entry.first.c_str()), - QString::fromUtf8(entry.second->description().c_str()))); - } - -#ifdef ENABLE_DECODE - s.append(""); - for (const GSList *l = srd_decoder_list(); l; l = l->next) { - dec = (struct srd_decoder *)l->data; - s.append(QString("") - .arg(QString::fromUtf8(dec->id), - QString::fromUtf8(dec->longname))); - } -#endif - - s.append("
" + - tr("Supported hardware drivers:") + - "
%1%2
" + - tr("Supported input formats:") + - "
%1%2
" + - tr("Supported output formats:") + - "
%1%2
" + - tr("Supported protocol decoders:") + - "
%1%2
"); - - supportedDoc = new QTextDocument(this); - supportedDoc->setHtml(s); - ui->supportList->setDocument(supportedDoc); -} - -About::~About() -{ - delete ui; -} - -} // namespace dialogs -} // namespace pv diff --git a/pv/dialogs/about.hpp b/pv/dialogs/about.hpp deleted file mode 100644 index 069ef627..00000000 --- a/pv/dialogs/about.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2012 Joel Holdsworth - * - * This program 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. - * - * This program 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 this program; if not, see . - */ - -#ifndef PULSEVIEW_PV_ABOUT_HPP -#define PULSEVIEW_PV_ABOUT_HPP - -#include - -#include - -class QTextDocument; - -namespace sigrok { - class Context; -} - -namespace Ui { -class About; -} - -namespace pv { -namespace dialogs { - -class About : public QDialog -{ - Q_OBJECT - -public: - explicit About(std::shared_ptr context, QWidget *parent = 0); - ~About(); - -private: - Ui::About *ui; - QTextDocument *supportedDoc; -}; - -} // namespace dialogs -} // namespace pv - -#endif // PULSEVIEW_PV_ABOUT_HPP diff --git a/pv/dialogs/about.ui b/pv/dialogs/about.ui deleted file mode 100644 index 11450f7f..00000000 --- a/pv/dialogs/about.ui +++ /dev/null @@ -1,96 +0,0 @@ - - - About - - - Qt::WindowModal - - - - 0 - 0 - 600 - 400 - - - - About - - - - - - - - - - - - - - :/icons/sigrok-logo-notext.svg - - - - - - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Ok - - - - - - - - - - - buttonBox - accepted() - About - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - About - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index c29d80b6..deeb71f1 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -17,24 +17,40 @@ * along with this program; if not, see . */ -#include "settings.hpp" -#include "pv/globalsettings.hpp" - +#include #include #include #include #include #include +#include +#include +#include +#include #include +#include "settings.hpp" + +#include "pv/devicemanager.hpp" +#include "pv/globalsettings.hpp" + +#include + +#ifdef ENABLE_DECODE +#include +#endif + namespace pv { namespace dialogs { -Settings::Settings(QWidget *parent) : - QDialog(parent, nullptr) +Settings::Settings(DeviceManager &device_manager, QWidget *parent) : + QDialog(parent, nullptr), + device_manager_(device_manager) { const int icon_size = 64; + resize(600, 400); + page_list = new QListWidget; page_list->setViewMode(QListView::IconMode); page_list->setIconSize(QSize(icon_size, icon_size)); @@ -76,6 +92,15 @@ void Settings::create_pages() viewButton->setText(tr("Views")); viewButton->setTextAlignment(Qt::AlignHCenter); viewButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + // About page + pages->addWidget(get_about_page(pages)); + + QListWidgetItem *aboutButton = new QListWidgetItem(page_list); + aboutButton->setIcon(QIcon(":/icons/information.svg")); + aboutButton->setText(tr("About")); + aboutButton->setTextAlignment(Qt::AlignHCenter); + aboutButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } QWidget *Settings::get_view_settings_form(QWidget *parent) const @@ -105,6 +130,88 @@ QWidget *Settings::get_view_settings_form(QWidget *parent) const return form; } +QWidget *Settings::get_about_page(QWidget *parent) const +{ +#ifdef ENABLE_DECODE + struct srd_decoder *dec; +#endif + + QLabel *icon = new QLabel(); + icon->setPixmap(QPixmap(QString::fromUtf8(":/icons/sigrok-logo-notext.svg"))); + + /* Setup the version field */ + QLabel *version_info = new QLabel(); + version_info->setText(tr("%1 %2
%3
%4") + .arg(QApplication::applicationName(), + QApplication::applicationVersion(), + tr("GNU GPL, version 3 or later"), + QApplication::organizationDomain())); + version_info->setOpenExternalLinks(true); + + std::shared_ptr context = device_manager_.context(); + + QString s; + s.append(""); + + /* Set up the supported field */ + s.append(""); + for (auto entry : context->drivers()) { + s.append(QString("") + .arg(QString::fromUtf8(entry.first.c_str()), + QString::fromUtf8(entry.second->long_name().c_str()))); + } + + s.append(""); + for (auto entry : context->input_formats()) { + s.append(QString("") + .arg(QString::fromUtf8(entry.first.c_str()), + QString::fromUtf8(entry.second->description().c_str()))); + } + + s.append(""); + for (auto entry : context->output_formats()) { + s.append(QString("") + .arg(QString::fromUtf8(entry.first.c_str()), + QString::fromUtf8(entry.second->description().c_str()))); + } + +#ifdef ENABLE_DECODE + s.append(""); + for (const GSList *l = srd_decoder_list(); l; l = l->next) { + dec = (struct srd_decoder *)l->data; + s.append(QString("") + .arg(QString::fromUtf8(dec->id), + QString::fromUtf8(dec->longname))); + } +#endif + + s.append("
" + + tr("Supported hardware drivers:") + + "
%1%2
" + + tr("Supported input formats:") + + "
%1%2
" + + tr("Supported output formats:") + + "
%1%2
" + + tr("Supported protocol decoders:") + + "
%1%2
"); + + QTextDocument *supported_doc = new QTextDocument(); + supported_doc->setHtml(s); + + QTextBrowser *support_list = new QTextBrowser(); + support_list->setDocument(supported_doc); + + QGridLayout *layout = new QGridLayout(); + layout->addWidget(icon, 0, 0, 1, 1); + layout->addWidget(version_info, 0, 1, 1, 1); + layout->addWidget(support_list, 1, 1, 1, 1); + + QWidget *page = new QWidget(parent); + page->setLayout(layout); + + return page; +} + void Settings::accept() { GlobalSettings settings; diff --git a/pv/dialogs/settings.hpp b/pv/dialogs/settings.hpp index 913da27e..f0501120 100644 --- a/pv/dialogs/settings.hpp +++ b/pv/dialogs/settings.hpp @@ -25,6 +25,9 @@ #include namespace pv { + +class DeviceManager; + namespace dialogs { class Settings : public QDialog @@ -32,11 +35,12 @@ class Settings : public QDialog Q_OBJECT public: - Settings(QWidget *parent = 0); + Settings(DeviceManager &device_manager, QWidget *parent = 0); void create_pages(); QWidget *get_view_settings_form(QWidget *parent) const; + QWidget *get_about_page(QWidget *parent) const; void accept(); void reject(); @@ -47,6 +51,7 @@ private Q_SLOTS: void on_view_colouredBG_changed(int state); private: + DeviceManager &device_manager_; QListWidget *page_list; QStackedWidget *pages; }; diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index eaaea089..d8247825 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -43,7 +43,6 @@ #include "globalsettings.hpp" #include "util.hpp" #include "devices/hardwaredevice.hpp" -#include "dialogs/about.hpp" #include "dialogs/settings.hpp" #include "toolbars/mainbar.hpp" #include "view/view.hpp" @@ -78,7 +77,6 @@ MainWindow::MainWindow(DeviceManager &device_manager, device_manager_(device_manager), session_selector_(this), session_state_mapper_(this), - action_about_(new QAction(this)), icon_red_(":/icons/status-red.svg"), icon_green_(":/icons/status-green.svg"), icon_grey_(":/icons/status-grey.svg") @@ -124,11 +122,6 @@ MainWindow::~MainWindow() remove_session(sessions_.front()); } -QAction* MainWindow::action_about() const -{ - return action_about_; -} - shared_ptr MainWindow::get_active_view() const { // If there's only one view, use it... @@ -354,9 +347,6 @@ void MainWindow::setup_ui() view_coloured_bg_shortcut_ = new QShortcut(QKeySequence(Qt::Key_B), this, SLOT(on_view_coloured_bg_shortcut())); view_coloured_bg_shortcut_->setAutoRepeat(false); - action_about_->setObjectName(QString::fromUtf8("actionAbout")); - action_about_->setToolTip(tr("&About...")); - // Set up the tab area new_session_button_ = new QToolButton(); new_session_button_->setIcon(QIcon::fromTheme("document-new", @@ -611,7 +601,7 @@ void MainWindow::on_run_stop_clicked() void MainWindow::on_settings_clicked() { - dialogs::Settings dlg; + dialogs::Settings dlg(device_manager_); dlg.exec(); } @@ -759,12 +749,6 @@ void MainWindow::on_settingViewColouredBg_changed(const QVariant new_value) } } -void MainWindow::on_actionAbout_triggered() -{ - dialogs::About dlg(device_manager_.context(), this); - dlg.exec(); -} - void MainWindow::on_close_current_tab() { int tab = session_selector_.currentIndex(); diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp index fdb3c888..e3a51c6d 100644 --- a/pv/mainwindow.hpp +++ b/pv/mainwindow.hpp @@ -71,8 +71,6 @@ public: ~MainWindow(); - QAction* action_about() const; - std::shared_ptr get_active_view() const; std::shared_ptr add_view(const QString &title, @@ -128,8 +126,6 @@ private Q_SLOTS: void on_settingViewColouredBg_changed(const QVariant new_value); - void on_actionAbout_triggered(); - void on_close_current_tab(); private: @@ -147,8 +143,6 @@ private: QTabWidget session_selector_; QSignalMapper session_state_mapper_; - QAction *const action_about_; - QIcon icon_red_; QIcon icon_green_; QIcon icon_grey_;