diff --git a/Software/PC_Application/modehandler.cpp b/Software/PC_Application/modehandler.cpp index b565e2b..db8b797 100644 --- a/Software/PC_Application/modehandler.cpp +++ b/Software/PC_Application/modehandler.cpp @@ -58,6 +58,15 @@ void ModeHandler::setCurrentIndex(int index) } } +void ModeHandler::currentModeMoved(int from, int to) +{ + auto modeFrom = modes.at(from); + auto modeTo = modes.at(to); + modes[from] = modeTo; + modes[to] = modeFrom; + setCurrentIndex(to); +} + int ModeHandler::getCurrentIndex() { return currentModeIndex; diff --git a/Software/PC_Application/modehandler.h b/Software/PC_Application/modehandler.h index 683701b..de4e1d0 100644 --- a/Software/PC_Application/modehandler.h +++ b/Software/PC_Application/modehandler.h @@ -17,6 +17,7 @@ public: void shutdown(); int createMode(QString name, Mode::Type t); void closeMode(int index); + void currentModeMoved(int from, int to); void closeModes(); int getCurrentIndex(); diff --git a/Software/PC_Application/modewindow.cpp b/Software/PC_Application/modewindow.cpp index 0e4c94a..1fe89d4 100644 --- a/Software/PC_Application/modewindow.cpp +++ b/Software/PC_Application/modewindow.cpp @@ -22,6 +22,7 @@ ModeWindow::ModeWindow(ModeHandler* handler, AppWindow* aw, QWidget* parent): connect(tabBar, &QTabBar::currentChanged, handler, &ModeHandler::setCurrentIndex); connect(tabBar, &QTabBar::tabCloseRequested, handler, &ModeHandler::closeMode); + connect(tabBar, &QTabBar::tabMoved, handler, &ModeHandler::currentModeMoved); } ModeWindow::~ModeWindow() @@ -94,7 +95,7 @@ void ModeWindow::ModeCreated(int modeIndex) tabBar->blockSignals(true); tabBar->insertTab(modeIndex, name); tabBar->blockSignals(false); - + tabBar->setMovable(true); tabBar->setCurrentIndex(modeIndex); } }