Parent: [b716ca] (diff)

Download this file

prefs.cpp    212 lines (178 with data), 7.9 kB

  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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#include <string>
#include <QSettings>
#include <QDebug>
#include <libupnpp/upnpputils.hxx>
#include "upadapt/upputils.h"
#include "prefs.h"
#include "utils/confgui.h"
#include "sortprefs.h"
using namespace std;
using namespace confgui;
class ConfLinkQS : public confgui::ConfLinkRep {
public:
ConfLinkQS(const QString& nm)
: m_nm(nm) {
}
virtual ~ConfLinkQS() {
}
virtual bool set(const std::string& val) {
QSettings settings;
settings.setValue(m_nm, QString::fromUtf8(val.c_str()));
return true;
}
virtual bool get(std::string& val) {
QSettings settings;
bool ret = settings.contains(m_nm);
if (ret) {
QString qv = settings.value(m_nm).toString();
val = string((const char*)qv.toUtf8());
}
return ret;
}
private:
const QString m_nm;
};
class MyConfLinkFactQS : public confgui::ConfLinkFact {
public:
MyConfLinkFactQS() {
}
virtual ConfLink operator()(const QString& nm) {
ConfLinkRep *lnk = new ConfLinkQS(nm);
return ConfLink(lnk);
}
};
static MyConfLinkFactQS lnkfact;
void UPPrefs::onShowPrefs()
{
if (m_w == 0) {
m_w = new ConfTabsW(m_parent, "UPPlay Preferences", &lnkfact);
int idx = m_w->addPanel("Application");
m_w->addParam(idx, ConfTabsW::CFPT_STR, "wholeuiscale",
"Display scale (e.g. 1.0)",
"Use this to scale the interface (font sizes mostly) "
" up or down. May help on HiDPI screens.");
// Restore tabs on startup ?
m_w->addParam(idx, ConfTabsW::CFPT_BOOL, "norestoretabs",
"Do not restore browsing state on startup",
"Start with one default initial tab instead of trying "
"to create the tabs and directory <br>"
"positions which existed when upplay was last closed.");
m_w->addParam(idx, ConfTabsW::CFPT_BOOL, "saveseekpos",
"Save seek position when switching tracks",
"When switching tracks by double-clicking in the <br>"
"playlist, start play either at the last pause position "
"for this track if the playlist is in repeat mode, or "
"at the last play position");
// Close to tray ?
m_w->addParam(idx, ConfTabsW::CFPT_BOOL, "min2tray", "Close to tray",
"Minimize to tray instead of exiting when the main window "
"is closed");
// Show notifications ?
ConfParamW *wsn =
m_w->addParam(idx, ConfTabsW::CFPT_BOOL, "shownotifications",
"Show notifications",
"Show pop-up message in notification area when a "
"track starts playing");
QSettings settings;
#ifndef _WIN32
ConfParamW *wuncmd =
m_w->addParam(idx, ConfTabsW::CFPT_BOOL, "usenotificationcmd",
"Use notification command (else use Qt)",
"Choose whether to use the Qt notification mechanism "
"or to execute a desktop command");
if (!settings.contains("notificationcmd")) {
settings.setValue("notificationcmd",
"notify-send --expire-time=1000 --icon=upplay");
}
ConfParamW *wncmd =
m_w->addParam(idx, ConfTabsW::CFPT_STR, "notificationcmd",
"Notification command",
"Command to execute to notify. The message argument "
" will be appended");
m_w->enableLink(wsn, wuncmd);
m_w->enableLink(wuncmd, wncmd);
#endif
// Truncate artist information in directory listings?
ConfParamW *b1 =
m_w->addParam(idx, ConfTabsW::CFPT_BOOL, "truncateartistindir",
"Truncate artist information in track lists",
"Truncate very long artist info so that the table "
"does not become weird");
m_w->addParam(idx, ConfTabsW::CFPT_INT, "maxcoverpopupsize",
"Max cover art popup height.", "", 500, 5000);
QString pname("truncateartistlen");
if (!settings.contains(pname)) {
settings.setValue(pname, 30);
}
ConfParamW *w1 =
m_w->addParam(idx, ConfTabsW::CFPT_INT, pname,
"Max artist info size in track lists.",
"", 0, 100);
m_w->enableLink(b1, w1);
// Show some artist information with albums ?
b1 = m_w->addParam(idx, ConfTabsW::CFPT_BOOL, "showartwithalb",
"Show some artist information in album lists",
"List the beginning of artist info when listing "
"albums.\nThe exact amount can be adjusted with the "
"following entry");
pname = "artwithalblen";
if (!settings.contains(pname)) {
settings.setValue(pname, 15);
}
w1 = m_w->addParam(idx, ConfTabsW::CFPT_INT, pname,
"Max artist info size in album lists.",
"", 0, 100);
m_w->enableLink(b1, w1);
m_w->endOfList(idx);
idx = m_w->addPanel("UPnP");
vector<string> adapters;
UPnPP::getAdapterNames(adapters);
QStringList qadapters;
qadapters.push_back("");
for (unsigned int i = 0; i < adapters.size(); i++) {
qadapters.push_back(u8s2qs(adapters[i]));
}
// Specify network interface ?
m_w->addParam(idx, ConfTabsW::CFPT_CSTR, "netifname",
"Network interface name (needs restart)",
"Specify network interface to use, or leave blank to "
"use the first or only appropriate interface",
0, 0, &qadapters);
// Filter out non-openhome renderers?
m_w->addParam(idx, ConfTabsW::CFPT_BOOL, "ohonly",
"Only show OpenHome renderers",
"Only show OpenHome-capable renderers in "
"the selection dialog. Avoids Bubble UPnP server dups.");
// Notify content directory updateid changes
m_w->addParam(idx, ConfTabsW::CFPT_BOOL, "monitorupdateid",
"Notify on Content Directory update",
"Show dialog when content directory state changes.");
//
m_w->addParam(idx, ConfTabsW::CFPT_BOOL, "noavtsetnext",
"Do not use AVTransport gapless functionality",
"Disables use of setNextAVTransportUri/Metadata.<br>"
"Useful with some buggy AVT renderers. Irrelevant "
"with OpenHome.");
idx = m_w->addPanel("Last.FM");
m_w->addParam(idx, ConfTabsW::CFPT_BOOL, "lastfmscrobble",
"Send track information to Last.FM", "");
m_w->addParam(idx, ConfTabsW::CFPT_STR, "lastfmusername",
"Last.FM user name", "");
m_w->addParam(idx, ConfTabsW::CFPT_STR, "lastfmpassword",
"Last.FM password (md5)", "");
m_w->endOfList(idx);
idx = m_w->addForeignPanel(new SortprefsW(m_w), "Directory Sorting");
m_w->endOfList(idx);
connect(m_w, SIGNAL(sig_prefsChanged()),
this, SIGNAL(sig_prefsChanged()));
}
m_w->reloadPanels();
m_w->show();
}
void UPPrefs::onShowPrefs(Tab tb)
{
onShowPrefs();
// The enum values and the tab order are currently identical, no
// need for complication
m_w->setCurrentIndex(tb);
}