main_bar = make_shared<MainBar>(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());
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<Session> s : sessions_)
+ if (s.get() == session)
+ add_view(session->name(), pv::view::TraceView, *s);
+}
+
void MainWindow::on_actionViewStickyScrolling_triggered()
{
shared_ptr<pv::view::View> view = get_active_view();
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();
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)),
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")));
#endif
// Setup the toolbar
+ addAction(action_new_session_);
+ addAction(action_new_view_);
+ addSeparator();
addWidget(open_button);
addWidget(save_button);
addSeparator();
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;
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;
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_;
void on_config_changed();
+ void on_actionNewSession_triggered();
+ void on_actionNewView_triggered();
+
void on_actionOpen_triggered();
void on_actionSaveAs_triggered();
void on_actionSaveSelectionAs_triggered();
protected:
bool eventFilter(QObject *watched, QEvent *event);
+Q_SIGNALS:
+ void new_session();
+ void new_view(Session *session);
+
private:
Session &session_;