1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#include <map>
#include <set>
#include <vector>
#include <QSettings>
#include <QList>
#include <QVariant>
#include "qmpmainwindow.hpp"
#include "qmpcustomizewindow.hpp"
#include "ui_qmpcustomizewindow.h"
qmpCustomizeWindow::qmpCustomizeWindow(QWidget *parent) :
QDialog(parent),
ui(new Ui::qmpCustomizeWindow)
{
ui->setupUi(this);
int w=size().width(),h=size().height();w=w*(logicalDpiX()/96.);h=h*(logicalDpiY()/96.);
setMinimumWidth(w);setMinimumHeight(h);
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()
{
delete ui;
}
void qmpCustomizeWindow::launch(int w)
{
show();
ui->lwAvail->clear();
ui->lwEnabled->clear();
ow=w;
std::vector<std::string>& v=qmpMainWindow::getInstance()->getWidgets(w);
std::map<std::string,qmpFuncPrivate>& m=qmpMainWindow::getInstance()->getFunc();
std::set<std::string> s;
for(auto i=v.begin();i!=v.end();++i)
{
s.insert(*i);
QListWidgetItem* it=new QListWidgetItem(
m[*i].icon(),
QString(m[*i].desc().c_str())
);
it->setToolTip(i->c_str());
ui->lwEnabled->addItem(it);
}
for(auto i=m.begin();i!=m.end();++i)
{
if(s.find(i->first)==s.end())
{
QListWidgetItem* it=new QListWidgetItem(
i->second.icon(),
QString(i->second.desc().c_str())
);
it->setToolTip(i->first.c_str());
ui->lwAvail->addItem(it);
}
}
}
void qmpCustomizeWindow::on_tbAdd_clicked()
{
if(!ui->lwAvail->currentItem())return;
ui->lwEnabled->addItem(ui->lwAvail->takeItem(ui->lwAvail->currentRow()));
ui->lwAvail->removeItemWidget(ui->lwAvail->currentItem());
}
void qmpCustomizeWindow::on_tbRemove_clicked()
{
if(!ui->lwEnabled->currentItem())return;
ui->lwAvail->addItem(ui->lwEnabled->takeItem(ui->lwEnabled->currentRow()));
}
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();
close();
}
void qmpCustomizeWindow::on_buttonBox_rejected()
{
close();
}
|