#include <QApplication>
#include <QCloseEvent>
#include <QDockWidget>
+#include <QHBoxLayout>
#include <QSettings>
#include <QWidget>
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*)));
}
action_about_->setObjectName(QString::fromUtf8("actionAbout"));
action_about_->setText(tr("&About..."));
+ // Set up the tab area
+ new_session_button_ = new QToolButton();
+ new_session_button_->setIcon(QIcon::fromTheme("document-new",
+ QIcon(":/icons/document-new.png")));
+ new_session_button_->setAutoRaise(true);
+
+ QHBoxLayout* layout = new QHBoxLayout();
+ layout->setContentsMargins(2, 2, 2, 2);
+ layout->addWidget(new_session_button_);
+
+ QWidget* static_tab_widget_ = new QWidget();
+ static_tab_widget_->setLayout(layout);
+
+ session_selector_.setCornerWidget(static_tab_widget_, Qt::TopLeftCorner);
+
session_selector_.setTabsClosable(true);
+ connect(new_session_button_, SIGNAL(clicked(bool)),
+ this, SLOT(on_new_session_clicked()));
+
connect(&session_selector_, SIGNAL(tabCloseRequested(int)),
this, SLOT(on_tab_close_requested(int)));
+
connect(static_cast<QApplication *>(QCoreApplication::instance()),
SIGNAL(focusChanged(QWidget*, QWidget*)),
this, SLOT(on_focus_changed()));
setWindowTitle(WindowTitle);
}
-void MainWindow::on_new_session()
+void MainWindow::on_new_session_clicked()
{
add_session();
}
#include <memory>
#include <QMainWindow>
+#include <QToolButton>
#include <QTabWidget>
#include "session.hpp"
void on_focus_changed();
- void on_new_session();
+ void on_new_session_clicked();
void on_session_name_changed();
void on_new_view(Session *session);
void on_view_close_clicked();
std::map< std::shared_ptr<Session>, QMainWindow*> session_windows_;
+ QToolButton *new_session_button_;
QTabWidget session_selector_;
QAction *const action_view_sticky_scrolling_;
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)),
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")));
#endif
// Setup the toolbar
- addAction(action_new_session_);
addAction(action_new_view_);
addSeparator();
addWidget(open_button);
commit_sample_rate();
}
-void MainBar::on_actionNewSession_triggered()
-{
- new_session();
-}
-
void MainBar::on_actionNewView_triggered()
{
new_view(&session_);
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;
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_;
void on_config_changed();
- void on_actionNewSession_triggered();
void on_actionNewView_triggered();
void on_actionOpen_triggered();
bool eventFilter(QObject *watched, QEvent *event);
Q_SIGNALS:
- void new_session();
void new_view(Session *session);
private: