diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 9977326e3..a8221700c 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -458,6 +458,7 @@ MainWindow::MainWindow(const QDir &home) tabbar->setAutoFillBackground(true); tabbar->setShape(QTabBar::RoundedSouth); tabbar->setDrawBase(false); + tabbar->setTabsClosable(true); QPalette tabbarPalette; tabbarPalette.setBrush(backgroundRole(), QColor("#B3B4B6")); tabbar->setPalette(tabbarPalette); @@ -475,6 +476,7 @@ MainWindow::MainWindow(const QDir &home) tabStack->setCurrentIndex(0); connect(tabbar, SIGNAL(currentChanged(int)), this, SLOT(switchTab(int))); + connect(tabbar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTabClicked(int))); /*---------------------------------------------------------------------- * Central Widget @@ -1337,6 +1339,16 @@ MainWindow::openTab(QString name) setUpdatesEnabled(true); } +void +MainWindow::closeTabClicked(int index) +{ + Tab *tab = tabList[index]; + if (saveRideExitDialog(tab->context) == false) return; + + // lets wipe it + removeTab(tab); +} + bool MainWindow::closeTab() { @@ -1520,6 +1532,12 @@ MainWindow::switchTab(int index) { if (index < 0) return; + setUpdatesEnabled(false); + + // Only have close button on current tab (prettier) + for(int i=0; icount(); i++) tabbar->tabButton(i, QTabBar::RightSide)->hide(); + tabbar->tabButton(index, QTabBar::RightSide)->show(); + // save how we are saveState(currentTab->context); @@ -1531,6 +1549,7 @@ MainWindow::switchTab(int index) setWindowTitle(currentTab->context->athlete->home.dirName()); + setUpdatesEnabled(true); } diff --git a/src/MainWindow.h b/src/MainWindow.h index be8fde03b..aec032145 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -101,6 +101,7 @@ class MainWindow : public QMainWindow void setOpenTabMenu(); // set the Open Tab menu void newCyclistTab(); // create a new Cyclist void openTab(QString name); + void closeTabClicked(int index); // user clicked to close tab bool closeTab(); // close current, might not if the user // changes mind if there are unsaved changes. void removeTab(Tab*); // remove without question