]> sigrok.org Git - pulseview.git/commitdiff
Introduce ViewBase::is_main_view
authorSoeren Apel <redacted>
Sun, 5 Mar 2017 20:07:23 +0000 (21:07 +0100)
committerUwe Hermann <redacted>
Tue, 7 Mar 2017 21:59:36 +0000 (22:59 +0100)
pv/mainwindow.cpp
pv/view/view.cpp
pv/view/view.hpp
pv/views/viewbase.cpp
pv/views/viewbase.hpp

index 2f9ab323008948395f3496e5e14bf39bb0a23736..985f698f8127f1e6efb2cf5f31ed067ec318c132 100644 (file)
@@ -168,6 +168,8 @@ shared_ptr<views::ViewBase> MainWindow::add_view(const QString &title,
 
        assert(main_window);
 
+       shared_ptr<MainBar> 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<views::ViewBase> MainWindow::add_view(const QString &title,
        dock_main->setWindowFlags(Qt::Widget);  // Remove Qt::Window flag
 
        if (type == views::ViewTypeTrace)
-               v =     make_shared<views::TraceView::View>(session, dock_main);
+               // This view will be the main view if there's no main bar yet
+               v = make_shared<views::TraceView::View>(session,
+                       (main_bar ? false : true), dock_main);
 
        if (!v)
                return nullptr;
@@ -209,7 +213,6 @@ shared_ptr<views::ViewBase> MainWindow::add_view(const QString &title,
                tv->enable_sticky_scrolling(true);
                tv->enable_coloured_bg(settings.value(GlobalSettings::Key_View_ColouredBG).toBool());
 
-               shared_ptr<MainBar> main_bar = session.main_bar();
                if (!main_bar) {
                        /* Initial view, create the main bar */
                        main_bar = make_shared<MainBar>(session, this, tv);
index d460e8686c3e22decc8f0b9d11e3f0ab32d59bd9..9ca973a7ea9ca3b4227cde8973f2add6f284348a 100644 (file)
@@ -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)),
index 0e1a54438a4206f00254453e26f4565c270de3bb..c289cfcb00ce93060d42c5095ba18a689444972d 100644 (file)
@@ -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;
index 6fb95279fe8fb5b5958e6ce2c0f7b13fd020efc1..b1190562a9338b15c25926002b0781fde9283d43 100644 (file)
@@ -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;
 
index 8e09043b22ec811a56a8cfe086047c8bb1af9325..3e180830f897574de522b460cf775f43a264361e 100644 (file)
@@ -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_;
 };