#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*)));
}
session_windows_[session] = window;
session_selector_.addTab(window, name);
+ window->setDockNestingEnabled(true);
+
shared_ptr<views::ViewBase> main_view =
add_view(name, views::ViewTypeTrace, *session);
action_about_->setObjectName(QString::fromUtf8("actionAbout"));
action_about_->setText(tr("&About..."));
- setDockNestingEnabled(true);
+ // 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*)),
setWindowTitle(WindowTitle);
}
-void MainWindow::on_new_session()
+void MainWindow::on_new_session_clicked()
{
add_session();
}
}
}
+void MainWindow::on_tab_close_requested(int index)
+{
+ // TODO Ask user if this is intended in case data is unsaved
+
+ // Find the session that belongs to this main window and remove it
+ for (auto entry : session_windows_)
+ if (entry.second == session_selector_.widget(index)) {
+ remove_session(entry.first);
+ break;
+ }
+}
+
void MainWindow::on_actionViewStickyScrolling_triggered()
{
shared_ptr<views::ViewBase> viewbase = get_active_view();