From c9da51187f8db0c9822d544a0253e0e7a58945d7 Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Thu, 1 Sep 2016 21:11:18 +0200 Subject: [PATCH] Add "new session" and "new view" toolbar buttons Those are temporary and will eventually replaced by a proper UI. --- icons/document-new.png | Bin 0 -> 692 bytes icons/window-new.png | Bin 0 -> 718 bytes pv/mainwindow.cpp | 18 ++++++++++++++++++ pv/mainwindow.hpp | 3 +++ pv/toolbars/mainbar.cpp | 27 +++++++++++++++++++++++++++ pv/toolbars/mainbar.hpp | 11 +++++++++++ 6 files changed, 59 insertions(+) create mode 100644 icons/document-new.png create mode 100644 icons/window-new.png diff --git a/icons/document-new.png b/icons/document-new.png new file mode 100644 index 0000000000000000000000000000000000000000..e3808a108e335b14e13711783a3717f7b6013375 GIT binary patch literal 692 zcmV;l0!#ggP);y z08cd6u?+wK010qNS#tmY4c7nw4c7reD4Tcy000McNliru)dCU@B{0fECJ6ul0zpYc zK~y-)t(DDd6JZdCpPAiMn&Jmdn>7fYJcxJ_#8&Vh@X~`PZ{pRn2x2dy;>SPX!Ham1 z+(i)tHKi8|da}9HkQgW;F{asM$HRVRQ|)SfA!K*h_jzZ2znNWOpKH`v5ugP4u2;7> zF7d_vhj(uStA7Jk38)+yP+RQbsIfED#}_X&uen~m?`ED`y>b0!VW^o8{zroTOMI(f zl-d6J>5AdJ8g*8ly7>*wW)sJ8Ff&91k+7)jH5esnQPvkYrCDs|65`BrXyG*$Ji9FR zZC&%=7!X6u49qYyEHKOf#;EiV*}-H1bRJOP05C2ChxY^{Kpay+6+|2YIY_`FGTH?H z4FnyAg9c(hHh}Hlf>kyA7ePeR!$eVW2sp}sWrlVFhHJR~b2dM3Ap}o=mb)8RRa1=- zkgUc6DhM-}9K)x=m{ZKom1t~y=gi602jJ&a#%t@1NwYH9CqLpU98Bjh=QuKRnqI$z z>(%?NSGOtfxwA{uYPFoEq;jZ4_fd7CVO5i3!LCxY+wE|ZX(&TdK1mgkr$i4-E%#4d zVPZ*k`Cd*A5J4#bPBsA=nH6dZqS1XEkCF}JxpB`2-o1Z2m61p&MGVbqEU^iDftQ!g zQ>|9h9@fZ2G%`*Q6xD2(Xfchu-R?xYG4Y;|`| aWBLmt`;((hn6}^m0000WFU8GbZ8({Xk{QrNlj4iWF>9@00J^eL_t(I%hi+3OH@%9 z#((b}N1bs7%iKh!6d4E+Z6hiOTm%tBi#A37PV2UJC#vuwq{fCtGSo=ftkZV8}((D))qN2{DoSrirEO#Cisu91O4l0CtS)` zJTrac=HbfizJTsKPy;GgAvgoR!d`235;muxeZC-t1ZQtOD&^k3@}4`_mbh^4B=yD^ z^~OEuKF4f?NEWLXHI_4a>U1f%Z|E0$+5ol)yDPMIpD|ed9?5}kgVqXQmw5g7ZYkI_ zNuc9Y^acy&fzJ?b(Q0)VXtqB>=R;8nz~cTdNDLvnh_p!dCi#IhKT6DGXB#ORnLVBDi75 z#xcgDLad7WT;@X&?6`X-OGeDerL+hv`zsaK?K4lVY%>;%E>eAz^Ffw6b0Am}p@$g+ z1J8z12F8SvL#zahM+OSROi@J!PBgaEOd&H&!sEU~3diHJq+BH8XDKT_Q{{U3K^2SC zyxu&UL7c>%WJl|q(uzIyD~VMswP#0Jj_S#mmzXD4yhgDxNv>`GO%&}hqdXP0TCL}r zc~m@ONzRk}8Q!B)3hs8g4;S9fKjmoc0sn3L1Gj@eEe-q;QUCw|07*qoM6N<$f_Aer A9{>OV literal 0 HcmV?d00001 diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index a99ba352..dab9c786 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -200,6 +200,11 @@ shared_ptr MainWindow::add_view(const QString &title, main_bar = make_shared(session, *this); dock_main->addToolBar(main_bar.get()); session.set_main_bar(main_bar); + + connect(main_bar.get(), SIGNAL(new_session()), + this, SLOT(on_new_session())); + connect(main_bar.get(), SIGNAL(new_view(Session*)), + this, SLOT(on_new_view(Session*))); } main_bar->action_view_show_cursors()->setChecked(v->cursors_shown()); @@ -348,6 +353,19 @@ void MainWindow::on_add_view(const QString &title, view::ViewType type, add_view(title, type, *s); } +void MainWindow::on_new_session() +{ + add_session(); +} + +void MainWindow::on_new_view(Session *session) +{ + // We get a pointer and need a reference + for (std::shared_ptr s : sessions_) + if (s.get() == session) + add_view(session->name(), pv::view::TraceView, *s); +} + void MainWindow::on_actionViewStickyScrolling_triggered() { shared_ptr view = get_active_view(); diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp index 87e8755b..2bd8dadb 100644 --- a/pv/mainwindow.hpp +++ b/pv/mainwindow.hpp @@ -94,6 +94,9 @@ private Q_SLOTS: void on_add_view(const QString &title, view::ViewType type, Session *session); + void on_new_session(); + void on_new_view(Session *session); + void on_actionViewStickyScrolling_triggered(); void on_actionViewColouredBg_triggered(); diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index 0adb6c92..a0f190f7 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -89,6 +89,8 @@ const char *MainBar::SettingSaveDirectory = "MainWindow/SaveDirectory"; MainBar::MainBar(Session &session, MainWindow &main_window) : QToolBar("Sampling Bar", &main_window), + action_new_session_(new QAction(this)), + action_new_view_(new QAction(this)), action_open_(new QAction(this)), action_save_as_(new QAction(this)), action_save_selection_as_(new QAction(this)), @@ -127,6 +129,18 @@ MainBar::MainBar(Session &session, MainWindow &main_window) : setContextMenuPolicy(Qt::PreventContextMenu); // Actions + action_new_session_->setText(tr("New &Session")); + action_new_session_->setIcon(QIcon::fromTheme("document-new", + QIcon(":/icons/document-new.png"))); + connect(action_new_session_, SIGNAL(triggered(bool)), + this, SLOT(on_actionNewSession_triggered())); + + action_new_view_->setText(tr("New &View")); + action_new_view_->setIcon(QIcon::fromTheme("window-new", + QIcon(":/icons/window-new.png"))); + connect(action_new_view_, SIGNAL(triggered(bool)), + this, SLOT(on_actionNewView_triggered())); + action_open_->setText(tr("&Open...")); action_open_->setIcon(QIcon::fromTheme("document-open", QIcon(":/icons/document-open.png"))); @@ -255,6 +269,9 @@ MainBar::MainBar(Session &session, MainWindow &main_window) : #endif // Setup the toolbar + addAction(action_new_session_); + addAction(action_new_view_); + addSeparator(); addWidget(open_button); addWidget(save_button); addSeparator(); @@ -944,6 +961,16 @@ void MainBar::on_config_changed() commit_sample_rate(); } +void MainBar::on_actionNewSession_triggered() +{ + new_session(); +} + +void MainBar::on_actionNewView_triggered() +{ + new_view(&session_); +} + void MainBar::on_actionOpen_triggered() { QSettings settings; diff --git a/pv/toolbars/mainbar.hpp b/pv/toolbars/mainbar.hpp index ed38dfaa..d39cb5e4 100644 --- a/pv/toolbars/mainbar.hpp +++ b/pv/toolbars/mainbar.hpp @@ -93,6 +93,8 @@ public: void load_init_file(const std::string &file_name, const std::string &format); + QAction* action_new_session() const; + QAction* action_new_view() const; QAction* action_open() const; QAction* action_save_as() const; QAction* action_save_selection_as() const; @@ -125,6 +127,8 @@ private: void session_error(const QString text, const QString info_text); + QAction *const action_new_session_; + QAction *const action_new_view_; QAction *const action_open_; QAction *const action_save_as_; QAction *const action_save_selection_as_; @@ -154,6 +158,9 @@ private Q_SLOTS: void on_config_changed(); + void on_actionNewSession_triggered(); + void on_actionNewView_triggered(); + void on_actionOpen_triggered(); void on_actionSaveAs_triggered(); void on_actionSaveSelectionAs_triggered(); @@ -175,6 +182,10 @@ private Q_SLOTS: protected: bool eventFilter(QObject *watched, QEvent *event); +Q_SIGNALS: + void new_session(); + void new_view(Session *session); + private: Session &session_; -- 2.30.2