Skip to content

Commit

Permalink
buttons changes, refactored tab switch functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne committed Oct 29, 2024
1 parent 5fa34ed commit 5daa1f1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 47 deletions.
75 changes: 33 additions & 42 deletions src/Configurator/Configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,58 +278,49 @@ void Configurator::fadeOut(QWidget *widget, std::function<void()> 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);
}
3 changes: 3 additions & 0 deletions src/Configurator/Configurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QMainWindow>
#include <QString>
#include <QSettings>
#include <QPushButton>

namespace Ui {
class Configurator;
Expand Down Expand Up @@ -47,6 +48,8 @@ private slots:
void initUI();
void fadeIn(QWidget *widget);
void fadeOut(QWidget *widget, std::function<void()> onFinished);
void showFrame(QWidget* targetFrame, QPushButton* activeButton, int frameIndex);
void switchTab(int targetFrame, QPushButton* targetButton, QWidget* targetFrameWidget);

Ui::Configurator *ui;
QSettings settings;
Expand Down
10 changes: 5 additions & 5 deletions src/Configurator/Configurator.ui
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,10 @@
<string>General</string>
</property>
<property name="checkable">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand All @@ -689,7 +689,7 @@
<string>Audio/Video</string>
</property>
<property name="checkable">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand All @@ -705,7 +705,7 @@
<string>Actions</string>
</property>
<property name="checkable">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand All @@ -721,7 +721,7 @@
<string>Advanced</string>
</property>
<property name="checkable">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand Down

0 comments on commit 5daa1f1

Please sign in to comment.