From: Soeren Apel Date: Sun, 5 Mar 2017 20:07:23 +0000 (+0100) Subject: Introduce ViewBase::is_main_view X-Git-Tag: pulseview-0.4.0~168 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=143d322d0c92ea5c2cc51facc37b68787362c244;p=pulseview.git Introduce ViewBase::is_main_view --- diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 2f9ab323..985f698f 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -168,6 +168,8 @@ shared_ptr MainWindow::add_view(const QString &title, assert(main_window); + shared_ptr main_bar = session.main_bar(); + QDockWidget* dock = new QDockWidget(title, main_window); dock->setObjectName(title); main_window->addDockWidget(Qt::TopDockWidgetArea, dock); @@ -177,7 +179,9 @@ shared_ptr MainWindow::add_view(const QString &title, dock_main->setWindowFlags(Qt::Widget); // Remove Qt::Window flag if (type == views::ViewTypeTrace) - v = make_shared(session, dock_main); + // This view will be the main view if there's no main bar yet + v = make_shared(session, + (main_bar ? false : true), dock_main); if (!v) return nullptr; @@ -209,7 +213,6 @@ shared_ptr MainWindow::add_view(const QString &title, tv->enable_sticky_scrolling(true); tv->enable_coloured_bg(settings.value(GlobalSettings::Key_View_ColouredBG).toBool()); - shared_ptr main_bar = session.main_bar(); if (!main_bar) { /* Initial view, create the main bar */ main_bar = make_shared(session, this, tv); diff --git a/pv/view/view.cpp b/pv/view/view.cpp index d460e868..9ca973a7 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -136,8 +136,8 @@ bool CustomAbstractScrollArea::viewportEvent(QEvent *event) } } -View::View(Session &session, QWidget *parent) : - ViewBase(session, parent), +View::View(Session &session, bool is_main_view, QWidget *parent) : + ViewBase(session, is_main_view, parent), viewport_(new Viewport(*this)), ruler_(new Ruler(*this)), header_(new Header(*this)), diff --git a/pv/view/view.hpp b/pv/view/view.hpp index 0e1a5443..c289cfcb 100644 --- a/pv/view/view.hpp +++ b/pv/view/view.hpp @@ -89,7 +89,7 @@ private: static const int ScaleUnits[3]; public: - explicit View(Session &session, QWidget *parent = 0); + explicit View(Session &session, bool is_main_view=false, QWidget *parent = 0); Session& session(); const Session& session() const; diff --git a/pv/views/viewbase.cpp b/pv/views/viewbase.cpp index 6fb95279..b1190562 100644 --- a/pv/views/viewbase.cpp +++ b/pv/views/viewbase.cpp @@ -32,8 +32,9 @@ using std::shared_ptr; namespace pv { namespace views { -ViewBase::ViewBase(Session &session, QWidget *parent) : - session_(session) +ViewBase::ViewBase(Session &session, bool is_main_view, QWidget *parent) : + session_(session), + is_main_view_(is_main_view) { (void)parent; diff --git a/pv/views/viewbase.hpp b/pv/views/viewbase.hpp index 8e09043b..3e180830 100644 --- a/pv/views/viewbase.hpp +++ b/pv/views/viewbase.hpp @@ -52,7 +52,7 @@ class ViewBase : public QWidget { Q_OBJECT public: - explicit ViewBase(Session &session, QWidget *parent = 0); + explicit ViewBase(Session &session, bool is_main_view=false, QWidget *parent = 0); Session& session(); const Session& session() const; @@ -80,6 +80,8 @@ public Q_SLOTS: protected: Session &session_; + const bool is_main_view_; + util::TimeUnit time_unit_; };