1 |
// qsamplerMainForm.cpp |
// qsamplerMainForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2020, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2021, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007-2019 Christian Schoenebeck |
Copyright (C) 2007-2019 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 |
35 |
#include "qsamplerOptionsForm.h" |
#include "qsamplerOptionsForm.h" |
36 |
#include "qsamplerDeviceStatusForm.h" |
#include "qsamplerDeviceStatusForm.h" |
37 |
|
|
38 |
|
#include "qsamplerPaletteForm.h" |
39 |
|
|
40 |
|
#include <QStyleFactory> |
41 |
|
|
42 |
#include <QMdiArea> |
#include <QMdiArea> |
43 |
#include <QMdiSubWindow> |
#include <QMdiSubWindow> |
44 |
|
|
46 |
#include <QProcess> |
#include <QProcess> |
47 |
#include <QMessageBox> |
#include <QMessageBox> |
48 |
|
|
|
#include <QRegExp> |
|
49 |
#include <QTextStream> |
#include <QTextStream> |
50 |
#include <QFileDialog> |
#include <QFileDialog> |
51 |
#include <QFileInfo> |
#include <QFileInfo> |
74 |
#endif |
#endif |
75 |
|
|
76 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
77 |
|
#if defined(Q_CC_GNU) || defined(Q_CC_MINGW) |
78 |
|
#pragma GCC diagnostic push |
79 |
|
#pragma GCC diagnostic ignored "-Wunused-parameter" |
80 |
|
#endif |
81 |
#include <gig.h> |
#include <gig.h> |
82 |
|
#if defined(Q_CC_GNU) || defined(Q_CC_MINGW) |
83 |
|
#pragma GCC diagnostic pop |
84 |
|
#endif |
85 |
#endif |
#endif |
86 |
|
|
87 |
// Needed for lroundf() |
// Deprecated QTextStreamFunctions/Qt namespaces workaround. |
88 |
#include <math.h> |
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) |
89 |
|
#define endl Qt::endl |
90 |
|
#endif |
91 |
|
|
92 |
#ifndef CONFIG_ROUND |
// Needed for lroundf() |
93 |
|
#ifdef CONFIG_ROUND |
94 |
|
#include <cmath> |
95 |
|
#else |
96 |
static inline long lroundf ( float x ) |
static inline long lroundf ( float x ) |
97 |
{ |
{ |
98 |
if (x >= 0.0f) |
if (x >= 0.0f) |
1106 |
// Write the file. |
// Write the file. |
1107 |
int iErrors = 0; |
int iErrors = 0; |
1108 |
QTextStream ts(&file); |
QTextStream ts(&file); |
1109 |
ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << Qt::endl; |
ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl; |
1110 |
ts << "# " << tr("Version") << ": " CONFIG_BUILD_VERSION << Qt::endl; |
ts << "# " << tr("Version") << ": " CONFIG_BUILD_VERSION << endl; |
1111 |
// ts << "# " << tr("Build") << ": " CONFIG_BUILD_DATE << Qt::endl; |
// ts << "# " << tr("Build") << ": " CONFIG_BUILD_DATE << endl; |
1112 |
ts << "#" << Qt::endl; |
ts << "#" << endl; |
1113 |
ts << "# " << tr("File") |
ts << "# " << tr("File") |
1114 |
<< ": " << QFileInfo(sFilename).fileName() << Qt::endl; |
<< ": " << QFileInfo(sFilename).fileName() << endl; |
1115 |
ts << "# " << tr("Date") |
ts << "# " << tr("Date") |
1116 |
<< ": " << QDate::currentDate().toString("MMM dd yyyy") |
<< ": " << QDate::currentDate().toString("MMM dd yyyy") |
1117 |
<< " " << QTime::currentTime().toString("hh:mm:ss") << Qt::endl; |
<< " " << QTime::currentTime().toString("hh:mm:ss") << endl; |
1118 |
ts << "#" << Qt::endl; |
ts << "#" << endl; |
1119 |
ts << Qt::endl; |
ts << endl; |
1120 |
|
|
1121 |
// It is assumed that this new kind of device+session file |
// It is assumed that this new kind of device+session file |
1122 |
// will be loaded from a complete initialized server... |
// will be loaded from a complete initialized server... |
1123 |
int *piDeviceIDs; |
int *piDeviceIDs; |
1124 |
int i, iDevice; |
int i, iDevice; |
1125 |
ts << "RESET" << Qt::endl; |
ts << "RESET" << endl; |
1126 |
|
|
1127 |
// Audio device mapping. |
// Audio device mapping. |
1128 |
QMap<int, int> audioDeviceMap; iDevice = 0; |
QMap<int, int> audioDeviceMap; iDevice = 0; |
1133 |
if (device.driverName().toUpper() == "PLUGIN") |
if (device.driverName().toUpper() == "PLUGIN") |
1134 |
continue; |
continue; |
1135 |
// Audio device specification... |
// Audio device specification... |
1136 |
ts << Qt::endl; |
ts << endl; |
1137 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
1138 |
<< " " << tr("Device") << " " << iDevice << Qt::endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
1139 |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
1140 |
DeviceParamMap::ConstIterator deviceParam; |
DeviceParamMap::ConstIterator deviceParam; |
1141 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
1145 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
1146 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
1147 |
} |
} |
1148 |
ts << Qt::endl; |
ts << endl; |
1149 |
// Audio channel parameters... |
// Audio channel parameters... |
1150 |
int iPort = 0; |
int iPort = 0; |
1151 |
QListIterator<DevicePort *> iter(device.ports()); |
QListIterator<DevicePort *> iter(device.ports()); |
1159 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
1160 |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
1161 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
1162 |
<< "='" << param.value << "'" << Qt::endl; |
<< "='" << param.value << "'" << endl; |
1163 |
} |
} |
1164 |
iPort++; |
iPort++; |
1165 |
} |
} |
1178 |
if (device.driverName().toUpper() == "PLUGIN") |
if (device.driverName().toUpper() == "PLUGIN") |
1179 |
continue; |
continue; |
1180 |
// MIDI device specification... |
// MIDI device specification... |
1181 |
ts << Qt::endl; |
ts << endl; |
1182 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
1183 |
<< " " << tr("Device") << " " << iDevice << Qt::endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
1184 |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
1185 |
DeviceParamMap::ConstIterator deviceParam; |
DeviceParamMap::ConstIterator deviceParam; |
1186 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
1190 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
1191 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
1192 |
} |
} |
1193 |
ts << Qt::endl; |
ts << endl; |
1194 |
// MIDI port parameters... |
// MIDI port parameters... |
1195 |
int iPort = 0; |
int iPort = 0; |
1196 |
QListIterator<DevicePort *> iter(device.ports()); |
QListIterator<DevicePort *> iter(device.ports()); |
1204 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
1205 |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
1206 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
1207 |
<< "='" << param.value << "'" << Qt::endl; |
<< "='" << param.value << "'" << endl; |
1208 |
} |
} |
1209 |
iPort++; |
iPort++; |
1210 |
} |
} |
1213 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
1214 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
1215 |
} |
} |
1216 |
ts << Qt::endl; |
ts << endl; |
1217 |
|
|
1218 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
1219 |
// MIDI instrument mapping... |
// MIDI instrument mapping... |
1226 |
ts << "# " << tr("MIDI instrument map") << " " << iMap; |
ts << "# " << tr("MIDI instrument map") << " " << iMap; |
1227 |
if (pszMapName) |
if (pszMapName) |
1228 |
ts << " - " << pszMapName; |
ts << " - " << pszMapName; |
1229 |
ts << Qt::endl; |
ts << endl; |
1230 |
ts << "ADD MIDI_INSTRUMENT_MAP"; |
ts << "ADD MIDI_INSTRUMENT_MAP"; |
1231 |
if (pszMapName) |
if (pszMapName) |
1232 |
ts << " '" << pszMapName << "'"; |
ts << " '" << pszMapName << "'"; |
1233 |
ts << Qt::endl; |
ts << endl; |
1234 |
// MIDI instrument mapping... |
// MIDI instrument mapping... |
1235 |
lscp_midi_instrument_t *pInstrs |
lscp_midi_instrument_t *pInstrs |
1236 |
= ::lscp_list_midi_instruments(m_pClient, iMidiMap); |
= ::lscp_list_midi_instruments(m_pClient, iMidiMap); |
1261 |
} |
} |
1262 |
if (pInstrInfo->name) |
if (pInstrInfo->name) |
1263 |
ts << " '" << pInstrInfo->name << "'"; |
ts << " '" << pInstrInfo->name << "'"; |
1264 |
ts << Qt::endl; |
ts << endl; |
1265 |
} // Check for errors... |
} // Check for errors... |
1266 |
else if (::lscp_client_get_errno(m_pClient)) { |
else if (::lscp_client_get_errno(m_pClient)) { |
1267 |
appendMessagesClient("lscp_get_midi_instrument_info"); |
appendMessagesClient("lscp_get_midi_instrument_info"); |
1270 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
1271 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
1272 |
} |
} |
1273 |
ts << Qt::endl; |
ts << endl; |
1274 |
// Check for errors... |
// Check for errors... |
1275 |
if (pInstrs == nullptr && ::lscp_client_get_errno(m_pClient)) { |
if (pInstrs == nullptr && ::lscp_client_get_errno(m_pClient)) { |
1276 |
appendMessagesClient("lscp_list_midi_instruments"); |
appendMessagesClient("lscp_list_midi_instruments"); |
1304 |
if (!midiDeviceMap.contains(iMidiDevice)) |
if (!midiDeviceMap.contains(iMidiDevice)) |
1305 |
continue; |
continue; |
1306 |
// Go for regular, canonical devices... |
// Go for regular, canonical devices... |
1307 |
ts << "# " << tr("Channel") << " " << iChannelID << Qt::endl; |
ts << "# " << tr("Channel") << " " << iChannelID << endl; |
1308 |
ts << "ADD CHANNEL" << Qt::endl; |
ts << "ADD CHANNEL" << endl; |
1309 |
if (audioDeviceMap.isEmpty()) { |
if (audioDeviceMap.isEmpty()) { |
1310 |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID |
1311 |
<< " " << pChannel->audioDriver() << Qt::endl; |
<< " " << pChannel->audioDriver() << endl; |
1312 |
} else { |
} else { |
1313 |
ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID |
ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID |
1314 |
<< " " << audioDeviceMap.value(iAudioDevice) << Qt::endl; |
<< " " << audioDeviceMap.value(iAudioDevice) << endl; |
1315 |
} |
} |
1316 |
if (midiDeviceMap.isEmpty()) { |
if (midiDeviceMap.isEmpty()) { |
1317 |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID |
1318 |
<< " " << pChannel->midiDriver() << Qt::endl; |
<< " " << pChannel->midiDriver() << endl; |
1319 |
} else { |
} else { |
1320 |
ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID |
ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID |
1321 |
<< " " << midiDeviceMap.value(iMidiDevice) << Qt::endl; |
<< " " << midiDeviceMap.value(iMidiDevice) << endl; |
1322 |
} |
} |
1323 |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID |
1324 |
<< " " << pChannel->midiPort() << Qt::endl; |
<< " " << pChannel->midiPort() << endl; |
1325 |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " "; |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " "; |
1326 |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
1327 |
ts << "ALL"; |
ts << "ALL"; |
1328 |
else |
else |
1329 |
ts << pChannel->midiChannel(); |
ts << pChannel->midiChannel(); |
1330 |
ts << Qt::endl; |
ts << endl; |
1331 |
ts << "LOAD ENGINE " << pChannel->engineName() |
ts << "LOAD ENGINE " << pChannel->engineName() |
1332 |
<< " " << iChannelID << Qt::endl; |
<< " " << iChannelID << endl; |
1333 |
if (pChannel->instrumentStatus() < 100) ts << "# "; |
if (pChannel->instrumentStatus() < 100) ts << "# "; |
1334 |
ts << "LOAD INSTRUMENT NON_MODAL '" |
ts << "LOAD INSTRUMENT NON_MODAL '" |
1335 |
<< pChannel->instrumentFile() << "' " |
<< pChannel->instrumentFile() << "' " |
1336 |
<< pChannel->instrumentNr() << " " << iChannelID << Qt::endl; |
<< pChannel->instrumentNr() << " " << iChannelID << endl; |
1337 |
ChannelRoutingMap::ConstIterator audioRoute; |
ChannelRoutingMap::ConstIterator audioRoute; |
1338 |
for (audioRoute = pChannel->audioRouting().begin(); |
for (audioRoute = pChannel->audioRouting().begin(); |
1339 |
audioRoute != pChannel->audioRouting().end(); |
audioRoute != pChannel->audioRouting().end(); |
1340 |
++audioRoute) { |
++audioRoute) { |
1341 |
ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannelID |
ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannelID |
1342 |
<< " " << audioRoute.key() |
<< " " << audioRoute.key() |
1343 |
<< " " << audioRoute.value() << Qt::endl; |
<< " " << audioRoute.value() << endl; |
1344 |
} |
} |
1345 |
ts << "SET CHANNEL VOLUME " << iChannelID |
ts << "SET CHANNEL VOLUME " << iChannelID |
1346 |
<< " " << pChannel->volume() << Qt::endl; |
<< " " << pChannel->volume() << endl; |
1347 |
if (pChannel->channelMute()) |
if (pChannel->channelMute()) |
1348 |
ts << "SET CHANNEL MUTE " << iChannelID << " 1" << Qt::endl; |
ts << "SET CHANNEL MUTE " << iChannelID << " 1" << endl; |
1349 |
if (pChannel->channelSolo()) |
if (pChannel->channelSolo()) |
1350 |
ts << "SET CHANNEL SOLO " << iChannelID << " 1" << Qt::endl; |
ts << "SET CHANNEL SOLO " << iChannelID << " 1" << endl; |
1351 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
1352 |
const int iMidiMap = pChannel->midiMap(); |
const int iMidiMap = pChannel->midiMap(); |
1353 |
if (midiInstrumentMap.contains(iMidiMap)) { |
if (midiInstrumentMap.contains(iMidiMap)) { |
1354 |
ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID |
ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID |
1355 |
<< " " << midiInstrumentMap.value(iMidiMap) << Qt::endl; |
<< " " << midiInstrumentMap.value(iMidiMap) << endl; |
1356 |
} |
} |
1357 |
#endif |
#endif |
1358 |
#ifdef CONFIG_FXSEND |
#ifdef CONFIG_FXSEND |
1367 |
<< " " << pFxSendInfo->midi_controller; |
<< " " << pFxSendInfo->midi_controller; |
1368 |
if (pFxSendInfo->name) |
if (pFxSendInfo->name) |
1369 |
ts << " '" << pFxSendInfo->name << "'"; |
ts << " '" << pFxSendInfo->name << "'"; |
1370 |
ts << Qt::endl; |
ts << endl; |
1371 |
int *piRouting = pFxSendInfo->audio_routing; |
int *piRouting = pFxSendInfo->audio_routing; |
1372 |
for (int iAudioSrc = 0; |
for (int iAudioSrc = 0; |
1373 |
piRouting && piRouting[iAudioSrc] >= 0; |
piRouting && piRouting[iAudioSrc] >= 0; |
1376 |
<< iChannelID |
<< iChannelID |
1377 |
<< " " << iFxSend |
<< " " << iFxSend |
1378 |
<< " " << iAudioSrc |
<< " " << iAudioSrc |
1379 |
<< " " << piRouting[iAudioSrc] << Qt::endl; |
<< " " << piRouting[iAudioSrc] << endl; |
1380 |
} |
} |
1381 |
#ifdef CONFIG_FXSEND_LEVEL |
#ifdef CONFIG_FXSEND_LEVEL |
1382 |
ts << "SET FX_SEND LEVEL " << iChannelID |
ts << "SET FX_SEND LEVEL " << iChannelID |
1383 |
<< " " << iFxSend |
<< " " << iFxSend |
1384 |
<< " " << pFxSendInfo->level << Qt::endl; |
<< " " << pFxSendInfo->level << endl; |
1385 |
#endif |
#endif |
1386 |
} // Check for errors... |
} // Check for errors... |
1387 |
else if (::lscp_client_get_errno(m_pClient)) { |
else if (::lscp_client_get_errno(m_pClient)) { |
1390 |
} |
} |
1391 |
} |
} |
1392 |
#endif |
#endif |
1393 |
ts << Qt::endl; |
ts << endl; |
1394 |
// Go for next channel... |
// Go for next channel... |
1395 |
++iChannelID; |
++iChannelID; |
1396 |
} |
} |
1400 |
} |
} |
1401 |
|
|
1402 |
#ifdef CONFIG_VOLUME |
#ifdef CONFIG_VOLUME |
1403 |
ts << "# " << tr("Global volume level") << Qt::endl; |
ts << "# " << tr("Global volume level") << endl; |
1404 |
ts << "SET VOLUME " << ::lscp_get_volume(m_pClient) << Qt::endl; |
ts << "SET VOLUME " << ::lscp_get_volume(m_pClient) << endl; |
1405 |
ts << Qt::endl; |
ts << endl; |
1406 |
#endif |
#endif |
1407 |
|
|
1408 |
// Ok. we've wrote it. |
// Ok. we've wrote it. |
1883 |
if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages) |
if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages) |
1884 |
m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString(); |
m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString(); |
1885 |
// To track down deferred or immediate changes. |
// To track down deferred or immediate changes. |
1886 |
const QString sOldServerHost = m_pOptions->sServerHost; |
const QString sOldServerHost = m_pOptions->sServerHost; |
1887 |
const int iOldServerPort = m_pOptions->iServerPort; |
const int iOldServerPort = m_pOptions->iServerPort; |
1888 |
const int iOldServerTimeout = m_pOptions->iServerTimeout; |
const int iOldServerTimeout = m_pOptions->iServerTimeout; |
1889 |
const bool bOldServerStart = m_pOptions->bServerStart; |
const bool bOldServerStart = m_pOptions->bServerStart; |
1890 |
const QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
const QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
1891 |
const bool bOldMessagesLog = m_pOptions->bMessagesLog; |
const bool bOldMessagesLog = m_pOptions->bMessagesLog; |
1892 |
const QString sOldMessagesLogPath = m_pOptions->sMessagesLogPath; |
const QString sOldMessagesLogPath = m_pOptions->sMessagesLogPath; |
1893 |
const QString sOldDisplayFont = m_pOptions->sDisplayFont; |
const QString sOldDisplayFont = m_pOptions->sDisplayFont; |
1894 |
const bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
const bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
1895 |
const int iOldMaxVolume = m_pOptions->iMaxVolume; |
const int iOldMaxVolume = m_pOptions->iMaxVolume; |
1896 |
const QString sOldMessagesFont = m_pOptions->sMessagesFont; |
const QString sOldMessagesFont = m_pOptions->sMessagesFont; |
1897 |
const bool bOldKeepOnTop = m_pOptions->bKeepOnTop; |
const bool bOldKeepOnTop = m_pOptions->bKeepOnTop; |
1898 |
const bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
const bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
1899 |
const int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
const int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
1900 |
const int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
const int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
1901 |
const bool bOldCompletePath = m_pOptions->bCompletePath; |
const bool bOldCompletePath = m_pOptions->bCompletePath; |
1902 |
const bool bOldInstrumentNames = m_pOptions->bInstrumentNames; |
const bool bOldInstrumentNames = m_pOptions->bInstrumentNames; |
1903 |
const int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
const int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
1904 |
const int iOldBaseFontSize = m_pOptions->iBaseFontSize; |
const int iOldBaseFontSize = m_pOptions->iBaseFontSize; |
1905 |
|
const QString sOldCustomStyleTheme = m_pOptions->sCustomStyleTheme; |
1906 |
|
const QString sOldCustomColorTheme = m_pOptions->sCustomColorTheme; |
1907 |
// Load the current setup settings. |
// Load the current setup settings. |
1908 |
pOptionsForm->setup(m_pOptions); |
pOptionsForm->setup(m_pOptions); |
1909 |
// Show the setup dialog... |
// Show the setup dialog... |
1910 |
if (pOptionsForm->exec()) { |
if (pOptionsForm->exec()) { |
1911 |
// Warn if something will be only effective on next run. |
// Warn if something will be only effective on next run. |
1912 |
|
int iNeedRestart = 0; |
1913 |
if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) || |
if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) || |
1914 |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture) || |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture)) { |
1915 |
( bOldKeepOnTop && !m_pOptions->bKeepOnTop) || |
updateMessagesCapture(); |
1916 |
|
++iNeedRestart; |
1917 |
|
} |
1918 |
|
if (( bOldKeepOnTop && !m_pOptions->bKeepOnTop) || |
1919 |
(!bOldKeepOnTop && m_pOptions->bKeepOnTop) || |
(!bOldKeepOnTop && m_pOptions->bKeepOnTop) || |
1920 |
(iOldBaseFontSize != m_pOptions->iBaseFontSize)) { |
(iOldBaseFontSize != m_pOptions->iBaseFontSize)) { |
1921 |
QMessageBox::information(this, |
++iNeedRestart; |
1922 |
tr("Information"), |
} |
1923 |
tr("Some settings may be only effective\n" |
// Check whether restart is needed or whether |
1924 |
"next time you start this program.")); |
// custom options maybe set up immediately... |
1925 |
updateMessagesCapture(); |
if (m_pOptions->sCustomStyleTheme != sOldCustomStyleTheme) { |
1926 |
|
if (m_pOptions->sCustomStyleTheme.isEmpty()) { |
1927 |
|
++iNeedRestart; |
1928 |
|
} else { |
1929 |
|
QApplication::setStyle( |
1930 |
|
QStyleFactory::create(m_pOptions->sCustomStyleTheme)); |
1931 |
|
} |
1932 |
|
} |
1933 |
|
if (m_pOptions->sCustomColorTheme != sOldCustomColorTheme) { |
1934 |
|
if (m_pOptions->sCustomColorTheme.isEmpty()) { |
1935 |
|
++iNeedRestart; |
1936 |
|
} else { |
1937 |
|
QPalette pal; |
1938 |
|
if (PaletteForm::namedPalette( |
1939 |
|
&m_pOptions->settings(), m_pOptions->sCustomColorTheme, pal)) |
1940 |
|
QApplication::setPalette(pal); |
1941 |
|
} |
1942 |
} |
} |
1943 |
// Check wheather something immediate has changed. |
// Check wheather something immediate has changed. |
1944 |
if (( bOldMessagesLog && !m_pOptions->bMessagesLog) || |
if (( bOldMessagesLog && !m_pOptions->bMessagesLog) || |
1966 |
(!bOldMessagesLimit && m_pOptions->bMessagesLimit) || |
(!bOldMessagesLimit && m_pOptions->bMessagesLimit) || |
1967 |
(iOldMessagesLimitLines != m_pOptions->iMessagesLimitLines)) |
(iOldMessagesLimitLines != m_pOptions->iMessagesLimitLines)) |
1968 |
updateMessagesLimit(); |
updateMessagesLimit(); |
1969 |
|
// Show restart needed message... |
1970 |
|
if (iNeedRestart > 0) { |
1971 |
|
QMessageBox::information(this, |
1972 |
|
tr("Information"), |
1973 |
|
tr("Some settings may be only effective\n" |
1974 |
|
"next time you start this program.")); |
1975 |
|
} |
1976 |
// And now the main thing, whether we'll do client/server recycling? |
// And now the main thing, whether we'll do client/server recycling? |
1977 |
if ((sOldServerHost != m_pOptions->sServerHost) || |
if ((sOldServerHost != m_pOptions->sServerHost) || |
1978 |
(iOldServerPort != m_pOptions->iServerPort) || |
(iOldServerPort != m_pOptions->iServerPort) || |
2107 |
sText += "</font></small>"; |
sText += "</font></small>"; |
2108 |
} |
} |
2109 |
sText += "<br />\n"; |
sText += "<br />\n"; |
2110 |
sText += tr("Using") + ": "; |
sText += tr("Using: Qt %1").arg(qVersion()); |
2111 |
|
#if defined(QT_STATIC) |
2112 |
|
sText += "-static"; |
2113 |
|
#endif |
2114 |
|
sText += ", "; |
2115 |
sText += ::lscp_client_package(); |
sText += ::lscp_client_package(); |
2116 |
sText += " "; |
sText += " "; |
2117 |
sText += ::lscp_client_version(); |
sText += ::lscp_client_version(); |
2504 |
// QSampler::MainForm -- Messages window form handlers. |
// QSampler::MainForm -- Messages window form handlers. |
2505 |
|
|
2506 |
// Messages output methods. |
// Messages output methods. |
2507 |
void MainForm::appendMessages( const QString& s ) |
void MainForm::appendMessages ( const QString& s ) |
2508 |
{ |
{ |
2509 |
if (m_pMessages) |
if (m_pMessages) |
2510 |
m_pMessages->appendMessages(s); |
m_pMessages->appendMessages(s); |
2512 |
statusBar()->showMessage(s, 3000); |
statusBar()->showMessage(s, 3000); |
2513 |
} |
} |
2514 |
|
|
2515 |
void MainForm::appendMessagesColor( const QString& s, const QString& c ) |
void MainForm::appendMessagesColor ( const QString& s, const QColor& rgb ) |
2516 |
{ |
{ |
2517 |
if (m_pMessages) |
if (m_pMessages) |
2518 |
m_pMessages->appendMessagesColor(s, c); |
m_pMessages->appendMessagesColor(s, rgb); |
2519 |
|
|
2520 |
statusBar()->showMessage(s, 3000); |
statusBar()->showMessage(s, 3000); |
2521 |
} |
} |
2522 |
|
|
2523 |
void MainForm::appendMessagesText( const QString& s ) |
void MainForm::appendMessagesText ( const QString& s ) |
2524 |
{ |
{ |
2525 |
if (m_pMessages) |
if (m_pMessages) |
2526 |
m_pMessages->appendMessagesText(s); |
m_pMessages->appendMessagesText(s); |
2527 |
} |
} |
2528 |
|
|
2529 |
void MainForm::appendMessagesError( const QString& sText ) |
void MainForm::appendMessagesError ( const QString& s ) |
2530 |
{ |
{ |
2531 |
if (m_pMessages) |
if (m_pMessages) |
2532 |
m_pMessages->show(); |
m_pMessages->show(); |
2533 |
|
|
2534 |
appendMessagesColor(sText.simplified(), "#ff0000"); |
appendMessagesColor(s.simplified(), Qt::red); |
2535 |
|
|
2536 |
// Make it look responsive...:) |
// Make it look responsive...:) |
2537 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2544 |
QMessageBox mbox(this); |
QMessageBox mbox(this); |
2545 |
mbox.setIcon(QMessageBox::Critical); |
mbox.setIcon(QMessageBox::Critical); |
2546 |
mbox.setWindowTitle(sTitle); |
mbox.setWindowTitle(sTitle); |
2547 |
mbox.setText(sText); |
mbox.setText(s); |
2548 |
mbox.setStandardButtons(QMessageBox::Cancel); |
mbox.setStandardButtons(QMessageBox::Cancel); |
2549 |
QCheckBox cbox(tr("Don't show this again")); |
QCheckBox cbox(tr("Don't show this again")); |
2550 |
cbox.setChecked(false); |
cbox.setChecked(false); |
2929 |
|
|
2930 |
// Show startup results... |
// Show startup results... |
2931 |
appendMessages( |
appendMessages( |
2932 |
tr("Server was started with PID=%1.").arg((long) m_pServer->pid())); |
tr("Server was started with PID=%1.") |
2933 |
|
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) |
2934 |
|
.arg(quint64(m_pServer->pid()))); |
2935 |
|
#else |
2936 |
|
.arg(quint64(m_pServer->processId()))); |
2937 |
|
#endif |
2938 |
|
|
2939 |
// Reset (yet again) the timer counters, |
// Reset (yet again) the timer counters, |
2940 |
// but this time is deferred as the user opted. |
// but this time is deferred as the user opted. |