1 |
// qsamplerOptions.cpp |
// qsamplerOptions.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2008, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
23 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
24 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
25 |
|
|
26 |
#include <qcombobox.h> |
#include <QTextStream> |
27 |
|
#include <QComboBox> |
28 |
|
|
29 |
#include <lscp/client.h> |
#include <lscp/client.h> |
30 |
|
|
33 |
#endif |
#endif |
34 |
|
|
35 |
|
|
36 |
|
namespace QSampler { |
37 |
|
|
38 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
39 |
// qsamplerOptions - Prototype settings structure. |
// QSampler::Options - Prototype settings structure. |
40 |
// |
// |
41 |
|
|
42 |
// Constructor. |
// Constructor. |
43 |
qsamplerOptions::qsamplerOptions (void) |
Options::Options (void) |
44 |
|
: m_settings(QSAMPLER_DOMAIN, QSAMPLER_TITLE) |
45 |
{ |
{ |
46 |
// Begin master key group. |
// Begin into general options group. |
47 |
m_settings.beginGroup("/qsampler"); |
m_settings.beginGroup("/Options"); |
48 |
|
|
49 |
// And go into general options group. |
// Load server options... |
50 |
m_settings.beginGroup("/Options"); |
m_settings.beginGroup("/Server"); |
51 |
|
sServerHost = m_settings.value("/ServerHost", "localhost").toString(); |
52 |
|
iServerPort = m_settings.value("/ServerPort", 8888).toInt(); |
53 |
|
#if defined(__APPLE__) // Toshi Nagata 20080105 |
54 |
|
// TODO: Should this be a configure option? |
55 |
|
iServerTimeout = m_settings.value("/ServerTimeout", 10000).toInt(); |
56 |
|
#else |
57 |
|
iServerTimeout = m_settings.value("/ServerTimeout", 1000).toInt(); |
58 |
|
#endif |
59 |
|
bServerStart = m_settings.value("/ServerStart", true).toBool(); |
60 |
|
#if defined(__APPLE__) // Toshi Nagata 20080113 |
61 |
|
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler.starter").toString(); |
62 |
|
#else |
63 |
|
sServerCmdLine = m_settings.value("/ServerCmdLine", "linuxsampler").toString(); |
64 |
|
#endif |
65 |
|
iStartDelay = m_settings.value("/StartDelay", 3).toInt(); |
66 |
|
m_settings.endGroup(); |
67 |
|
|
68 |
|
// Load logging options... |
69 |
|
m_settings.beginGroup("/Logging"); |
70 |
|
bMessagesLog = m_settings.value("/MessagesLog", false).toBool(); |
71 |
|
sMessagesLogPath = m_settings.value("/MessagesLogPath", "qsampler.log").toString(); |
72 |
|
m_settings.endGroup(); |
73 |
|
|
74 |
|
// Load display options... |
75 |
|
m_settings.beginGroup("/Display"); |
76 |
|
sDisplayFont = m_settings.value("/DisplayFont").toString(); |
77 |
|
bDisplayEffect = m_settings.value("/DisplayEffect", true).toBool(); |
78 |
|
bAutoRefresh = m_settings.value("/AutoRefresh", true).toBool(); |
79 |
|
iAutoRefreshTime = m_settings.value("/AutoRefreshTime", 1000).toInt(); |
80 |
|
iMaxVolume = m_settings.value("/MaxVolume", 100).toInt(); |
81 |
|
sMessagesFont = m_settings.value("/MessagesFont").toString(); |
82 |
|
bMessagesLimit = m_settings.value("/MessagesLimit", true).toBool(); |
83 |
|
iMessagesLimitLines = m_settings.value("/MessagesLimitLines", 1000).toInt(); |
84 |
|
bConfirmRemove = m_settings.value("/ConfirmRemove", true).toBool(); |
85 |
|
bKeepOnTop = m_settings.value("/KeepOnTop", true).toBool(); |
86 |
|
bStdoutCapture = m_settings.value("/StdoutCapture", true).toBool(); |
87 |
|
bCompletePath = m_settings.value("/CompletePath", true).toBool(); |
88 |
|
iMaxRecentFiles = m_settings.value("/MaxRecentFiles", 5).toInt(); |
89 |
|
// if libgig provides a fast way to retrieve instrument names even for large |
90 |
|
// .gig files, then we enable this feature by default |
91 |
|
#if HAVE_LIBGIG_SETAUTOLOAD |
92 |
|
bInstrumentNames = m_settings.value("/InstrumentNames", true).toBool(); |
93 |
|
#else |
94 |
|
bInstrumentNames = m_settings.value("/InstrumentNames", false).toBool(); |
95 |
|
#endif |
96 |
|
m_settings.endGroup(); |
97 |
|
|
98 |
// Load server options... |
// And go into view options group. |
99 |
m_settings.beginGroup("/Server"); |
m_settings.beginGroup("/View"); |
100 |
sServerHost = m_settings.readEntry("/ServerHost", "localhost"); |
bMenubar = m_settings.value("/Menubar", true).toBool(); |
101 |
iServerPort = m_settings.readNumEntry("/ServerPort", 8888); |
bToolbar = m_settings.value("/Toolbar", true).toBool(); |
102 |
iServerTimeout = m_settings.readNumEntry("/ServerTimeout", 1000); |
bStatusbar = m_settings.value("/Statusbar", true).toBool(); |
103 |
bServerStart = m_settings.readBoolEntry("/ServerStart", true); |
bAutoArrange = m_settings.value("/AutoArrange", true).toBool(); |
104 |
sServerCmdLine = m_settings.readEntry("/ServerCmdLine", "linuxsampler"); |
m_settings.endGroup(); |
105 |
iStartDelay = m_settings.readNumEntry("/StartDelay", 3); |
|
106 |
m_settings.endGroup(); |
m_settings.endGroup(); // Options group. |
107 |
|
|
108 |
// Load display options... |
// Recent file list. |
109 |
m_settings.beginGroup("/Display"); |
recentFiles.clear(); |
110 |
sDisplayFont = m_settings.readEntry("/DisplayFont", QString::null); |
m_settings.beginGroup("/RecentFiles"); |
111 |
bDisplayEffect = m_settings.readBoolEntry("/DisplayEffect", true); |
for (int iFile = 0; iFile < iMaxRecentFiles; iFile++) { |
112 |
bAutoRefresh = m_settings.readBoolEntry("/AutoRefresh", true); |
QString sFilename = m_settings.value( |
113 |
iAutoRefreshTime = m_settings.readNumEntry("/AutoRefreshTime", 1000); |
"/File" + QString::number(iFile + 1)).toString(); |
114 |
iMaxVolume = m_settings.readNumEntry("/MaxVolume", 100); |
if (!sFilename.isEmpty()) |
115 |
sMessagesFont = m_settings.readEntry("/MessagesFont", QString::null); |
recentFiles.append(sFilename); |
116 |
bMessagesLimit = m_settings.readBoolEntry("/MessagesLimit", true); |
} |
117 |
iMessagesLimitLines = m_settings.readNumEntry("/MessagesLimitLines", 1000); |
m_settings.endGroup(); |
118 |
bConfirmRemove = m_settings.readBoolEntry("/ConfirmRemove", true); |
|
119 |
bKeepOnTop = m_settings.readBoolEntry("/KeepOnTop", true); |
// Last but not least, get the default directories. |
120 |
bStdoutCapture = m_settings.readBoolEntry("/StdoutCapture", true); |
m_settings.beginGroup("/Default"); |
121 |
bCompletePath = m_settings.readBoolEntry("/CompletePath", true); |
sSessionDir = m_settings.value("/SessionDir").toString(); |
122 |
iMaxRecentFiles = m_settings.readNumEntry("/MaxRecentFiles", 5); |
sInstrumentDir = m_settings.value("/InstrumentDir").toString(); |
123 |
bInstrumentNames = m_settings.readBoolEntry("/InstrumentNames", false); |
sEngineName = m_settings.value("/EngineName").toString(); |
124 |
m_settings.endGroup(); |
sAudioDriver = m_settings.value("/AudioDriver").toString(); |
125 |
|
sMidiDriver = m_settings.value("/MidiDriver").toString(); |
126 |
// And go into view options group. |
iMidiMap = m_settings.value("/MidiMap", 0).toInt(); |
127 |
m_settings.beginGroup("/View"); |
iMidiBank = m_settings.value("/MidiBank", 0).toInt(); |
128 |
bMenubar = m_settings.readBoolEntry("/Menubar", true); |
iMidiProg = m_settings.value("/MidiProg", 0).toInt(); |
129 |
bToolbar = m_settings.readBoolEntry("/Toolbar", true); |
iVolume = m_settings.value("/Volume", 100).toInt(); |
130 |
bStatusbar = m_settings.readBoolEntry("/Statusbar", true); |
iLoadMode = m_settings.value("/Loadmode", 0).toInt(); |
131 |
bAutoArrange = m_settings.readBoolEntry("/AutoArrange", true); |
m_settings.endGroup(); |
|
m_settings.endGroup(); |
|
|
|
|
|
m_settings.endGroup(); // Options group. |
|
|
|
|
|
// Recent file list. |
|
|
m_settings.beginGroup("/RecentFiles"); |
|
|
recentFiles.clear(); |
|
|
for (int i = 0; i < iMaxRecentFiles; i++) { |
|
|
QString sFilename = m_settings.readEntry("/File" + QString::number(i + 1), QString::null); |
|
|
if (!sFilename.isEmpty()) |
|
|
recentFiles.append(sFilename); |
|
|
} |
|
|
m_settings.endGroup(); |
|
|
|
|
|
// Last but not least, get the default directories. |
|
|
m_settings.beginGroup("/Default"); |
|
|
sSessionDir = m_settings.readEntry("/SessionDir", QString::null); |
|
|
sInstrumentDir = m_settings.readEntry("/InstrumentDir", QString::null); |
|
|
sEngineName = m_settings.readEntry("/EngineName", QString::null); |
|
|
sAudioDriver = m_settings.readEntry("/AudioDriver", QString::null); |
|
|
sMidiDriver = m_settings.readEntry("/MidiDriver", QString::null); |
|
|
iMidiMap = m_settings.readNumEntry("/MidiMap", 0); |
|
|
iMidiBank = m_settings.readNumEntry("/MidiBank", 0); |
|
|
iMidiProg = m_settings.readNumEntry("/MidiProg", 0); |
|
|
iVolume = m_settings.readNumEntry("/Volume", 100); |
|
|
iLoadMode = m_settings.readNumEntry("/Loadmode", 0); |
|
|
m_settings.endGroup(); |
|
132 |
} |
} |
133 |
|
|
134 |
|
|
135 |
// Default Destructor. |
// Default Destructor. |
136 |
qsamplerOptions::~qsamplerOptions (void) |
Options::~Options (void) |
137 |
{ |
{ |
138 |
// Make program version available in the future. |
// Make program version available in the future. |
139 |
m_settings.beginGroup("/Program"); |
m_settings.beginGroup("/Program"); |
140 |
m_settings.writeEntry("/Version", QSAMPLER_VERSION); |
m_settings.setValue("/Version", QSAMPLER_VERSION); |
141 |
m_settings.endGroup(); |
m_settings.endGroup(); |
142 |
|
|
143 |
// And go into general options group. |
// And go into general options group. |
144 |
m_settings.beginGroup("/Options"); |
m_settings.beginGroup("/Options"); |
145 |
|
|
146 |
// Save server options. |
// Save server options. |
147 |
m_settings.beginGroup("/Server"); |
m_settings.beginGroup("/Server"); |
148 |
m_settings.writeEntry("/ServerHost", sServerHost); |
m_settings.setValue("/ServerHost", sServerHost); |
149 |
m_settings.writeEntry("/ServerPort", iServerPort); |
m_settings.setValue("/ServerPort", iServerPort); |
150 |
m_settings.writeEntry("/ServerTimeout", iServerTimeout); |
m_settings.setValue("/ServerTimeout", iServerTimeout); |
151 |
m_settings.writeEntry("/ServerStart", bServerStart); |
m_settings.setValue("/ServerStart", bServerStart); |
152 |
m_settings.writeEntry("/ServerCmdLine", sServerCmdLine); |
m_settings.setValue("/ServerCmdLine", sServerCmdLine); |
153 |
m_settings.writeEntry("/StartDelay", iStartDelay); |
m_settings.setValue("/StartDelay", iStartDelay); |
154 |
m_settings.endGroup(); |
m_settings.endGroup(); |
155 |
|
|
156 |
// Save display options. |
// Save logging options... |
157 |
m_settings.beginGroup("/Display"); |
m_settings.beginGroup("/Logging"); |
158 |
m_settings.writeEntry("/DisplayFont", sDisplayFont); |
m_settings.setValue("/MessagesLog", bMessagesLog); |
159 |
m_settings.writeEntry("/DisplayEffect", bDisplayEffect); |
m_settings.setValue("/MessagesLogPath", sMessagesLogPath); |
160 |
m_settings.writeEntry("/AutoRefresh", bAutoRefresh); |
m_settings.endGroup(); |
161 |
m_settings.writeEntry("/AutoRefreshTime", iAutoRefreshTime); |
|
162 |
m_settings.writeEntry("/MaxVolume", iMaxVolume); |
// Save display options. |
163 |
m_settings.writeEntry("/MessagesFont", sMessagesFont); |
m_settings.beginGroup("/Display"); |
164 |
m_settings.writeEntry("/MessagesLimit", bMessagesLimit); |
m_settings.setValue("/DisplayFont", sDisplayFont); |
165 |
m_settings.writeEntry("/MessagesLimitLines", iMessagesLimitLines); |
m_settings.setValue("/DisplayEffect", bDisplayEffect); |
166 |
m_settings.writeEntry("/ConfirmRemove", bConfirmRemove); |
m_settings.setValue("/AutoRefresh", bAutoRefresh); |
167 |
m_settings.writeEntry("/KeepOnTop", bKeepOnTop); |
m_settings.setValue("/AutoRefreshTime", iAutoRefreshTime); |
168 |
m_settings.writeEntry("/StdoutCapture", bStdoutCapture); |
m_settings.setValue("/MaxVolume", iMaxVolume); |
169 |
m_settings.writeEntry("/CompletePath", bCompletePath); |
m_settings.setValue("/MessagesFont", sMessagesFont); |
170 |
m_settings.writeEntry("/MaxRecentFiles", iMaxRecentFiles); |
m_settings.setValue("/MessagesLimit", bMessagesLimit); |
171 |
m_settings.writeEntry("/InstrumentNames", bInstrumentNames); |
m_settings.setValue("/MessagesLimitLines", iMessagesLimitLines); |
172 |
m_settings.endGroup(); |
m_settings.setValue("/ConfirmRemove", bConfirmRemove); |
173 |
|
m_settings.setValue("/KeepOnTop", bKeepOnTop); |
174 |
// View options group. |
m_settings.setValue("/StdoutCapture", bStdoutCapture); |
175 |
m_settings.beginGroup("/View"); |
m_settings.setValue("/CompletePath", bCompletePath); |
176 |
m_settings.writeEntry("/Menubar", bMenubar); |
m_settings.setValue("/MaxRecentFiles", iMaxRecentFiles); |
177 |
m_settings.writeEntry("/Toolbar", bToolbar); |
m_settings.setValue("/InstrumentNames", bInstrumentNames); |
178 |
m_settings.writeEntry("/Statusbar", bStatusbar); |
m_settings.endGroup(); |
179 |
m_settings.writeEntry("/AutoArrange", bAutoArrange); |
|
180 |
m_settings.endGroup(); |
// View options group. |
181 |
|
m_settings.beginGroup("/View"); |
182 |
m_settings.endGroup(); // Options group. |
m_settings.setValue("/Menubar", bMenubar); |
183 |
|
m_settings.setValue("/Toolbar", bToolbar); |
184 |
// Recent file list. |
m_settings.setValue("/Statusbar", bStatusbar); |
185 |
m_settings.beginGroup("/RecentFiles"); |
m_settings.setValue("/AutoArrange", bAutoArrange); |
186 |
for (int i = 0; i < (int) recentFiles.count(); i++) |
m_settings.endGroup(); |
187 |
m_settings.writeEntry("/File" + QString::number(i + 1), recentFiles[i]); |
|
188 |
m_settings.endGroup(); |
m_settings.endGroup(); // Options group. |
189 |
|
|
190 |
// Default directories. |
// Recent file list. |
191 |
m_settings.beginGroup("/Default"); |
int iFile = 0; |
192 |
m_settings.writeEntry("/SessionDir", sSessionDir); |
m_settings.beginGroup("/RecentFiles"); |
193 |
m_settings.writeEntry("/InstrumentDir", sInstrumentDir); |
QStringListIterator iter(recentFiles); |
194 |
m_settings.writeEntry("/EngineName", sEngineName); |
while (iter.hasNext()) |
195 |
m_settings.writeEntry("/AudioDriver", sAudioDriver); |
m_settings.setValue("/File" + QString::number(++iFile), iter.next()); |
196 |
m_settings.writeEntry("/MidiDriver", sMidiDriver); |
m_settings.endGroup(); |
197 |
m_settings.writeEntry("/MidiMap", iMidiMap); |
|
198 |
m_settings.writeEntry("/MidiBank", iMidiBank); |
// Default directories. |
199 |
m_settings.writeEntry("/MidiProg", iMidiProg); |
m_settings.beginGroup("/Default"); |
200 |
m_settings.writeEntry("/Volume", iVolume); |
m_settings.setValue("/SessionDir", sSessionDir); |
201 |
m_settings.writeEntry("/Loadmode", iLoadMode); |
m_settings.setValue("/InstrumentDir", sInstrumentDir); |
202 |
m_settings.endGroup(); |
m_settings.setValue("/EngineName", sEngineName); |
203 |
|
m_settings.setValue("/AudioDriver", sAudioDriver); |
204 |
m_settings.endGroup(); |
m_settings.setValue("/MidiDriver", sMidiDriver); |
205 |
|
m_settings.setValue("/MidiMap", iMidiMap); |
206 |
|
m_settings.setValue("/MidiBank", iMidiBank); |
207 |
|
m_settings.setValue("/MidiProg", iMidiProg); |
208 |
|
m_settings.setValue("/Volume", iVolume); |
209 |
|
m_settings.setValue("/Loadmode", iLoadMode); |
210 |
|
m_settings.endGroup(); |
211 |
} |
} |
212 |
|
|
213 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
214 |
// Settings accessor. |
// Settings accessor. |
215 |
// |
// |
216 |
|
|
217 |
QSettings& qsamplerOptions::settings (void) |
QSettings& Options::settings (void) |
218 |
{ |
{ |
219 |
return m_settings; |
return m_settings; |
220 |
} |
} |
221 |
|
|
222 |
|
|
225 |
// |
// |
226 |
|
|
227 |
// Help about command line options. |
// Help about command line options. |
228 |
void qsamplerOptions::print_usage ( const char *arg0 ) |
void Options::print_usage ( const char *arg0 ) |
229 |
{ |
{ |
230 |
const QString sEot = "\n\t"; |
QTextStream out(stderr); |
231 |
const QString sEol = "\n\n"; |
out << QObject::tr("Usage: %1 [options] [session-file]\n\n" |
232 |
|
QSAMPLER_TITLE " - " QSAMPLER_SUBTITLE "\n\n" |
233 |
fprintf(stderr, QObject::tr("Usage") + ": %s [" + QObject::tr("options") + "] [" + |
"Options:\n\n" |
234 |
QObject::tr("session-file") + "]" + sEol, arg0); |
" -s, --start\n\tStart linuxsampler server locally\n\n" |
235 |
fprintf(stderr, QSAMPLER_TITLE " - " + QObject::tr(QSAMPLER_SUBTITLE) + sEol); |
" -h, --hostname\n\tSpecify linuxsampler server hostname\n\n" |
236 |
fprintf(stderr, QObject::tr("Options") + ":" + sEol); |
" -p, --port\n\tSpecify linuxsampler server port number\n\n" |
237 |
fprintf(stderr, " -s, --start" + sEot + |
" -?, --help\n\tShow help about command line options\n\n" |
238 |
QObject::tr("Start linuxsampler server locally") + sEol); |
" -v, --version\n\tShow version information\n\n") |
239 |
fprintf(stderr, " -h, --hostname" + sEot + |
.arg(arg0); |
|
QObject::tr("Specify linuxsampler server hostname") + sEol); |
|
|
fprintf(stderr, " -p, --port" + sEot + |
|
|
QObject::tr("Specify linuxsampler server port number") + sEol); |
|
|
fprintf(stderr, " -?, --help" + sEot + |
|
|
QObject::tr("Show help about command line options") + sEol); |
|
|
fprintf(stderr, " -v, --version" + sEot + |
|
|
QObject::tr("Show version information") + sEol); |
|
240 |
} |
} |
241 |
|
|
242 |
|
|
243 |
// Parse command line arguments into m_settings. |
// Parse command line arguments into m_settings. |
244 |
bool qsamplerOptions::parse_args ( int argc, char **argv ) |
bool Options::parse_args ( int argc, char **argv ) |
245 |
{ |
{ |
246 |
const QString sEol = "\n\n"; |
QTextStream out(stderr); |
247 |
int iCmdArgs = 0; |
const QString sEol = "\n\n"; |
248 |
|
int iCmdArgs = 0; |
249 |
for (int i = 1; i < argc; i++) { |
|
250 |
|
for (int i = 1; i < argc; i++) { |
251 |
if (iCmdArgs > 0) { |
|
252 |
sSessionFile += " "; |
if (iCmdArgs > 0) { |
253 |
sSessionFile += argv[i]; |
sSessionFile += " "; |
254 |
iCmdArgs++; |
sSessionFile += argv[i]; |
255 |
continue; |
iCmdArgs++; |
256 |
} |
continue; |
257 |
|
} |
258 |
QString sArg = argv[i]; |
|
259 |
QString sVal = QString::null; |
QString sArg = argv[i]; |
260 |
int iEqual = sArg.find("="); |
QString sVal = QString::null; |
261 |
if (iEqual >= 0) { |
int iEqual = sArg.indexOf("="); |
262 |
sVal = sArg.right(sArg.length() - iEqual - 1); |
if (iEqual >= 0) { |
263 |
sArg = sArg.left(iEqual); |
sVal = sArg.right(sArg.length() - iEqual - 1); |
264 |
} |
sArg = sArg.left(iEqual); |
265 |
else if (i < argc) |
} |
266 |
sVal = argv[i + 1]; |
else if (i < argc) |
267 |
|
sVal = argv[i + 1]; |
268 |
if (sArg == "-s" || sArg == "--start") { |
|
269 |
bServerStart = true; |
if (sArg == "-s" || sArg == "--start") { |
270 |
} |
bServerStart = true; |
271 |
else if (sArg == "-h" || sArg == "--hostname") { |
} |
272 |
if (sVal.isNull()) { |
else if (sArg == "-h" || sArg == "--hostname") { |
273 |
fprintf(stderr, QObject::tr("Option -h requires an argument (hostname).") + sEol); |
if (sVal.isNull()) { |
274 |
return false; |
out << QObject::tr("Option -h requires an argument (hostname).") + sEol; |
275 |
} |
return false; |
276 |
sServerHost = sVal; |
} |
277 |
if (iEqual < 0) |
sServerHost = sVal; |
278 |
i++; |
if (iEqual < 0) |
279 |
} |
i++; |
280 |
else if (sArg == "-p" || sArg == "--port") { |
} |
281 |
if (sVal.isNull()) { |
else if (sArg == "-p" || sArg == "--port") { |
282 |
fprintf(stderr, QObject::tr("Option -p requires an argument (port).") + sEol); |
if (sVal.isNull()) { |
283 |
return false; |
out << QObject::tr("Option -p requires an argument (port).") + sEol; |
284 |
} |
return false; |
285 |
iServerPort = sVal.toInt(); |
} |
286 |
if (iEqual < 0) |
iServerPort = sVal.toInt(); |
287 |
i++; |
if (iEqual < 0) |
288 |
} |
i++; |
289 |
else if (sArg == "-?" || sArg == "--help") { |
} |
290 |
print_usage(argv[0]); |
else if (sArg == "-?" || sArg == "--help") { |
291 |
return false; |
print_usage(argv[0]); |
292 |
} |
return false; |
293 |
else if (sArg == "-v" || sArg == "--version") { |
} |
294 |
fprintf(stderr, "Qt: %s\n", qVersion()); |
else if (sArg == "-v" || sArg == "--version") { |
295 |
|
out << QObject::tr("Qt: %1\n").arg(qVersion()); |
296 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
297 |
fprintf(stderr, "%s: %s\n", gig::libraryName().c_str(), gig::libraryVersion().c_str()); |
out << QString("%1: %2\n") |
298 |
#endif |
.arg(gig::libraryName().c_str()) |
299 |
fprintf(stderr, "%s: %s\n", ::lscp_client_package(), ::lscp_client_version()); |
.arg(gig::libraryVersion().c_str()); |
300 |
fprintf(stderr, "qsampler: %s\n", QSAMPLER_VERSION); |
#endif |
301 |
return false; |
out << QString("%1: %2\n") |
302 |
} |
.arg(::lscp_client_package()) |
303 |
else { |
.arg(::lscp_client_version()); |
304 |
// If we don't have one by now, |
out << QObject::tr(QSAMPLER_TITLE ": %1\n").arg(QSAMPLER_VERSION); |
305 |
// this will be the startup sesion file... |
return false; |
306 |
sSessionFile += sArg; |
} |
307 |
iCmdArgs++; |
else { |
308 |
} |
// If we don't have one by now, |
309 |
} |
// this will be the startup sesion file... |
310 |
|
sSessionFile += sArg; |
311 |
|
iCmdArgs++; |
312 |
|
} |
313 |
|
} |
314 |
|
|
315 |
// Alright with argument parsing. |
// Alright with argument parsing. |
316 |
return true; |
return true; |
317 |
} |
} |
318 |
|
|
319 |
|
|
320 |
//--------------------------------------------------------------------------- |
//--------------------------------------------------------------------------- |
321 |
// Widget geometry persistence helper methods. |
// Widget geometry persistence helper methods. |
322 |
|
|
323 |
void qsamplerOptions::loadWidgetGeometry ( QWidget *pWidget ) |
void Options::loadWidgetGeometry ( QWidget *pWidget ) |
324 |
{ |
{ |
325 |
// Try to restore old form window positioning. |
// Try to restore old form window positioning. |
326 |
if (pWidget) { |
if (pWidget) { |
327 |
QPoint fpos; |
QPoint fpos; |
328 |
QSize fsize; |
QSize fsize; |
329 |
bool bVisible; |
bool bVisible; |
330 |
m_settings.beginGroup("/Geometry/" + QString(pWidget->name())); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
331 |
fpos.setX(m_settings.readNumEntry("/x", -1)); |
fpos.setX(m_settings.value("/x", -1).toInt()); |
332 |
fpos.setY(m_settings.readNumEntry("/y", -1)); |
fpos.setY(m_settings.value("/y", -1).toInt()); |
333 |
fsize.setWidth(m_settings.readNumEntry("/width", -1)); |
fsize.setWidth(m_settings.value("/width", -1).toInt()); |
334 |
fsize.setHeight(m_settings.readNumEntry("/height", -1)); |
fsize.setHeight(m_settings.value("/height", -1).toInt()); |
335 |
bVisible = m_settings.readBoolEntry("/visible", false); |
bVisible = m_settings.value("/visible", false).toBool(); |
336 |
m_settings.endGroup(); |
m_settings.endGroup(); |
337 |
if (fpos.x() > 0 && fpos.y() > 0) |
if (fpos.x() > 0 && fpos.y() > 0) |
338 |
pWidget->move(fpos); |
pWidget->move(fpos); |
339 |
if (fsize.width() > 0 && fsize.height() > 0) |
if (fsize.width() > 0 && fsize.height() > 0) |
340 |
pWidget->resize(fsize); |
pWidget->resize(fsize); |
341 |
else |
else |
342 |
pWidget->adjustSize(); |
pWidget->adjustSize(); |
343 |
if (bVisible) |
if (bVisible) |
344 |
pWidget->show(); |
pWidget->show(); |
345 |
else |
else |
346 |
pWidget->hide(); |
pWidget->hide(); |
347 |
} |
} |
348 |
} |
} |
349 |
|
|
350 |
|
|
351 |
void qsamplerOptions::saveWidgetGeometry ( QWidget *pWidget ) |
void Options::saveWidgetGeometry ( QWidget *pWidget ) |
352 |
{ |
{ |
353 |
// Try to save form window position... |
// Try to save form window position... |
354 |
// (due to X11 window managers ideossincrasies, we better |
// (due to X11 window managers ideossincrasies, we better |
355 |
// only save the form geometry while its up and visible) |
// only save the form geometry while its up and visible) |
356 |
if (pWidget) { |
if (pWidget) { |
357 |
m_settings.beginGroup("/Geometry/" + QString(pWidget->name())); |
m_settings.beginGroup("/Geometry/" + pWidget->objectName()); |
358 |
bool bVisible = pWidget->isVisible(); |
bool bVisible = pWidget->isVisible(); |
359 |
if (bVisible) { |
const QPoint& fpos = pWidget->pos(); |
360 |
QPoint fpos = pWidget->pos(); |
const QSize& fsize = pWidget->size(); |
361 |
QSize fsize = pWidget->size(); |
m_settings.setValue("/x", fpos.x()); |
362 |
m_settings.writeEntry("/x", fpos.x()); |
m_settings.setValue("/y", fpos.y()); |
363 |
m_settings.writeEntry("/y", fpos.y()); |
m_settings.setValue("/width", fsize.width()); |
364 |
m_settings.writeEntry("/width", fsize.width()); |
m_settings.setValue("/height", fsize.height()); |
365 |
m_settings.writeEntry("/height", fsize.height()); |
m_settings.setValue("/visible", bVisible); |
366 |
} |
m_settings.endGroup(); |
367 |
m_settings.writeEntry("/visible", bVisible); |
} |
|
m_settings.endGroup(); |
|
|
} |
|
368 |
} |
} |
369 |
|
|
370 |
|
|
371 |
//--------------------------------------------------------------------------- |
//--------------------------------------------------------------------------- |
372 |
// Combo box history persistence helper implementation. |
// Combo box history persistence helper implementation. |
373 |
|
|
374 |
void qsamplerOptions::add2ComboBoxHistory ( QComboBox *pComboBox, const QString& sNewText, int iLimit, int iIndex ) |
void Options::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
375 |
{ |
{ |
376 |
int iCount = pComboBox->count(); |
// Load combobox list from configuration settings file... |
377 |
for (int i = 0; i < iCount; i++) { |
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
|
QString sText = pComboBox->text(i); |
|
|
if (sText == sNewText) { |
|
|
pComboBox->removeItem(i); |
|
|
iCount--; |
|
|
break; |
|
|
} |
|
|
} |
|
|
while (iCount >= iLimit) |
|
|
pComboBox->removeItem(--iCount); |
|
|
pComboBox->insertItem(sNewText, iIndex); |
|
|
} |
|
|
|
|
|
|
|
|
void qsamplerOptions::loadComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
|
|
{ |
|
|
pComboBox->setUpdatesEnabled(false); |
|
|
pComboBox->setDuplicatesEnabled(false); |
|
378 |
|
|
379 |
m_settings.beginGroup("/History/" + QString(pComboBox->name())); |
if (m_settings.childKeys().count() > 0) { |
380 |
for (int i = 0; i < iLimit; i++) { |
pComboBox->setUpdatesEnabled(false); |
381 |
QString sText = m_settings.readEntry("/Item" + QString::number(i + 1), QString::null); |
pComboBox->setDuplicatesEnabled(false); |
382 |
if (sText.isEmpty()) |
pComboBox->clear(); |
383 |
break; |
for (int i = 0; i < iLimit; i++) { |
384 |
add2ComboBoxHistory(pComboBox, sText, iLimit); |
const QString& sText = m_settings.value( |
385 |
} |
"/Item" + QString::number(i + 1)).toString(); |
386 |
m_settings.endGroup(); |
if (sText.isEmpty()) |
387 |
|
break; |
388 |
|
pComboBox->addItem(sText); |
389 |
|
} |
390 |
|
pComboBox->setUpdatesEnabled(true); |
391 |
|
} |
392 |
|
|
393 |
pComboBox->setUpdatesEnabled(true); |
m_settings.endGroup(); |
394 |
} |
} |
395 |
|
|
396 |
|
|
397 |
void qsamplerOptions::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
void Options::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit ) |
398 |
{ |
{ |
399 |
add2ComboBoxHistory(pComboBox, pComboBox->currentText(), iLimit, 0); |
// Add current text as latest item... |
400 |
|
const QString& sCurrentText = pComboBox->currentText(); |
401 |
m_settings.beginGroup("/History/" + QString(pComboBox->name())); |
int iCount = pComboBox->count(); |
402 |
for (int i = 0; i < iLimit && i < pComboBox->count(); i++) { |
for (int i = 0; i < iCount; i++) { |
403 |
QString sText = pComboBox->text(i); |
const QString& sText = pComboBox->itemText(i); |
404 |
if (sText.isEmpty()) |
if (sText == sCurrentText) { |
405 |
break; |
pComboBox->removeItem(i); |
406 |
m_settings.writeEntry("/Item" + QString::number(i + 1), sText); |
iCount--; |
407 |
} |
break; |
408 |
m_settings.endGroup(); |
} |
409 |
|
} |
410 |
|
while (iCount >= iLimit) |
411 |
|
pComboBox->removeItem(--iCount); |
412 |
|
pComboBox->insertItem(0, sCurrentText); |
413 |
|
iCount++; |
414 |
|
|
415 |
|
// Save combobox list to configuration settings file... |
416 |
|
m_settings.beginGroup("/History/" + pComboBox->objectName()); |
417 |
|
for (int i = 0; i < iCount; i++) { |
418 |
|
const QString& sText = pComboBox->itemText(i); |
419 |
|
if (sText.isEmpty()) |
420 |
|
break; |
421 |
|
m_settings.setValue("/Item" + QString::number(i + 1), sText); |
422 |
|
} |
423 |
|
m_settings.endGroup(); |
424 |
} |
} |
425 |
|
|
426 |
|
} // namespace QSampler |
427 |
|
|
428 |
|
|
429 |
// end of qsamplerOptions.cpp |
// end of qsamplerOptions.cpp |