diff --git a/src/Configurator/Configurator.cpp b/src/Configurator/Configurator.cpp index 09844d4..577e260 100644 --- a/src/Configurator/Configurator.cpp +++ b/src/Configurator/Configurator.cpp @@ -278,58 +278,49 @@ void Configurator::fadeOut(QWidget *widget, std::function onFinished = n } } -void Configurator::setGeneralTab() { - if (activeFrame == 1) { +void Configurator::switchTab(int targetFrame, QPushButton* targetButton, QWidget* targetFrameWidget) { + if (activeFrame == targetFrame) { + targetButton->setChecked(true); return; } - fadeOut(ui->avFrame, [this]() { - fadeOut(ui->actionsFrame, [this]() { - fadeOut(ui->advancedFrame, [this]() { - fadeIn(ui->generalFrame); - }); + + ui->generalButton->setChecked(false); + ui->avButton->setChecked(false); + ui->actionsButton->setChecked(false); + ui->advancedButton->setChecked(false); + targetButton->setChecked(true); + + QWidget* currentFrame = nullptr; + + switch (activeFrame) { + case 1: currentFrame = ui->generalFrame; break; + case 2: currentFrame = ui->avFrame; break; + case 3: currentFrame = ui->actionsFrame; break; + case 4: currentFrame = ui->advancedFrame; break; + default: break; + } + + if (currentFrame) { + fadeOut(currentFrame, [this, targetFrameWidget]() { + fadeIn(targetFrameWidget); }); - }); - activeFrame = 1; + } + + activeFrame = targetFrame; +} + +void Configurator::setGeneralTab() { + switchTab(1, ui->generalButton, ui->generalFrame); } void Configurator::setAVTab() { - if (activeFrame == 2) { - return; - } - fadeOut(ui->generalFrame, [this]() { - fadeOut(ui->actionsFrame, [this]() { - fadeOut(ui->advancedFrame, [this]() { - fadeIn(ui->avFrame); - }); - }); - }); - activeFrame = 2; + switchTab(2, ui->avButton, ui->avFrame); } void Configurator::setActionsTab() { - if (activeFrame == 3) { - return; - } - fadeOut(ui->generalFrame, [this]() { - fadeOut(ui->avFrame, [this]() { - fadeOut(ui->advancedFrame, [this]() { - fadeIn(ui->actionsFrame); - }); - }); - }); - activeFrame = 3; + switchTab(3, ui->actionsButton, ui->actionsFrame); } void Configurator::setAdvancedTab() { - if (activeFrame == 4) { - return; - } - fadeOut(ui->generalFrame, [this]() { - fadeOut(ui->avFrame, [this]() { - fadeOut(ui->actionsFrame, [this]() { - fadeIn(ui->advancedFrame); - }); - }); - }); - activeFrame = 4; + switchTab(4, ui->advancedButton, ui->advancedFrame); } diff --git a/src/Configurator/Configurator.h b/src/Configurator/Configurator.h index 590745f..32878c9 100644 --- a/src/Configurator/Configurator.h +++ b/src/Configurator/Configurator.h @@ -7,6 +7,7 @@ #include #include #include +#include namespace Ui { class Configurator; @@ -47,6 +48,8 @@ private slots: void initUI(); void fadeIn(QWidget *widget); void fadeOut(QWidget *widget, std::function onFinished); + void showFrame(QWidget* targetFrame, QPushButton* activeButton, int frameIndex); + void switchTab(int targetFrame, QPushButton* targetButton, QWidget* targetFrameWidget); Ui::Configurator *ui; QSettings settings; diff --git a/src/Configurator/Configurator.ui b/src/Configurator/Configurator.ui index 655a4d5..2d5d1a9 100644 --- a/src/Configurator/Configurator.ui +++ b/src/Configurator/Configurator.ui @@ -670,10 +670,10 @@ General - false + true - false + true @@ -689,7 +689,7 @@ Audio/Video - false + true @@ -705,7 +705,7 @@ Actions - false + true @@ -721,7 +721,7 @@ Advanced - false + true