1 |
// qsamplerMainForm.cpp |
// qsamplerMainForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2021, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007,2008,2015 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 |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
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> |
61 |
#include <QTimer> |
#include <QTimer> |
62 |
#include <QDateTime> |
#include <QDateTime> |
63 |
|
|
64 |
|
#include <QElapsedTimer> |
65 |
|
|
66 |
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
67 |
#include <QMimeData> |
#include <QMimeData> |
68 |
#endif |
#endif |
74 |
#endif |
#endif |
75 |
|
|
76 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
77 |
|
#pragma GCC diagnostic push |
78 |
|
#pragma GCC diagnostic ignored "-Wunused-parameter" |
79 |
#include <gig.h> |
#include <gig.h> |
80 |
|
#pragma GCC diagnostic pop |
81 |
#endif |
#endif |
82 |
|
|
83 |
// Needed for lroundf() |
// Deprecated QTextStreamFunctions/Qt namespaces workaround. |
84 |
#include <math.h> |
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) |
85 |
|
#define endl Qt::endl |
86 |
|
#endif |
87 |
|
|
88 |
#ifndef CONFIG_ROUND |
// Needed for lroundf() |
89 |
|
#ifdef CONFIG_ROUND |
90 |
|
#include <cmath> |
91 |
|
#else |
92 |
static inline long lroundf ( float x ) |
static inline long lroundf ( float x ) |
93 |
{ |
{ |
94 |
if (x >= 0.0f) |
if (x >= 0.0f) |
979 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
980 |
const QList<QMdiSubWindow *>& wlist |
const QList<QMdiSubWindow *>& wlist |
981 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
982 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
983 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
984 |
ChannelStrip *pChannelStrip = nullptr; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
985 |
if (pChannelStrip) { |
if (pChannelStrip) { |
986 |
Channel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
987 |
if (bForce && pChannel) |
if (bForce && pChannel) |
988 |
pChannel->removeChannel(); |
pChannel->removeChannel(); |
989 |
delete pChannelStrip; |
delete pChannelStrip; |
990 |
} |
} |
991 |
if (pMdiSubWindow) |
delete pMdiSubWindow; |
|
delete pMdiSubWindow; |
|
992 |
} |
} |
993 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
994 |
// We're now clean, for sure. |
// We're now clean, for sure. |
1286 |
int iChannelID = 0; |
int iChannelID = 0; |
1287 |
const QList<QMdiSubWindow *>& wlist |
const QList<QMdiSubWindow *>& wlist |
1288 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
1289 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
1290 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
1291 |
ChannelStrip *pChannelStrip = nullptr; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
1292 |
if (pChannelStrip) { |
if (pChannelStrip) { |
1293 |
Channel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
1294 |
if (pChannel) { |
if (pChannel) { |
1768 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1769 |
const QList<QMdiSubWindow *>& wlist |
const QList<QMdiSubWindow *>& wlist |
1770 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
1771 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
1772 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
1773 |
ChannelStrip *pChannelStrip = nullptr; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
1774 |
if (pChannelStrip) |
if (pChannelStrip) |
1775 |
pChannelStrip->channelReset(); |
pChannelStrip->channelReset(); |
1776 |
} |
} |
1879 |
if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages) |
if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages) |
1880 |
m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString(); |
m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString(); |
1881 |
// To track down deferred or immediate changes. |
// To track down deferred or immediate changes. |
1882 |
const QString sOldServerHost = m_pOptions->sServerHost; |
const QString sOldServerHost = m_pOptions->sServerHost; |
1883 |
const int iOldServerPort = m_pOptions->iServerPort; |
const int iOldServerPort = m_pOptions->iServerPort; |
1884 |
const int iOldServerTimeout = m_pOptions->iServerTimeout; |
const int iOldServerTimeout = m_pOptions->iServerTimeout; |
1885 |
const bool bOldServerStart = m_pOptions->bServerStart; |
const bool bOldServerStart = m_pOptions->bServerStart; |
1886 |
const QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
const QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
1887 |
const bool bOldMessagesLog = m_pOptions->bMessagesLog; |
const bool bOldMessagesLog = m_pOptions->bMessagesLog; |
1888 |
const QString sOldMessagesLogPath = m_pOptions->sMessagesLogPath; |
const QString sOldMessagesLogPath = m_pOptions->sMessagesLogPath; |
1889 |
const QString sOldDisplayFont = m_pOptions->sDisplayFont; |
const QString sOldDisplayFont = m_pOptions->sDisplayFont; |
1890 |
const bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
const bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
1891 |
const int iOldMaxVolume = m_pOptions->iMaxVolume; |
const int iOldMaxVolume = m_pOptions->iMaxVolume; |
1892 |
const QString sOldMessagesFont = m_pOptions->sMessagesFont; |
const QString sOldMessagesFont = m_pOptions->sMessagesFont; |
1893 |
const bool bOldKeepOnTop = m_pOptions->bKeepOnTop; |
const bool bOldKeepOnTop = m_pOptions->bKeepOnTop; |
1894 |
const bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
const bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
1895 |
const int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
const int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
1896 |
const int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
const int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
1897 |
const bool bOldCompletePath = m_pOptions->bCompletePath; |
const bool bOldCompletePath = m_pOptions->bCompletePath; |
1898 |
const bool bOldInstrumentNames = m_pOptions->bInstrumentNames; |
const bool bOldInstrumentNames = m_pOptions->bInstrumentNames; |
1899 |
const int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
const int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
1900 |
const int iOldBaseFontSize = m_pOptions->iBaseFontSize; |
const int iOldBaseFontSize = m_pOptions->iBaseFontSize; |
1901 |
|
const QString sOldCustomStyleTheme = m_pOptions->sCustomStyleTheme; |
1902 |
|
const QString sOldCustomColorTheme = m_pOptions->sCustomColorTheme; |
1903 |
// Load the current setup settings. |
// Load the current setup settings. |
1904 |
pOptionsForm->setup(m_pOptions); |
pOptionsForm->setup(m_pOptions); |
1905 |
// Show the setup dialog... |
// Show the setup dialog... |
1906 |
if (pOptionsForm->exec()) { |
if (pOptionsForm->exec()) { |
1907 |
// Warn if something will be only effective on next run. |
// Warn if something will be only effective on next run. |
1908 |
|
int iNeedRestart = 0; |
1909 |
if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) || |
if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) || |
1910 |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture) || |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture)) { |
1911 |
( bOldKeepOnTop && !m_pOptions->bKeepOnTop) || |
updateMessagesCapture(); |
1912 |
|
++iNeedRestart; |
1913 |
|
} |
1914 |
|
if (( bOldKeepOnTop && !m_pOptions->bKeepOnTop) || |
1915 |
(!bOldKeepOnTop && m_pOptions->bKeepOnTop) || |
(!bOldKeepOnTop && m_pOptions->bKeepOnTop) || |
1916 |
(iOldBaseFontSize != m_pOptions->iBaseFontSize)) { |
(iOldBaseFontSize != m_pOptions->iBaseFontSize)) { |
1917 |
QMessageBox::information(this, |
++iNeedRestart; |
1918 |
tr("Information"), |
} |
1919 |
tr("Some settings may be only effective\n" |
// Check whether restart is needed or whether |
1920 |
"next time you start this program.")); |
// custom options maybe set up immediately... |
1921 |
updateMessagesCapture(); |
if (m_pOptions->sCustomStyleTheme != sOldCustomStyleTheme) { |
1922 |
|
if (m_pOptions->sCustomStyleTheme.isEmpty()) { |
1923 |
|
++iNeedRestart; |
1924 |
|
} else { |
1925 |
|
QApplication::setStyle( |
1926 |
|
QStyleFactory::create(m_pOptions->sCustomStyleTheme)); |
1927 |
|
} |
1928 |
|
} |
1929 |
|
if (m_pOptions->sCustomColorTheme != sOldCustomColorTheme) { |
1930 |
|
if (m_pOptions->sCustomColorTheme.isEmpty()) { |
1931 |
|
++iNeedRestart; |
1932 |
|
} else { |
1933 |
|
QPalette pal; |
1934 |
|
if (PaletteForm::namedPalette( |
1935 |
|
&m_pOptions->settings(), m_pOptions->sCustomColorTheme, pal)) |
1936 |
|
QApplication::setPalette(pal); |
1937 |
|
} |
1938 |
} |
} |
1939 |
// Check wheather something immediate has changed. |
// Check wheather something immediate has changed. |
1940 |
if (( bOldMessagesLog && !m_pOptions->bMessagesLog) || |
if (( bOldMessagesLog && !m_pOptions->bMessagesLog) || |
1962 |
(!bOldMessagesLimit && m_pOptions->bMessagesLimit) || |
(!bOldMessagesLimit && m_pOptions->bMessagesLimit) || |
1963 |
(iOldMessagesLimitLines != m_pOptions->iMessagesLimitLines)) |
(iOldMessagesLimitLines != m_pOptions->iMessagesLimitLines)) |
1964 |
updateMessagesLimit(); |
updateMessagesLimit(); |
1965 |
|
// Show restart needed message... |
1966 |
|
if (iNeedRestart > 0) { |
1967 |
|
QMessageBox::information(this, |
1968 |
|
tr("Information"), |
1969 |
|
tr("Some settings may be only effective\n" |
1970 |
|
"next time you start this program.")); |
1971 |
|
} |
1972 |
// And now the main thing, whether we'll do client/server recycling? |
// And now the main thing, whether we'll do client/server recycling? |
1973 |
if ((sOldServerHost != m_pOptions->sServerHost) || |
if ((sOldServerHost != m_pOptions->sServerHost) || |
1974 |
(iOldServerPort != m_pOptions->iServerPort) || |
(iOldServerPort != m_pOptions->iServerPort) || |
2002 |
|
|
2003 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2004 |
int y = 0; |
int y = 0; |
2005 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2006 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
pMdiSubWindow->adjustSize(); |
2007 |
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
const QRect& frameRect |
2008 |
if (pMdiSubWindow) { |
= pMdiSubWindow->frameGeometry(); |
2009 |
pMdiSubWindow->adjustSize(); |
int w = m_pWorkspace->width(); |
2010 |
int iWidth = m_pWorkspace->width(); |
if (w < frameRect.width()) |
2011 |
if (iWidth < pMdiSubWindow->width()) |
w = frameRect.width(); |
2012 |
iWidth = pMdiSubWindow->width(); |
const int h = frameRect.height(); |
2013 |
const int iHeight = pMdiSubWindow->frameGeometry().height(); |
pMdiSubWindow->setGeometry(0, y, w, h); |
2014 |
pMdiSubWindow->setGeometry(0, y, iWidth, iHeight); |
y += h; |
|
y += iHeight; |
|
|
} |
|
2015 |
} |
} |
2016 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
2017 |
|
|
2103 |
sText += "</font></small>"; |
sText += "</font></small>"; |
2104 |
} |
} |
2105 |
sText += "<br />\n"; |
sText += "<br />\n"; |
2106 |
sText += tr("Using") + ": "; |
sText += tr("Using: Qt %1").arg(qVersion()); |
2107 |
|
#if defined(QT_STATIC) |
2108 |
|
sText += "-static"; |
2109 |
|
#endif |
2110 |
|
sText += ", "; |
2111 |
sText += ::lscp_client_package(); |
sText += ::lscp_client_package(); |
2112 |
sText += " "; |
sText += " "; |
2113 |
sText += ::lscp_client_version(); |
sText += ::lscp_client_version(); |
2325 |
if (bRemoveDeadStrips) { |
if (bRemoveDeadStrips) { |
2326 |
const QList<QMdiSubWindow *>& wlist |
const QList<QMdiSubWindow *>& wlist |
2327 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
2328 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2329 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2330 |
ChannelStrip *pChannelStrip = nullptr; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2331 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2332 |
bool bExists = false; |
bool bExists = false; |
2333 |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) { |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) { |
2404 |
return; |
return; |
2405 |
|
|
2406 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2407 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2408 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2409 |
ChannelStrip *pChannelStrip = nullptr; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2410 |
if (pChannelStrip) |
if (pChannelStrip) |
2411 |
pChannelStrip->updateInstrumentName(true); |
pChannelStrip->updateInstrumentName(true); |
2412 |
} |
} |
2436 |
return; |
return; |
2437 |
|
|
2438 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2439 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2440 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2441 |
ChannelStrip *pChannelStrip = nullptr; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2442 |
if (pChannelStrip) |
if (pChannelStrip) |
2443 |
pChannelStrip->setDisplayFont(font); |
pChannelStrip->setDisplayFont(font); |
2444 |
} |
} |
2456 |
return; |
return; |
2457 |
|
|
2458 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2459 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2460 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2461 |
ChannelStrip *pChannelStrip = nullptr; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2462 |
if (pChannelStrip) |
if (pChannelStrip) |
2463 |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
2464 |
} |
} |
2486 |
return; |
return; |
2487 |
|
|
2488 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2489 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2490 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2491 |
ChannelStrip *pChannelStrip = nullptr; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2492 |
if (pChannelStrip) |
if (pChannelStrip) |
2493 |
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
2494 |
} |
} |
2500 |
// QSampler::MainForm -- Messages window form handlers. |
// QSampler::MainForm -- Messages window form handlers. |
2501 |
|
|
2502 |
// Messages output methods. |
// Messages output methods. |
2503 |
void MainForm::appendMessages( const QString& s ) |
void MainForm::appendMessages ( const QString& s ) |
2504 |
{ |
{ |
2505 |
if (m_pMessages) |
if (m_pMessages) |
2506 |
m_pMessages->appendMessages(s); |
m_pMessages->appendMessages(s); |
2508 |
statusBar()->showMessage(s, 3000); |
statusBar()->showMessage(s, 3000); |
2509 |
} |
} |
2510 |
|
|
2511 |
void MainForm::appendMessagesColor( const QString& s, const QString& c ) |
void MainForm::appendMessagesColor ( const QString& s, const QColor& rgb ) |
2512 |
{ |
{ |
2513 |
if (m_pMessages) |
if (m_pMessages) |
2514 |
m_pMessages->appendMessagesColor(s, c); |
m_pMessages->appendMessagesColor(s, rgb); |
2515 |
|
|
2516 |
statusBar()->showMessage(s, 3000); |
statusBar()->showMessage(s, 3000); |
2517 |
} |
} |
2518 |
|
|
2519 |
void MainForm::appendMessagesText( const QString& s ) |
void MainForm::appendMessagesText ( const QString& s ) |
2520 |
{ |
{ |
2521 |
if (m_pMessages) |
if (m_pMessages) |
2522 |
m_pMessages->appendMessagesText(s); |
m_pMessages->appendMessagesText(s); |
2523 |
} |
} |
2524 |
|
|
2525 |
void MainForm::appendMessagesError( const QString& sText ) |
void MainForm::appendMessagesError ( const QString& s ) |
2526 |
{ |
{ |
2527 |
if (m_pMessages) |
if (m_pMessages) |
2528 |
m_pMessages->show(); |
m_pMessages->show(); |
2529 |
|
|
2530 |
appendMessagesColor(sText.simplified(), "#ff0000"); |
appendMessagesColor(s.simplified(), Qt::red); |
2531 |
|
|
2532 |
// Make it look responsive...:) |
// Make it look responsive...:) |
2533 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2540 |
QMessageBox mbox(this); |
QMessageBox mbox(this); |
2541 |
mbox.setIcon(QMessageBox::Critical); |
mbox.setIcon(QMessageBox::Critical); |
2542 |
mbox.setWindowTitle(sTitle); |
mbox.setWindowTitle(sTitle); |
2543 |
mbox.setText(sText); |
mbox.setText(s); |
2544 |
mbox.setStandardButtons(QMessageBox::Cancel); |
mbox.setStandardButtons(QMessageBox::Cancel); |
2545 |
QCheckBox cbox(tr("Don't show this again")); |
QCheckBox cbox(tr("Don't show this again")); |
2546 |
cbox.setChecked(false); |
cbox.setChecked(false); |
2636 |
} |
} |
2637 |
|
|
2638 |
// Add it to workspace... |
// Add it to workspace... |
2639 |
m_pWorkspace->addSubWindow(pChannelStrip, |
QMdiSubWindow *pMdiSubWindow |
2640 |
Qt::SubWindow | Qt::FramelessWindowHint); |
= m_pWorkspace->addSubWindow(pChannelStrip, |
2641 |
|
Qt::SubWindow | Qt::FramelessWindowHint); |
2642 |
|
pMdiSubWindow->setAttribute(Qt::WA_DeleteOnClose); |
2643 |
|
|
2644 |
// Actual channel strip setup... |
// Actual channel strip setup... |
2645 |
pChannelStrip->setup(pChannel); |
pChannelStrip->setup(pChannel); |
2715 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2716 |
return nullptr; |
return nullptr; |
2717 |
|
|
2718 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2719 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2720 |
ChannelStrip *pChannelStrip = nullptr; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2721 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2722 |
Channel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
2723 |
if (pChannel && pChannel->channelID() == iChannelID) |
if (pChannel && pChannel->channelID() == iChannelID) |
2741 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
2742 |
if (!wlist.isEmpty()) { |
if (!wlist.isEmpty()) { |
2743 |
m_ui.channelsMenu->addSeparator(); |
m_ui.channelsMenu->addSeparator(); |
2744 |
const int iStripCount = wlist.count(); |
int iStrip = 0; |
2745 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2746 |
ChannelStrip *pChannelStrip = nullptr; |
ChannelStrip *pChannelStrip |
2747 |
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2748 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2749 |
QAction *pAction = m_ui.channelsMenu->addAction( |
QAction *pAction = m_ui.channelsMenu->addAction( |
2750 |
pChannelStrip->windowTitle(), |
pChannelStrip->windowTitle(), |
2753 |
pAction->setChecked(activeChannelStrip() == pChannelStrip); |
pAction->setChecked(activeChannelStrip() == pChannelStrip); |
2754 |
pAction->setData(iStrip); |
pAction->setData(iStrip); |
2755 |
} |
} |
2756 |
|
++iStrip; |
2757 |
} |
} |
2758 |
} |
} |
2759 |
} |
} |
2830 |
// Update the channel stream usage for each strip... |
// Update the channel stream usage for each strip... |
2831 |
const QList<QMdiSubWindow *>& wlist |
const QList<QMdiSubWindow *>& wlist |
2832 |
= m_pWorkspace->subWindowList(); |
= m_pWorkspace->subWindowList(); |
2833 |
const int iStripCount = wlist.count(); |
foreach (QMdiSubWindow *pMdiSubWindow, wlist) { |
2834 |
for (int iStrip = 0; iStrip < iStripCount; ++iStrip) { |
ChannelStrip *pChannelStrip |
2835 |
ChannelStrip *pChannelStrip = nullptr; |
= static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iStrip); |
|
|
if (pMdiSubWindow) |
|
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
|
2836 |
if (pChannelStrip && pChannelStrip->isVisible()) |
if (pChannelStrip && pChannelStrip->isVisible()) |
2837 |
pChannelStrip->updateChannelUsage(); |
pChannelStrip->updateChannelUsage(); |
2838 |
} |
} |
2839 |
} |
} |
2840 |
} |
} |
2841 |
|
|
2842 |
|
#if CONFIG_LSCP_CLIENT_CONNECTION_LOST |
2843 |
|
// If we lost connection to server: Try to automatically reconnect if we |
2844 |
|
// did not start the server. |
2845 |
|
// |
2846 |
|
// TODO: If we started the server, then we might inform the user that |
2847 |
|
// the server probably crashed and asking user ONCE whether we should |
2848 |
|
// restart the server. |
2849 |
|
if (lscp_client_connection_lost(m_pClient) && !m_pServer) |
2850 |
|
startAutoReconnectClient(); |
2851 |
|
#endif // CONFIG_LSCP_CLIENT_CONNECTION_LOST |
2852 |
} |
} |
2853 |
|
|
2854 |
// Register the next timer slot. |
// Register the next timer slot. |
2925 |
|
|
2926 |
// Show startup results... |
// Show startup results... |
2927 |
appendMessages( |
appendMessages( |
2928 |
tr("Server was started with PID=%1.").arg((long) m_pServer->pid())); |
tr("Server was started with PID=%1.") |
2929 |
|
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) |
2930 |
|
.arg(quint64(m_pServer->pid()))); |
2931 |
|
#else |
2932 |
|
.arg(quint64(m_pServer->processId()))); |
2933 |
|
#endif |
2934 |
|
|
2935 |
// Reset (yet again) the timer counters, |
// Reset (yet again) the timer counters, |
2936 |
// but this time is deferred as the user opted. |
// but this time is deferred as the user opted. |
2980 |
|
|
2981 |
// Give it some time to terminate gracefully and stabilize... |
// Give it some time to terminate gracefully and stabilize... |
2982 |
if (bGraceWait) { |
if (bGraceWait) { |
2983 |
QTime t; |
QElapsedTimer timer; |
2984 |
t.start(); |
timer.start(); |
2985 |
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
while (timer.elapsed() < QSAMPLER_TIMER_MSECS) |
2986 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2987 |
} |
} |
2988 |
} |
} |
3012 |
// Force final server shutdown... |
// Force final server shutdown... |
3013 |
m_pServer->kill(); |
m_pServer->kill(); |
3014 |
// Give it some time to terminate gracefully and stabilize... |
// Give it some time to terminate gracefully and stabilize... |
3015 |
QTime t; |
QElapsedTimer timer; |
3016 |
t.start(); |
timer.start(); |
3017 |
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
while (timer.elapsed() < QSAMPLER_TIMER_MSECS) |
3018 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
3019 |
} |
} |
3020 |
// Force final server shutdown... |
// Force final server shutdown... |
3052 |
|
|
3053 |
|
|
3054 |
// Start our almighty client... |
// Start our almighty client... |
3055 |
bool MainForm::startClient (void) |
bool MainForm::startClient (bool bReconnectOnly) |
3056 |
{ |
{ |
3057 |
// Have it a setup? |
// Have it a setup? |
3058 |
if (m_pOptions == nullptr) |
if (m_pOptions == nullptr) |
3073 |
// Is this the first try? |
// Is this the first try? |
3074 |
// maybe we need to start a local server... |
// maybe we need to start a local server... |
3075 |
if ((m_pServer && m_pServer->state() == QProcess::Running) |
if ((m_pServer && m_pServer->state() == QProcess::Running) |
3076 |
|| !m_pOptions->bServerStart) { |
|| !m_pOptions->bServerStart || bReconnectOnly) |
3077 |
appendMessagesError( |
{ |
3078 |
tr("Could not connect to server as client.\n\nSorry.")); |
// if this method is called from autoReconnectClient() |
3079 |
|
// then don't bother user with an error message... |
3080 |
|
if (!bReconnectOnly) { |
3081 |
|
appendMessagesError( |
3082 |
|
tr("Could not connect to server as client.\n\nSorry.") |
3083 |
|
); |
3084 |
|
} |
3085 |
} else { |
} else { |
3086 |
startServer(); |
startServer(); |
3087 |
} |
} |
3210 |
} |
} |
3211 |
|
|
3212 |
|
|
3213 |
|
void MainForm::startAutoReconnectClient (void) |
3214 |
|
{ |
3215 |
|
stopClient(); |
3216 |
|
appendMessages(tr("Trying to reconnect...")); |
3217 |
|
QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient())); |
3218 |
|
} |
3219 |
|
|
3220 |
|
|
3221 |
|
void MainForm::autoReconnectClient (void) |
3222 |
|
{ |
3223 |
|
const bool bSuccess = startClient(true); |
3224 |
|
if (!bSuccess) |
3225 |
|
QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient())); |
3226 |
|
} |
3227 |
|
|
3228 |
|
|
3229 |
// Channel strip activation/selection. |
// Channel strip activation/selection. |
3230 |
void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow ) |
void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow ) |
3231 |
{ |
{ |