Child: [2c3960] (diff)

Download this file

prefs.cpp    109 lines (89 with data), 3.2 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
#include <string>
#include <QSettings>
#include <QDebug>
#include "prefs.h"
#include "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()
{
qDebug() << "UPPrefs::onShowPrefs(). m_w: " << (void *)m_w;
if (m_w == 0) {
m_w = new ConfTabsW(m_parent, "UPPlay Preferences", &lnkfact);
int idx = m_w->addPanel("Application");
// 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");
// 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");
QSettings settings;
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);
idx = m_w->addForeignPanel(new SortprefsW(m_w), "Directory Sorting");
connect(m_w, SIGNAL(sig_prefsChanged()),
this, SIGNAL(sig_prefsChanged()));
}
m_w->reloadPanels();
m_w->show();
}