mode: set tabs moveable

This commit is contained in:
Kiara Navarro 2022-07-04 13:06:08 -05:00
parent cb9b03e418
commit 77e0d156d0
No known key found for this signature in database
GPG Key ID: CBA9F2172CE33FBA
3 changed files with 12 additions and 1 deletions

View File

@ -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() int ModeHandler::getCurrentIndex()
{ {
return currentModeIndex; return currentModeIndex;

View File

@ -17,6 +17,7 @@ public:
void shutdown(); void shutdown();
int createMode(QString name, Mode::Type t); int createMode(QString name, Mode::Type t);
void closeMode(int index); void closeMode(int index);
void currentModeMoved(int from, int to);
void closeModes(); void closeModes();
int getCurrentIndex(); int getCurrentIndex();

View File

@ -22,6 +22,7 @@ ModeWindow::ModeWindow(ModeHandler* handler, AppWindow* aw, QWidget* parent):
connect(tabBar, &QTabBar::currentChanged, handler, &ModeHandler::setCurrentIndex); connect(tabBar, &QTabBar::currentChanged, handler, &ModeHandler::setCurrentIndex);
connect(tabBar, &QTabBar::tabCloseRequested, handler, &ModeHandler::closeMode); connect(tabBar, &QTabBar::tabCloseRequested, handler, &ModeHandler::closeMode);
connect(tabBar, &QTabBar::tabMoved, handler, &ModeHandler::currentModeMoved);
} }
ModeWindow::~ModeWindow() ModeWindow::~ModeWindow()
@ -94,7 +95,7 @@ void ModeWindow::ModeCreated(int modeIndex)
tabBar->blockSignals(true); tabBar->blockSignals(true);
tabBar->insertTab(modeIndex, name); tabBar->insertTab(modeIndex, name);
tabBar->blockSignals(false); tabBar->blockSignals(false);
tabBar->setMovable(true);
tabBar->setCurrentIndex(modeIndex); tabBar->setCurrentIndex(modeIndex);
} }
} }