Skip to content

Commit 1e809fb

Browse files
author
ThePBone
committed
Add switch to use the legacy tab layout instead of the new animated one
1 parent ffa2b7c commit 1e809fb

File tree

7 files changed

+152
-29
lines changed

7 files changed

+152
-29
lines changed

config/appconfigwrapper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,13 @@ void AppConfigWrapper::setIntroShown(bool b){
256256
bool AppConfigWrapper::getIntroShown(){
257257
return appconf->getBool("app.firstlaunch");
258258
}
259+
void AppConfigWrapper::setLegacyTabs(bool b){
260+
appconf->setValue("theme.tab.legacy",QVariant(b));
261+
saveAppConfig();
262+
}
263+
bool AppConfigWrapper::getLegacyTabs(){
264+
return appconf->getBool("theme.tab.legacy");
265+
}
259266
//--------
260267
QString AppConfigWrapper::getAppConfigFilePath(){
261268
return QString("%1/.config/viper4linux/ui.2.conf").arg(QDir::homePath());

config/appconfigwrapper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class AppConfigWrapper : public QObject
9292
void setTrayContextMenu(const QString &ctx);
9393
void setSpectrumShape(int number);
9494
int getSpectrumShape();
95+
bool getLegacyTabs();
96+
void setLegacyTabs(bool b);
9597
signals:
9698
void spectrumChanged();
9799
void spectrumReloadRequired();

dialog/settings.ui

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</property>
3131
<layout class="QVBoxLayout" name="verticalLayout">
3232
<item>
33-
<layout class="QHBoxLayout" name="horizontalLayout_7" stretch="4,9">
33+
<layout class="QHBoxLayout" name="horizontalLayout_7" stretch="4,0">
3434
<property name="topMargin">
3535
<number>0</number>
3636
</property>
@@ -44,6 +44,12 @@
4444
</property>
4545
<item>
4646
<widget class="QTreeWidget" name="selector">
47+
<property name="minimumSize">
48+
<size>
49+
<width>190</width>
50+
<height>0</height>
51+
</size>
52+
</property>
4753
<property name="verticalScrollBarPolicy">
4854
<enum>Qt::ScrollBarAlwaysOff</enum>
4955
</property>
@@ -554,20 +560,43 @@
554560
</layout>
555561
</item>
556562
<item>
557-
<widget class="QGroupBox" name="groupBox_6">
558-
<property name="title">
559-
<string>Equalizer</string>
563+
<layout class="QHBoxLayout" name="horizontalLayout_11">
564+
<property name="topMargin">
565+
<number>0</number>
560566
</property>
561-
<layout class="QVBoxLayout" name="verticalLayout_15">
562-
<item>
563-
<widget class="QCheckBox" name="eq_alwaysdrawhandles">
564-
<property name="text">
565-
<string>Always display handles</string>
566-
</property>
567-
</widget>
568-
</item>
569-
</layout>
570-
</widget>
567+
<item>
568+
<widget class="QGroupBox" name="groupBox_6">
569+
<property name="title">
570+
<string>Equalizer</string>
571+
</property>
572+
<layout class="QVBoxLayout" name="verticalLayout_15">
573+
<item>
574+
<widget class="QCheckBox" name="eq_alwaysdrawhandles">
575+
<property name="text">
576+
<string>Always display handles</string>
577+
</property>
578+
</widget>
579+
</item>
580+
</layout>
581+
</widget>
582+
</item>
583+
<item>
584+
<widget class="QGroupBox" name="groupBox_8">
585+
<property name="title">
586+
<string>Tab Container</string>
587+
</property>
588+
<layout class="QVBoxLayout" name="verticalLayout_20">
589+
<item>
590+
<widget class="QCheckBox" name="legacytabs">
591+
<property name="text">
592+
<string>Use legacy tabs</string>
593+
</property>
594+
</widget>
595+
</item>
596+
</layout>
597+
</widget>
598+
</item>
599+
</layout>
571600
</item>
572601
<item>
573602
<spacer name="verticalSpacer_2">

dialog/settingsdlg.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ SettingsDlg::SettingsDlg(MainWindow* mainwin,QWidget *parent) :
153153
connect(ui->systray_minOnBoot,&QPushButton::clicked,this,autostart_update);
154154
connect(ui->systray_autostartViper,&QPushButton::clicked,this,autostart_update);
155155
connect(ui->systray_delay,&QPushButton::clicked,this,autostart_update);
156-
156+
/*
157+
* Connect all signals for Interface
158+
*/
157159
auto change_theme_mode = [this]{
158160
if(lockslot)return;
159161
int mode = 0;
@@ -189,7 +191,19 @@ SettingsDlg::SettingsDlg(MainWindow* mainwin,QWidget *parent) :
189191
connect(ui->eq_alwaysdrawhandles,&QCheckBox::clicked,[this](){
190192
appconf->setEqualizerPermanentHandles(ui->eq_alwaysdrawhandles->isChecked());
191193
});
192-
194+
connect(ui->legacytabs,&QCheckBox::clicked,[this](){
195+
appconf->setLegacyTabs(ui->legacytabs->isChecked());
196+
if(ui->legacytabs->isChecked())
197+
m_mainwin->InitializeLegacyTabs();
198+
else{
199+
QMessageBox::StandardButton reply =
200+
QMessageBox::question(this, tr("Restart required"), tr("Please restart this application to make sure all changes are applied correctly.\n"
201+
"Press 'OK' to quit or 'Cancel' if you want to continue without a restart."),
202+
QMessageBox::Ok|QMessageBox::Cancel);
203+
if (reply == QMessageBox::Ok)
204+
QApplication::quit();
205+
}
206+
});
193207
/*
194208
* Connect all signals for Convolver
195209
*/
@@ -442,6 +456,7 @@ void SettingsDlg::refreshAll(){
442456
ui->deftab_filesys->setChecked(appconf->getConv_DefTab());
443457

444458
ui->eq_alwaysdrawhandles->setChecked(appconf->getEqualizerPermanentHandles());
459+
ui->legacytabs->setChecked(appconf->getLegacyTabs());
445460

446461
refreshDevices();
447462

mainwindow.cpp

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ MainWindow::MainWindow(QString exepath, bool statupInTray, bool allowMultipleIns
3232
ui->setupUi(this);
3333
bool aboutToQuit = false;
3434

35+
ui->tabhost_legacy->hide();
36+
3537
m_exepath = exepath;
3638
m_startupInTraySwitch = statupInTray;
3739

@@ -162,25 +164,42 @@ MainWindow::MainWindow(QString exepath, bool statupInTray, bool allowMultipleIns
162164
RunDiagnosticChecks();
163165
});
164166

165-
ui->tabbar->setAnimatePageChange(true);
166-
ui->tabbar->setCustomStackWidget(ui->tabhost);
167-
ui->tabbar->setDetachCustomStackedWidget(true);
168-
ui->tabbar->addPage("Bass/Clarity");
169-
ui->tabbar->addPage("Dynamic");
170-
ui->tabbar->addPage("Surround");
171-
ui->tabbar->addPage("Equalizer");
172-
ui->tabbar->addPage("Compressor");
173-
ui->tabbar->addPage("Volume");
174-
ui->tabbar->addPage("Miscellaneous");
175-
ui->frame->setStyleSheet(QString("QFrame#frame{background-color: %1;}").arg(qApp->palette().window().color().lighter().name()));
176-
ui->tabhost->setStyleSheet(QString("QWidget#tabhostPage1,QWidget#tabhostPage2,QWidget#tabhostPage3,QWidget#tabhostPage4,QWidget#tabhostPage5,QWidget#tabhostPage6,QWidget#tabhostPage7{background-color: %1;}").arg(qApp->palette().window().color().lighter().name()));
177-
ui->tabbar->redrawTabBar();
167+
if(m_appwrapper->getLegacyTabs())
168+
InitializeLegacyTabs();
169+
else{
170+
ui->tabbar->setAnimatePageChange(true);
171+
ui->tabbar->setCustomStackWidget(ui->tabhost);
172+
ui->tabbar->setDetachCustomStackedWidget(true);
173+
ui->tabbar->addPage("Bass/Clarity");
174+
ui->tabbar->addPage("Dynamic");
175+
ui->tabbar->addPage("Surround");
176+
ui->tabbar->addPage("Equalizer");
177+
ui->tabbar->addPage("Compressor");
178+
ui->tabbar->addPage("Volume");
179+
ui->tabbar->addPage("Miscellaneous");
180+
ui->frame->setStyleSheet(QString("QFrame#frame{background-color: %1;}").arg(qApp->palette().window().color().lighter().name()));
181+
ui->tabhost->setStyleSheet(QString("QWidget#tabhostPage1,QWidget#tabhostPage2,QWidget#tabhostPage3,QWidget#tabhostPage4,QWidget#tabhostPage5,QWidget#tabhostPage6,QWidget#tabhostPage7{background-color: %1;}").arg(qApp->palette().window().color().lighter().name()));
182+
ui->tabbar->redrawTabBar();
183+
}
178184
}
179185

180186
MainWindow::~MainWindow()
181187
{
182188
delete ui;
183189
}
190+
void MainWindow::InitializeLegacyTabs(){
191+
if(!ui->frame->isVisible())
192+
return;
193+
194+
ui->frame->hide();
195+
ui->tabhost_legacy->show();
196+
for(int i = 1; i <= 7; i++){
197+
QWidget* w = findChild<QWidget*>(QString("tabhostPage%1").arg(i));
198+
replaceTab(ui->tabhost_legacy,i - 1, w);
199+
ui->tabhost_legacy->widget(i - 1)->setContentsMargins(9,9,9,9);
200+
}
201+
ui->tabhost_legacy->setCurrentIndex(0);
202+
}
184203
void MainWindow::LaunchFirstRunSetup(){
185204
FirstLaunchWizard* wiz = new FirstLaunchWizard(m_appwrapper,this);
186205
QHBoxLayout* lbLayout = new QHBoxLayout;

mainwindow.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class MainWindow : public QMainWindow
7070
QMenu *getTrayContextMenu();
7171

7272
SettingsDlg *settings_dlg;
73+
void InitializeLegacyTabs();
7374
protected:
7475
void closeEvent(QCloseEvent *event) override;
7576
public slots:
@@ -152,6 +153,14 @@ private slots:
152153
void initGlobalTrayActions();
153154
void updateTrayConvolverList();
154155
void SetSpectrumVisibility(bool v);
156+
157+
static void replaceTab(QTabWidget* tab, int index, QWidget *page, QString title = ""){
158+
if(title.isEmpty()) title = tab->tabText(index);
159+
auto toDelete = tab->widget(index);
160+
tab->removeTab(index);
161+
toDelete->deleteLater();
162+
tab->insertTab(index, page, title);
163+
}
155164
};
156165

157166
#endif // MAINWINDOW_H

mainwindow.ui

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,48 @@
4040
<property name="topMargin">
4141
<number>9</number>
4242
</property>
43+
<item>
44+
<widget class="QTabWidget" name="tabhost_legacy">
45+
<property name="currentIndex">
46+
<number>0</number>
47+
</property>
48+
<widget class="QWidget" name="tab_1">
49+
<attribute name="title">
50+
<string>Bass/Clarity</string>
51+
</attribute>
52+
</widget>
53+
<widget class="QWidget" name="tab_2">
54+
<attribute name="title">
55+
<string>Dynamic</string>
56+
</attribute>
57+
</widget>
58+
<widget class="QWidget" name="tab_3">
59+
<attribute name="title">
60+
<string>Surround</string>
61+
</attribute>
62+
</widget>
63+
<widget class="QWidget" name="tab_4">
64+
<attribute name="title">
65+
<string>Equalizer</string>
66+
</attribute>
67+
</widget>
68+
<widget class="QWidget" name="tab_5">
69+
<attribute name="title">
70+
<string>Compressor</string>
71+
</attribute>
72+
</widget>
73+
<widget class="QWidget" name="tab_6">
74+
<attribute name="title">
75+
<string>Volume</string>
76+
</attribute>
77+
</widget>
78+
<widget class="QWidget" name="tab_7">
79+
<attribute name="title">
80+
<string>Misc</string>
81+
</attribute>
82+
</widget>
83+
</widget>
84+
</item>
4385
<item>
4486
<widget class="QFrame" name="frame">
4587
<property name="frameShape">

0 commit comments

Comments
 (0)