aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmpcustomizewindow.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2020-04-19 23:36:48 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2020-04-19 23:36:48 +0800
commit6d568d07b31ba2ae39703cfd272d3003ea542018 (patch)
tree58dca1ac27ffe9dd6bb045c5a71d04644b7a2e07 /qmidiplayer-desktop/qmpcustomizewindow.cpp
parentc7bf3e37e6eaed6895c797f72ef116b42c6f8a44 (diff)
downloadQMidiPlayer-6d568d07b31ba2ae39703cfd272d3003ea542018.tar.xz
Legacy code massacre!
Complete reconstruction of the settings infrastructure. All options are now registered using a revamped option API. Legacy configuration files are no longer compatible. Please make a backup.
Diffstat (limited to 'qmidiplayer-desktop/qmpcustomizewindow.cpp')
-rw-r--r--qmidiplayer-desktop/qmpcustomizewindow.cpp47
1 files changed, 18 insertions, 29 deletions
diff --git a/qmidiplayer-desktop/qmpcustomizewindow.cpp b/qmidiplayer-desktop/qmpcustomizewindow.cpp
index a2ff19c..0ea3228 100644
--- a/qmidiplayer-desktop/qmpcustomizewindow.cpp
+++ b/qmidiplayer-desktop/qmpcustomizewindow.cpp
@@ -8,24 +8,11 @@
#include "qmpcustomizewindow.hpp"
#include "ui_qmpcustomizewindow.h"
-qmpCustomizeWindow::qmpCustomizeWindow(QWidget *parent) :
+qmpCustomizeWindow::qmpCustomizeWindow(QWidget *parent):
QDialog(parent),
ui(new Ui::qmpCustomizeWindow)
{
ui->setupUi(this);
- QSettings *s=qmpMainWindow::getInstance()->getSettingsWindow()->getSettingsIntf();
- QList<QVariant> defa={"FileInfo","Render","Panic","ReloadSynth"};
- QList<QVariant> defb={"Channel","Playlist","Effects","Visualization"};
- QList<QVariant> a=s->value("Behavior/Actions",QVariant(defa)).toList();
- QList<QVariant> b=s->value("Behavior/Toolbar",QVariant(defb)).toList();
- std::vector<std::string>& v=qmpMainWindow::getInstance()->getWidgets(1);
- v.clear();
- for(int i=0;i<a.size();++i)
- v.push_back(a[i].toString().toStdString());
- std::vector<std::string>& vv=qmpMainWindow::getInstance()->getWidgets(0);
- vv.clear();
- for(int i=0;i<b.size();++i)
- vv.push_back(b[i].toString().toStdString());
}
qmpCustomizeWindow::~qmpCustomizeWindow()
@@ -33,13 +20,14 @@ qmpCustomizeWindow::~qmpCustomizeWindow()
delete ui;
}
-void qmpCustomizeWindow::launch(int w)
+void qmpCustomizeWindow::load(void *data)
{
- show();
ui->lwAvail->clear();
ui->lwEnabled->clear();
- ow=w;
- std::vector<std::string>& v=qmpMainWindow::getInstance()->getWidgets(w);
+ QList<QVariant> list=static_cast<QVariant*>(data)->toList();
+ std::vector<std::string> v;
+ for(auto i:list)
+ v.push_back(i.toString().toStdString());
std::map<std::string,qmpFuncPrivate>& m=qmpMainWindow::getInstance()->getFunc();
std::set<std::string> s;
for(auto i=v.begin();i!=v.end();++i)
@@ -67,6 +55,16 @@ void qmpCustomizeWindow::launch(int w)
}
}
+void *qmpCustomizeWindow::save()
+{
+ QList<QVariant> ret;
+ for(int i=0;i<ui->lwEnabled->count();++i)
+ {
+ ret.push_back(QVariant(ui->lwEnabled->item(i)->toolTip()));
+ }
+ return new QVariant(ret);
+}
+
void qmpCustomizeWindow::on_tbAdd_clicked()
{
if(!ui->lwAvail->currentItem())return;
@@ -82,21 +80,12 @@ void qmpCustomizeWindow::on_tbRemove_clicked()
void qmpCustomizeWindow::on_buttonBox_accepted()
{
- std::vector<std::string>& v=qmpMainWindow::getInstance()->getWidgets(ow);
- v.clear();
- QList<QVariant> ql;
- for(int i=0;i<ui->lwEnabled->count();++i)
- {
- v.push_back(ui->lwEnabled->item(i)->toolTip().toStdString());
- ql.push_back(QVariant(ui->lwEnabled->item(i)->toolTip()));
- }
- QSettings *s=qmpMainWindow::getInstance()->getSettingsWindow()->getSettingsIntf();
- s->setValue(ow?"Behavior/Actions":"Behavior/Toolbar",ql);
- qmpMainWindow::getInstance()->setupWidget();
+ accept();
close();
}
void qmpCustomizeWindow::on_buttonBox_rejected()
{
+ reject();
close();
}