aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2020-05-12 00:58:40 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2020-05-12 00:58:40 +0800
commita7407edaf81c685d4a389785a405a53a5de4b148 (patch)
treee6e4f2d85f2172c94ac83a6e8f01e1e90a78ede9 /qmidiplayer-desktop
parent437b7b16c322a8e53ac55a5f831098494d9a7073 (diff)
downloadQMidiPlayer-a7407edaf81c685d4a389785a405a53a5de4b148.tar.xz
Format EVERYTHING.
Hopefully this will make the source code less horrendous and actually readable. The command used was: ``` astyle --suffix=none --style=allman --attach-extern-c --attach-closing-while --indent-switches --indent-after-parens --pad-oper --pad-header --unpad-paren --align-pointer=name --recursive './*.cpp,*.hpp' ```
Diffstat (limited to 'qmidiplayer-desktop')
-rw-r--r--qmidiplayer-desktop/main.cpp71
-rw-r--r--qmidiplayer-desktop/qdialskulpturestyle.cpp742
-rw-r--r--qmidiplayer-desktop/qdialskulpturestyle.hpp10
-rw-r--r--qmidiplayer-desktop/qmpchanneleditor.cpp207
-rw-r--r--qmidiplayer-desktop/qmpchanneleditor.hpp55
-rw-r--r--qmidiplayer-desktop/qmpchannelswindow.cpp612
-rw-r--r--qmidiplayer-desktop/qmpchannelswindow.hpp129
-rw-r--r--qmidiplayer-desktop/qmpcustomizewindow.cpp103
-rw-r--r--qmidiplayer-desktop/qmpcustomizewindow.hpp31
-rw-r--r--qmidiplayer-desktop/qmpdeviceprioritydialog.cpp141
-rw-r--r--qmidiplayer-desktop/qmpdeviceprioritydialog.hpp33
-rw-r--r--qmidiplayer-desktop/qmpdevpropdialog.cpp149
-rw-r--r--qmidiplayer-desktop/qmpdevpropdialog.hpp31
-rw-r--r--qmidiplayer-desktop/qmpefxwindow.cpp367
-rw-r--r--qmidiplayer-desktop/qmpefxwindow.hpp95
-rw-r--r--qmidiplayer-desktop/qmphelpwindow.cpp51
-rw-r--r--qmidiplayer-desktop/qmphelpwindow.hpp21
-rw-r--r--qmidiplayer-desktop/qmpinfowindow.cpp125
-rw-r--r--qmidiplayer-desktop/qmpinfowindow.hpp65
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp1399
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.hpp459
-rw-r--r--qmidiplayer-desktop/qmpplistwindow.cpp532
-rw-r--r--qmidiplayer-desktop/qmpplistwindow.hpp91
-rw-r--r--qmidiplayer-desktop/qmpplugin.cpp582
-rw-r--r--qmidiplayer-desktop/qmpplugin.hpp182
-rw-r--r--qmidiplayer-desktop/qmppresetselect.cpp205
-rw-r--r--qmidiplayer-desktop/qmppresetselect.hpp41
-rw-r--r--qmidiplayer-desktop/qmpsettings.cpp320
-rw-r--r--qmidiplayer-desktop/qmpsettings.hpp131
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.cpp1013
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.hpp162
31 files changed, 4455 insertions, 3700 deletions
diff --git a/qmidiplayer-desktop/main.cpp b/qmidiplayer-desktop/main.cpp
index 6bf21c0..c9408b9 100644
--- a/qmidiplayer-desktop/main.cpp
+++ b/qmidiplayer-desktop/main.cpp
@@ -26,56 +26,57 @@
#include <windows.h>
#endif
-int main(int argc,char **argv)
+int main(int argc, char **argv)
{
#ifdef _WIN32
- if(!LoadLibraryA("libbacktrace.dll"))
- fputs("Failed to load backtrace library. Stack trace will not be printed if unhandled exception occurs.\n",stderr);
+ if (!LoadLibraryA("libbacktrace.dll"))
+ fputs("Failed to load backtrace library. Stack trace will not be printed if unhandled exception occurs.\n", stderr);
#endif
- QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
- QCoreApplication::setApplicationName("qmidiplayer");
- QCoreApplication::setApplicationVersion(APP_VERSION);
- if(!qgetenv("QT_SCALE_FACTOR").length()&&!qgetenv("QT_SCREEN_SCALE_FACTORS").length())
- QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
- qSetMessagePattern("%{time} @ %{file} : %{line}, in %{function} : %{message}");
- QApplication a(argc,argv);
+ QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+ QCoreApplication::setApplicationName("qmidiplayer");
+ QCoreApplication::setApplicationVersion(APP_VERSION);
+ if (!qgetenv("QT_SCALE_FACTOR").length() && !qgetenv("QT_SCREEN_SCALE_FACTORS").length())
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ qSetMessagePattern("%{time} @ %{file} : %{line}, in %{function} : %{message}");
+ QApplication a(argc, argv);
- QTranslator qtTranslator;
- qtTranslator.load("qt_"+QLocale::system().name(),
- QLibraryInfo::location(QLibraryInfo::TranslationsPath));
- a.installTranslator(&qtTranslator);
- QTranslator qmpTranslator;
+ QTranslator qtTranslator;
+ qtTranslator.load("qt_" + QLocale::system().name(),
+ QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+ a.installTranslator(&qtTranslator);
+ QTranslator qmpTranslator;
#ifndef NON_PORTABLE
- qmpTranslator.load("qmp_"+QLocale::system().name(),
- QCoreApplication::applicationDirPath()+"/translations/");
+ qmpTranslator.load("qmp_" + QLocale::system().name(),
+ QCoreApplication::applicationDirPath() + "/translations/");
#else
#define strify(s) #s
- qmpTranslator.load("qmp_"+QLocale::system().name(),
- QString(strify(INSTALL_PREFIX))+"/share/qmidiplayer/translations");
+ qmpTranslator.load("qmp_" + QLocale::system().name(),
+ QString(strify(INSTALL_PREFIX)) + "/share/qmidiplayer/translations");
#undef strify
#endif
- a.installTranslator(&qmpTranslator);
+ a.installTranslator(&qmpTranslator);
- QCommandLineParser clp;
- clp.setApplicationDescription(QCoreApplication::translate("main","A cross-platform MIDI player."));
- clp.addHelpOption();
- clp.addVersionOption();
- clp.addPositionalArgument("file",QCoreApplication::translate("main","midi files to play (optional)."),"[files...]");
- clp.addOption(QCommandLineOption("plugin",QCoreApplication::translate("main","Load a plugin from <plugin library>."),"plugin library"));
- clp.addOption(QCommandLineOption({"l","load-all-files"},QCoreApplication::translate("main","Load all files from the same folder.")));
+ QCommandLineParser clp;
+ clp.setApplicationDescription(QCoreApplication::translate("main", "A cross-platform MIDI player."));
+ clp.addHelpOption();
+ clp.addVersionOption();
+ clp.addPositionalArgument("file", QCoreApplication::translate("main", "midi files to play (optional)."), "[files...]");
+ clp.addOption(QCommandLineOption("plugin", QCoreApplication::translate("main", "Load a plugin from <plugin library>."), "plugin library"));
+ clp.addOption(QCommandLineOption({"l", "load-all-files"}, QCoreApplication::translate("main", "Load all files from the same folder.")));
#ifdef _WIN32
- clp.addOption(QCommandLineOption("keep-console",QCoreApplication::translate("main","Keep console window open.")));
+ clp.addOption(QCommandLineOption("keep-console", QCoreApplication::translate("main", "Keep console window open.")));
#endif
- clp.process(a);
+ clp.process(a);
#ifdef _WIN32
- if(!clp.isSet("keep-console"))
- FreeConsole();
+ if (!clp.isSet("keep-console"))
+ FreeConsole();
#endif
- qmpMainWindow w(&clp);
- if(w.parseArgs()==1)return 0;
- w.init();
+ qmpMainWindow w(&clp);
+ if (w.parseArgs() == 1)
+ return 0;
+ w.init();
- return a.exec();
+ return a.exec();
}
diff --git a/qmidiplayer-desktop/qdialskulpturestyle.cpp b/qmidiplayer-desktop/qdialskulpturestyle.cpp
index 7650edb..29c8f79 100644
--- a/qmidiplayer-desktop/qdialskulpturestyle.cpp
+++ b/qmidiplayer-desktop/qdialskulpturestyle.cpp
@@ -36,35 +36,40 @@
static const bool UsePixmapCache = true;
static void
-paintIndicatorCached(QPainter *painter, const QStyleOption *option, std::function<void(QPainter*,const QStyleOption*)> paintFunc, bool useCache, const QString &pixmapName)
+paintIndicatorCached(QPainter *painter, const QStyleOption *option, std::function<void(QPainter *, const QStyleOption *)> paintFunc, bool useCache, const QString &pixmapName)
{
- QRect rect = option->rect;
- QPixmap internalPixmapCache;
- QImage imageCache;
- QPainter *p = painter;
- int txType = painter->deviceTransform().type() | painter->worldTransform().type();
- bool doPixmapCache = useCache && (!option->rect.isEmpty())
- && ((txType <= QTransform::TxTranslate) || (painter->deviceTransform().type() == QTransform::TxScale));
- if (doPixmapCache && QPixmapCache::find(pixmapName, &internalPixmapCache)) {
- painter->drawPixmap(option->rect.topLeft(), internalPixmapCache);
- } else {
- if (doPixmapCache) {
- rect.setRect(0, 0, option->rect.width(), option->rect.height());
- qreal pixelRatio=painter->device()->devicePixelRatioF();
- imageCache = QImage(option->rect.size() * pixelRatio, QImage::Format_ARGB32_Premultiplied);
- imageCache.setDevicePixelRatio(pixelRatio);
- imageCache.fill(0);
- p = new QPainter(&imageCache);
- }
- paintFunc(p,option);
- if (doPixmapCache) {
- p->end();
- delete p;
- internalPixmapCache = QPixmap::fromImage(imageCache);
- painter->drawPixmap(option->rect.topLeft(), internalPixmapCache);
- QPixmapCache::insert(pixmapName, internalPixmapCache);
- }
- }
+ QRect rect = option->rect;
+ QPixmap internalPixmapCache;
+ QImage imageCache;
+ QPainter *p = painter;
+ int txType = painter->deviceTransform().type() | painter->worldTransform().type();
+ bool doPixmapCache = useCache && (!option->rect.isEmpty())
+ && ((txType <= QTransform::TxTranslate) || (painter->deviceTransform().type() == QTransform::TxScale));
+ if (doPixmapCache && QPixmapCache::find(pixmapName, &internalPixmapCache))
+ {
+ painter->drawPixmap(option->rect.topLeft(), internalPixmapCache);
+ }
+ else
+ {
+ if (doPixmapCache)
+ {
+ rect.setRect(0, 0, option->rect.width(), option->rect.height());
+ qreal pixelRatio = painter->device()->devicePixelRatioF();
+ imageCache = QImage(option->rect.size() * pixelRatio, QImage::Format_ARGB32_Premultiplied);
+ imageCache.setDevicePixelRatio(pixelRatio);
+ imageCache.fill(0);
+ p = new QPainter(&imageCache);
+ }
+ paintFunc(p, option);
+ if (doPixmapCache)
+ {
+ p->end();
+ delete p;
+ internalPixmapCache = QPixmap::fromImage(imageCache);
+ painter->drawPixmap(option->rect.topLeft(), internalPixmapCache);
+ QPixmapCache::insert(pixmapName, internalPixmapCache);
+ }
+ }
}
void
@@ -73,120 +78,132 @@ paintDialBase(QPainter *painter, const QStyleOption *option)
// painter->fillRect(option->rect, Qt::red);
// painter->save();
// painter->setRenderHint(QPainter::Antialiasing, true);
- int d = qMin(option->rect.width(), option->rect.height());
-/* if (d > 20 && option->notchTarget > 0) {
- d += -1;
- }
-*/ QRectF r((option->rect.width() - d) / 2.0, (option->rect.height() - d) / 2.0, d, d);
- const qreal angle = option->direction == Qt::LeftToRight ? 135.0 : 45.0;
+ int d = qMin(option->rect.width(), option->rect.height());
+ /* if (d > 20 && option->notchTarget > 0) {
+ d += -1;
+ }
+ */
+ QRectF r((option->rect.width() - d) / 2.0, (option->rect.height() - d) / 2.0, d, d);
+ const qreal angle = option->direction == Qt::LeftToRight ? 135.0 : 45.0;
// const qreal angle = 90;
- painter->setPen(Qt::NoPen);
- painter->setRenderHint(QPainter::Antialiasing);
- QColor border_color = option->palette.color(QPalette::Window);
+ painter->setPen(Qt::NoPen);
+ painter->setRenderHint(QPainter::Antialiasing);
+ QColor border_color = option->palette.color(QPalette::Window);
#if 0
- {
- QRadialGradient depth_gradient(r.center(), d / 2);
+ {
+ QRadialGradient depth_gradient(r.center(), d / 2);
// depth_gradient.setColorAt(0.0, QColor(0, 0, 0, 255));
- depth_gradient.setColorAt(0.5, QColor(0, 0, 0, 255));
- depth_gradient.setColorAt(1.0, QColor(0, 0, 0, 0));
- painter->setBrush(depth_gradient);
- painter->drawEllipse(r);
- }
+ depth_gradient.setColorAt(0.5, QColor(0, 0, 0, 255));
+ depth_gradient.setColorAt(1.0, QColor(0, 0, 0, 0));
+ painter->setBrush(depth_gradient);
+ painter->drawEllipse(r);
+ }
#endif
#if 1
- if (option->state & QStyle::State_HasFocus && option->state & QStyle::State_KeyboardFocusChange) {
- painter->setBrush(option->palette.color(QPalette::Highlight).darker(180));
- r.adjust(1, 1, -1, -1);
- painter->drawEllipse(r);
- painter->setBrush(border_color);
- r.adjust(1, 1, -1, -1);
- painter->drawEllipse(r);
- r.adjust(1, 1, -1, -1);
- } else {
- painter->setBrush(border_color);
- r.adjust(1, 1, -1, -1);
- painter->drawEllipse(r);
- r.adjust(1, 1, -1, -1);
- QConicalGradient border_gradient(r.center(), angle);
- if (!(option->state & QStyle::State_Enabled)) {
- border_color = border_color.lighter(120);
- }
- border_gradient.setColorAt(0.0, border_color.darker(180));
- border_gradient.setColorAt(0.3, border_color.darker(130));
- border_gradient.setColorAt(0.5, border_color.darker(170));
- border_gradient.setColorAt(0.7, border_color.darker(130));
- border_gradient.setColorAt(1.0, border_color.darker(180));
- painter->setBrush(border_gradient);
+ if (option->state & QStyle::State_HasFocus && option->state & QStyle::State_KeyboardFocusChange)
+ {
+ painter->setBrush(option->palette.color(QPalette::Highlight).darker(180));
+ r.adjust(1, 1, -1, -1);
+ painter->drawEllipse(r);
+ painter->setBrush(border_color);
+ r.adjust(1, 1, -1, -1);
+ painter->drawEllipse(r);
+ r.adjust(1, 1, -1, -1);
+ }
+ else
+ {
+ painter->setBrush(border_color);
+ r.adjust(1, 1, -1, -1);
+ painter->drawEllipse(r);
+ r.adjust(1, 1, -1, -1);
+ QConicalGradient border_gradient(r.center(), angle);
+ if (!(option->state & QStyle::State_Enabled))
+ {
+ border_color = border_color.lighter(120);
+ }
+ border_gradient.setColorAt(0.0, border_color.darker(180));
+ border_gradient.setColorAt(0.3, border_color.darker(130));
+ border_gradient.setColorAt(0.5, border_color.darker(170));
+ border_gradient.setColorAt(0.7, border_color.darker(130));
+ border_gradient.setColorAt(1.0, border_color.darker(180));
+ painter->setBrush(border_gradient);
// painter->setBrush(Qt::blue);
- painter->drawEllipse(r);
- r.adjust(1, 1, -1, -1);
- }
- d -= 6;
-
- QColor dial_color;
- if (option->state & QStyle::State_Enabled) {
- dial_color = option->palette.color(QPalette::Button).lighter(101);
- if (option->state & QStyle::State_MouseOver) {
- dial_color = dial_color.lighter(103);
- }
- } else {
- dial_color = option->palette.color(QPalette::Window);
- }
- qreal t = option->state & QStyle::State_Enabled ? 2.0 : 1.5;
- // ###: work around Qt 4.3.0 bug? (this works for 4.3.1)
- QConicalGradient border_gradient(r.center(), angle);
- border_gradient.setColorAt(0.0, dial_color.lighter(120));
- border_gradient.setColorAt(0.2, dial_color);
- border_gradient.setColorAt(0.5, dial_color.darker(130));
- border_gradient.setColorAt(0.8, dial_color);
- border_gradient.setColorAt(1.0, dial_color.lighter(120));
- painter->setPen(QPen(border_gradient, t));
+ painter->drawEllipse(r);
+ r.adjust(1, 1, -1, -1);
+ }
+ d -= 6;
+
+ QColor dial_color;
+ if (option->state & QStyle::State_Enabled)
+ {
+ dial_color = option->palette.color(QPalette::Button).lighter(101);
+ if (option->state & QStyle::State_MouseOver)
+ {
+ dial_color = dial_color.lighter(103);
+ }
+ }
+ else
+ {
+ dial_color = option->palette.color(QPalette::Window);
+ }
+ qreal t = option->state & QStyle::State_Enabled ? 2.0 : 1.5;
+ // ###: work around Qt 4.3.0 bug? (this works for 4.3.1)
+ QConicalGradient border_gradient(r.center(), angle);
+ border_gradient.setColorAt(0.0, dial_color.lighter(120));
+ border_gradient.setColorAt(0.2, dial_color);
+ border_gradient.setColorAt(0.5, dial_color.darker(130));
+ border_gradient.setColorAt(0.8, dial_color);
+ border_gradient.setColorAt(1.0, dial_color.lighter(120));
+ painter->setPen(QPen(border_gradient, t));
#if 0
- QLinearGradient dial_gradient(r.topLeft(), r.bottomLeft());
- dial_gradient.setColorAt(0.0, dial_color.darker(105));
- dial_gradient.setColorAt(0.5, dial_color.lighter(102));
- dial_gradient.setColorAt(1.0, dial_color.lighter(105));
+ QLinearGradient dial_gradient(r.topLeft(), r.bottomLeft());
+ dial_gradient.setColorAt(0.0, dial_color.darker(105));
+ dial_gradient.setColorAt(0.5, dial_color.lighter(102));
+ dial_gradient.setColorAt(1.0, dial_color.lighter(105));
#elif 1
- QLinearGradient dial_gradient(option->direction == Qt::LeftToRight ? r.topLeft() : r.topRight(), option->direction == Qt::LeftToRight ? r.bottomRight() : r.bottomLeft());
+ QLinearGradient dial_gradient(option->direction == Qt::LeftToRight ? r.topLeft() : r.topRight(), option->direction == Qt::LeftToRight ? r.bottomRight() : r.bottomLeft());
// QLinearGradient dial_gradient(r.topLeft(), r.bottomLeft());
- if (option->state & QStyle::State_Enabled) {
+ if (option->state & QStyle::State_Enabled)
+ {
#if 1
- dial_gradient.setColorAt(0.0, dial_color.darker(106));
- dial_gradient.setColorAt(1.0, dial_color.lighter(104));
+ dial_gradient.setColorAt(0.0, dial_color.darker(106));
+ dial_gradient.setColorAt(1.0, dial_color.lighter(104));
#else
- dial_gradient.setColorAt(0.0, dial_color.lighter(101));
- dial_gradient.setColorAt(0.5, dial_color.darker(103));
- dial_gradient.setColorAt(1.0, dial_color.lighter(104));
+ dial_gradient.setColorAt(0.0, dial_color.lighter(101));
+ dial_gradient.setColorAt(0.5, dial_color.darker(103));
+ dial_gradient.setColorAt(1.0, dial_color.lighter(104));
#endif
- } else {
- dial_gradient.setColorAt(0.0, dial_color);
- dial_gradient.setColorAt(1.0, dial_color);
- }
+ }
+ else
+ {
+ dial_gradient.setColorAt(0.0, dial_color);
+ dial_gradient.setColorAt(1.0, dial_color);
+ }
#elif 0
- QConicalGradient dial_gradient(r.center(), angle);
- dial_gradient.setColorAt(0.0, dial_color.lighter(102));
- dial_gradient.setColorAt(0.5, dial_color.darker(103));
- dial_gradient.setColorAt(1.0, dial_color.lighter(102));
+ QConicalGradient dial_gradient(r.center(), angle);
+ dial_gradient.setColorAt(0.0, dial_color.lighter(102));
+ dial_gradient.setColorAt(0.5, dial_color.darker(103));
+ dial_gradient.setColorAt(1.0, dial_color.lighter(102));
#else
- QBrush dial_gradient(dial_color);
+ QBrush dial_gradient(dial_color);
#endif
- painter->setBrush(dial_gradient);
- t = t / 2;
- painter->drawEllipse(r.adjusted(t, t, -t, -t));
+ painter->setBrush(dial_gradient);
+ t = t / 2;
+ painter->drawEllipse(r.adjusted(t, t, -t, -t));
// painter->setPen(Qt::NoPen);
// painter->setBrush(dial_color);
// painter->drawEllipse(r.adjusted(d / 4, d / 4, - d / 4, - d / 4));
#if 0
- QLinearGradient border2_gradient(r.topLeft(), r.bottomRight());
- border2_gradient.setColorAt(1.0, dial_color.darker(425));
- border2_gradient.setColorAt(0.9, dial_color);
- border2_gradient.setColorAt(0.0, dial_color.darker(400));
- painter->setPen(QPen(border2_gradient, 1.3));
- painter->setBrush(Qt::NoBrush);
- painter->drawEllipse(r.adjusted(0.3, 0.3, -0.3, -0.3));
+ QLinearGradient border2_gradient(r.topLeft(), r.bottomRight());
+ border2_gradient.setColorAt(1.0, dial_color.darker(425));
+ border2_gradient.setColorAt(0.9, dial_color);
+ border2_gradient.setColorAt(0.0, dial_color.darker(400));
+ painter->setPen(QPen(border2_gradient, 1.3));
+ painter->setBrush(Qt::NoBrush);
+ painter->drawEllipse(r.adjusted(0.3, 0.3, -0.3, -0.3));
#endif
// painter->restore();
#endif
@@ -195,262 +212,297 @@ paintDialBase(QPainter *painter, const QStyleOption *option)
void
paintCachedDialBase(QPainter *painter, const QStyleOptionSlider *option)
{
- bool useCache = UsePixmapCache;
- QString pixmapName;
- QRect r = option->rect;
- int d = qMin(r.width(), r.height());
-
- if (/* option->state & (QStyle::State_HasFocus | QStyle::State_MouseOver) ||*/ d > 128) {
- useCache = false;
- }
- if (useCache) {
- uint state = uint(option->state) & (QStyle::State_Enabled | QStyle::State_On | QStyle::State_MouseOver | QStyle::State_KeyboardFocusChange | QStyle::State_HasFocus);
- if (!(state & QStyle::State_Enabled)) {
- state &= ~(QStyle::State_MouseOver | QStyle::State_HasFocus | QStyle::State_KeyboardFocusChange);
- }
- // state &= ~(QStyle::State_HasFocus);
- pixmapName = QString("scp-qdb-%1-%2-%3-%4")
- .arg(state, 0, 16)
- .arg(option->direction, 0, 16)
- .arg(option->palette.cacheKey(), 0, 16)
- .arg(d, 0, 16);
- }
- paintIndicatorCached(painter, option, paintDialBase, useCache, pixmapName);
+ bool useCache = UsePixmapCache;
+ QString pixmapName;
+ QRect r = option->rect;
+ int d = qMin(r.width(), r.height());
+
+ if (/* option->state & (QStyle::State_HasFocus | QStyle::State_MouseOver) ||*/ d > 128)
+ {
+ useCache = false;
+ }
+ if (useCache)
+ {
+ uint state = uint(option->state) & (QStyle::State_Enabled | QStyle::State_On | QStyle::State_MouseOver | QStyle::State_KeyboardFocusChange | QStyle::State_HasFocus);
+ if (!(state & QStyle::State_Enabled))
+ {
+ state &= ~(QStyle::State_MouseOver | QStyle::State_HasFocus | QStyle::State_KeyboardFocusChange);
+ }
+ // state &= ~(QStyle::State_HasFocus);
+ pixmapName = QString("scp-qdb-%1-%2-%3-%4")
+ .arg(state, 0, 16)
+ .arg(option->direction, 0, 16)
+ .arg(option->palette.cacheKey(), 0, 16)
+ .arg(d, 0, 16);
+ }
+ paintIndicatorCached(painter, option, paintDialBase, useCache, pixmapName);
}
void
paintIndicatorDial(QPainter *painter, const QStyleOptionSlider *option)
{
- int d = qMin(option->rect.width(), option->rect.height());
- QRect rect(option->rect.center() - QPoint((d - 1) / 2, (d - 1) / 2), QSize(d, d));
- QStyleOptionSlider opt;
- opt.QStyleOption::operator=(*option);
- opt.rect = rect;
- paintCachedDialBase(painter, &opt);
+ int d = qMin(option->rect.width(), option->rect.height());
+ QRect rect(option->rect.center() - QPoint((d - 1) / 2, (d - 1) / 2), QSize(d, d));
+ QStyleOptionSlider opt;
+ opt.QStyleOption::operator=(*option);
+ opt.rect = rect;
+ paintCachedDialBase(painter, &opt);
}
QColor
shaded_color(const QColor &color, int shade)
{
#if 1
- const qreal contrast = 1.0;
- int r, g, b;
- color.getRgb(&r, &g, &b);
- int gray = qGray(r, g, b);
- gray = qMax(r, qMax(g, b));
- gray = (r + b + g + 3 * gray) / 6;
- if (shade < 0) {
- qreal k = 220.0 / 255.0 * shade;
- k *= contrast;
- int a = 255;
- if (gray > 0) {
- a = int(k * 255 / (0 - gray));
- if (a < 0) a = 0;
- if (a > 255) a = 255;
- }
- return QColor(0, 0, 0, a);
- } else {
- qreal k = (255 - 220.0) / (255.0) * shade;
- k *= contrast;
- int a = 255;
- if (gray < 255) {
- a = int(k * 255 / (255 - gray));
- if (a < 0) a = 0;
- if (a > 255) a = 255;
- }
- return QColor(255, 255, 255, a);
- }
+ const qreal contrast = 1.0;
+ int r, g, b;
+ color.getRgb(&r, &g, &b);
+ int gray = qGray(r, g, b);
+ gray = qMax(r, qMax(g, b));
+ gray = (r + b + g + 3 * gray) / 6;
+ if (shade < 0)
+ {
+ qreal k = 220.0 / 255.0 * shade;
+ k *= contrast;
+ int a = 255;
+ if (gray > 0)
+ {
+ a = int(k * 255 / (0 - gray));
+ if (a < 0) a = 0;
+ if (a > 255) a = 255;
+ }
+ return QColor(0, 0, 0, a);
+ }
+ else
+ {
+ qreal k = (255 - 220.0) / (255.0) * shade;
+ k *= contrast;
+ int a = 255;
+ if (gray < 255)
+ {
+ a = int(k * 255 / (255 - gray));
+ if (a < 0) a = 0;
+ if (a > 255) a = 255;
+ }
+ return QColor(255, 255, 255, a);
+ }
#else
- if (shade < 0) {
- return QColor(0, 0, 0, -shade);
- } else {
- return QColor(255, 255, 255, shade);
- }
+ if (shade < 0)
+ {
+ return QColor(0, 0, 0, -shade);
+ }
+ else
+ {
+ return QColor(255, 255, 255, shade);
+ }
#endif
}
static void
paintGrip(QPainter *painter, const QStyleOption *option)
{
- //painter->fillRect(option->rect, Qt::red);
- int d = qMin(option->rect.width(), option->rect.height());
- // good values are 3 (very small), 4 (small), 5 (good), 7 (large), 9 (huge)
- // int d = 5;
- QRectF rect(QRectF(option->rect).center() - QPointF(d / 2.0, d / 2.0), QSizeF(d, d));
- const qreal angle = option->direction == Qt::LeftToRight ? 135.0 : 45.0;
+ //painter->fillRect(option->rect, Qt::red);
+ int d = qMin(option->rect.width(), option->rect.height());
+ // good values are 3 (very small), 4 (small), 5 (good), 7 (large), 9 (huge)
+ // int d = 5;
+ QRectF rect(QRectF(option->rect).center() - QPointF(d / 2.0, d / 2.0), QSizeF(d, d));
+ const qreal angle = option->direction == Qt::LeftToRight ? 135.0 : 45.0;
// const qreal angle = 90;
- QColor color;
- qreal opacity = 0.9;
-
- painter->save();
- painter->setRenderHint(QPainter::Antialiasing);
- painter->setPen(Qt::NoPen);
- if (option->state & QStyle::State_Enabled) {
- if (option->state & QStyle::State_Sunken) {
- color = option->palette.color(QPalette::Highlight).darker(110);
- } else {
- color = option->palette.color(QPalette::Button);
- }
- } else {
- color = option->palette.color(QPalette::Button);
- opacity = 0.5;
- }
-
- QConicalGradient gradient1(rect.center(), angle);
- gradient1.setColorAt(0.0, shaded_color(color, -110));
- gradient1.setColorAt(0.25, shaded_color(color, -30));
- gradient1.setColorAt(0.5, shaded_color(color, 180));
- gradient1.setColorAt(0.75, shaded_color(color, -30));
- gradient1.setColorAt(1.0, shaded_color(color, -110));
- painter->setBrush(color);
- painter->drawEllipse(rect);
- painter->setBrush(gradient1);
+ QColor color;
+ qreal opacity = 0.9;
+
+ painter->save();
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->setPen(Qt::NoPen);
+ if (option->state & QStyle::State_Enabled)
+ {
+ if (option->state & QStyle::State_Sunken)
+ {
+ color = option->palette.color(QPalette::Highlight).darker(110);
+ }
+ else
+ {
+ color = option->palette.color(QPalette::Button);
+ }
+ }
+ else
+ {
+ color = option->palette.color(QPalette::Button);
+ opacity = 0.5;
+ }
+
+ QConicalGradient gradient1(rect.center(), angle);
+ gradient1.setColorAt(0.0, shaded_color(color, -110));
+ gradient1.setColorAt(0.25, shaded_color(color, -30));
+ gradient1.setColorAt(0.5, shaded_color(color, 180));
+ gradient1.setColorAt(0.75, shaded_color(color, -30));
+ gradient1.setColorAt(1.0, shaded_color(color, -110));
+ painter->setBrush(color);
+ painter->drawEllipse(rect);
+ painter->setBrush(gradient1);
#if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0))
- // ### merge opacity into color
- painter->setOpacity(opacity);
+ // ### merge opacity into color
+ painter->setOpacity(opacity);
#endif
- painter->drawEllipse(rect);
+ painter->drawEllipse(rect);
#if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0))
- painter->setOpacity(1.0);
- if (d > 2) {
- QConicalGradient gradient2(rect.center(), angle);
- gradient2.setColorAt(0.0, shaded_color(color, -40));
- gradient2.setColorAt(0.25, shaded_color(color, 0));
- gradient2.setColorAt(0.5, shaded_color(color, 210));
- gradient2.setColorAt(0.75, shaded_color(color, 0));
- gradient2.setColorAt(1.0, shaded_color(color, -40));
- rect.adjust(1, 1, -1, -1);
- painter->setBrush(color);
- painter->drawEllipse(rect);
- painter->setBrush(gradient2);
- painter->setOpacity(opacity);
- painter->drawEllipse(rect);
- painter->setOpacity(1.0);
- if (d > 8) {
- QConicalGradient gradient3(rect.center(), angle);
- gradient3.setColorAt(0.0, shaded_color(color, -10));
- gradient3.setColorAt(0.25, shaded_color(color, 0));
- gradient3.setColorAt(0.5, shaded_color(color, 180));
- gradient3.setColorAt(0.75, shaded_color(color, 0));
- gradient3.setColorAt(1.0, shaded_color(color, -10));
- rect.adjust(2, 2, -2, -2);
- painter->setBrush(color);
- painter->drawEllipse(rect);
- painter->setBrush(gradient3);
- painter->setOpacity(opacity);
- painter->drawEllipse(rect);
- painter->setOpacity(1.0);
- }
- }
+ painter->setOpacity(1.0);
+ if (d > 2)
+ {
+ QConicalGradient gradient2(rect.center(), angle);
+ gradient2.setColorAt(0.0, shaded_color(color, -40));
+ gradient2.setColorAt(0.25, shaded_color(color, 0));
+ gradient2.setColorAt(0.5, shaded_color(color, 210));
+ gradient2.setColorAt(0.75, shaded_color(color, 0));
+ gradient2.setColorAt(1.0, shaded_color(color, -40));
+ rect.adjust(1, 1, -1, -1);
+ painter->setBrush(color);
+ painter->drawEllipse(rect);
+ painter->setBrush(gradient2);
+ painter->setOpacity(opacity);
+ painter->drawEllipse(rect);
+ painter->setOpacity(1.0);
+ if (d > 8)
+ {
+ QConicalGradient gradient3(rect.center(), angle);
+ gradient3.setColorAt(0.0, shaded_color(color, -10));
+ gradient3.setColorAt(0.25, shaded_color(color, 0));
+ gradient3.setColorAt(0.5, shaded_color(color, 180));
+ gradient3.setColorAt(0.75, shaded_color(color, 0));
+ gradient3.setColorAt(1.0, shaded_color(color, -10));
+ rect.adjust(2, 2, -2, -2);
+ painter->setBrush(color);
+ painter->drawEllipse(rect);
+ painter->setBrush(gradient3);
+ painter->setOpacity(opacity);
+ painter->drawEllipse(rect);
+ painter->setOpacity(1.0);
+ }
+ }
#endif
- painter->restore();
+ painter->restore();
}
void
paintCachedGrip(QPainter *painter, const QStyleOption *option)
{
- bool useCache = UsePixmapCache;
- QString pixmapName;
-
- if (/* option->state & (QStyle::State_HasFocus | QStyle::State_MouseOver) ||*/ option->rect.width() * option->rect.height() > 4096) {
- useCache = false;
- }
- if (useCache) {
- QStyle::State state = option->state & (QStyle::State_Enabled | QStyle::State_On | QStyle::State_MouseOver | QStyle::State_Sunken | QStyle::State_HasFocus);
- if (!(state & QStyle::State_Enabled)) {
- state &= ~(QStyle::State_MouseOver | QStyle::State_HasFocus);
- }
- state &= ~(QStyle::State_HasFocus);
- QByteArray colorName = option->palette.color(QPalette::Button).name().toLatin1();
- pixmapName = QString("scp-isg-%1-%2-%3-%4-%5")
- .arg(state, 0, 16)
- .arg(option->direction, 0, 16)
- .arg(QString(colorName))
- .arg(option->rect.width(), 0, 16)
- .arg(option->rect.height(), 0, 16);
- }
- paintIndicatorCached(painter,option,
- [=](QPainter *painter,const QStyleOption *option){
- QStyleOption opt(*option);
- opt.rect.moveTo(0, 0);
- paintGrip(painter,&opt);
- },
- useCache,pixmapName);
+ bool useCache = UsePixmapCache;
+ QString pixmapName;
+
+ if (/* option->state & (QStyle::State_HasFocus | QStyle::State_MouseOver) ||*/ option->rect.width() * option->rect.height() > 4096)
+ {
+ useCache = false;
+ }
+ if (useCache)
+ {
+ QStyle::State state = option->state & (QStyle::State_Enabled | QStyle::State_On | QStyle::State_MouseOver | QStyle::State_Sunken | QStyle::State_HasFocus);
+ if (!(state & QStyle::State_Enabled))
+ {
+ state &= ~(QStyle::State_MouseOver | QStyle::State_HasFocus);
+ }
+ state &= ~(QStyle::State_HasFocus);
+ QByteArray colorName = option->palette.color(QPalette::Button).name().toLatin1();
+ pixmapName = QString("scp-isg-%1-%2-%3-%4-%5")
+ .arg(state, 0, 16)
+ .arg(option->direction, 0, 16)
+ .arg(QString(colorName))
+ .arg(option->rect.width(), 0, 16)
+ .arg(option->rect.height(), 0, 16);
+ }
+ paintIndicatorCached(painter, option,
+ [ = ](QPainter * painter, const QStyleOption * option)
+ {
+ QStyleOption opt(*option);
+ opt.rect.moveTo(0, 0);
+ paintGrip(painter, &opt);
+ },
+ useCache, pixmapName);
}
void
-QDialSkulptureStyle::drawComplexControl( ComplexControl cc,
- const QStyleOptionComplex *optc,
- QPainter *painter,
- const QWidget *widget) const
+QDialSkulptureStyle::drawComplexControl(ComplexControl cc,
+ const QStyleOptionComplex *optc,
+ QPainter *painter,
+ const QWidget *widget) const
{
- if (cc != QStyle::CC_Dial) {
- QCommonStyle::drawComplexControl(cc, optc, painter, widget);
- return;
- }
-
- const QStyleOptionSlider *option = qstyleoption_cast<const QStyleOptionSlider *>(optc);
- if (option == nullptr)
- return;
-
- int d = qMin(option->rect.width() & ~1, option->rect.height() & ~1);
- QStyleOptionSlider opt = *option;
- const QAbstractSlider *slider = nullptr;
- // always highlight knob if pressed (even if mouse is not over knob)
- if ((option->state & QStyle::State_HasFocus) && (slider = qobject_cast<const QAbstractSlider *>(widget))) {
- if (slider->isSliderDown()) {
- opt.state |= QStyle::State_MouseOver;
- }
- }
-
- // tickmarks
- opt.palette.setColor(QPalette::Inactive, QPalette::WindowText, QColor(80, 80, 80, 255));
- opt.palette.setColor(QPalette::Active, QPalette::WindowText, QColor(80, 80, 80, 255));
- opt.state &= ~QStyle::State_HasFocus;
- opt.rect.setWidth(opt.rect.width() & ~1);
- opt.rect.setHeight(opt.rect.height() & ~1);
- opt.rect.moveCenter(option->rect.center());
- QCommonStyle::drawComplexControl(QStyle::CC_Dial, &opt, painter, widget);
-
- // focus rectangle
- if (option->state & QStyle::State_HasFocus) {
- QStyleOptionFocusRect focus;
- opt.state |= QStyle::State_HasFocus;
- focus.QStyleOption::operator=(opt);
- focus.rect.adjust(-1, -1, 1, 1);
- //drawPrimitive(QStyle::PE_FrameFocusRect, &focus, painter, widget);
- }
- opt.palette = option->palette;
-
- // dial base
- if (d <= 256) {
- QStyleOptionSlider topt(opt);
- topt.rect.adjust(2,2,-2,-2);
- topt.rect.moveCenter(option->rect.center());
- paintIndicatorDial(painter, &topt);
- } else {
- // large dials are slow to render, do not render them
- }
-
- // dial knob
- d -= 6;
- int gripSize = (option->fontMetrics.height() / 4) * 2 - 1;
- opt.rect.setSize(QSize(gripSize, gripSize));
- opt.rect.moveCenter(option->rect.center());
- // angle calculation from qcommonstyle.cpp (c) Trolltech 1992-2007, ASA.
- qreal angle;
- int sliderPosition = option->upsideDown ? option->sliderPosition : (option->maximum - option->sliderPosition);
- int range = option->maximum - option->minimum;
- if (!range) {
- angle = M_PI / 2;
- } else if (option->dialWrapping) {
- angle = M_PI * 1.5 - (sliderPosition - option->minimum) * 2 * M_PI / range;
- } else {
- angle = (M_PI * 8 - (sliderPosition - option->minimum) * 10 * M_PI / range) / 6;
- }
-
- qreal rr = d / 2.0 - gripSize - 2;
- opt.rect.translate(int(0.5 + rr * cos(angle)), int(0.5 - rr * sin(angle)));
- paintCachedGrip(painter, &opt);
+ if (cc != QStyle::CC_Dial)
+ {
+ QCommonStyle::drawComplexControl(cc, optc, painter, widget);
+ return;
+ }
+
+ const QStyleOptionSlider *option = qstyleoption_cast<const QStyleOptionSlider *>(optc);
+ if (option == nullptr)
+ return;
+
+ int d = qMin(option->rect.width() & ~1, option->rect.height() & ~1);
+ QStyleOptionSlider opt = *option;
+ const QAbstractSlider *slider = nullptr;
+ // always highlight knob if pressed (even if mouse is not over knob)
+ if ((option->state & QStyle::State_HasFocus) && (slider = qobject_cast<const QAbstractSlider *>(widget)))
+ {
+ if (slider->isSliderDown())
+ {
+ opt.state |= QStyle::State_MouseOver;
+ }
+ }
+
+ // tickmarks
+ opt.palette.setColor(QPalette::Inactive, QPalette::WindowText, QColor(80, 80, 80, 255));
+ opt.palette.setColor(QPalette::Active, QPalette::WindowText, QColor(80, 80, 80, 255));
+ opt.state &= ~QStyle::State_HasFocus;
+ opt.rect.setWidth(opt.rect.width() & ~1);
+ opt.rect.setHeight(opt.rect.height() & ~1);
+ opt.rect.moveCenter(option->rect.center());
+ QCommonStyle::drawComplexControl(QStyle::CC_Dial, &opt, painter, widget);
+
+ // focus rectangle
+ if (option->state & QStyle::State_HasFocus)
+ {
+ QStyleOptionFocusRect focus;
+ opt.state |= QStyle::State_HasFocus;
+ focus.QStyleOption::operator=(opt);
+ focus.rect.adjust(-1, -1, 1, 1);
+ //drawPrimitive(QStyle::PE_FrameFocusRect, &focus, painter, widget);
+ }
+ opt.palette = option->palette;
+
+ // dial base
+ if (d <= 256)
+ {
+ QStyleOptionSlider topt(opt);
+ topt.rect.adjust(2, 2, -2, -2);
+ topt.rect.moveCenter(option->rect.center());
+ paintIndicatorDial(painter, &topt);
+ }
+ else
+ {
+ // large dials are slow to render, do not render them
+ }
+
+ // dial knob
+ d -= 6;
+ int gripSize = (option->fontMetrics.height() / 4) * 2 - 1;
+ opt.rect.setSize(QSize(gripSize, gripSize));
+ opt.rect.moveCenter(option->rect.center());
+ // angle calculation from qcommonstyle.cpp (c) Trolltech 1992-2007, ASA.
+ qreal angle;
+ int sliderPosition = option->upsideDown ? option->sliderPosition : (option->maximum - option->sliderPosition);
+ int range = option->maximum - option->minimum;
+ if (!range)
+ {
+ angle = M_PI / 2;
+ }
+ else if (option->dialWrapping)
+ {
+ angle = M_PI * 1.5 - (sliderPosition - option->minimum) * 2 * M_PI / range;
+ }
+ else
+ {
+ angle = (M_PI * 8 - (sliderPosition - option->minimum) * 10 * M_PI / range) / 6;
+ }
+
+ qreal rr = d / 2.0 - gripSize - 2;
+ opt.rect.translate(int(0.5 + rr * cos(angle)), int(0.5 - rr * sin(angle)));
+ paintCachedGrip(painter, &opt);
}
diff --git a/qmidiplayer-desktop/qdialskulpturestyle.hpp b/qmidiplayer-desktop/qdialskulpturestyle.hpp
index 2f3ba04..42a8e0d 100644
--- a/qmidiplayer-desktop/qdialskulpturestyle.hpp
+++ b/qmidiplayer-desktop/qdialskulpturestyle.hpp
@@ -25,14 +25,14 @@
#include <QCommonStyle>
-class QDialSkulptureStyle:public QCommonStyle
+class QDialSkulptureStyle : public QCommonStyle
{
public:
- QDialSkulptureStyle(){}
- virtual ~QDialSkulptureStyle(){}
+ QDialSkulptureStyle() {}
+ virtual ~QDialSkulptureStyle() {}
- virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *widget=0) const;
+ virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
+ const QWidget *widget = nullptr) const;
};
diff --git a/qmidiplayer-desktop/qmpchanneleditor.cpp b/qmidiplayer-desktop/qmpchanneleditor.cpp
index 5343c1c..8f92932 100644
--- a/qmidiplayer-desktop/qmpchanneleditor.cpp
+++ b/qmidiplayer-desktop/qmpchanneleditor.cpp
@@ -4,140 +4,163 @@
#include "qmpmainwindow.hpp"
qmpChannelEditor::qmpChannelEditor(QWidget *parent):
- QDialog(parent),
- ui(new Ui::qmpChannelEditor)
+ QDialog(parent),
+ ui(new Ui::qmpChannelEditor)
{
- ui->setupUi(this);ch=0;
- styl=new QDialSkulptureStyle();
- dials=findChildren<QDial*>();
- for(auto&d:dials)
- d->setStyle(styl);
+ ui->setupUi(this);
+ ch = 0;
+ styl = new QDialSkulptureStyle();
+ dials = findChildren<QDial *>();
+ for (auto &d : dials)
+ d->setStyle(styl);
}
qmpChannelEditor::~qmpChannelEditor()
{
- delete styl;
- delete ui;
+ delete styl;
+ delete ui;
}
void qmpChannelEditor::setupWindow(int chid)
{
- char str[256];if(~chid)ch=chid;
- setWindowTitle(tr("Channel Parameter Editor - Channel #%1").arg(ch+1));
- CMidiPlayer* player=qmpMainWindow::getInstance()->getPlayer();
- uint16_t b;uint8_t p;std::string pstn;
- if(!player->getChannelOutputDevice(ch)->getChannelPreset(ch,&b,&p,pstn))
- {
- b=player->getCC(ch,0)<<7|player->getCC(ch,32);
- p=player->getCC(ch,128);
- pstn=player->getChannelOutputDevice(ch)->getPresetName(b,p);
- }
- ui->lbPresetName->setText(pstn.c_str());
- sprintf(str,"BK: %03d",b);ui->lbBank->setText(str);
- sprintf(str,"PC: %03d",p);ui->lbPreset->setText(str);
- ui->lbChannelNumber->setText(QString::number(ch+1));
- auto setupControl=[this,player](int ccid,QLabel* lb,QDial* d,QString ccname,std::function<QString(uint16_t)> valconv)
- {
- uint16_t b=player->getCC(ch,ccid);
- lb->setText(QString("%1 %2").arg(ccname).arg(valconv(b)));
- d->setValue(b);
- };
- auto defconv=std::bind(static_cast<QString(*)(uint,int)>(&QString::number),std::placeholders::_1,10);
- auto panconv=[](uint v)->QString{
- if(v==64)return tr("C");
- else if(v<64)return tr("L%1").arg(64-v);
- else return tr("R%1").arg(v-64);
- };
- setupControl(7,ui->lbVol,ui->dVol,tr("Vol."),defconv);
- setupControl(91,ui->lbReverb,ui->dReverb,tr("Rev."),defconv);
- setupControl(93,ui->lbChorus,ui->dChorus,tr("Chr."),defconv);
- setupControl(71,ui->lbReso,ui->dReso,tr("Res."),defconv);
- setupControl(74,ui->lbCut,ui->dCut,tr("Cut."),defconv);
- setupControl(73,ui->lbAttack,ui->dAttack,tr("Atk."),defconv);
- setupControl(75,ui->lbDecay,ui->dDecay,tr("Dec."),defconv);
- setupControl(72,ui->lbRelease,ui->dRelease,tr("Rel."),defconv);
- setupControl(76,ui->lbRate,ui->dRate,tr("Rate"),defconv);
- setupControl(77,ui->lbDepth,ui->dDepth,tr("Dep."),defconv);
- setupControl(78,ui->lbDelay,ui->dDelay,tr("Del."),defconv);
- setupControl(10,ui->lbPan,ui->dPan,tr("Pan."),panconv);
+ char str[256];
+ if (~chid)
+ ch = chid;
+ setWindowTitle(tr("Channel Parameter Editor - Channel #%1").arg(ch + 1));
+ CMidiPlayer *player = qmpMainWindow::getInstance()->getPlayer();
+ uint16_t b;
+ uint8_t p;
+ std::string pstn;
+ if (!player->getChannelOutputDevice(ch)->getChannelPreset(ch, &b, &p, pstn))
+ {
+ b = player->getCC(ch, 0) << 7 | player->getCC(ch, 32);
+ p = player->getCC(ch, 128);
+ pstn = player->getChannelOutputDevice(ch)->getPresetName(b, p);
+ }
+ ui->lbPresetName->setText(pstn.c_str());
+ sprintf(str, "BK: %03d", b);
+ ui->lbBank->setText(str);
+ sprintf(str, "PC: %03d", p);
+ ui->lbPreset->setText(str);
+ ui->lbChannelNumber->setText(QString::number(ch + 1));
+ auto setupControl = [this, player](int ccid, QLabel *lb, QDial *d, QString ccname, std::function<QString(uint16_t)> valconv)
+ {
+ uint16_t b = player->getCC(ch, ccid);
+ lb->setText(QString("%1 %2").arg(ccname).arg(valconv(b)));
+ d->setValue(b);
+ };
+ auto defconv = std::bind(static_cast<QString(*)(uint, int)>(&QString::number), std::placeholders::_1, 10);
+ auto panconv = [](uint v)->QString
+ {
+ if (v == 64)
+ return tr("C");
+ else if (v < 64)
+ return tr("L%1").arg(64 - v);
+ else return tr("R%1").arg(v - 64);
+ };
+ setupControl(7, ui->lbVol, ui->dVol, tr("Vol."), defconv);
+ setupControl(91, ui->lbReverb, ui->dReverb, tr("Rev."), defconv);
+ setupControl(93, ui->lbChorus, ui->dChorus, tr("Chr."), defconv);
+ setupControl(71, ui->lbReso, ui->dReso, tr("Res."), defconv);
+ setupControl(74, ui->lbCut, ui->dCut, tr("Cut."), defconv);
+ setupControl(73, ui->lbAttack, ui->dAttack, tr("Atk."), defconv);
+ setupControl(75, ui->lbDecay, ui->dDecay, tr("Dec."), defconv);
+ setupControl(72, ui->lbRelease, ui->dRelease, tr("Rel."), defconv);
+ setupControl(76, ui->lbRate, ui->dRate, tr("Rate"), defconv);
+ setupControl(77, ui->lbDepth, ui->dDepth, tr("Dep."), defconv);
+ setupControl(78, ui->lbDelay, ui->dDelay, tr("Del."), defconv);
+ setupControl(10, ui->lbPan, ui->dPan, tr("Pan."), panconv);
}
void qmpChannelEditor::sendCC()
{
- CMidiPlayer* player=qmpMainWindow::getInstance()->getPlayer();
- player->setCC(ch,7,ui->dVol->value());
- player->setCC(ch,10,ui->dPan->value());
- player->setCC(ch,91,ui->dReverb->value());
- player->setCC(ch,93,ui->dChorus->value());
- player->setCC(ch,71,ui->dReso->value());
- player->setCC(ch,74,ui->dCut->value());
- player->setCC(ch,73,ui->dAttack->value());
- player->setCC(ch,75,ui->dDecay->value());
- player->setCC(ch,72,ui->dRelease->value());
- player->setCC(ch,76,ui->dRate->value());
- player->setCC(ch,77,ui->dDepth->value());
- player->setCC(ch,78,ui->dDelay->value());
- qmpMainWindow::getInstance()->invokeCallback("channel.ccchange",nullptr);
+ CMidiPlayer *player = qmpMainWindow::getInstance()->getPlayer();
+ player->setCC(ch, 7, ui->dVol->value());
+ player->setCC(ch, 10, ui->dPan->value());
+ player->setCC(ch, 91, ui->dReverb->value());
+ player->setCC(ch, 93, ui->dChorus->value());
+ player->setCC(ch, 71, ui->dReso->value());
+ player->setCC(ch, 74, ui->dCut->value());
+ player->setCC(ch, 73, ui->dAttack->value());
+ player->setCC(ch, 75, ui->dDecay->value());
+ player->setCC(ch, 72, ui->dRelease->value());
+ player->setCC(ch, 76, ui->dRate->value());
+ player->setCC(ch, 77, ui->dDepth->value());
+ player->setCC(ch, 78, ui->dDelay->value());
+ qmpMainWindow::getInstance()->invokeCallback("channel.ccchange", nullptr);
}
void qmpChannelEditor::showEvent(QShowEvent *e)
{
- knobpressed=0;
- setupWindow();
- connectSlots();
- updconn=connect(qmpMainWindow::getInstance()->getTimer(),&QTimer::timeout,std::bind(&qmpChannelEditor::setupWindow,this,-1));
- e->accept();
+ knobpressed = 0;
+ setupWindow();
+ connectSlots();
+ updconn = connect(qmpMainWindow::getInstance()->getTimer(), &QTimer::timeout, std::bind(&qmpChannelEditor::setupWindow, this, -1));
+ e->accept();
}
void qmpChannelEditor::closeEvent(QCloseEvent *e)
{
- disconnectSlots();
- disconnect(updconn);
- e->accept();
+ disconnectSlots();
+ disconnect(updconn);
+ e->accept();
}
void qmpChannelEditor::on_pbChLeft_clicked()
{
- disconnectSlots();
- if(ch>0)--ch;else ch=15;setupWindow();
- connectSlots();
+ disconnectSlots();
+ if (ch > 0)
+ --ch;
+ else ch = 15;
+ setupWindow();
+ connectSlots();
}
void qmpChannelEditor::on_pbChRight_clicked()
{
- disconnectSlots();
- if(ch<15)++ch;else ch=0;setupWindow();
- connectSlots();
+ disconnectSlots();
+ if (ch < 15)
+ ++ch;
+ else ch = 0;
+ setupWindow();
+ connectSlots();
}
void qmpChannelEditor::commonPressed()
{
- disconnect(updconn);
- knobpressed=1;
+ disconnect(updconn);
+ knobpressed = 1;
}
void qmpChannelEditor::commonReleased()
{
- updconn=connect(qmpMainWindow::getInstance()->getTimer(),&QTimer::timeout,std::bind(&qmpChannelEditor::setupWindow,this,-1));
- sendCC();knobpressed=0;
+ updconn = connect(qmpMainWindow::getInstance()->getTimer(), &QTimer::timeout, std::bind(&qmpChannelEditor::setupWindow, this, -1));
+ sendCC();
+ knobpressed = 0;
}
void qmpChannelEditor::commonChanged()
-{if(knobpressed){sendCC();setupWindow();}}
+{
+ if (knobpressed)
+ {
+ sendCC();
+ setupWindow();
+ }
+}
void qmpChannelEditor::connectSlots()
{
- for(auto&d:dials)
- {
- connect(d,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
- connect(d,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
- connect(d,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
- }
+ for (auto &d : dials)
+ {
+ connect(d, &QDial::sliderPressed, this, &qmpChannelEditor::commonPressed);
+ connect(d, &QDial::sliderReleased, this, &qmpChannelEditor::commonReleased);
+ connect(d, &QDial::valueChanged, this, &qmpChannelEditor::commonChanged);
+ }
}
void qmpChannelEditor::disconnectSlots()
{
- for(auto&d:dials)
- {
- disconnect(d,&QDial::sliderPressed,this,&qmpChannelEditor::commonPressed);
- disconnect(d,&QDial::sliderReleased,this,&qmpChannelEditor::commonReleased);
- disconnect(d,&QDial::valueChanged,this,&qmpChannelEditor::commonChanged);
- }
+ for (auto &d : dials)
+ {
+ disconnect(d, &QDial::sliderPressed, this, &qmpChannelEditor::commonPressed);
+ disconnect(d, &QDial::sliderReleased, this, &qmpChannelEditor::commonReleased);
+ disconnect(d, &QDial::valueChanged, this, &qmpChannelEditor::commonChanged);
+ }
}
diff --git a/qmidiplayer-desktop/qmpchanneleditor.hpp b/qmidiplayer-desktop/qmpchanneleditor.hpp
index c7ef028..9749124 100644
--- a/qmidiplayer-desktop/qmpchanneleditor.hpp
+++ b/qmidiplayer-desktop/qmpchanneleditor.hpp
@@ -6,40 +6,41 @@
#include <QCloseEvent>
#include "qdialskulpturestyle.hpp"
-namespace Ui {
- class qmpChannelEditor;
+namespace Ui
+{
+class qmpChannelEditor;
}
class QDial;
-class qmpChannelEditor:public QDialog
+class qmpChannelEditor: public QDialog
{
- Q_OBJECT
+ Q_OBJECT
- public:
- explicit qmpChannelEditor(QWidget *parent=nullptr);
- ~qmpChannelEditor();
- protected:
- void showEvent(QShowEvent *e);
- void closeEvent(QCloseEvent *e);
- public slots:
- void setupWindow(int chid=-1);
+public:
+ explicit qmpChannelEditor(QWidget *parent = nullptr);
+ ~qmpChannelEditor();
+protected:
+ void showEvent(QShowEvent *e);
+ void closeEvent(QCloseEvent *e);
+public slots:
+ void setupWindow(int chid = -1);
- private slots:
- void commonPressed();
- void commonReleased();
- void commonChanged();
- void on_pbChLeft_clicked();
- void on_pbChRight_clicked();
+private slots:
+ void commonPressed();
+ void commonReleased();
+ void commonChanged();
+ void on_pbChLeft_clicked();
+ void on_pbChRight_clicked();
- private:
- Ui::qmpChannelEditor *ui;
- int ch,knobpressed;
- void sendCC();
- void connectSlots();
- void disconnectSlots();
- QList<QDial*> dials;
- QMetaObject::Connection updconn;
- QCommonStyle* styl;
+private:
+ Ui::qmpChannelEditor *ui;
+ int ch, knobpressed;
+ void sendCC();
+ void connectSlots();
+ void disconnectSlots();
+ QList<QDial *> dials;
+ QMetaObject::Connection updconn;
+ QCommonStyle *styl;
};
#endif // QMPCHANNELEDITOR_H
diff --git a/qmidiplayer-desktop/qmpchannelswindow.cpp b/qmidiplayer-desktop/qmpchannelswindow.cpp
index 0854e4c..e22d75e 100644
--- a/qmidiplayer-desktop/qmpchannelswindow.cpp
+++ b/qmidiplayer-desktop/qmpchannelswindow.cpp
@@ -9,360 +9,394 @@
#include "ui_qmpchannelswindow.h"
#include "qmpmainwindow.hpp"
-qmpChannelsModel::qmpChannelsModel(QObject*parent):QAbstractTableModel(parent)
+qmpChannelsModel::qmpChannelsModel(QObject *parent): QAbstractTableModel(parent)
{
- evh=qmpMainWindow::getInstance()->getPlayer()->registerEventHandler(
- [this](const void* _e,void*){
- if(!updatequeued)
- {
- updatequeued=true;
- const SEvent *e=(const SEvent*)(_e);
- if((e->p1&0xF0)==0xC0)
- emit dataChanged(index(e->p1&0xF0,4),index(e->p1&0xF0,4),{Qt::ItemDataRole::DisplayRole});
- QMetaObject::invokeMethod(this, &qmpChannelsModel::updateChannelActivity, Qt::ConnectionType::QueuedConnection);
- }
- }
- ,nullptr,false);
- QTimer*t=new QTimer(this);
- t->setInterval(500);
- t->setSingleShot(false);
- connect(t,&QTimer::timeout,[this](){emit this->dataChanged(this->index(0,4),this->index(15,4),{Qt::ItemDataRole::DisplayRole});});
- memset(mute,0,sizeof(mute));
- memset(solo,0,sizeof(solo));
+ evh = qmpMainWindow::getInstance()->getPlayer()->registerEventHandler(
+ [this](const void *_e, void *)
+ {
+ if (!updatequeued)
+ {
+ updatequeued = true;
+ const SEvent *e = (const SEvent *)(_e);
+ if ((e->p1 & 0xF0) == 0xC0)
+ emit dataChanged(index(e->p1 & 0xF0, 4), index(e->p1 & 0xF0, 4), {Qt::ItemDataRole::DisplayRole});
+ QMetaObject::invokeMethod(this, &qmpChannelsModel::updateChannelActivity, Qt::ConnectionType::QueuedConnection);
+ }
+ }
+ , nullptr, false);
+ QTimer *t = new QTimer(this);
+ t->setInterval(500);
+ t->setSingleShot(false);
+ connect(t, &QTimer::timeout, [this]()
+ {
+ emit this->dataChanged(this->index(0, 4), this->index(15, 4), {Qt::ItemDataRole::DisplayRole});
+ });
+ memset(mute, 0, sizeof(mute));
+ memset(solo, 0, sizeof(solo));
}
-int qmpChannelsModel::columnCount(const QModelIndex&parent)const
-{return parent.isValid()?0:6;}
-int qmpChannelsModel::rowCount(const QModelIndex&parent)const
-{return parent.isValid()?0:16;}
-QModelIndex qmpChannelsModel::parent(const QModelIndex&child)const
+int qmpChannelsModel::columnCount(const QModelIndex &parent)const
{
- Q_UNUSED(child)
- return QModelIndex();
+ return parent.isValid() ? 0 : 6;
}
-QVariant qmpChannelsModel::data(const QModelIndex&index,int role)const
+int qmpChannelsModel::rowCount(const QModelIndex &parent)const
{
- switch(index.column())
- {
- case 0:
- if(role==Qt::ItemDataRole::DecorationRole)
- {
- using namespace std::chrono_literals;
- bool lit=(std::chrono::system_clock::now()-qmpMainWindow::getInstance()->getPlayer()->getLastEventTS()[index.row()])<50ms;
- return lit?QIcon(":/img/ledon.svg"):QIcon(":/img/ledoff.svg");
- }
- break;
- case 1:
- if(role==Qt::ItemDataRole::CheckStateRole)
- return mute[index.row()]?Qt::CheckState::Checked:Qt::CheckState::Unchecked;
- break;
- case 2:
- if(role==Qt::ItemDataRole::CheckStateRole)
- return solo[index.row()]?Qt::CheckState::Checked:Qt::CheckState::Unchecked;
- break;
- case 3:
- if(role==Qt::ItemDataRole::DisplayRole)
- {
- std::vector<std::string> devs=qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices();
- return QString::fromStdString(devs[qmpMainWindow::getInstance()->getPlayer()->getChannelOutput(index.row())]);
- }
- break;
- case 4:
- {
- if(role==Qt::ItemDataRole::DisplayRole)
- {
- int ch=index.row();
- uint16_t b;uint8_t p;
- std::string nm;
- char data[256];
- CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer();
- bool r=plyr->getChannelOutputDevice(ch)->getChannelPreset(ch,&b,&p,nm);
- sprintf(data,"%03d:%03d %s",b,p,nm.c_str());
- if(!r)
- {
- nm=plyr->getChannelOutputDevice(ch)->getPresetName(plyr->getCC(ch,0)<<7|plyr->getCC(ch,32),plyr->getCC(ch,128));
- sprintf(data,"%03d:%03d:%03d %s",plyr->getCC(ch,0),plyr->getCC(ch,32),plyr->getCC(ch,128),nm.c_str());
- }
- return QString(data);
- }
- }
- break;
- case 5:
- if(role==Qt::ItemDataRole::DisplayRole)
- return "...";
- if(role==Qt::ItemDataRole::TextAlignmentRole)
- return Qt::AlignmentFlag::AlignCenter;
- break;
- }
- return QVariant();
+ return parent.isValid() ? 0 : 16;
}
-bool qmpChannelsModel::setData(const QModelIndex&index,const QVariant&value,int role)
+QModelIndex qmpChannelsModel::parent(const QModelIndex &child)const
{
- if(index.column()==3)
- {
- if(role!=Qt::ItemDataRole::DisplayRole)return false;
- std::vector<std::string> dsv=CMidiPlayer::getInstance()->getMidiOutDevices();
- int idx=std::find(dsv.begin(),dsv.end(),value.toString().toStdString())-dsv.begin();
- if(idx==CMidiPlayer::getInstance()->getChannelOutput(index.row()))return false;
- CMidiPlayer::getInstance()->setChannelOutput(index.row(),idx);
- emit dataChanged(index,index,{Qt::DisplayRole});
- return true;
- }
- return false;
+ Q_UNUSED(child)
+ return QModelIndex();
}
-QVariant qmpChannelsModel::headerData(int section,Qt::Orientation orientation,int role)const
+QVariant qmpChannelsModel::data(const QModelIndex &index, int role)const
{
- if(role!=Qt::ItemDataRole::DisplayRole)return QVariant();
- if(orientation==Qt::Orientation::Vertical)
- return section+1;
- switch(section)
- {
- case 0:return QString("A");
- case 1:return QString("M");
- case 2:return QString("S");
- case 3:return QString("Device");
- case 4:return QString("Preset");
- case 5:return QString("...");
- }
- return QString();
+ switch (index.column())
+ {
+ case 0:
+ if (role == Qt::ItemDataRole::DecorationRole)
+ {
+ using namespace std::chrono_literals;
+ bool lit = (std::chrono::system_clock::now() - qmpMainWindow::getInstance()->getPlayer()->getLastEventTS()[index.row()]) < 50ms;
+ return lit ? QIcon(":/img/ledon.svg") : QIcon(":/img/ledoff.svg");
+ }
+ break;
+ case 1:
+ if (role == Qt::ItemDataRole::CheckStateRole)
+ return mute[index.row()] ? Qt::CheckState::Checked : Qt::CheckState::Unchecked;
+ break;
+ case 2:
+ if (role == Qt::ItemDataRole::CheckStateRole)
+ return solo[index.row()] ? Qt::CheckState::Checked : Qt::CheckState::Unchecked;
+ break;
+ case 3:
+ if (role == Qt::ItemDataRole::DisplayRole)
+ {
+ std::vector<std::string> devs = qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices();
+ return QString::fromStdString(devs[qmpMainWindow::getInstance()->getPlayer()->getChannelOutput(index.row())]);
+ }
+ break;
+ case 4:
+ {
+ if (role == Qt::ItemDataRole::DisplayRole)
+ {
+ int ch = index.row();
+ uint16_t b;
+ uint8_t p;
+ std::string nm;
+ char data[256];
+ CMidiPlayer *plyr = qmpMainWindow::getInstance()->getPlayer();
+ bool r = plyr->getChannelOutputDevice(ch)->getChannelPreset(ch, &b, &p, nm);
+ sprintf(data, "%03d:%03d %s", b, p, nm.c_str());
+ if (!r)
+ {
+ nm = plyr->getChannelOutputDevice(ch)->getPresetName(plyr->getCC(ch, 0) << 7 | plyr->getCC(ch, 32), plyr->getCC(ch, 128));
+ sprintf(data, "%03d:%03d:%03d %s", plyr->getCC(ch, 0), plyr->getCC(ch, 32), plyr->getCC(ch, 128), nm.c_str());
+ }
+ return QString(data);
+ }
+ }
+ break;
+ case 5:
+ if (role == Qt::ItemDataRole::DisplayRole)
+ return "...";
+ if (role == Qt::ItemDataRole::TextAlignmentRole)
+ return Qt::AlignmentFlag::AlignCenter;
+ break;
+ }
+ return QVariant();
}
-Qt::ItemFlags qmpChannelsModel::flags(const QModelIndex&idx)const
+bool qmpChannelsModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
- Qt::ItemFlags ret=Qt::ItemFlag::ItemIsEnabled|Qt::ItemFlag::ItemIsSelectable;
- if(idx.column()==1||idx.column()==2)
- ret|=Qt::ItemFlag::ItemIsUserCheckable;
- if(idx.column()==3)
- ret|=Qt::ItemFlag::ItemIsEditable;
- return ret;
+ if (index.column() == 3)
+ {
+ if (role != Qt::ItemDataRole::DisplayRole)
+ return false;
+ std::vector<std::string> dsv = CMidiPlayer::getInstance()->getMidiOutDevices();
+ int idx = std::find(dsv.begin(), dsv.end(), value.toString().toStdString()) - dsv.begin();
+ if (idx == CMidiPlayer::getInstance()->getChannelOutput(index.row()))
+ return false;
+ CMidiPlayer::getInstance()->setChannelOutput(index.row(), idx);
+ emit dataChanged(index, index, {Qt::DisplayRole});
+ return true;
+ }
+ return false;
+}
+QVariant qmpChannelsModel::headerData(int section, Qt::Orientation orientation, int role)const
+{
+ if (role != Qt::ItemDataRole::DisplayRole)
+ return QVariant();
+ if (orientation == Qt::Orientation::Vertical)
+ return section + 1;
+ switch (section)
+ {
+ case 0:
+ return QString("A");
+ case 1:
+ return QString("M");
+ case 2:
+ return QString("S");
+ case 3:
+ return QString("Device");
+ case 4:
+ return QString("Preset");
+ case 5:
+ return QString("...");
+ }
+ return QString();
+}
+Qt::ItemFlags qmpChannelsModel::flags(const QModelIndex &idx)const
+{
+ Qt::ItemFlags ret = Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable;
+ if (idx.column() == 1 || idx.column() == 2)
+ ret |= Qt::ItemFlag::ItemIsUserCheckable;
+ if (idx.column() == 3)
+ ret |= Qt::ItemFlag::ItemIsEditable;
+ return ret;
}
void qmpChannelsModel::updateChannelActivity()
{
- emit dataChanged(index(0,0),index(15,0),{Qt::ItemDataRole::DecorationRole});
- updatequeued=false;
+ emit dataChanged(index(0, 0), index(15, 0), {Qt::ItemDataRole::DecorationRole});
+ updatequeued = false;
}
-void qmpChannelsModel::channelMSClicked(const QModelIndex&idx)
+void qmpChannelsModel::channelMSClicked(const QModelIndex &idx)
{
- bool*x[3]={nullptr,mute,solo};
- if(x[idx.column()][idx.row()]^=1)
- x[3-idx.column()][idx.row()]=0;
- qmpMainWindow::getInstance()->getPlayer()->setMute(idx.row(),mute[idx.row()]);
- qmpMainWindow::getInstance()->getPlayer()->setSolo(idx.row(),solo[idx.row()]);
- emit dataChanged(index(idx.row(),1),index(idx.row(),2),{Qt::ItemDataRole::CheckStateRole});
+ bool *x[3] = {nullptr, mute, solo};
+ if (x[idx.column()][idx.row()] ^= 1)
+ x[3 - idx.column()][idx.row()] = 0;
+ qmpMainWindow::getInstance()->getPlayer()->setMute(idx.row(), mute[idx.row()]);
+ qmpMainWindow::getInstance()->getPlayer()->setSolo(idx.row(), solo[idx.row()]);
+ emit dataChanged(index(idx.row(), 1), index(idx.row(), 2), {Qt::ItemDataRole::CheckStateRole});
}
void qmpChannelsModel::channelMSClearAll(int type)
{
- if(type==1)
- {
- memset(mute,0,sizeof(mute));
- for(int i=0;i<16;++i)
- qmpMainWindow::getInstance()->getPlayer()->setMute(i,0);
- emit dataChanged(index(0,1),index(15,1),{Qt::ItemDataRole::CheckStateRole});
- }
- if(type==2)
- {
- memset(solo,0,sizeof(solo));
- for(int i=0;i<16;++i)
- qmpMainWindow::getInstance()->getPlayer()->setSolo(i,0);
- emit dataChanged(index(0,2),index(15,2),{Qt::ItemDataRole::CheckStateRole});
- }
+ if (type == 1)
+ {
+ memset(mute, 0, sizeof(mute));
+ for (int i = 0; i < 16; ++i)
+ qmpMainWindow::getInstance()->getPlayer()->setMute(i, 0);
+ emit dataChanged(index(0, 1), index(15, 1), {Qt::ItemDataRole::CheckStateRole});
+ }
+ if (type == 2)
+ {
+ memset(solo, 0, sizeof(solo));
+ for (int i = 0; i < 16; ++i)
+ qmpMainWindow::getInstance()->getPlayer()->setSolo(i, 0);
+ emit dataChanged(index(0, 2), index(15, 2), {Qt::ItemDataRole::CheckStateRole});
+ }
}
-qmpDeviceItemDelegate::qmpDeviceItemDelegate(bool ignoreInternal,QWidget*parent):
- QStyledItemDelegate(parent),par(parent),nofs(ignoreInternal){}
-void qmpDeviceItemDelegate::paint(QPainter*painter,const QStyleOptionViewItem&option,const QModelIndex&index)const
+qmpDeviceItemDelegate::qmpDeviceItemDelegate(bool ignoreInternal, QWidget *parent):
+ QStyledItemDelegate(parent), par(parent), nofs(ignoreInternal) {}
+void qmpDeviceItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)const
{
- QStyleOptionViewItem opt;
- initStyleOption(&opt,index);
- QStyleOptionComboBox socb;
- socb.currentText=opt.text;
- socb.editable=false;
- socb.rect=option.rect;
- socb.state=opt.state;
- par->style()->drawComplexControl(QStyle::ComplexControl::CC_ComboBox,&socb,painter,option.widget);
- par->style()->drawControl(QStyle::CE_ComboBoxLabel,&socb,painter,option.widget);
+ QStyleOptionViewItem opt;
+ initStyleOption(&opt, index);
+ QStyleOptionComboBox socb;
+ socb.currentText = opt.text;
+ socb.editable = false;
+ socb.rect = option.rect;
+ socb.state = opt.state;
+ par->style()->drawComplexControl(QStyle::ComplexControl::CC_ComboBox, &socb, painter, option.widget);
+ par->style()->drawControl(QStyle::CE_ComboBoxLabel, &socb, painter, option.widget);
}
-QSize qmpDeviceItemDelegate::sizeHint(const QStyleOptionViewItem&option,const QModelIndex&index)const
+QSize qmpDeviceItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index)const
{
- QStyleOptionViewItem opt;
- initStyleOption(&opt,index);
- QStyleOptionComboBox socb;
- socb.currentText=opt.text;
- socb.editable=false;
- socb.rect=option.rect;
- QSize sz=par->fontMetrics().size(Qt::TextFlag::TextSingleLine,socb.currentText);
- return par->style()->sizeFromContents(QStyle::ContentsType::CT_ComboBox,&socb,sz,option.widget);
+ QStyleOptionViewItem opt;
+ initStyleOption(&opt, index);
+ QStyleOptionComboBox socb;
+ socb.currentText = opt.text;
+ socb.editable = false;
+ socb.rect = option.rect;
+ QSize sz = par->fontMetrics().size(Qt::TextFlag::TextSingleLine, socb.currentText);
+ return par->style()->sizeFromContents(QStyle::ContentsType::CT_ComboBox, &socb, sz, option.widget);
}
-QWidget* qmpDeviceItemDelegate::createEditor(QWidget*parent,const QStyleOptionViewItem&option,const QModelIndex&index)const
+QWidget *qmpDeviceItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index)const
{
- Q_UNUSED(option)
- Q_UNUSED(index)
- QComboBox *cb=new QComboBox(parent);
- cb->setEditable(false);
- connect(cb,static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),this,[index,cb](int){
- const_cast<QAbstractItemModel*>(index.model())->setData(index,cb->currentText(),Qt::ItemDataRole::DisplayRole);
- cb->hidePopup();
- });
- return cb;
+ Q_UNUSED(option)
+ Q_UNUSED(index)
+ QComboBox *cb = new QComboBox(parent);
+ cb->setEditable(false);
+ connect(cb, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [index, cb](int)
+ {
+ const_cast<QAbstractItemModel *>(index.model())->setData(index, cb->currentText(), Qt::ItemDataRole::DisplayRole);
+ cb->hidePopup();
+ });
+ return cb;
}
-void qmpDeviceItemDelegate::setEditorData(QWidget*widget,const QModelIndex&index)const
+void qmpDeviceItemDelegate::setEditorData(QWidget *widget, const QModelIndex &index)const
{
- /*
- * We want to quit editing as soon as the popup of the combobox is closed.
- * Unfortunately QTableView does not do that. And I don't feel like sub-classing
- * it. So here are some dirty tricks to make it work that way.
- */
- QComboBox *cb=qobject_cast<QComboBox*>(widget);
- QSignalBlocker sblk(cb);
- cb->clear();
- std::vector<std::string> devs=qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices();
- for(auto s:devs)
- if(!nofs||(nofs&&s!="Internal FluidSynth"))
- cb->addItem(QString::fromStdString(s));
- cb->setCurrentText(index.data().toString());
- cb->showPopup();
+ /*
+ * We want to quit editing as soon as the popup of the combobox is closed.
+ * Unfortunately QTableView does not do that. And I don't feel like sub-classing
+ * it. So here are some dirty tricks to make it work that way.
+ */
+ QComboBox *cb = qobject_cast<QComboBox *>(widget);
+ QSignalBlocker sblk(cb);
+ cb->clear();
+ std::vector<std::string> devs = qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices();
+ for (auto s : devs)
+ if (!nofs || (nofs && s != "Internal FluidSynth"))
+ cb->addItem(QString::fromStdString(s));
+ cb->setCurrentText(index.data().toString());
+ cb->showPopup();
}
-void qmpDeviceItemDelegate::setModelData(QWidget*editor,QAbstractItemModel*model,const QModelIndex&index)const
+void qmpDeviceItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index)const
{
- QComboBox *cb=qobject_cast<QComboBox*>(editor);
- model->setData(index,cb->currentText(),Qt::ItemDataRole::DisplayRole);
+ QComboBox *cb = qobject_cast<QComboBox *>(editor);
+ model->setData(index, cb->currentText(), Qt::ItemDataRole::DisplayRole);
}
-void qmpDeviceItemDelegate::updateEditorGeometry(QWidget*editor,const QStyleOptionViewItem&option,const QModelIndex&index)const
+void qmpDeviceItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index)const
{
- Q_UNUSED(index)
- editor->setGeometry(option.rect);
+ Q_UNUSED(index)
+ editor->setGeometry(option.rect);
}
-qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) :
- QWidget(parent,Qt::Dialog),
- ui(new Ui::qmpChannelsWindow)
+qmpChannelsWindow::qmpChannelsWindow(QWidget *parent):
+ QWidget(parent, Qt::Dialog),
+ ui(new Ui::qmpChannelsWindow)
{
- ui->setupUi(this);
- mainwindow=qmpMainWindow::getInstance();
- ui->tvChannels->setHorizontalHeader(new QHeaderView(Qt::Orientation::Horizontal));
- ui->tvChannels->setModel(chmodel=new qmpChannelsModel(ui->tvChannels));
- ui->tvChannels->setItemDelegateForColumn(3,new qmpDeviceItemDelegate(false,ui->tvChannels));
- ui->tvChannels->setAlternatingRowColors(true);
- ui->tvChannels->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
- ui->tvChannels->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
- ui->tvChannels->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeMode::Stretch);
- connect(ui->tvChannels,&QTableView::clicked,[this](const QModelIndex&idx){
- if(idx.column()==1||idx.column()==2)
- this->chmodel->channelMSClicked(idx);
- if(idx.column()==3)
- this->ui->tvChannels->edit(idx);
- if(idx.column()==5)
- this->showChannelEditorWindow(idx.row());
- });
- connect(ui->tvChannels,&QTableView::activated,[this](const QModelIndex&idx){
- if(idx.column()==4)
- {
- pselectw->show();
- pselectw->setupWindow(idx.row());
- }
- });
- pselectw=new qmpPresetSelector(this);
- ceditw=new qmpChannelEditor(this);
- cha=new QIcon(":/img/ledon.svg");chi=new QIcon(":/img/ledoff.svg");
- eh=qmpMainWindow::getInstance()->getPlayer()->registerEventHandler(
- [this](const void *ee,void*){
- const SEvent *e=(const SEvent*)ee;
- if((e->type&0xF0)==0x90&&e->p2>0&&(e->flags&0x01))
- emit this->noteOn();
- }
- ,nullptr,false);
- qmpMainWindow::getInstance()->registerFunctionality(
- chnlf=new qmpChannelFunc(this),
- std::string("Channel"),
- tr("Channel").toStdString(),
- getThemedIconc(":/img/channel.svg"),
- 0,
- true
- );
- if(mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlW",QRect(-999,-999,999,999)).toRect()!=QRect(-999,-999,999,999))
- setGeometry(mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlW",QRect(-999,-999,999,999)).toRect());
- if(mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlWShown",0).toInt())
- {show();qmpMainWindow::getInstance()->setFuncState("Channel",true);}
+ ui->setupUi(this);
+ mainwindow = qmpMainWindow::getInstance();
+ ui->tvChannels->setHorizontalHeader(new QHeaderView(Qt::Orientation::Horizontal));
+ ui->tvChannels->setModel(chmodel = new qmpChannelsModel(ui->tvChannels));
+ ui->tvChannels->setItemDelegateForColumn(3, new qmpDeviceItemDelegate(false, ui->tvChannels));
+ ui->tvChannels->setAlternatingRowColors(true);
+ ui->tvChannels->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
+ ui->tvChannels->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
+ ui->tvChannels->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeMode::Stretch);
+ connect(ui->tvChannels, &QTableView::clicked, [this](const QModelIndex &idx)
+ {
+ if (idx.column() == 1 || idx.column() == 2)
+ this->chmodel->channelMSClicked(idx);
+ if (idx.column() == 3)
+ this->ui->tvChannels->edit(idx);
+ if (idx.column() == 5)
+ this->showChannelEditorWindow(idx.row());
+ });
+ connect(ui->tvChannels, &QTableView::activated, [this](const QModelIndex &idx)
+ {
+ if (idx.column() == 4)
+ {
+ pselectw->show();
+ pselectw->setupWindow(idx.row());
+ }
+ });
+ pselectw = new qmpPresetSelector(this);
+ ceditw = new qmpChannelEditor(this);
+ cha = new QIcon(":/img/ledon.svg");
+ chi = new QIcon(":/img/ledoff.svg");
+ eh = qmpMainWindow::getInstance()->getPlayer()->registerEventHandler(
+ [this](const void *ee, void *)
+ {
+ const SEvent *e = (const SEvent *)ee;
+ if ((e->type & 0xF0) == 0x90 && e->p2 > 0 && (e->flags & 0x01))
+ emit this->noteOn();
+ }
+ , nullptr, false);
+ qmpMainWindow::getInstance()->registerFunctionality(
+ chnlf = new qmpChannelFunc(this),
+ std::string("Channel"),
+ tr("Channel").toStdString(),
+ getThemedIconc(":/img/channel.svg"),
+ 0,
+ true
+ );
+ if (mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlW", QRect(-999, -999, 999, 999)).toRect() != QRect(-999, -999, 999, 999))
+ setGeometry(mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlW", QRect(-999, -999, 999, 999)).toRect());
+ if (mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlWShown", 0).toInt())
+ {
+ show();
+ qmpMainWindow::getInstance()->setFuncState("Channel", true);
+ }
}
void qmpChannelsWindow::showEvent(QShowEvent *event)
{
- if(mainwindow->getSettings()->getOptionBool("Behavior/DialogStatus"))
- {
- mainwindow->getSettings()->setOptionRaw("DialogStatus/ChnlWShown",1);
- }
- if(mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlW",QRect(-999,-999,999,999)).toRect()!=QRect(-999,-999,999,999))
- setGeometry(mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlW",QRect(-999,-999,999,999)).toRect());
- event->accept();
+ if (mainwindow->getSettings()->getOptionBool("Behavior/DialogStatus"))
+ {
+ mainwindow->getSettings()->setOptionRaw("DialogStatus/ChnlWShown", 1);
+ }
+ if (mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlW", QRect(-999, -999, 999, 999)).toRect() != QRect(-999, -999, 999, 999))
+ setGeometry(mainwindow->getSettings()->getOptionRaw("DialogStatus/ChnlW", QRect(-999, -999, 999, 999)).toRect());
+ event->accept();
}
void qmpChannelsWindow::closeEvent(QCloseEvent *event)
{
- if(mainwindow->getSettings()->getOptionBool("Behavior/DialogStatus"))
- {
- mainwindow->getSettings()->setOptionRaw("DialogStatus/ChnlW",geometry());
- }
- setVisible(false);
- if(!qmpMainWindow::getInstance()->isFinalizing()&&mainwindow->getSettings()->getOptionBool("Behavior/DialogStatus"))
- {
- mainwindow->getSettings()->setOptionRaw("DialogStatus/ChnlWShown",0);
- }
- mainwindow->setFuncState("Channel",false);
- event->accept();
+ if (mainwindow->getSettings()->getOptionBool("Behavior/DialogStatus"))
+ {
+ mainwindow->getSettings()->setOptionRaw("DialogStatus/ChnlW", geometry());
+ }
+ setVisible(false);
+ if (!qmpMainWindow::getInstance()->isFinalizing() && mainwindow->getSettings()->getOptionBool("Behavior/DialogStatus"))
+ {
+ mainwindow->getSettings()->setOptionRaw("DialogStatus/ChnlWShown", 0);
+ }
+ mainwindow->setFuncState("Channel", false);
+ event->accept();
}
void qmpChannelsWindow::selectDefaultDevice()
{
- std::string selecteddev;
- std::vector<std::string> devs=mainwindow->getPlayer()->getMidiOutDevices();
- size_t devc=devs.size();
- std::set<std::string> devset;
- for(auto dev:devs)devset.insert(dev);
- QVariant *devpriov=static_cast<QVariant*>(qmpMainWindow::getInstance()->getSettings()->getOptionCustom("Midi/DevicePriority"));
- QList<QVariant> devprio=devpriov->toList();
- delete devpriov;
- for(auto &setdev:devprio)
- if(devset.find(setdev.toString().toStdString())!=devset.end())
- {
- selecteddev=setdev.toString().toStdString();
- break;
- }
- for(int ch=0;ch<16;++ch)
- {
- for(size_t j=0;j<devc;++j)
- {
- if(selecteddev==devs[j])
- mainwindow->getPlayer()->setChannelOutput(ch,j);
- }
- }
+ std::string selecteddev;
+ std::vector<std::string> devs = mainwindow->getPlayer()->getMidiOutDevices();
+ size_t devc = devs.size();
+ std::set<std::string> devset;
+ for (auto dev : devs)
+ devset.insert(dev);
+ QVariant *devpriov = static_cast<QVariant *>(qmpMainWindow::getInstance()->getSettings()->getOptionCustom("Midi/DevicePriority"));
+ QList<QVariant> devprio = devpriov->toList();
+ delete devpriov;
+ for (auto &setdev : devprio)
+ if (devset.find(setdev.toString().toStdString()) != devset.end())
+ {
+ selecteddev = setdev.toString().toStdString();
+ break;
+ }
+ for (int ch = 0; ch < 16; ++ch)
+ {
+ for (size_t j = 0; j < devc; ++j)
+ {
+ if (selecteddev == devs[j])
+ mainwindow->getPlayer()->setChannelOutput(ch, j);
+ }
+ }
}
qmpChannelsWindow::~qmpChannelsWindow()
{
- mainwindow->unregisterFunctionality("Channel");
- mainwindow->getPlayer()->unregisterEventHandler(eh);
- delete chnlf;
- delete chi;delete cha;
- delete ui;
+ mainwindow->unregisterFunctionality("Channel");
+ mainwindow->getPlayer()->unregisterEventHandler(eh);
+ delete chnlf;
+ delete chi;
+ delete cha;
+ delete ui;
}
void qmpChannelsWindow::on_pbUnmute_clicked()
{
- chmodel->channelMSClearAll(1);
+ chmodel->channelMSClearAll(1);
}
void qmpChannelsWindow::on_pbUnsolo_clicked()
{
- chmodel->channelMSClearAll(2);
+ chmodel->channelMSClearAll(2);
}
void qmpChannelsWindow::showChannelEditorWindow(int chid)
{
- ceditw->show();
- ceditw->setupWindow(chid);
+ ceditw->show();
+ ceditw->setupWindow(chid);
}
qmpChannelFunc::qmpChannelFunc(qmpChannelsWindow *par)
-{p=par;}
+{
+ p = par;
+}
void qmpChannelFunc::show()
-{p->show();}
+{
+ p->show();
+}
void qmpChannelFunc::close()
-{p->close();}
+{
+ p->close();
+}
diff --git a/qmidiplayer-desktop/qmpchannelswindow.hpp b/qmidiplayer-desktop/qmpchannelswindow.hpp
index f78d032..c8443e7 100644
--- a/qmidiplayer-desktop/qmpchannelswindow.hpp
+++ b/qmidiplayer-desktop/qmpchannelswindow.hpp
@@ -15,88 +15,89 @@
#include "../core/qmpmidiplay.hpp"
#include "../core/qmpmidioutrtmidi.hpp"
-namespace Ui {
- class qmpChannelsWindow;
+namespace Ui
+{
+class qmpChannelsWindow;
}
class qmpChannelsWindow;
class qmpMainWindow;
-class qmpChannelFunc:public qmpFuncBaseIntf
+class qmpChannelFunc : public qmpFuncBaseIntf
{
- private:
- qmpChannelsWindow *p;
- public:
- qmpChannelFunc(qmpChannelsWindow *par);
- void show();
- void close();
+private:
+ qmpChannelsWindow *p;
+public:
+ qmpChannelFunc(qmpChannelsWindow *par);
+ void show();
+ void close();
};
-class qmpChannelsModel:public QAbstractTableModel
+class qmpChannelsModel : public QAbstractTableModel
{
- Q_OBJECT
- public:
- explicit qmpChannelsModel(QObject*parent=nullptr);
- int columnCount(const QModelIndex&parent=QModelIndex())const override;
- int rowCount(const QModelIndex&parent=QModelIndex())const override;
- QModelIndex parent(const QModelIndex&child)const override;
- QVariant data(const QModelIndex&index,int role=Qt::ItemDataRole::DisplayRole)const override;
- bool setData(const QModelIndex &index,const QVariant &value,int role=Qt::EditRole)override;
- QVariant headerData(int section,Qt::Orientation orientation,int role=Qt::ItemDataRole::DisplayRole)const override;
- Qt::ItemFlags flags(const QModelIndex&idx)const override;
- public slots:
- void updateChannelActivity();
- void channelMSClicked(const QModelIndex&idx);
- void channelMSClearAll(int type);
- private:
- int evh;
- bool updatequeued;
- bool mute[16],solo[16];
+ Q_OBJECT
+public:
+ explicit qmpChannelsModel(QObject *parent = nullptr);
+ int columnCount(const QModelIndex &parent = QModelIndex())const override;
+ int rowCount(const QModelIndex &parent = QModelIndex())const override;
+ QModelIndex parent(const QModelIndex &child)const override;
+ QVariant data(const QModelIndex &index, int role = Qt::ItemDataRole::DisplayRole)const override;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole)override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::ItemDataRole::DisplayRole)const override;
+ Qt::ItemFlags flags(const QModelIndex &idx)const override;
+public slots:
+ void updateChannelActivity();
+ void channelMSClicked(const QModelIndex &idx);
+ void channelMSClearAll(int type);
+private:
+ int evh;
+ bool updatequeued;
+ bool mute[16], solo[16];
};
-class qmpDeviceItemDelegate:public QStyledItemDelegate
+class qmpDeviceItemDelegate: public QStyledItemDelegate
{
- Q_OBJECT
- public:
- explicit qmpDeviceItemDelegate(bool ignoreInternal=false,QWidget*parent=nullptr);
- void paint(QPainter*painter,const QStyleOptionViewItem&option,const QModelIndex&index)const override;
- QSize sizeHint(const QStyleOptionViewItem&option,const QModelIndex&index)const override;
- QWidget* createEditor(QWidget*parent,const QStyleOptionViewItem&option,const QModelIndex&index)const override;
- void setEditorData(QWidget*editor,const QModelIndex&index)const override;
- void setModelData(QWidget*editor,QAbstractItemModel*model,const QModelIndex&index)const override;
- void updateEditorGeometry(QWidget*editor,const QStyleOptionViewItem&option,const QModelIndex&index)const override;
- private:
- QWidget *par;
- bool nofs;
+ Q_OBJECT
+public:
+ explicit qmpDeviceItemDelegate(bool ignoreInternal = false, QWidget *parent = nullptr);
+ void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)const override;
+ QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index)const override;
+ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index)const override;
+ void setEditorData(QWidget *editor, const QModelIndex &index)const override;
+ void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index)const override;
+ void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index)const override;
+private:
+ QWidget *par;
+ bool nofs;
};
-class qmpChannelsWindow:public QWidget
+class qmpChannelsWindow: public QWidget
{
- Q_OBJECT
+ Q_OBJECT
- public:
- explicit qmpChannelsWindow(QWidget *parent=nullptr);
- ~qmpChannelsWindow();
- void showEvent(QShowEvent *event);
- void closeEvent(QCloseEvent *event);
- void selectDefaultDevice();
- public slots:
- void showChannelEditorWindow(int chid);
- void on_pbUnmute_clicked();
- void on_pbUnsolo_clicked();
+public:
+ explicit qmpChannelsWindow(QWidget *parent = nullptr);
+ ~qmpChannelsWindow();
+ void showEvent(QShowEvent *event);
+ void closeEvent(QCloseEvent *event);
+ void selectDefaultDevice();
+public slots:
+ void showChannelEditorWindow(int chid);
+ void on_pbUnmute_clicked();
+ void on_pbUnsolo_clicked();
- signals:
- void noteOn();
+signals:
+ void noteOn();
- private:
- qmpMainWindow* mainwindow;
- Ui::qmpChannelsWindow *ui;
- qmpPresetSelector *pselectw;
- qmpChannelEditor *ceditw;
- qmpChannelsModel *chmodel;
- QIcon *cha,*chi;
- qmpChannelFunc *chnlf;
- int eh;
+private:
+ qmpMainWindow *mainwindow;
+ Ui::qmpChannelsWindow *ui;
+ qmpPresetSelector *pselectw;
+ qmpChannelEditor *ceditw;
+ qmpChannelsModel *chmodel;
+ QIcon *cha, *chi;
+ qmpChannelFunc *chnlf;
+ int eh;
};
#endif // QMPCHANNELSWINDOW_H
diff --git a/qmidiplayer-desktop/qmpcustomizewindow.cpp b/qmidiplayer-desktop/qmpcustomizewindow.cpp
index 0ea3228..f4346b4 100644
--- a/qmidiplayer-desktop/qmpcustomizewindow.cpp
+++ b/qmidiplayer-desktop/qmpcustomizewindow.cpp
@@ -9,83 +9,86 @@
#include "ui_qmpcustomizewindow.h"
qmpCustomizeWindow::qmpCustomizeWindow(QWidget *parent):
- QDialog(parent),
- ui(new Ui::qmpCustomizeWindow)
+ QDialog(parent),
+ ui(new Ui::qmpCustomizeWindow)
{
- ui->setupUi(this);
+ ui->setupUi(this);
}
qmpCustomizeWindow::~qmpCustomizeWindow()
{
- delete ui;
+ delete ui;
}
void qmpCustomizeWindow::load(void *data)
{
- ui->lwAvail->clear();
- ui->lwEnabled->clear();
- QList<QVariant> list=static_cast<QVariant*>(data)->toList();
- std::vector<std::string> v;
- for(auto i:list)
- v.push_back(i.toString().toStdString());
- std::map<std::string,qmpFuncPrivate>& m=qmpMainWindow::getInstance()->getFunc();
- std::set<std::string> s;
- for(auto i=v.begin();i!=v.end();++i)
- {
- if(m.find(*i)==m.end())continue;
- s.insert(*i);
- QListWidgetItem* it=new QListWidgetItem(
- m[*i].icon(),
- QString(m[*i].desc().c_str())
- );
- it->setToolTip(i->c_str());
- ui->lwEnabled->addItem(it);
- }
- for(auto i=m.begin();i!=m.end();++i)
- {
- if(s.find(i->first)==s.end())
- {
- QListWidgetItem* it=new QListWidgetItem(
- i->second.icon(),
- QString(i->second.desc().c_str())
- );
- it->setToolTip(i->first.c_str());
- ui->lwAvail->addItem(it);
- }
- }
+ ui->lwAvail->clear();
+ ui->lwEnabled->clear();
+ QList<QVariant> list = static_cast<QVariant *>(data)->toList();
+ std::vector<std::string> v;
+ for (auto i : list)
+ v.push_back(i.toString().toStdString());
+ std::map<std::string, qmpFuncPrivate> &m = qmpMainWindow::getInstance()->getFunc();
+ std::set<std::string> s;
+ for (auto i = v.begin(); i != v.end(); ++i)
+ {
+ if (m.find(*i) == m.end())
+ continue;
+ s.insert(*i);
+ QListWidgetItem *it = new QListWidgetItem(
+ m[*i].icon(),
+ QString(m[*i].desc().c_str())
+ );
+ it->setToolTip(i->c_str());
+ ui->lwEnabled->addItem(it);
+ }
+ for (auto i = m.begin(); i != m.end(); ++i)
+ {
+ if (s.find(i->first) == s.end())
+ {
+ QListWidgetItem *it = new QListWidgetItem(
+ i->second.icon(),
+ QString(i->second.desc().c_str())
+ );
+ it->setToolTip(i->first.c_str());
+ ui->lwAvail->addItem(it);
+ }
+ }
}
void *qmpCustomizeWindow::save()
{
- QList<QVariant> ret;
- for(int i=0;i<ui->lwEnabled->count();++i)
- {
- ret.push_back(QVariant(ui->lwEnabled->item(i)->toolTip()));
- }
- return new QVariant(ret);
+ QList<QVariant> ret;
+ for (int i = 0; i < ui->lwEnabled->count(); ++i)
+ {
+ ret.push_back(QVariant(ui->lwEnabled->item(i)->toolTip()));
+ }
+ return new QVariant(ret);
}
void qmpCustomizeWindow::on_tbAdd_clicked()
{
- if(!ui->lwAvail->currentItem())return;
- ui->lwEnabled->addItem(ui->lwAvail->takeItem(ui->lwAvail->currentRow()));
- ui->lwAvail->removeItemWidget(ui->lwAvail->currentItem());
+ if (!ui->lwAvail->currentItem())
+ return;
+ ui->lwEnabled->addItem(ui->lwAvail->takeItem(ui->lwAvail->currentRow()));
+ ui->lwAvail->removeItemWidget(ui->lwAvail->currentItem());
}
void qmpCustomizeWindow::on_tbRemove_clicked()
{
- if(!ui->lwEnabled->currentItem())return;
- ui->lwAvail->addItem(ui->lwEnabled->takeItem(ui->lwEnabled->currentRow()));
+ if (!ui->lwEnabled->currentItem())
+ return;
+ ui->lwAvail->addItem(ui->lwEnabled->takeItem(ui->lwEnabled->currentRow()));
}
void qmpCustomizeWindow::on_buttonBox_accepted()
{
- accept();
- close();
+ accept();
+ close();
}
void qmpCustomizeWindow::on_buttonBox_rejected()
{
- reject();
- close();
+ reject();
+ close();
}
diff --git a/qmidiplayer-desktop/qmpcustomizewindow.hpp b/qmidiplayer-desktop/qmpcustomizewindow.hpp
index 321c22e..002d2fc 100644
--- a/qmidiplayer-desktop/qmpcustomizewindow.hpp
+++ b/qmidiplayer-desktop/qmpcustomizewindow.hpp
@@ -3,28 +3,29 @@
#include <QDialog>
-namespace Ui {
+namespace Ui
+{
class qmpCustomizeWindow;
}
-class qmpCustomizeWindow:public QDialog
+class qmpCustomizeWindow: public QDialog
{
- Q_OBJECT
+ Q_OBJECT
- public:
- explicit qmpCustomizeWindow(QWidget *parent=nullptr);
- ~qmpCustomizeWindow();
- void load(void* data);
- void* save();
+public:
+ explicit qmpCustomizeWindow(QWidget *parent = nullptr);
+ ~qmpCustomizeWindow();
+ void load(void *data);
+ void *save();
- private slots:
- void on_tbAdd_clicked();
- void on_tbRemove_clicked();
- void on_buttonBox_accepted();
- void on_buttonBox_rejected();
+private slots:
+ void on_tbAdd_clicked();
+ void on_tbRemove_clicked();
+ void on_buttonBox_accepted();
+ void on_buttonBox_rejected();
- private:
- Ui::qmpCustomizeWindow *ui;
+private:
+ Ui::qmpCustomizeWindow *ui;
};
#endif // QMPCUSTOMIZEWINDOW_HPP
diff --git a/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp b/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp
index bf358d8..9c77e0a 100644
--- a/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp
+++ b/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp
@@ -6,107 +6,108 @@
#include "ui_qmpdeviceprioritydialog.h"
qmpDevicePriorityDialog::qmpDevicePriorityDialog(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::qmpDevicePriorityDialog)
+ QDialog(parent),
+ ui(new Ui::qmpDevicePriorityDialog)
{
- ui->setupUi(this);
- model=new QStandardItemModel(this);
- ui->tvDevices->setModel(model);
- ui->tvDevices->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
- ui->tvDevices->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
- ui->tvDevices->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
- model->setHorizontalHeaderLabels({"E","Device","Connected?"});
+ ui->setupUi(this);
+ model = new QStandardItemModel(this);
+ ui->tvDevices->setModel(model);
+ ui->tvDevices->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
+ ui->tvDevices->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
+ ui->tvDevices->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
+ model->setHorizontalHeaderLabels({"E", "Device", "Connected?"});
}
qmpDevicePriorityDialog::~qmpDevicePriorityDialog()
{
- delete ui;
+ delete ui;
}
void qmpDevicePriorityDialog::setupRegisteredDevices()
{
- std::set<std::string> sset,sconn;
- auto conndevs=CMidiPlayer::getInstance()->getMidiOutDevices();
- for(auto dev:conndevs)
- sconn.insert(dev);
- model->removeRows(0,model->rowCount());
- for(auto dev:setdevs)
- {
- QStandardItem *e=new QStandardItem;
- e->setCheckable(true);
- e->setEditable(false);
- e->setCheckState(Qt::CheckState::Checked);
- QStandardItem *a=new QStandardItem;
- a->setText(sconn.find(dev.toString().toStdString())!=sconn.end()?"Connected":"Disconnected");
- a->setEditable(false);
- QStandardItem *devn=new QStandardItem(dev.toString());
- devn->setEditable(false);
- model->appendRow({e,devn,a});
- sset.insert(dev.toString().toStdString());
- }
- for(auto dev:conndevs)
- {
- if(sset.find(dev)!=sset.end())continue;
- QStandardItem *e=new QStandardItem;
- e->setCheckable(true);
- e->setEditable(false);
- e->setCheckState(Qt::CheckState::Unchecked);
- QStandardItem *a=new QStandardItem;
- a->setText("Connected");
- a->setEditable(false);
- QStandardItem *devn=new QStandardItem(QString::fromStdString(dev));
- devn->setEditable(false);
- model->appendRow({e,devn,a});
- }
+ std::set<std::string> sset, sconn;
+ auto conndevs = CMidiPlayer::getInstance()->getMidiOutDevices();
+ for (auto dev : conndevs)
+ sconn.insert(dev);
+ model->removeRows(0, model->rowCount());
+ for (auto dev : setdevs)
+ {
+ QStandardItem *e = new QStandardItem;
+ e->setCheckable(true);
+ e->setEditable(false);
+ e->setCheckState(Qt::CheckState::Checked);
+ QStandardItem *a = new QStandardItem;
+ a->setText(sconn.find(dev.toString().toStdString()) != sconn.end() ? "Connected" : "Disconnected");
+ a->setEditable(false);
+ QStandardItem *devn = new QStandardItem(dev.toString());
+ devn->setEditable(false);
+ model->appendRow({e, devn, a});
+ sset.insert(dev.toString().toStdString());
+ }
+ for (auto dev : conndevs)
+ {
+ if (sset.find(dev) != sset.end())
+ continue;
+ QStandardItem *e = new QStandardItem;
+ e->setCheckable(true);
+ e->setEditable(false);
+ e->setCheckState(Qt::CheckState::Unchecked);
+ QStandardItem *a = new QStandardItem;
+ a->setText("Connected");
+ a->setEditable(false);
+ QStandardItem *devn = new QStandardItem(QString::fromStdString(dev));
+ devn->setEditable(false);
+ model->appendRow({e, devn, a});
+ }
}
void qmpDevicePriorityDialog::load(void *data)
{
- setdevs=static_cast<QVariant*>(data)->toList();
- setupRegisteredDevices();
+ setdevs = static_cast<QVariant *>(data)->toList();
+ setupRegisteredDevices();
}
void *qmpDevicePriorityDialog::save()
{
- QList<QVariant> ret;
- for(int i=0;i<model->rowCount();++i)
- if(model->item(i,0)->checkState()==Qt::CheckState::Checked)
- ret.push_back(model->item(i,1)->text());
- return new QVariant(ret);
+ QList<QVariant> ret;
+ for (int i = 0; i < model->rowCount(); ++i)
+ if (model->item(i, 0)->checkState() == Qt::CheckState::Checked)
+ ret.push_back(model->item(i, 1)->text());
+ return new QVariant(ret);
}
void qmpDevicePriorityDialog::on_pbUp_clicked()
{
- const QModelIndex &idx=ui->tvDevices->selectionModel()->currentIndex();
- if(idx.isValid()&&idx.row()>0)
- {
- int row=idx.row();
- auto r=model->takeRow(row);
- model->insertRow(row-1,r);
- ui->tvDevices->clearSelection();
- ui->tvDevices->selectionModel()->setCurrentIndex(model->index(row-1,idx.column()),QItemSelectionModel::Rows|QItemSelectionModel::Select);
- }
+ const QModelIndex &idx = ui->tvDevices->selectionModel()->currentIndex();
+ if (idx.isValid() && idx.row() > 0)
+ {
+ int row = idx.row();
+ auto r = model->takeRow(row);
+ model->insertRow(row - 1, r);
+ ui->tvDevices->clearSelection();
+ ui->tvDevices->selectionModel()->setCurrentIndex(model->index(row - 1, idx.column()), QItemSelectionModel::Rows | QItemSelectionModel::Select);
+ }
}
void qmpDevicePriorityDialog::on_pbDown_clicked()
{
- const QModelIndex &idx=ui->tvDevices->selectionModel()->currentIndex();
- if(idx.isValid()&&idx.row()<model->rowCount()-1)
- {
- int row=idx.row();
- auto r=model->takeRow(row);
- model->insertRow(row+1,r);
- ui->tvDevices->clearSelection();
- ui->tvDevices->selectionModel()->setCurrentIndex(model->index(row+1,idx.column()),QItemSelectionModel::Rows|QItemSelectionModel::Select);
- }
+ const QModelIndex &idx = ui->tvDevices->selectionModel()->currentIndex();
+ if (idx.isValid() && idx.row() < model->rowCount() - 1)
+ {
+ int row = idx.row();
+ auto r = model->takeRow(row);
+ model->insertRow(row + 1, r);
+ ui->tvDevices->clearSelection();
+ ui->tvDevices->selectionModel()->setCurrentIndex(model->index(row + 1, idx.column()), QItemSelectionModel::Rows | QItemSelectionModel::Select);
+ }
}
void qmpDevicePriorityDialog::on_buttonBox_accepted()
{
- accept();
+ accept();
}
void qmpDevicePriorityDialog::on_buttonBox_rejected()
{
- reject();
+ reject();
}
diff --git a/qmidiplayer-desktop/qmpdeviceprioritydialog.hpp b/qmidiplayer-desktop/qmpdeviceprioritydialog.hpp
index 78ce3fa..85170b9 100644
--- a/qmidiplayer-desktop/qmpdeviceprioritydialog.hpp
+++ b/qmidiplayer-desktop/qmpdeviceprioritydialog.hpp
@@ -5,32 +5,33 @@
#include <QShowEvent>
#include <QStandardItemModel>
-namespace Ui {
+namespace Ui
+{
class qmpDevicePriorityDialog;
}
-class qmpDevicePriorityDialog:public QDialog
+class qmpDevicePriorityDialog : public QDialog
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit qmpDevicePriorityDialog(QWidget *parent=nullptr);
- ~qmpDevicePriorityDialog();
- void load(void* data);
- void* save();
+ explicit qmpDevicePriorityDialog(QWidget *parent = nullptr);
+ ~qmpDevicePriorityDialog();
+ void load(void *data);
+ void *save();
private slots:
- void on_pbUp_clicked();
- void on_pbDown_clicked();
- void on_buttonBox_accepted();
+ void on_pbUp_clicked();
+ void on_pbDown_clicked();
+ void on_buttonBox_accepted();
- void on_buttonBox_rejected();
+ void on_buttonBox_rejected();
- private:
- Ui::qmpDevicePriorityDialog *ui;
- QStandardItemModel *model;
- QList<QVariant> setdevs;
- void setupRegisteredDevices();
+private:
+ Ui::qmpDevicePriorityDialog *ui;
+ QStandardItemModel *model;
+ QList<QVariant> setdevs;
+ void setupRegisteredDevices();
};
#endif // QMPDEVICEPRIORITYDIALOG_HPP
diff --git a/qmidiplayer-desktop/qmpdevpropdialog.cpp b/qmidiplayer-desktop/qmpdevpropdialog.cpp
index 3b9ccc4..c5f1966 100644
--- a/qmidiplayer-desktop/qmpdevpropdialog.cpp
+++ b/qmidiplayer-desktop/qmpdevpropdialog.cpp
@@ -10,108 +10,113 @@
#include "ui_qmpdevpropdialog.h"
qmpDevPropDialog::qmpDevPropDialog(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::qmpDevPropDialog)
+ QDialog(parent),
+ ui(new Ui::qmpDevPropDialog)
{
- ui->setupUi(this);
- ui->twProps->setItemDelegateForColumn(0,new qmpDeviceItemDelegate(true,ui->twProps));
- ui->twProps->setEditTriggers(QAbstractItemView::EditTrigger::NoEditTriggers);
- connect(ui->twProps,&QTableWidget::cellClicked,[this](int r,int c){
- if(c==0)
- this->ui->twProps->edit(ui->twProps->model()->index(r,c));
- if(c==3)
- {
- QString p=QFileDialog::getOpenFileUrl(this,tr("Select Device Initialization File"),QUrl()).toLocalFile();
- if(p.length())this->ui->twProps->item(r,2)->setText(p);
- }
- });
- connect(ui->twProps,&QTableWidget::cellChanged,this,[this](int r,int c){
- if(c!=0)return;
- QString connst(tr("Disconnected"));
- for(auto&ds:qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices())
- if(ui->twProps->item(r,c)->text()==QString::fromStdString(ds))
- {
- connst=tr("Connected");
- break;
- }
- ui->twProps->item(r,1)->setText(connst);
- });
+ ui->setupUi(this);
+ ui->twProps->setItemDelegateForColumn(0, new qmpDeviceItemDelegate(true, ui->twProps));
+ ui->twProps->setEditTriggers(QAbstractItemView::EditTrigger::NoEditTriggers);
+ connect(ui->twProps, &QTableWidget::cellClicked, [this](int r, int c)
+ {
+ if (c == 0)
+ this->ui->twProps->edit(ui->twProps->model()->index(r, c));
+ if (c == 3)
+ {
+ QString p = QFileDialog::getOpenFileUrl(this, tr("Select Device Initialization File"), QUrl()).toLocalFile();
+ if (p.length())
+ this->ui->twProps->item(r, 2)->setText(p);
+ }
+ });
+ connect(ui->twProps, &QTableWidget::cellChanged, this, [this](int r, int c)
+ {
+ if (c != 0)
+ return;
+ QString connst(tr("Disconnected"));
+ for (auto &ds : qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices())
+ if (ui->twProps->item(r, c)->text() == QString::fromStdString(ds))
+ {
+ connst = tr("Connected");
+ break;
+ }
+ ui->twProps->item(r, 1)->setText(connst);
+ });
}
qmpDevPropDialog::~qmpDevPropDialog()
{
- delete ui;
+ delete ui;
}
void qmpDevPropDialog::load(void *data)
{
- QList<QVariant> lst=static_cast<QVariant*>(data)->toList();
- ui->twProps->clearContents();
- ui->twProps->setRowCount(0);
- for(auto&i:lst)
- {
- QPair<QString,QString> p=i.value<QPair<QString,QString>>();
- setupRow(p.first,p.second);
- }
+ QList<QVariant> lst = static_cast<QVariant *>(data)->toList();
+ ui->twProps->clearContents();
+ ui->twProps->setRowCount(0);
+ for (auto &i : lst)
+ {
+ QPair<QString, QString> p = i.value<QPair<QString, QString>>();
+ setupRow(p.first, p.second);
+ }
}
void *qmpDevPropDialog::save()
{
- QList<QVariant> ret;
- for(int i=0;i<ui->twProps->rowCount();++i)
- {
- QPair<QString,QString> p
- {
- ui->twProps->item(i,0)->text(),
- ui->twProps->item(i,2)->text()
- };
- ret.push_back(QVariant::fromValue(p));
- }
- return new QVariant(ret);
+ QList<QVariant> ret;
+ for (int i = 0; i < ui->twProps->rowCount(); ++i)
+ {
+ QPair<QString, QString> p
+ {
+ ui->twProps->item(i, 0)->text(),
+ ui->twProps->item(i, 2)->text()
+ };
+ ret.push_back(QVariant::fromValue(p));
+ }
+ return new QVariant(ret);
}
void qmpDevPropDialog::on_pbAdd_clicked()
{
- setupRow();
+ setupRow();
}
void qmpDevPropDialog::on_pbRemove_clicked()
{
- ui->twProps->removeRow(ui->twProps->currentRow());
+ ui->twProps->removeRow(ui->twProps->currentRow());
}
-void qmpDevPropDialog::setupRow(const QString&dn,const QString&din)
+void qmpDevPropDialog::setupRow(const QString &dn, const QString &din)
{
- int r;
- ui->twProps->insertRow(r=ui->twProps->rowCount());
- ui->twProps->setRowHeight(r,32);
- QTableWidgetItem *cbx=new QTableWidgetItem;
- ui->twProps->setItem(r,1,cbx);
- QTableWidgetItem *cb;
- ui->twProps->setItem(r,0,cb=new QTableWidgetItem);
- ui->twProps->setItem(r,2,new QTableWidgetItem);
- ui->twProps->setItem(r,3,new QTableWidgetItem("..."));
- if(din.length())ui->twProps->item(r,2)->setText(din);
- cbx->setFlags(Qt::ItemFlag::ItemIsEnabled|Qt::ItemFlag::ItemIsSelectable);
- cbx->setText(tr("Disconnected"));
- ui->twProps->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
- if(dn.length())
- {
- cb->setText(dn);
- cb->setFlags(cb->flags()|Qt::ItemFlag::ItemIsEditable);
- std::vector<std::string> dsv=CMidiPlayer::getInstance()->getMidiOutDevices();
- if(std::find(dsv.begin(),dsv.end(),dn.toStdString())==dsv.end())
- cb->setFlags(cb->flags()&(~Qt::ItemFlag::ItemIsEnabled));
- else cb->setFlags(cb->flags()|Qt::ItemFlag::ItemIsEnabled);
- }
+ int r;
+ ui->twProps->insertRow(r = ui->twProps->rowCount());
+ ui->twProps->setRowHeight(r, 32);
+ QTableWidgetItem *cbx = new QTableWidgetItem;
+ ui->twProps->setItem(r, 1, cbx);
+ QTableWidgetItem *cb;
+ ui->twProps->setItem(r, 0, cb = new QTableWidgetItem);
+ ui->twProps->setItem(r, 2, new QTableWidgetItem);
+ ui->twProps->setItem(r, 3, new QTableWidgetItem("..."));
+ if (din.length())
+ ui->twProps->item(r, 2)->setText(din);
+ cbx->setFlags(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable);
+ cbx->setText(tr("Disconnected"));
+ ui->twProps->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
+ if (dn.length())
+ {
+ cb->setText(dn);
+ cb->setFlags(cb->flags() | Qt::ItemFlag::ItemIsEditable);
+ std::vector<std::string> dsv = CMidiPlayer::getInstance()->getMidiOutDevices();
+ if (std::find(dsv.begin(), dsv.end(), dn.toStdString()) == dsv.end())
+ cb->setFlags(cb->flags() & (~Qt::ItemFlag::ItemIsEnabled));
+ else cb->setFlags(cb->flags() | Qt::ItemFlag::ItemIsEnabled);
+ }
}
void qmpDevPropDialog::on_buttonBox_accepted()
{
- accept();
+ accept();
}
void qmpDevPropDialog::on_buttonBox_rejected()
{
- reject();
+ reject();
}
diff --git a/qmidiplayer-desktop/qmpdevpropdialog.hpp b/qmidiplayer-desktop/qmpdevpropdialog.hpp
index e98aba9..eb69d81 100644
--- a/qmidiplayer-desktop/qmpdevpropdialog.hpp
+++ b/qmidiplayer-desktop/qmpdevpropdialog.hpp
@@ -3,32 +3,33 @@
#include <QDialog>
-namespace Ui {
+namespace Ui
+{
class qmpDevPropDialog;
}
class qmpDevPropDialog : public QDialog
{
- Q_OBJECT
+ Q_OBJECT
- public:
- explicit qmpDevPropDialog(QWidget *parent = nullptr);
- ~qmpDevPropDialog();
- void load(void* data);
- void* save();
+public:
+ explicit qmpDevPropDialog(QWidget *parent = nullptr);
+ ~qmpDevPropDialog();
+ void load(void *data);
+ void *save();
- private slots:
- void on_pbAdd_clicked();
+private slots:
+ void on_pbAdd_clicked();
- void on_pbRemove_clicked();
+ void on_pbRemove_clicked();
- void on_buttonBox_accepted();
+ void on_buttonBox_accepted();
- void on_buttonBox_rejected();
+ void on_buttonBox_rejected();
- private:
- Ui::qmpDevPropDialog *ui;
- void setupRow(const QString &dn="",const QString &din="");
+private:
+ Ui::qmpDevPropDialog *ui;
+ void setupRow(const QString &dn = QString(), const QString &din = QString());
};
#endif // QMPDEVPROPDIALOG_HPP
diff --git a/qmidiplayer-desktop/qmpefxwindow.cpp b/qmidiplayer-desktop/qmpefxwindow.cpp
index 7691756..ec1cef3 100644
--- a/qmidiplayer-desktop/qmpefxwindow.cpp
+++ b/qmidiplayer-desktop/qmpefxwindow.cpp
@@ -4,215 +4,296 @@
#include "qmpmainwindow.hpp"
qmpEfxWindow::qmpEfxWindow(QWidget *parent) :
- QWidget(parent,Qt::Dialog),
- ui(new Ui::qmpEfxWindow)
-{
- ui->setupUi(this);initialized=false;
- styl=new QDialSkulptureStyle();
- QList<QDial*> dials=findChildren<QDial*>();
- for(int i=0;i<dials.count();++i)
- dials.at(i)->setStyle(styl);
- qmpSettings *settings=qmpMainWindow::getInstance()->getSettings();
- ui->cbEnabledC->setChecked(settings->getOptionRaw("Effects/ChorusEnabled",1).toInt());
- ui->cbEnabledR->setChecked(settings->getOptionRaw("Effects/ReverbEnabled",1).toInt());
- rr=settings->getOptionRaw("Effects/ReverbRoom",0.2).toDouble();
- rd=settings->getOptionRaw("Effects/ReverbDamp",0.0).toDouble();
- rw=settings->getOptionRaw("Effects/ReverbWidth",0.5).toDouble();
- rl=settings->getOptionRaw("Effects/ReverbLevel",0.9).toDouble();
-
- cfb=settings->getOptionRaw("Effects/ChorusFeedbk",3).toInt();
- cl=settings->getOptionRaw("Effects/ChorusLevel",2.0).toDouble();
- cr=settings->getOptionRaw("Effects/ChorusRate",0.3).toDouble();
- cd=settings->getOptionRaw("Effects/ChorusDepth",8.0).toDouble();
- ct=settings->getOptionRaw("Effects/ChorusType",FLUID_CHORUS_MOD_SINE).toInt();
- qmpMainWindow::getInstance()->registerFunctionality(
- efxf=new qmpEfxFunc(this),
- std::string("Effects"),
- tr("Effects").toStdString(),
- getThemedIconc(":/img/effects.svg"),
- 0,
- true
- );
- if(settings->getOptionRaw("DialogStatus/EfxW",QRect(-999,-999,999,999)).toRect()!=QRect(-999,-999,999,999))
- setGeometry(settings->getOptionRaw("DialogStatus/EfxW",QRect(-999,-999,999,999)).toRect());
- if(settings->getOptionRaw("DialogStatus/EfxWShown",0).toInt())
- {show();qmpMainWindow::getInstance()->setFuncState("Effects",true);}
+ QWidget(parent, Qt::Dialog),
+ ui(new Ui::qmpEfxWindow)
+{
+ ui->setupUi(this);
+ initialized = false;
+ styl = new QDialSkulptureStyle();
+ QList<QDial *> dials = findChildren<QDial *>();
+ for (int i = 0; i < dials.count(); ++i)
+ dials.at(i)->setStyle(styl);
+ qmpSettings *settings = qmpMainWindow::getInstance()->getSettings();
+ ui->cbEnabledC->setChecked(settings->getOptionRaw("Effects/ChorusEnabled", 1).toInt());
+ ui->cbEnabledR->setChecked(settings->getOptionRaw("Effects/ReverbEnabled", 1).toInt());
+ rr = settings->getOptionRaw("Effects/ReverbRoom", 0.2).toDouble();
+ rd = settings->getOptionRaw("Effects/ReverbDamp", 0.0).toDouble();
+ rw = settings->getOptionRaw("Effects/ReverbWidth", 0.5).toDouble();
+ rl = settings->getOptionRaw("Effects/ReverbLevel", 0.9).toDouble();
+
+ cfb = settings->getOptionRaw("Effects/ChorusFeedbk", 3).toInt();
+ cl = settings->getOptionRaw("Effects/ChorusLevel", 2.0).toDouble();
+ cr = settings->getOptionRaw("Effects/ChorusRate", 0.3).toDouble();
+ cd = settings->getOptionRaw("Effects/ChorusDepth", 8.0).toDouble();
+ ct = settings->getOptionRaw("Effects/ChorusType", FLUID_CHORUS_MOD_SINE).toInt();
+ qmpMainWindow::getInstance()->registerFunctionality(
+ efxf = new qmpEfxFunc(this),
+ std::string("Effects"),
+ tr("Effects").toStdString(),
+ getThemedIconc(":/img/effects.svg"),
+ 0,
+ true
+ );
+ if (settings->getOptionRaw("DialogStatus/EfxW", QRect(-999, -999, 999, 999)).toRect() != QRect(-999, -999, 999, 999))
+ setGeometry(settings->getOptionRaw("DialogStatus/EfxW", QRect(-999, -999, 999, 999)).toRect());
+ if (settings->getOptionRaw("DialogStatus/EfxWShown", 0).toInt())
+ {
+ show();
+ qmpMainWindow::getInstance()->setFuncState("Effects", true);
+ }
}
qmpEfxWindow::~qmpEfxWindow()
{
- qmpMainWindow::getInstance()->unregisterFunctionality("Effects");
- delete efxf;
- delete styl;
- delete ui;
+ qmpMainWindow::getInstance()->unregisterFunctionality("Effects");
+ delete efxf;
+ delete styl;
+ delete ui;
}
void qmpEfxWindow::closeEvent(QCloseEvent *event)
{
- qmpSettings *settings=qmpMainWindow::getInstance()->getSettings();
- if(settings->getOptionBool("Behavior/DialogStatus"))
- {
- settings->setOptionRaw("DialogStatus/EfxW",geometry());
- }
- setVisible(false);
- if(!qmpMainWindow::getInstance()->isFinalizing()&&settings->getOptionBool("Behavior/DialogStatus"))
- {
- settings->setOptionRaw("DialogStatus/EfxWShown",0);
- }
- qmpMainWindow::getInstance()->setFuncState("Effects",false);
- event->accept();
+ qmpSettings *settings = qmpMainWindow::getInstance()->getSettings();
+ if (settings->getOptionBool("Behavior/DialogStatus"))
+ {
+ settings->setOptionRaw("DialogStatus/EfxW", geometry());
+ }
+ setVisible(false);
+ if (!qmpMainWindow::getInstance()->isFinalizing() && settings->getOptionBool("Behavior/DialogStatus"))
+ {
+ settings->setOptionRaw("DialogStatus/EfxWShown", 0);
+ }
+ qmpMainWindow::getInstance()->setFuncState("Effects", false);
+ event->accept();
}
void qmpEfxWindow::showEvent(QShowEvent *event)
{
- //CMidiPlayer* player=qmpMainWindow::getInstance()->getPlayer();
- //These parameters will never be modified outside this window...
- /*if(initialized)
- {
- player->getReverbPara(&rr,&rd,&rw,&rl);
- player->getChorusPara(&cfb,&cl,&cr,&cd,&ct);
- }*/
- ui->sbRoom->setValue((int)round(rr*100));ui->dRoom->setValue((int)round(rr*100));
- ui->sbDamp->setValue((int)round(rd*100));ui->dDamp->setValue((int)round(rd*100));
- ui->sbWidth->setValue((int)round(rw*100));ui->dWidth->setValue((int)round(rw*100));
- ui->sbLevelR->setValue((int)round(rl*100));ui->dLevelR->setValue((int)round(rl*100));
-
- ui->sbFeedBack->setValue(cfb);ui->dFeedBack->setValue(cfb);
- ui->sbRate->setValue(cr);ui->dRate->setValue((int)round(cr*100));
- ui->sbDepth->setValue(cd);ui->dDepth->setValue((int)round(cd*10));
- ui->sbLevelC->setValue((int)round(cl*100));ui->dLevelC->setValue((int)round(cl*100));
- if(ct==FLUID_CHORUS_MOD_SINE)ui->rbSine->setChecked(true),ui->rbTriangle->setChecked(false);
- if(ct==FLUID_CHORUS_MOD_TRIANGLE)ui->rbSine->setChecked(false),ui->rbTriangle->setChecked(true);
- initialized=true;
- qmpSettings *settings=qmpMainWindow::getInstance()->getSettings();
- if(settings->getOptionRaw("DialogStatus/EfxW",QRect(-999,-999,999,999)).toRect()!=QRect(-999,-999,999,999))
- setGeometry(settings->getOptionRaw("DialogStatus/EfxW",QRect(-999,-999,999,999)).toRect());
- if(settings->getOptionBool("Behavior/DialogStatus"))
- {
- settings->setOptionRaw("DialogStatus/EfxWShown",1);
- }
- event->accept();
+ //These parameters will never be modified outside this window...
+ /*if(initialized)
+ {
+ player->getReverbPara(&rr,&rd,&rw,&rl);
+ player->getChorusPara(&cfb,&cl,&cr,&cd,&ct);
+ }*/
+ ui->sbRoom->setValue((int)round(rr * 100));
+ ui->dRoom->setValue((int)round(rr * 100));
+ ui->sbDamp->setValue((int)round(rd * 100));
+ ui->dDamp->setValue((int)round(rd * 100));
+ ui->sbWidth->setValue((int)round(rw * 100));
+ ui->dWidth->setValue((int)round(rw * 100));
+ ui->sbLevelR->setValue((int)round(rl * 100));
+ ui->dLevelR->setValue((int)round(rl * 100));
+
+ ui->sbFeedBack->setValue(cfb);
+ ui->dFeedBack->setValue(cfb);
+ ui->sbRate->setValue(cr);
+ ui->dRate->setValue((int)round(cr * 100));
+ ui->sbDepth->setValue(cd);
+ ui->dDepth->setValue((int)round(cd * 10));
+ ui->sbLevelC->setValue((int)round(cl * 100));
+ ui->dLevelC->setValue((int)round(cl * 100));
+ if (ct == FLUID_CHORUS_MOD_SINE)
+ {
+ ui->rbSine->setChecked(true);
+ ui->rbTriangle->setChecked(false);
+ }
+ if (ct == FLUID_CHORUS_MOD_TRIANGLE)
+ {
+ ui->rbSine->setChecked(false);
+ ui->rbTriangle->setChecked(true);
+ }
+ initialized = true;
+ qmpSettings *settings = qmpMainWindow::getInstance()->getSettings();
+ if (settings->getOptionRaw("DialogStatus/EfxW", QRect(-999, -999, 999, 999)).toRect() != QRect(-999, -999, 999, 999))
+ setGeometry(settings->getOptionRaw("DialogStatus/EfxW", QRect(-999, -999, 999, 999)).toRect());
+ if (settings->getOptionBool("Behavior/DialogStatus"))
+ {
+ settings->setOptionRaw("DialogStatus/EfxWShown", 1);
+ }
+ event->accept();
}
void qmpEfxWindow::sendEfxChange(void *_fs)
{
- if(!qmpMainWindow::getInstance()||!initialized)return;
- rr=ui->sbRoom->value()/100.;rd=ui->sbDamp->value()/100.;
- rw=ui->sbWidth->value()/100.;rl=ui->sbLevelR->value()/100.;
- ct=ui->rbSine->isChecked()?FLUID_CHORUS_MOD_SINE:FLUID_CHORUS_MOD_TRIANGLE;
- cfb=ui->sbFeedBack->value();cl=ui->sbLevelC->value()/100.;
- cr=ui->sbRate->value();cd=ui->sbDepth->value();
- IFluidSettings* fs=(IFluidSettings*)_fs;
- if(!_fs)fs=qmpMainWindow::getInstance()->getFluid();
- fs->setReverbPara(ui->cbEnabledR->isChecked()?1:0,rr,rd,rw,rl);
- fs->setChorusPara(ui->cbEnabledC->isChecked()?1:0,cfb,cl,cr,cd,ct);
-
- qmpSettings *settings=qmpMainWindow::getInstance()->getSettings();
- settings->setOptionRaw("Effects/ChorusEnabled",ui->cbEnabledC->isChecked()?1:0);
- settings->setOptionRaw("Effects/ReverbEnabled",ui->cbEnabledR->isChecked()?1:0);
- settings->setOptionRaw("Effects/ReverbRoom",rr);
- settings->setOptionRaw("Effects/ReverbDamp",rd);
- settings->setOptionRaw("Effects/ReverbWidth",rw);
- settings->setOptionRaw("Effects/ReverbLevel",rl);
-
- settings->setOptionRaw("Effects/ChorusFeedbk",cfb);
- settings->setOptionRaw("Effects/ChorusLevel",cl);
- settings->setOptionRaw("Effects/ChorusRate",cr);
- settings->setOptionRaw("Effects/ChorusDepth",cd);
- settings->setOptionRaw("Effects/ChorusType",ct);
+ if (!qmpMainWindow::getInstance() || !initialized)
+ return;
+ rr = ui->sbRoom->value() / 100.;
+ rd = ui->sbDamp->value() / 100.;
+ rw = ui->sbWidth->value() / 100.;
+ rl = ui->sbLevelR->value() / 100.;
+ ct = ui->rbSine->isChecked() ? FLUID_CHORUS_MOD_SINE : FLUID_CHORUS_MOD_TRIANGLE;
+ cfb = ui->sbFeedBack->value();
+ cl = ui->sbLevelC->value() / 100.;
+ cr = ui->sbRate->value();
+ cd = ui->sbDepth->value();
+ IFluidSettings *fs = (IFluidSettings *)_fs;
+ if (!_fs)
+ fs = qmpMainWindow::getInstance()->getFluid();
+ fs->setReverbPara(ui->cbEnabledR->isChecked() ? 1 : 0, rr, rd, rw, rl);
+ fs->setChorusPara(ui->cbEnabledC->isChecked() ? 1 : 0, cfb, cl, cr, cd, ct);
+
+ qmpSettings *settings = qmpMainWindow::getInstance()->getSettings();
+ settings->setOptionRaw("Effects/ChorusEnabled", ui->cbEnabledC->isChecked() ? 1 : 0);
+ settings->setOptionRaw("Effects/ReverbEnabled", ui->cbEnabledR->isChecked() ? 1 : 0);
+ settings->setOptionRaw("Effects/ReverbRoom", rr);
+ settings->setOptionRaw("Effects/ReverbDamp", rd);
+ settings->setOptionRaw("Effects/ReverbWidth", rw);
+ settings->setOptionRaw("Effects/ReverbLevel", rl);
+
+ settings->setOptionRaw("Effects/ChorusFeedbk", cfb);
+ settings->setOptionRaw("Effects/ChorusLevel", cl);
+ settings->setOptionRaw("Effects/ChorusRate", cr);
+ settings->setOptionRaw("Effects/ChorusDepth", cd);
+ settings->setOptionRaw("Effects/ChorusType", ct);
}
void qmpEfxWindow::dailValueChange()
{
- if(!initialized)return;
- ui->sbRoom->setValue(ui->dRoom->value());
- ui->sbDamp->setValue(ui->dDamp->value());
- ui->sbWidth->setValue(ui->dWidth->value());
- ui->sbLevelR->setValue(ui->dLevelR->value());
- ui->sbFeedBack->setValue(ui->dFeedBack->value());
- ui->sbRate->setValue(ui->dRate->value()/100.);
- ui->sbDepth->setValue(ui->dDepth->value()/10.);
- ui->sbLevelC->setValue(ui->dLevelC->value());
- sendEfxChange();
+ if (!initialized)
+ return;
+ ui->sbRoom->setValue(ui->dRoom->value());
+ ui->sbDamp->setValue(ui->dDamp->value());
+ ui->sbWidth->setValue(ui->dWidth->value());
+ ui->sbLevelR->setValue(ui->dLevelR->value());
+ ui->sbFeedBack->setValue(ui->dFeedBack->value());
+ ui->sbRate->setValue(ui->dRate->value() / 100.);
+ ui->sbDepth->setValue(ui->dDepth->value() / 10.);
+ ui->sbLevelC->setValue(ui->dLevelC->value());
+ sendEfxChange();
}
void qmpEfxWindow::spinValueChange()
{
- if(!initialized)return;
- ui->dRoom->setValue(ui->sbRoom->value());
- ui->dDamp->setValue(ui->sbDamp->value());
- ui->dWidth->setValue(ui->sbWidth->value());
- ui->dLevelR->setValue(ui->sbLevelR->value());
- ui->dFeedBack->setValue(ui->sbFeedBack->value());
- ui->dRate->setValue((int)(ui->sbRate->value()*100));
- ui->dDepth->setValue((int)(ui->sbDepth->value()*10));
- ui->dLevelC->setValue(ui->sbLevelC->value());
- sendEfxChange();
+ if (!initialized)
+ return;
+ ui->dRoom->setValue(ui->sbRoom->value());
+ ui->dDamp->setValue(ui->sbDamp->value());
+ ui->dWidth->setValue(ui->sbWidth->value());
+ ui->dLevelR->setValue(ui->sbLevelR->value());
+ ui->dFeedBack->setValue(ui->sbFeedBack->value());
+ ui->dRate->setValue((int)(ui->sbRate->value() * 100));
+ ui->dDepth->setValue((int)(ui->sbDepth->value() * 10));
+ ui->dLevelC->setValue(ui->sbLevelC->value());
+ sendEfxChange();
}
void qmpEfxWindow::on_dRoom_valueChanged()
-{dailValueChange();}
+{
+ dailValueChange();
+}
void qmpEfxWindow::on_dDamp_valueChanged()
-{dailValueChange();}
+{
+ dailValueChange();
+}
void qmpEfxWindow::on_dWidth_valueChanged()
-{dailValueChange();}
+{
+ dailValueChange();
+}
void qmpEfxWindow::on_dLevelR_valueChanged()
-{dailValueChange();}
+{
+ dailValueChange();
+}
void qmpEfxWindow::on_dFeedBack_valueChanged()
-{dailValueChange();}
+{
+ dailValueChange();
+}
void qmpEfxWindow::on_dRate_valueChanged()
-{dailValueChange();}
+{
+ dailValueChange();
+}
void qmpEfxWindow::on_dDepth_valueChanged()
-{dailValueChange();}
+{
+ dailValueChange();
+}
void qmpEfxWindow::on_dLevelC_valueChanged()
-{dailValueChange();}
+{
+ dailValueChange();
+}
void qmpEfxWindow::on_sbRoom_valueChanged(QString s)
-{s=QString();spinValueChange();}
+{
+ s = QString();
+ spinValueChange();
+}
void qmpEfxWindow::on_sbDamp_valueChanged(QString s)
-{s=QString();spinValueChange();}
+{
+ s = QString();
+ spinValueChange();
+}
void qmpEfxWindow::on_sbWidth_valueChanged(QString s)
-{s=QString();spinValueChange();}
+{
+ s = QString();
+ spinValueChange();
+}
void qmpEfxWindow::on_sbLevelR_valueChanged(QString s)
-{s=QString();spinValueChange();}
+{
+ s = QString();
+ spinValueChange();
+}
void qmpEfxWindow::on_sbFeedBack_valueChanged(QString s)
-{s=QString();spinValueChange();}
+{
+ s = QString();
+ spinValueChange();
+}
void qmpEfxWindow::on_sbRate_valueChanged(QString s)
-{s=QString();spinValueChange();}
+{
+ s = QString();
+ spinValueChange();
+}
void qmpEfxWindow::on_sbDepth_valueChanged(QString s)
-{s=QString();spinValueChange();}
+{
+ s = QString();
+ spinValueChange();
+}
void qmpEfxWindow::on_sbLevelC_valueChanged(QString s)
-{s=QString();spinValueChange();}
+{
+ s = QString();
+ spinValueChange();
+}
void qmpEfxWindow::on_cbEnabledC_stateChanged()
-{sendEfxChange();}
+{
+ sendEfxChange();
+}
void qmpEfxWindow::on_cbEnabledR_stateChanged()
-{sendEfxChange();}
+{
+ sendEfxChange();
+}
void qmpEfxWindow::on_rbSine_toggled()
-{sendEfxChange();}
+{
+ sendEfxChange();
+}
void qmpEfxWindow::on_rbTriangle_toggled()
-{sendEfxChange();}
+{
+ sendEfxChange();
+}
qmpEfxFunc::qmpEfxFunc(qmpEfxWindow *par)
-{p=par;}
+{
+ p = par;
+}
void qmpEfxFunc::show()
-{p->show();}
+{
+ p->show();
+}
void qmpEfxFunc::close()
-{p->close();}
+{
+ p->close();
+}
diff --git a/qmidiplayer-desktop/qmpefxwindow.hpp b/qmidiplayer-desktop/qmpefxwindow.hpp
index bacda1d..9e5e8bf 100644
--- a/qmidiplayer-desktop/qmpefxwindow.hpp
+++ b/qmidiplayer-desktop/qmpefxwindow.hpp
@@ -9,64 +9,65 @@
#include "qdialskulpturestyle.hpp"
#include "../include/qmpcorepublic.hpp"
-namespace Ui {
- class qmpEfxWindow;
+namespace Ui
+{
+class qmpEfxWindow;
}
class qmpEfxWindow;
-class qmpEfxFunc:public qmpFuncBaseIntf
+class qmpEfxFunc : public qmpFuncBaseIntf
{
- private:
- qmpEfxWindow *p;
- public:
- qmpEfxFunc(qmpEfxWindow *par);
- void show();
- void close();
+private:
+ qmpEfxWindow *p;
+public:
+ qmpEfxFunc(qmpEfxWindow *par);
+ void show();
+ void close();
};
-class qmpEfxWindow:public QWidget
+class qmpEfxWindow : public QWidget
{
- Q_OBJECT
+ Q_OBJECT
- public:
- explicit qmpEfxWindow(QWidget *parent=0);
- ~qmpEfxWindow();
- void closeEvent(QCloseEvent *event);
- void showEvent(QShowEvent *event);
- void sendEfxChange(void *_fs=nullptr);
+public:
+ explicit qmpEfxWindow(QWidget *parent = nullptr);
+ ~qmpEfxWindow();
+ void closeEvent(QCloseEvent *event);
+ void showEvent(QShowEvent *event);
+ void sendEfxChange(void *_fs = nullptr);
- private slots:
- void on_dRoom_valueChanged();
- void on_dDamp_valueChanged();
- void on_dWidth_valueChanged();
- void on_dLevelR_valueChanged();
- void on_dFeedBack_valueChanged();
- void on_dRate_valueChanged();
- void on_dDepth_valueChanged();
- void on_dLevelC_valueChanged();
- void on_sbRoom_valueChanged(QString s);
- void on_sbDamp_valueChanged(QString s);
- void on_sbWidth_valueChanged(QString s);
- void on_sbLevelR_valueChanged(QString s);
- void on_sbFeedBack_valueChanged(QString s);
- void on_sbRate_valueChanged(QString s);
- void on_sbDepth_valueChanged(QString s);
- void on_sbLevelC_valueChanged(QString s);
- void on_cbEnabledC_stateChanged();
- void on_cbEnabledR_stateChanged();
- void on_rbSine_toggled();
- void on_rbTriangle_toggled();
+private slots:
+ void on_dRoom_valueChanged();
+ void on_dDamp_valueChanged();
+ void on_dWidth_valueChanged();
+ void on_dLevelR_valueChanged();
+ void on_dFeedBack_valueChanged();
+ void on_dRate_valueChanged();
+ void on_dDepth_valueChanged();
+ void on_dLevelC_valueChanged();
+ void on_sbRoom_valueChanged(QString s);
+ void on_sbDamp_valueChanged(QString s);
+ void on_sbWidth_valueChanged(QString s);
+ void on_sbLevelR_valueChanged(QString s);
+ void on_sbFeedBack_valueChanged(QString s);
+ void on_sbRate_valueChanged(QString s);
+ void on_sbDepth_valueChanged(QString s);
+ void on_sbLevelC_valueChanged(QString s);
+ void on_cbEnabledC_stateChanged();
+ void on_cbEnabledR_stateChanged();
+ void on_rbSine_toggled();
+ void on_rbTriangle_toggled();
- private:
- void dailValueChange();
- void spinValueChange();
- Ui::qmpEfxWindow *ui;
- double rr,rd,rw,rl;
- int cfb,ct,initialized;
- double cl,cr,cd;
- QCommonStyle* styl;
- qmpEfxFunc *efxf;
+private:
+ void dailValueChange();
+ void spinValueChange();
+ Ui::qmpEfxWindow *ui;
+ double rr, rd, rw, rl;
+ int cfb, ct, initialized;
+ double cl, cr, cd;
+ QCommonStyle *styl;
+ qmpEfxFunc *efxf;
};
#endif // QMPEFXWINDOW_HPP
diff --git a/qmidiplayer-desktop/qmphelpwindow.cpp b/qmidiplayer-desktop/qmphelpwindow.cpp
index 4579e2c..082c2f6 100644
--- a/qmidiplayer-desktop/qmphelpwindow.cpp
+++ b/qmidiplayer-desktop/qmphelpwindow.cpp
@@ -2,43 +2,44 @@
#include "qmphelpwindow.hpp"
#include "ui_qmphelpwindow.h"
-static const char *months="JanFebMarAprMayJunJulAugSepOctNovDec";
+static const char *months = "JanFebMarAprMayJunJulAugSepOctNovDec";
std::string parseDate(const char *date)
{
- char ms[8];
- int y,d,m;sscanf(date,"%s %d %d",ms,&d,&y);
- m=(strstr(months,ms)-months)/3+1;
- char r[16];
- sprintf(r,"%04d-%02d-%02d",y,m,d);
- return std::string(r);
+ char ms[8];
+ int y, d, m;
+ sscanf(date, "%s %d %d", ms, &d, &y);
+ m = (strstr(months, ms) - months) / 3 + 1;
+ char r[16];
+ sprintf(r, "%04d-%02d-%02d", y, m, d);
+ return std::string(r);
}
qmpHelpWindow::qmpHelpWindow(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::qmpHelpWindow)
+ QDialog(parent),
+ ui(new Ui::qmpHelpWindow)
{
- ui->setupUi(this);
- ui->textBrowser->setSearchPaths(QStringList(QString(":/doc"))+QStringList(QString(":/img")));
- ui->textBrowser->setSource(QUrl("qrc:///doc/index_internal.html"));
+ ui->setupUi(this);
+ ui->textBrowser->setSearchPaths(QStringList(QString(":/doc")) + QStringList(QString(":/img")));
+ ui->textBrowser->setSource(QUrl("qrc:///doc/index_internal.html"));
}
qmpHelpWindow::~qmpHelpWindow()
{
- delete ui;
+ delete ui;
}
void qmpHelpWindow::on_textBrowser_sourceChanged(const QUrl &src)
{
- if(src.fileName()==QString("version_internal.html"))
- {
- QString s=ui->textBrowser->toHtml();
- s.replace("CT_QT_VERSION_STR",QT_VERSION_STR);
- s.replace("RT_QT_VERSION_STR",qVersion());
- s.replace("CT_FLUIDSYNTH_VERSION",FLUIDSYNTH_VERSION);
- s.replace("RT_FLUIDSYNTH_VERSION",fluid_version_str());
- s.replace("APP_VERSION",APP_VERSION);
- s.replace("BUILD_DATE",parseDate(__DATE__).c_str());
- s.replace("BUILD_MACHINE",QT_STRINGIFY(BUILD_MACHINE));
- ui->textBrowser->setHtml(s);
- }
+ if (src.fileName() == QString("version_internal.html"))
+ {
+ QString s = ui->textBrowser->toHtml();
+ s.replace("CT_QT_VERSION_STR", QT_VERSION_STR);
+ s.replace("RT_QT_VERSION_STR", qVersion());
+ s.replace("CT_FLUIDSYNTH_VERSION", FLUIDSYNTH_VERSION);
+ s.replace("RT_FLUIDSYNTH_VERSION", fluid_version_str());
+ s.replace("APP_VERSION", APP_VERSION);
+ s.replace("BUILD_DATE", parseDate(__DATE__).c_str());
+ s.replace("BUILD_MACHINE", QT_STRINGIFY(BUILD_MACHINE));
+ ui->textBrowser->setHtml(s);
+ }
}
diff --git a/qmidiplayer-desktop/qmphelpwindow.hpp b/qmidiplayer-desktop/qmphelpwindow.hpp
index a94da33..35824ed 100644
--- a/qmidiplayer-desktop/qmphelpwindow.hpp
+++ b/qmidiplayer-desktop/qmphelpwindow.hpp
@@ -6,23 +6,24 @@
#define BUILD_MACHINE UNKNOWN
#endif
-namespace Ui {
- class qmpHelpWindow;
+namespace Ui
+{
+class qmpHelpWindow;
}
class qmpHelpWindow : public QDialog
{
- Q_OBJECT
+ Q_OBJECT
- public:
- explicit qmpHelpWindow(QWidget *parent = 0);
- ~qmpHelpWindow();
+public:
+ explicit qmpHelpWindow(QWidget *parent = nullptr);
+ ~qmpHelpWindow();
- private slots:
- void on_textBrowser_sourceChanged(const QUrl &src);
+private slots:
+ void on_textBrowser_sourceChanged(const QUrl &src);
- private:
- Ui::qmpHelpWindow *ui;
+private:
+ Ui::qmpHelpWindow *ui;
};
#endif // QMPHELPWINDOW_H
diff --git a/qmidiplayer-desktop/qmpinfowindow.cpp b/qmidiplayer-desktop/qmpinfowindow.cpp
index c0b8892..654c8f4 100644
--- a/qmidiplayer-desktop/qmpinfowindow.cpp
+++ b/qmidiplayer-desktop/qmpinfowindow.cpp
@@ -4,84 +4,95 @@
#include "qmpmainwindow.hpp"
#include "qmpsettingswindow.hpp"
-const char* minors="abebbbf c g d a e b f#c#g#d#a#";
-const char* majors="CbGbDbAbEbBbF C G D A E B F#C#";
-const char* standards="? GM GM2GS XG ";
+const char *minors = "abebbbf c g d a e b f#c#g#d#a#";
+const char *majors = "CbGbDbAbEbBbF C G D A E B F#C#";
+const char *standards = "? GM GM2GS XG ";
qmpInfoWindow::qmpInfoWindow(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::qmpInfoWindow)
+ QDialog(parent),
+ ui(new Ui::qmpInfoWindow)
{
- ui->setupUi(this);
- qmpMainWindow::getInstance()->registerFunctionality(
- infof=new qmpInfoFunc(this),
- std::string("FileInfo"),
- tr("File Information").toStdString(),
- getThemedIconc(":/img/info.svg"),
- 0,
- true
- );
+ ui->setupUi(this);
+ qmpMainWindow::getInstance()->registerFunctionality(
+ infof = new qmpInfoFunc(this),
+ std::string("FileInfo"),
+ tr("File Information").toStdString(),
+ getThemedIconc(":/img/info.svg"),
+ 0,
+ true
+ );
}
qmpInfoWindow::~qmpInfoWindow()
{
- qmpMainWindow::getInstance()->unregisterFunctionality("FileInfo");
- delete infof;
- delete ui;
+ qmpMainWindow::getInstance()->unregisterFunctionality("FileInfo");
+ delete infof;
+ delete ui;
}
void qmpInfoWindow::closeEvent(QCloseEvent *e)
{
- setVisible(false);
- qmpMainWindow::getInstance()->setFuncState("FileInfo",false);
- e->accept();
+ setVisible(false);
+ qmpMainWindow::getInstance()->setFuncState("FileInfo", false);
+ e->accept();
}
void qmpInfoWindow::hideEvent(QHideEvent *e)
{
- qmpMainWindow::getInstance()->setFuncState("FileInfo",false);
- e->accept();
+ qmpMainWindow::getInstance()->setFuncState("FileInfo", false);
+ e->accept();
}
void qmpInfoWindow::updateInfo()
{
- char str[256];
- CMidiPlayer* player=qmpMainWindow::getInstance()->getPlayer();
- std::string textencoding=qmpMainWindow::getInstance()->getSettings()->getOptionEnumIntOptName("Midi/TextEncoding");
- ui->lbFileName->setText(QString("File name: ")+qmpMainWindow::getInstance()->getFileName());
- if(player->getTitle())
- {
- if(textencoding!="Unicode")
- ui->lbTitle->setText(QString("Title: ")+
- QTextCodec::codecForName(textencoding.c_str())->toUnicode(player->getTitle()));
- else
- ui->lbTitle->setText(QString("Title: ")+player->getTitle());
- }
- else ui->lbTitle->setText(QString("Title: "));
- if(player->getCopyright())
- {
- if(textencoding!="Unicode")
- ui->lbCopyright->setText(QString("Copyright: ")+
- QTextCodec::codecForName(textencoding.c_str())->toUnicode(player->getCopyright()));
- else
- ui->lbCopyright->setText(QString("Copyright: ")+player->getCopyright());
- }
- else ui->lbCopyright->setText(QString("Copyright: "));
- ui->lbTempo->setText(QString("Tempo: ")+QString::number(player->getTempo(),'g',5));
- int t,r;t=player->getCurrentKeySignature();r=(int8_t)((t>>8)&0xFF)+7;
- strncpy(str,t&0xFF?minors+2*r:majors+2*r,2);str[2]='\0';
- ui->lbKeySig->setText(QString("Key Sig.: ")+str);
- player->getCurrentTimeSignature(&t,&r);sprintf(str,"Time Sig.: %d/%d",t,r);
- ui->lbTimeSig->setText(str);
- sprintf(str,"Note count: %u",player->getFileNoteCount());
- ui->lbNoteCount->setText(str);
- strncpy(str,standards+player->getFileStandard()*3,3);str[3]='\0';
- ui->lbFileStandard->setText(QString("File standard: ")+str);
+ char str[256];
+ CMidiPlayer *player = qmpMainWindow::getInstance()->getPlayer();
+ std::string textencoding = qmpMainWindow::getInstance()->getSettings()->getOptionEnumIntOptName("Midi/TextEncoding");
+ ui->lbFileName->setText(QString("File name: ") + qmpMainWindow::getInstance()->getFileName());
+ if (player->getTitle())
+ {
+ if (textencoding != "Unicode")
+ ui->lbTitle->setText(QString("Title: ") +
+ QTextCodec::codecForName(textencoding.c_str())->toUnicode(player->getTitle()));
+ else
+ ui->lbTitle->setText(QString("Title: ") + player->getTitle());
+ }
+ else ui->lbTitle->setText(QString("Title: "));
+ if (player->getCopyright())
+ {
+ if (textencoding != "Unicode")
+ ui->lbCopyright->setText(QString("Copyright: ") +
+ QTextCodec::codecForName(textencoding.c_str())->toUnicode(player->getCopyright()));
+ else
+ ui->lbCopyright->setText(QString("Copyright: ") + player->getCopyright());
+ }
+ else ui->lbCopyright->setText(QString("Copyright: "));
+ ui->lbTempo->setText(QString("Tempo: ") + QString::number(player->getTempo(), 'g', 5));
+ int t, r;
+ t = player->getCurrentKeySignature();
+ r = (int8_t)((t >> 8) & 0xFF) + 7;
+ strncpy(str, t & 0xFF ? minors + 2 * r : majors + 2 * r, 2);
+ str[2] = '\0';
+ ui->lbKeySig->setText(QString("Key Sig.: ") + str);
+ player->getCurrentTimeSignature(&t, &r);
+ sprintf(str, "Time Sig.: %d/%d", t, r);
+ ui->lbTimeSig->setText(str);
+ sprintf(str, "Note count: %u", player->getFileNoteCount());
+ ui->lbNoteCount->setText(str);
+ strncpy(str, standards + player->getFileStandard() * 3, 3);
+ str[3] = '\0';
+ ui->lbFileStandard->setText(QString("File standard: ") + str);
}
qmpInfoFunc::qmpInfoFunc(qmpInfoWindow *par)
-{p=par;}
+{
+ p = par;
+}
void qmpInfoFunc::show()
-{p->show();}
+{
+ p->show();
+}
void qmpInfoFunc::close()
-{p->close();}
+{
+ p->close();
+}
diff --git a/qmidiplayer-desktop/qmpinfowindow.hpp b/qmidiplayer-desktop/qmpinfowindow.hpp
index 6a179af..7e09b8a 100644
--- a/qmidiplayer-desktop/qmpinfowindow.hpp
+++ b/qmidiplayer-desktop/qmpinfowindow.hpp
@@ -10,50 +10,51 @@
#include <QHideEvent>
#include "../include/qmpcorepublic.hpp"
-namespace Ui {
- class qmpInfoWindow;
+namespace Ui
+{
+class qmpInfoWindow;
}
class QClickableLabel : public QLabel
{
- Q_OBJECT
- public:
- explicit QClickableLabel(QWidget *parent=0):QLabel(parent){}
- protected:
- void mousePressEvent(QMouseEvent *e)
- {
- QLabel::mousePressEvent(e);
- if(e->buttons()&Qt::LeftButton)
- QApplication::clipboard()->setText(text());
- }
+ Q_OBJECT
+public:
+ explicit QClickableLabel(QWidget *parent = nullptr) : QLabel(parent) {}
+protected:
+ void mousePressEvent(QMouseEvent *e)
+ {
+ QLabel::mousePressEvent(e);
+ if (e->buttons() & Qt::LeftButton)
+ QApplication::clipboard()->setText(text());
+ }
};
class qmpInfoWindow;
-class qmpInfoFunc:public qmpFuncBaseIntf
+class qmpInfoFunc : public qmpFuncBaseIntf
{
- private:
- qmpInfoWindow *p;
- public:
- qmpInfoFunc(qmpInfoWindow *par);
- void show();
- void close();
+private:
+ qmpInfoWindow *p;
+public:
+ qmpInfoFunc(qmpInfoWindow *par);
+ void show();
+ void close();
};
class qmpInfoWindow : public QDialog
{
- Q_OBJECT
-
- public:
- explicit qmpInfoWindow(QWidget *parent = 0);
- ~qmpInfoWindow();
- void closeEvent(QCloseEvent *e);
- void hideEvent(QHideEvent *e);
- public slots:
- void updateInfo();
-
- private:
- Ui::qmpInfoWindow *ui;
- qmpInfoFunc *infof;
+ Q_OBJECT
+
+public:
+ explicit qmpInfoWindow(QWidget *parent = nullptr);
+ ~qmpInfoWindow();
+ void closeEvent(QCloseEvent *e);
+ void hideEvent(QHideEvent *e);
+public slots:
+ void updateInfo();
+
+private:
+ Ui::qmpInfoWindow *ui;
+ qmpInfoFunc *infof;
};
#endif // QMPINFOWINDOW_HPP
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index ea90493..98378aa 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -16,797 +16,938 @@
#define setButtonWidth(x,h) {x->setMaximumWidth(h*(logicalDpiY()/96.));x->setMinimumWidth(h*(logicalDpiY()/96.));}
#ifdef _WIN32
#include <windows.h>
-char* wcsto8bit(const wchar_t* s)
+char *wcsto8bit(const wchar_t *s)
{
- int size=WideCharToMultiByte(CP_OEMCP,WC_NO_BEST_FIT_CHARS,s,-1,0,0,0,0);
- char* c=(char*)calloc(size,sizeof(char));
- WideCharToMultiByte(CP_OEMCP,WC_NO_BEST_FIT_CHARS,s,-1,c,size,0,0);
- return c;
+ int size = WideCharToMultiByte(CP_OEMCP, WC_NO_BEST_FIT_CHARS, s, -1, 0, 0, 0, 0);
+ char *c = (char *)calloc(size, sizeof(char));
+ WideCharToMultiByte(CP_OEMCP, WC_NO_BEST_FIT_CHARS, s, -1, c, size, 0, 0);
+ return c;
}
#endif
#define UPDATE_INTERVAL 66
-qmpMainWindow* qmpMainWindow::ref=nullptr;
-
-qmpMainWindow::qmpMainWindow(QCommandLineParser *_clp,QWidget *parent):
- QMainWindow(parent),
- ui(new Ui::qmpMainWindow),
- clp(_clp)
-{
- ui->setupUi(this);
- ui->lbCurPoly->setText("00000");ui->lbMaxPoly->setText("00000");
- ui->lbFileName->setText("");ref=this;ui->verticalLayout->setAlignment(ui->pushButton,Qt::AlignRight);
- setButtonHeight(ui->pbNext,36);setButtonHeight(ui->pbPlayPause,36);setButtonHeight(ui->pbAdd,36);
- setButtonHeight(ui->pbPrev,36);setButtonHeight(ui->pbSettings,36);setButtonHeight(ui->pbStop,36);
- playing=false;stopped=true;dragging=false;fin=false;
- settings.reset(new qmpSettings());
- settingsw=new qmpSettingsWindow(settings.get(),this);
- player=nullptr;timer=nullptr;fluidrenderer=nullptr;
+qmpMainWindow *qmpMainWindow::ref = nullptr;
+
+qmpMainWindow::qmpMainWindow(QCommandLineParser *_clp, QWidget *parent):
+ QMainWindow(parent),
+ ui(new Ui::qmpMainWindow),
+ clp(_clp)
+{
+ ui->setupUi(this);
+ ui->lbCurPoly->setText("00000");
+ ui->lbMaxPoly->setText("00000");
+ ui->lbFileName->setText("");
+ ref = this;
+ ui->verticalLayout->setAlignment(ui->pushButton, Qt::AlignRight);
+ setButtonHeight(ui->pbNext, 36);
+ setButtonHeight(ui->pbPlayPause, 36);
+ setButtonHeight(ui->pbAdd, 36);
+ setButtonHeight(ui->pbPrev, 36);
+ setButtonHeight(ui->pbSettings, 36);
+ setButtonHeight(ui->pbStop, 36);
+ playing = false;
+ stopped = true;
+ dragging = false;
+ fin = false;
+ settings.reset(new qmpSettings());
+ settingsw = new qmpSettingsWindow(settings.get(), this);
+ player = nullptr;
+ timer = nullptr;
+ fluidrenderer = nullptr;
}
qmpMainWindow::~qmpMainWindow()
{
- QList<QAction*>a=ui->lbFileName->actions();
- for(unsigned i=0;i<a.size();++i)
- {
- ui->lbFileName->removeAction(a[i]);
- delete a[i];
- }
- pmgr->deinitPlugins();
- auto rtdev=qmpRtMidiManager::getDevices();
- for(auto &i:rtdev)player->unregisterMidiOutDevice(i.second);
- delete pmgr;
- if(timer)delete timer;
- delete helpw;helpw=nullptr;
- delete efxw;efxw=nullptr;
- delete chnlw;chnlw=nullptr;
- delete plistw;plistw=nullptr;
- delete infow;infow=nullptr;
- delete settingsw;settingsw=nullptr;
- delete panicf;panicf=nullptr;
- delete renderf;renderf=nullptr;
- delete reloadsynf;reloadsynf=nullptr;
- if(player)delete player;
- internalfluid->deviceDeinit();
- delete internalfluid;
- delete ui;
+ QList<QAction *>a = ui->lbFileName->actions();
+ for (unsigned i = 0; i < a.size(); ++i)
+ {
+ ui->lbFileName->removeAction(a[i]);
+ delete a[i];
+ }
+ pmgr->deinitPlugins();
+ auto rtdev = qmpRtMidiManager::getDevices();
+ for (auto &i : rtdev)
+ player->unregisterMidiOutDevice(i.second);
+ delete pmgr;
+ if (timer)
+ delete timer;
+ delete helpw;
+ helpw = nullptr;
+ delete efxw;
+ efxw = nullptr;
+ delete chnlw;
+ chnlw = nullptr;
+ delete plistw;
+ plistw = nullptr;
+ delete infow;
+ infow = nullptr;
+ delete settingsw;
+ settingsw = nullptr;
+ delete panicf;
+ panicf = nullptr;
+ delete renderf;
+ renderf = nullptr;
+ delete reloadsynf;
+ reloadsynf = nullptr;
+ if (player)
+ delete player;
+ internalfluid->deviceDeinit();
+ delete internalfluid;
+ delete ui;
}
void qmpMainWindow::init()
{
- show();
- ui->centralWidget->setEnabled(false);
-
- pmgr=new qmpPluginManager();
- registerMidiOptions();
-
- std::future<void> f=std::async(std::launch::async,
- [this]
- {
- player=new CMidiPlayer();
- internalfluid=new qmpMidiOutFluid();
- player->registerMidiOutDevice(internalfluid,"Internal FluidSynth");
- reloadsynf=new qmpReloadSynthFunc(this);
-
- internalfluid->registerOptions(pmgr->pluginAPI);
- playerSetup(internalfluid);
- internalfluid->deviceInit();
- loadSoundFont(internalfluid);
- for(int i=0;i<16;++i)
- player->setChannelOutput(i,0);
-
- auto rtdev=qmpRtMidiManager::getDevices();
- for(auto &i:rtdev)
- player->registerMidiOutDevice(i.first,i.second);
- }
- );
- while(f.wait_for(std::chrono::milliseconds(100))==std::future_status::timeout)
- QApplication::processEvents();
- ui->centralWidget->setEnabled(true);
-
- settingsw->registerSoundFontOption();
- registerBehaviorOptions();
- settingsw->registerCustomizeWidgetOptions();
-
- plistw=new qmpPlistWindow(this);
- chnlw=new qmpChannelsWindow(this);
- efxw=new qmpEfxWindow(this);
- infow=new qmpInfoWindow(this);
- helpw=new qmpHelpWindow(this);
- timer=new QTimer(this);
- renderf=new qmpRenderFunc(this);
- panicf=new qmpPanicFunc(this);
- if(argfiles.size())
- {
- plistw->emptyList();
- for(auto&i:argfiles)plistw->insertItem(i);
- }
-
- if(settings->getOptionBool("Behavior/DialogStatus"))
- {
- QRect g=settings->getOptionRaw("DialogStatus/MainW",QRect(-999,-999,999,999)).toRect();
- if(g!=QRect(-999,-999,999,999))setGeometry(g);
- }
-
- registerFunctionality(renderf,"Render",tr("Render to wave").toStdString(),getThemedIconc(":/img/render.svg"),0,false);
- registerFunctionality(panicf,"Panic",tr("Panic").toStdString(),getThemedIconc(":/img/panic.svg"),0,false);
- registerFunctionality(reloadsynf,"ReloadSynth",tr("Restart fluidsynth").toStdString(),getThemedIconc(":/img/repeat-base.svg"),0,false);
- const QStringList &qpp=clp->values("plugin");
- std::vector<std::string> pp;
- for(auto s:qpp)
- pp.push_back(s.toStdString());
- pmgr->scanPlugins(pp);
- settingsw->registerPluginOption(pmgr);
- settingsw->updatePluginList(pmgr);
- pmgr->initPlugins();
-
- settingsw->registerExtraMidiOptions();
-
- QVariant* dinif_v=static_cast<QVariant*>(settings->getOptionCustom("Midi/DeviceInitializationFiles"));
- QList<QVariant> devinif_list=dinif_v->toList();
- delete dinif_v;
- QMap<QString,QString> devinif_map;
- for(auto &i:devinif_list)
- {
- QPair<QString,QString> p=i.value<QPair<QString,QString>>();
- devinif_map[p.first]=p.second;
- }
- auto rtdev=qmpRtMidiManager::getDevices();
- for(auto &i:rtdev)
- {
- if(devinif_map.contains(QString(i.second.c_str())))
- i.first->setInitializerFile(devinif_map[QString(i.second.c_str())].toStdString().c_str());
- }
- chnlw->selectDefaultDevice();
-
- ui->vsMasterVol->setValue(settings->getOptionRaw("FluidSynth/Gain",50).toInt());
- connect(timer,&QTimer::timeout,this,&qmpMainWindow::updateWidgets);
- connect(timer,&QTimer::timeout,infow,&qmpInfoWindow::updateInfo);
- ui->pbNext->setIcon(QIcon(getThemedIcon(":/img/next.svg")));
- ui->pbPrev->setIcon(QIcon(getThemedIcon(":/img/prev.svg")));
- ui->pbPlayPause->setIcon(QIcon(getThemedIcon(":/img/play.svg")));
- ui->pbStop->setIcon(QIcon(getThemedIcon(":/img/stop.svg")));
- ui->pbSettings->setIcon(QIcon(getThemedIcon(":/img/settings.svg")));
- ui->pbAdd->setIcon(QIcon(getThemedIcon(":/img/open.svg")));
- if(argfiles.size())on_pbPlayPause_clicked();
- setupWidget();settingsw->postInit();
+ show();
+ ui->centralWidget->setEnabled(false);
+
+ pmgr = new qmpPluginManager();
+ registerMidiOptions();
+
+ std::future<void> f = std::async(std::launch::async, [this]
+ {
+ player = new CMidiPlayer();
+ internalfluid = new qmpMidiOutFluid();
+ player->registerMidiOutDevice(internalfluid, "Internal FluidSynth");
+ reloadsynf = new qmpReloadSynthFunc(this);
+
+ internalfluid->registerOptions(pmgr->pluginAPI);
+ playerSetup(internalfluid);
+ internalfluid->deviceInit();
+ loadSoundFont(internalfluid);
+ for (int i = 0; i < 16; ++i)
+ player->setChannelOutput(i, 0);
+
+ auto rtdev = qmpRtMidiManager::getDevices();
+ for (auto &i : rtdev)
+ player->registerMidiOutDevice(i.first, i.second);
+ });
+ while (f.wait_for(std::chrono::milliseconds(100)) == std::future_status::timeout)
+ QApplication::processEvents();
+ ui->centralWidget->setEnabled(true);
+
+ settingsw->registerSoundFontOption();
+ registerBehaviorOptions();
+ settingsw->registerCustomizeWidgetOptions();
+
+ plistw = new qmpPlistWindow(this);
+ chnlw = new qmpChannelsWindow(this);
+ efxw = new qmpEfxWindow(this);
+ infow = new qmpInfoWindow(this);
+ helpw = new qmpHelpWindow(this);
+ timer = new QTimer(this);
+ renderf = new qmpRenderFunc(this);
+ panicf = new qmpPanicFunc(this);
+ if (argfiles.size())
+ {
+ plistw->emptyList();
+ for (auto &i : argfiles)
+ plistw->insertItem(i);
+ }
+
+ if (settings->getOptionBool("Behavior/DialogStatus"))
+ {
+ QRect g = settings->getOptionRaw("DialogStatus/MainW", QRect(-999, -999, 999, 999)).toRect();
+ if (g != QRect(-999, -999, 999, 999))
+ setGeometry(g);
+ }
+
+ registerFunctionality(renderf, "Render", tr("Render to wave").toStdString(), getThemedIconc(":/img/render.svg"), 0, false);
+ registerFunctionality(panicf, "Panic", tr("Panic").toStdString(), getThemedIconc(":/img/panic.svg"), 0, false);
+ registerFunctionality(reloadsynf, "ReloadSynth", tr("Restart fluidsynth").toStdString(), getThemedIconc(":/img/repeat-base.svg"), 0, false);
+ const QStringList &qpp = clp->values("plugin");
+ std::vector<std::string> pp;
+ for (auto &s : qpp)
+ pp.push_back(s.toStdString());
+ pmgr->scanPlugins(pp);
+ settingsw->registerPluginOption(pmgr);
+ settingsw->updatePluginList(pmgr);
+ pmgr->initPlugins();
+
+ settingsw->registerExtraMidiOptions();
+
+ QVariant *dinif_v = static_cast<QVariant *>(settings->getOptionCustom("Midi/DeviceInitializationFiles"));
+ QList<QVariant> devinif_list = dinif_v->toList();
+ delete dinif_v;
+ QMap<QString, QString> devinif_map;
+ for (auto &i : devinif_list)
+ {
+ QPair<QString, QString> p = i.value<QPair<QString, QString>>();
+ devinif_map[p.first] = p.second;
+ }
+ auto rtdev = qmpRtMidiManager::getDevices();
+ for (auto &i : rtdev)
+ {
+ if (devinif_map.contains(QString(i.second.c_str())))
+ i.first->setInitializerFile(devinif_map[QString(i.second.c_str())].toStdString().c_str());
+ }
+ chnlw->selectDefaultDevice();
+
+ ui->vsMasterVol->setValue(settings->getOptionRaw("FluidSynth/Gain", 50).toInt());
+ connect(timer, &QTimer::timeout, this, &qmpMainWindow::updateWidgets);
+ connect(timer, &QTimer::timeout, infow, &qmpInfoWindow::updateInfo);
+ ui->pbNext->setIcon(QIcon(getThemedIcon(":/img/next.svg")));
+ ui->pbPrev->setIcon(QIcon(getThemedIcon(":/img/prev.svg")));
+ ui->pbPlayPause->setIcon(QIcon(getThemedIcon(":/img/play.svg")));
+ ui->pbStop->setIcon(QIcon(getThemedIcon(":/img/stop.svg")));
+ ui->pbSettings->setIcon(QIcon(getThemedIcon(":/img/settings.svg")));
+ ui->pbAdd->setIcon(QIcon(getThemedIcon(":/img/open.svg")));
+ if (argfiles.size())
+ on_pbPlayPause_clicked();
+ setupWidget();
+ settingsw->postInit();
}
int qmpMainWindow::parseArgs()
{
- bool loadfolder=clp->isSet("load-all-files");
- const QStringList &args=clp->positionalArguments();
- for(int i=0;i<args.size();++i)
- {
- if(QFileInfo(args.at(i)).exists())
- {
- if(loadfolder||settings->getOptionBool("Behavior/LoadFolder"))
- {
- QDirIterator di(QFileInfo(args.at(i)).absolutePath());
- while(di.hasNext())
- {
- QString c=di.next();
- argfiles.push_back(c);
- }
- }
- else
- argfiles.push_back(args.at(i));
- }
- }
- return 0;
+ bool loadfolder = clp->isSet("load-all-files");
+ const QStringList &args = clp->positionalArguments();
+ for (int i = 0; i < args.size(); ++i)
+ {
+ if (QFileInfo(args.at(i)).exists())
+ {
+ if (loadfolder || settings->getOptionBool("Behavior/LoadFolder"))
+ {
+ QDirIterator di(QFileInfo(args.at(i)).absolutePath());
+ while (di.hasNext())
+ {
+ QString c = di.next();
+ argfiles.push_back(c);
+ }
+ }
+ else
+ argfiles.push_back(args.at(i));
+ }
+ }
+ return 0;
}
void qmpMainWindow::closeEvent(QCloseEvent *event)
{
- if(settings->getOptionBool("Behavior/DialogStatus"))
- {
- settings->setOptionRaw("DialogStatus/MainW",geometry());
- }
- on_pbStop_clicked();fin=true;
- for(auto i=mfunc.begin();i!=mfunc.end();++i)
- {
- i->second.i()->close();
- i->second.setAssignedControl((QReflectiveAction*)nullptr),
- i->second.setAssignedControl((QReflectivePushButton*)nullptr);
- }
- efxw->close();chnlw->close();
- plistw->close();infow->close();
- settingsw->close();
- event->accept();
+ if (settings->getOptionBool("Behavior/DialogStatus"))
+ {
+ settings->setOptionRaw("DialogStatus/MainW", geometry());
+ }
+ on_pbStop_clicked();
+ fin = true;
+ for (auto i = mfunc.begin(); i != mfunc.end(); ++i)
+ {
+ i->second.i()->close();
+ i->second.setAssignedControl((QReflectiveAction *)nullptr),
+ i->second.setAssignedControl((QReflectivePushButton *)nullptr);
+ }
+ efxw->close();
+ chnlw->close();
+ plistw->close();
+ infow->close();
+ settingsw->close();
+ event->accept();
}
void qmpMainWindow::dropEvent(QDropEvent *event)
{
- QList<QUrl> l=event->mimeData()->urls();
- QStringList sl;
- for(int i=0;i<l.size();++i)
- sl.push_back(l.at(i).toLocalFile());
- plistw->insertItems(sl);
- switchTrack(plistw->getLastItem());
+ QList<QUrl> l = event->mimeData()->urls();
+ QStringList sl;
+ for (int i = 0; i < l.size(); ++i)
+ sl.push_back(l.at(i).toLocalFile());
+ plistw->insertItems(sl);
+ switchTrack(plistw->getLastItem());
}
void qmpMainWindow::dragEnterEvent(QDragEnterEvent *event)
{
- //if(event->mimeData()->hasFormat("application/x-midi"))
- event->acceptProposedAction();
+ //if(event->mimeData()->hasFormat("application/x-midi"))
+ event->acceptProposedAction();
}
void qmpMainWindow::updateWidgets()
{
- setFuncEnabled("Render",stopped);setFuncEnabled("ReloadSynth",stopped);
- if(player->isFinished()&&playerTh)
- {
- if(!plistw->getRepeat())
- {
- timer->stop();stopped=true;playing=false;
- invokeCallback("main.stop",nullptr);
- setFuncEnabled("Render",stopped);setFuncEnabled("ReloadSynth",stopped);
- player->playerDeinit();
- auto f=std::async([this]{playerTh->join();});
- while(f.wait_for(std::chrono::milliseconds(100))==std::future_status::timeout)
- {
- QApplication::processEvents();
- ui->lbCurPoly->setText(QString("%1").arg(internalfluid->getPolyphone(),5,10,QChar('0')));
- ui->lbMaxPoly->setText(QString("%1").arg(internalfluid->getMaxPolyphone(),5,10,QChar('0')));
- }
- delete playerTh;playerTh=nullptr;
- player->playerPanic(true);
- chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
- ui->pbPlayPause->setIcon(QIcon(getThemedIcon(":/img/play.svg")));
- ui->hsTimer->setValue(0);
- ui->lbCurPoly->setText("00000");ui->lbMaxPoly->setText("00000");
- ui->lbCurTime->setText("00:00");
- }
- else
- switchTrack(plistw->getNextItem(),false);
- }
- if(renderTh)
- {
- if(fluidrenderer->isFinished())
- {
- renderTh->join();timer->stop();
- ui->centralWidget->setEnabled(true);
- delete renderTh;renderTh=nullptr;
- fluidrenderer->renderDeinit();
- delete fluidrenderer;fluidrenderer=nullptr;
- }
- }
- while(!player->isFinished()&&player->getTCeptr()>player->getStamp(ui->hsTimer->value())
- &&ui->hsTimer->value()<100&&!dragging)
- ui->hsTimer->setValue(ui->hsTimer->value()+1);
- if(playing)
- {
- std::chrono::duration<double> elapsed=
- std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::steady_clock::now()-st);
- char ts[100];
- sprintf(ts,"%02d:%02d",(int)(elapsed.count()+offset)/60,(int)(elapsed.count()+offset)%60);
- ui->lbCurTime->setText(ts);
- ui->lbCurPoly->setText(QString("%1").arg(internalfluid->getPolyphone(),5,10,QChar('0')));
- ui->lbMaxPoly->setText(QString("%1").arg(internalfluid->getMaxPolyphone(),5,10,QChar('0')));
- }
-}
-
-QString qmpMainWindow::getFileName(){return ui->lbFileName->text();}
-void qmpMainWindow::switchTrack(QString s,bool interrupt)
-{
- stopped=false;playing=true;
- setFuncEnabled("Render",stopped);setFuncEnabled("ReloadSynth",stopped);
- ui->pbPlayPause->setIcon(QIcon(getThemedIcon(":/img/pause.svg")));
- if(interrupt)
- {
- player->playerDeinit();
- player->playerPanic();
- }
- invokeCallback("main.stop",nullptr);
- if(playerTh)
- {
- auto f=std::async([this]{playerTh->join();});
- while(f.wait_for(std::chrono::milliseconds(100))==std::future_status::timeout)
- {
- QApplication::processEvents();
- ui->lbCurPoly->setText(QString("%1").arg(internalfluid->getPolyphone(),5,10,QChar('0')));
- ui->lbMaxPoly->setText(QString("%1").arg(internalfluid->getMaxPolyphone(),5,10,QChar('0')));
- }
- delete playerTh;playerTh=nullptr;
- }
- timer->stop();
- player->playerPanic(true);
- ui->hsTimer->setValue(0);
- chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
- QString fns=s;setWindowTitle(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.'))+" - QMidiPlayer");
- ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.')));
- onfnChanged();
- if(!loadFile(fns))return;
- char ts[100];
- sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
- ui->lbFinTime->setText(ts);
- player->playerInit();
- invokeCallback("main.start",nullptr);
- internalfluid->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange();
- playerTh=new std::thread([this]{
- player->playerThread();
- if(settings->getOptionBool("Midi/WaitVoice")&&player->isFinished())
- while(internalfluid->getPolyphone()>0)
- std::this_thread::sleep_for(std::chrono::milliseconds(10));
- });
+ setFuncEnabled("Render", stopped);
+ setFuncEnabled("ReloadSynth", stopped);
+ if (player->isFinished() && playerTh)
+ {
+ if (!plistw->getRepeat())
+ {
+ timer->stop();
+ stopped = true;
+ playing = false;
+ invokeCallback("main.stop", nullptr);
+ setFuncEnabled("Render", stopped);
+ setFuncEnabled("ReloadSynth", stopped);
+ player->playerDeinit();
+ auto f = std::async([this] {playerTh->join();});
+ while (f.wait_for(std::chrono::milliseconds(100)) == std::future_status::timeout)
+ {
+ QApplication::processEvents();
+ ui->lbCurPoly->setText(QString("%1").arg(internalfluid->getPolyphone(), 5, 10, QChar('0')));
+ ui->lbMaxPoly->setText(QString("%1").arg(internalfluid->getMaxPolyphone(), 5, 10, QChar('0')));
+ }
+ delete playerTh;
+ playerTh = nullptr;
+ player->playerPanic(true);
+ chnlw->on_pbUnmute_clicked();
+ chnlw->on_pbUnsolo_clicked();
+ ui->pbPlayPause->setIcon(QIcon(getThemedIcon(":/img/play.svg")));
+ ui->hsTimer->setValue(0);
+ ui->lbCurPoly->setText("00000");
+ ui->lbMaxPoly->setText("00000");
+ ui->lbCurTime->setText("00:00");
+ }
+ else
+ switchTrack(plistw->getNextItem(), false);
+ }
+ if (renderTh)
+ {
+ if (fluidrenderer->isFinished())
+ {
+ renderTh->join();
+ timer->stop();
+ ui->centralWidget->setEnabled(true);
+ delete renderTh;
+ renderTh = nullptr;
+ fluidrenderer->renderDeinit();
+ delete fluidrenderer;
+ fluidrenderer = nullptr;
+ }
+ }
+ while (!player->isFinished() && player->getTCeptr() > player->getStamp(ui->hsTimer->value())
+ && ui->hsTimer->value() < 100 && !dragging)
+ ui->hsTimer->setValue(ui->hsTimer->value() + 1);
+ if (playing)
+ {
+ std::chrono::duration<double> elapsed =
+ std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::steady_clock::now() - st);
+ char ts[100];
+ sprintf(ts, "%02d:%02d", (int)(elapsed.count() + offset) / 60, (int)(elapsed.count() + offset) % 60);
+ ui->lbCurTime->setText(ts);
+ ui->lbCurPoly->setText(QString("%1").arg(internalfluid->getPolyphone(), 5, 10, QChar('0')));
+ ui->lbMaxPoly->setText(QString("%1").arg(internalfluid->getMaxPolyphone(), 5, 10, QChar('0')));
+ }
+}
+
+QString qmpMainWindow::getFileName()
+{
+ return ui->lbFileName->text();
+}
+void qmpMainWindow::switchTrack(QString s, bool interrupt)
+{
+ stopped = false;
+ playing = true;
+ setFuncEnabled("Render", stopped);
+ setFuncEnabled("ReloadSynth", stopped);
+ ui->pbPlayPause->setIcon(QIcon(getThemedIcon(":/img/pause.svg")));
+ if (interrupt)
+ {
+ player->playerDeinit();
+ player->playerPanic();
+ }
+ invokeCallback("main.stop", nullptr);
+ if (playerTh)
+ {
+ auto f = std::async([this] {playerTh->join();});
+ while (f.wait_for(std::chrono::milliseconds(100)) == std::future_status::timeout)
+ {
+ QApplication::processEvents();
+ ui->lbCurPoly->setText(QString("%1").arg(internalfluid->getPolyphone(), 5, 10, QChar('0')));
+ ui->lbMaxPoly->setText(QString("%1").arg(internalfluid->getMaxPolyphone(), 5, 10, QChar('0')));
+ }
+ delete playerTh;
+ playerTh = nullptr;
+ }
+ timer->stop();
+ player->playerPanic(true);
+ ui->hsTimer->setValue(0);
+ chnlw->on_pbUnmute_clicked();
+ chnlw->on_pbUnsolo_clicked();
+ QString fns = s;
+ setWindowTitle(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.')) + " - QMidiPlayer");
+ ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.')));
+ onfnChanged();
+ if (!loadFile(fns))
+ return;
+ char ts[100];
+ sprintf(ts, "%02d:%02d", (int)player->getFtime() / 60, (int)player->getFtime() % 60);
+ ui->lbFinTime->setText(ts);
+ player->playerInit();
+ invokeCallback("main.start", nullptr);
+ internalfluid->setGain(ui->vsMasterVol->value() / 250.);
+ efxw->sendEfxChange();
+ playerTh = new std::thread([this]
+ {
+ player->playerThread();
+ if (settings->getOptionBool("Midi/WaitVoice") && player->isFinished())
+ while (internalfluid->getPolyphone() > 0)
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
+ });
#ifdef _WIN32
- SetThreadPriority((void*)playerTh->native_handle(),THREAD_PRIORITY_TIME_CRITICAL);
+ SetThreadPriority((void *)playerTh->native_handle(), THREAD_PRIORITY_TIME_CRITICAL);
#endif
- st=std::chrono::steady_clock::now();offset=0;
- timer->start(UPDATE_INTERVAL);
+ st = std::chrono::steady_clock::now();
+ offset = 0;
+ timer->start(UPDATE_INTERVAL);
}
std::string qmpMainWindow::getTitle()
{
- if(settings->getOptionEnumIntOptName("Midi/TextEncoding")=="Unicode")
- return std::string(player->getTitle());
- return QTextCodec::codecForName(
- settings->getOptionEnumIntOptName("Midi/TextEncoding").c_str())->
- toUnicode(player->getTitle()).toStdString();
+ if (settings->getOptionEnumIntOptName("Midi/TextEncoding") == "Unicode")
+ return std::string(player->getTitle());
+ return QTextCodec::codecForName(
+ settings->getOptionEnumIntOptName("Midi/TextEncoding").c_str())->
+ toUnicode(player->getTitle()).toStdString();
}
std::wstring qmpMainWindow::getWTitle()
{
- if(settings->getOptionEnumIntOptName("Midi/TextEncoding")=="Unicode")
- return QString(player->getTitle()).toStdWString();
- return QTextCodec::codecForName(
- settings->getOptionEnumIntOptName("Midi/TextEncoding").c_str())->
- toUnicode(player->getTitle()).toStdWString();
-}
-
-void qmpMainWindow::playerSetup(IFluidSettings* fs)
-{
- fs->setOptStr("audio.driver",settings->getOptionEnumIntOptName("FluidSynth/AudioDriver").c_str());
- fs->setOptInt("audio.period-size",settings->getOptionInt("FluidSynth/BufSize"));
- fs->setOptInt("audio.periods",settings->getOptionInt("FluidSynth/BufCnt"));
- fs->setOptStr("audio.sample-format",settings->getOptionEnumIntOptName("FluidSynth/SampleFormat").c_str());
- fs->setOptNum("synth.sample-rate",settings->getOptionInt("FluidSynth/SampleRate"));
- fs->setOptInt("synth.polyphony",settings->getOptionInt("FluidSynth/Polyphony"));
- fs->setOptInt("synth.cpu-cores",settings->getOptionInt("FluidSynth/Threads"));
- std::string bsmode;
- if(settings->getOptionBool("FluidSynth/AutoBS")&&player->getFileStandard())
- switch(player->getFileStandard())
- {
- case 1:bsmode="gm";break;
- case 2:bsmode="mma";break;
- case 3:bsmode="gs";break;
- case 4:bsmode="xg";break;
- }
- else
- {
- bsmode=settings->getOptionEnumIntOptName("FluidSynth/BankSelect");
- std::transform(bsmode.begin(),bsmode.end(),bsmode.begin(),[](char i){return tolower(i);});
- }
- fs->setOptStr("synth.midi-bank-select",bsmode.c_str());
- player->sendSysX(settings->getOptionBool("Midi/SendSysEx"));
+ if (settings->getOptionEnumIntOptName("Midi/TextEncoding") == "Unicode")
+ return QString(player->getTitle()).toStdWString();
+ return QTextCodec::codecForName(
+ settings->getOptionEnumIntOptName("Midi/TextEncoding").c_str())->
+ toUnicode(player->getTitle()).toStdWString();
+}
+
+void qmpMainWindow::playerSetup(IFluidSettings *fs)
+{
+ fs->setOptStr("audio.driver", settings->getOptionEnumIntOptName("FluidSynth/AudioDriver").c_str());
+ fs->setOptInt("audio.period-size", settings->getOptionInt("FluidSynth/BufSize"));
+ fs->setOptInt("audio.periods", settings->getOptionInt("FluidSynth/BufCnt"));
+ fs->setOptStr("audio.sample-format", settings->getOptionEnumIntOptName("FluidSynth/SampleFormat").c_str());
+ fs->setOptNum("synth.sample-rate", settings->getOptionInt("FluidSynth/SampleRate"));
+ fs->setOptInt("synth.polyphony", settings->getOptionInt("FluidSynth/Polyphony"));
+ fs->setOptInt("synth.cpu-cores", settings->getOptionInt("FluidSynth/Threads"));
+ std::string bsmode;
+ if (settings->getOptionBool("FluidSynth/AutoBS") && player->getFileStandard())
+ switch (player->getFileStandard())
+ {
+ case 1:
+ bsmode = "gm";
+ break;
+ case 2:
+ bsmode = "mma";
+ break;
+ case 3:
+ bsmode = "gs";
+ break;
+ case 4:
+ bsmode = "xg";
+ break;
+ }
+ else
+ {
+ bsmode = settings->getOptionEnumIntOptName("FluidSynth/BankSelect");
+ std::transform(bsmode.begin(), bsmode.end(), bsmode.begin(), [](char i)
+ {
+ return tolower(i);
+ });
+ }
+ fs->setOptStr("synth.midi-bank-select", bsmode.c_str());
+ player->sendSysX(settings->getOptionBool("Midi/SendSysEx"));
}
void qmpMainWindow::loadSoundFont(IFluidSettings *fs)
{
- QVariant *data=static_cast<QVariant*>(settings->getOptionCustom("FluidSynth/SoundFonts"));
- QList<QVariant> sflist=data->toList();
- for(auto i=sflist.rbegin();i!=sflist.rend();++i)
- {
- if(i->toString().startsWith('#'))continue;
- QString sf=i->toString();
+ QVariant *data = static_cast<QVariant *>(settings->getOptionCustom("FluidSynth/SoundFonts"));
+ QList<QVariant> sflist = data->toList();
+ for (auto i = sflist.rbegin(); i != sflist.rend(); ++i)
+ {
+ if (i->toString().startsWith('#'))
+ continue;
+ QString sf = i->toString();
#ifdef _WIN32
- char* c=wcsto8bit(sf.toStdWString().c_str());
- fs->loadSFont(c);
- free(c);
+ char *c = wcsto8bit(sf.toStdWString().c_str());
+ fs->loadSFont(c);
+ free(c);
#else
- fs->loadSFont(sf.toStdString().c_str());
+ fs->loadSFont(sf.toStdString().c_str());
#endif
- }
- delete data;
+ }
+ delete data;
}
int qmpMainWindow::loadFile(QString fns)
{
#ifdef _WIN32
- char* c=wcsto8bit(fns.toStdWString().c_str());
+ char *c = wcsto8bit(fns.toStdWString().c_str());
#else
- std::string s=fns.toStdString();
- const char* c=s.c_str();
+ std::string s = fns.toStdString();
+ const char *c = s.c_str();
#endif
- int ret=1;
- invokeCallback("main.reset",nullptr);
- if(!player->playerLoadFile(c))
- {QMessageBox::critical(this,tr("Error"),tr("%1 is not a valid midi file.").arg(fns));ret=0;}
+ int ret = 1;
+ invokeCallback("main.reset", nullptr);
+ if (!player->playerLoadFile(c))
+ {
+ QMessageBox::critical(this, tr("Error"), tr("%1 is not a valid midi file.").arg(fns));
+ ret = 0;
+ }
#ifdef _WIN32
- free(c);
+ free(c);
#endif
- return ret;
+ return ret;
}
void qmpMainWindow::registerMidiOptions()
{
- settings->registerOptionBool("MIDI","Disable MIDI Mapping","Midi/DisableMapping",false);
- settings->registerOptionBool("MIDI","Send system exclusive messages","Midi/SendSysEx",true);
- settings->registerOptionBool("MIDI","Wait for remaining voice before stopping","Midi/WaitVoice",true);
- settings->registerOptionEnumInt("MIDI","Text encoding","Midi/TextEncoding",{"Unicode","Big5","Big5-HKSCS","CP949","EUC-JP","EUC-KR","GB18030","KOI8-R","KOI8-U","Macintosh","Shift-JIS"},0);
+ settings->registerOptionBool("MIDI", "Disable MIDI Mapping", "Midi/DisableMapping", false);
+ settings->registerOptionBool("MIDI", "Send system exclusive messages", "Midi/SendSysEx", true);
+ settings->registerOptionBool("MIDI", "Wait for remaining voice before stopping", "Midi/WaitVoice", true);
+ settings->registerOptionEnumInt("MIDI", "Text encoding", "Midi/TextEncoding", {"Unicode", "Big5", "Big5-HKSCS", "CP949", "EUC-JP", "EUC-KR", "GB18030", "KOI8-R", "KOI8-U", "Macintosh", "Shift-JIS"}, 0);
}
void qmpMainWindow::registerBehaviorOptions()
{
- settings->registerOptionBool("Behavior","Restore last playlist on startup","Behavior/RestorePlaylist",false);
- settings->registerOptionBool("Behavior","Add files in the same folder to playlist","Behavior/LoadFolder",false);
- settings->registerOptionBool("Behavior","Save dialog status","Behavior/DialogStatus",false);
- settings->registerOptionBool("Behavior","Show labels beside icon in toolbar buttons","Behavior/ShowButtonLabel",false);
- settings->registerOptionEnumInt("Behavior","Icon Theme","Behavior/IconTheme",{"Auto","Dark","Light"},0);
+ settings->registerOptionBool("Behavior", "Restore last playlist on startup", "Behavior/RestorePlaylist", false);
+ settings->registerOptionBool("Behavior", "Add files in the same folder to playlist", "Behavior/LoadFolder", false);
+ settings->registerOptionBool("Behavior", "Save dialog status", "Behavior/DialogStatus", false);
+ settings->registerOptionBool("Behavior", "Show labels beside icon in toolbar buttons", "Behavior/ShowButtonLabel", false);
+ settings->registerOptionEnumInt("Behavior", "Icon Theme", "Behavior/IconTheme", {"Auto", "Dark", "Light"}, 0);
}
void qmpMainWindow::on_pbPlayPause_clicked()
{
- playing=!playing;
- if(stopped)
- {
- QString fns=plistw->getFirstItem();
- if(!fns.length())
- {
- if(!plistw->on_pbAdd_clicked()){playing=false;return;}
- fns=plistw->getFirstItem();
- if(!fns.length())return(void)(playing=false);
- }setWindowTitle(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.'))+" - QMidiPlayer");
- ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.')));
- onfnChanged();
- if(!loadFile(fns))return;
- char ts[100];
- sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
- ui->lbFinTime->setText(ts);
- player->playerInit();
- invokeCallback("main.start",nullptr);
- internalfluid->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange();
- playerTh=new std::thread([this]{
- player->playerThread();
- if(settings->getOptionBool("Midi/WaitVoice")&&player->isFinished())
- while(internalfluid->getPolyphone()>0)
- std::this_thread::sleep_for(std::chrono::milliseconds(10));
- });
+ playing = !playing;
+ if (stopped)
+ {
+ QString fns = plistw->getFirstItem();
+ if (!fns.length())
+ {
+ if (!plistw->on_pbAdd_clicked())
+ {
+ playing = false;
+ return;
+ }
+ fns = plistw->getFirstItem();
+ if (!fns.length())
+ return (void)(playing = false);
+ }
+ setWindowTitle(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.')) + " - QMidiPlayer");
+ ui->lbFileName->setText(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.')));
+ onfnChanged();
+ if (!loadFile(fns))
+ return;
+ char ts[100];
+ sprintf(ts, "%02d:%02d", (int)player->getFtime() / 60, (int)player->getFtime() % 60);
+ ui->lbFinTime->setText(ts);
+ player->playerInit();
+ invokeCallback("main.start", nullptr);
+ internalfluid->setGain(ui->vsMasterVol->value() / 250.);
+ efxw->sendEfxChange();
+ playerTh = new std::thread([this]
+ {
+ player->playerThread();
+ if (settings->getOptionBool("Midi/WaitVoice") && player->isFinished())
+ while (internalfluid->getPolyphone() > 0)
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
+ });
#ifdef _WIN32
- SetThreadPriority((void*)playerTh->native_handle(),THREAD_PRIORITY_TIME_CRITICAL);
+ SetThreadPriority((void *)playerTh->native_handle(), THREAD_PRIORITY_TIME_CRITICAL);
#endif
- st=std::chrono::steady_clock::now();offset=0;
- timer->start(UPDATE_INTERVAL);
- stopped=false;
- }
- else
- {
- if(!playing)
- {
- player->playerPanic();
- offset=ui->hsTimer->value()/100.*player->getFtime();
- }
- else
- {
- st=std::chrono::steady_clock::now();
- player->setResumed();
- }
- player->setTCpaused(!playing);
- invokeCallback("main.pause",nullptr);
- }
- ui->pbPlayPause->setIcon(QIcon(getThemedIcon(playing?":/img/pause.svg":":/img/play.svg")));
+ st = std::chrono::steady_clock::now();
+ offset = 0;
+ timer->start(UPDATE_INTERVAL);
+ stopped = false;
+ }
+ else
+ {
+ if (!playing)
+ {
+ player->playerPanic();
+ offset = ui->hsTimer->value() / 100.*player->getFtime();
+ }
+ else
+ {
+ st = std::chrono::steady_clock::now();
+ player->setResumed();
+ }
+ player->setTCpaused(!playing);
+ invokeCallback("main.pause", nullptr);
+ }
+ ui->pbPlayPause->setIcon(QIcon(getThemedIcon(playing ? ":/img/pause.svg" : ":/img/play.svg")));
}
void qmpMainWindow::on_hsTimer_sliderPressed()
{
- dragging=true;
+ dragging = true;
}
void qmpMainWindow::on_hsTimer_sliderReleased()
{
- dragging=false;
- if(playing)
- {
- if(ui->hsTimer->value()==100){on_pbNext_clicked();return;}
- player->playerPanic();
- player->setTCeptr(player->getStamp(ui->hsTimer->value()),ui->hsTimer->value());
- offset=ui->hsTimer->value()/100.*player->getFtime();
- st=std::chrono::steady_clock::now();
- }
- else
- {
- if(stopped){ui->hsTimer->setValue(0);return;}
- player->setTCeptr(player->getStamp(ui->hsTimer->value()),ui->hsTimer->value());
- offset=ui->hsTimer->value()/100.*player->getFtime();
- char ts[100];
- sprintf(ts,"%02d:%02d",(int)(offset)/60,(int)(offset)%60);
- ui->lbCurTime->setText(ts);
- }
- invokeCallback("main.seek",nullptr);
-}
-
-uint32_t qmpMainWindow::getPlaybackPercentage(){return ui->hsTimer->value();}
+ dragging = false;
+ if (playing)
+ {
+ if (ui->hsTimer->value() == 100)
+ {
+ on_pbNext_clicked();
+ return;
+ }
+ player->playerPanic();
+ player->setTCeptr(player->getStamp(ui->hsTimer->value()), ui->hsTimer->value());
+ offset = ui->hsTimer->value() / 100.*player->getFtime();
+ st = std::chrono::steady_clock::now();
+ }
+ else
+ {
+ if (stopped)
+ {
+ ui->hsTimer->setValue(0);
+ return;
+ }
+ player->setTCeptr(player->getStamp(ui->hsTimer->value()), ui->hsTimer->value());
+ offset = ui->hsTimer->value() / 100.*player->getFtime();
+ char ts[100];
+ sprintf(ts, "%02d:%02d", (int)(offset) / 60, (int)(offset) % 60);
+ ui->lbCurTime->setText(ts);
+ }
+ invokeCallback("main.seek", nullptr);
+}
+
+uint32_t qmpMainWindow::getPlaybackPercentage()
+{
+ return ui->hsTimer->value();
+}
void qmpMainWindow::playerSeek(uint32_t percentage)
{
- if(percentage>100)percentage=100;
- if(percentage<0)percentage=0;
- invokeCallback("main.seek",nullptr);
- if(playing)
- {
- if(percentage==100){on_pbNext_clicked();return;}
- player->playerPanic();ui->hsTimer->setValue(percentage);
- player->setTCeptr(player->getStamp(percentage),percentage);
- offset=percentage/100.*player->getFtime();
- st=std::chrono::steady_clock::now();
- }
- else
- {
- if(stopped){ui->hsTimer->setValue(0);return;}
- player->setTCeptr(player->getStamp(percentage),percentage);
- offset=percentage/100.*player->getFtime();ui->hsTimer->setValue(percentage);
- char ts[100];
- sprintf(ts,"%02d:%02d",(int)(offset)/60,(int)(offset)%60);
- ui->lbCurTime->setText(ts);
- }
+ if (percentage > 100)
+ percentage = 100;
+ if (percentage < 0)
+ percentage = 0;
+ invokeCallback("main.seek", nullptr);
+ if (playing)
+ {
+ if (percentage == 100)
+ {
+ on_pbNext_clicked();
+ return;
+ }
+ player->playerPanic();
+ ui->hsTimer->setValue(percentage);
+ player->setTCeptr(player->getStamp(percentage), percentage);
+ offset = percentage / 100.*player->getFtime();
+ st = std::chrono::steady_clock::now();
+ }
+ else
+ {
+ if (stopped)
+ {
+ ui->hsTimer->setValue(0);
+ return;
+ }
+ player->setTCeptr(player->getStamp(percentage), percentage);
+ offset = percentage / 100.*player->getFtime();
+ ui->hsTimer->setValue(percentage);
+ char ts[100];
+ sprintf(ts, "%02d:%02d", (int)(offset) / 60, (int)(offset) % 60);
+ ui->lbCurTime->setText(ts);
+ }
}
void qmpMainWindow::on_vsMasterVol_valueChanged()
{
- if(!stopped)internalfluid->setGain(ui->vsMasterVol->value()/250.);
- settings->setOptionRaw("FluidSynth/Gain",ui->vsMasterVol->value());
+ if (!stopped)
+ internalfluid->setGain(ui->vsMasterVol->value() / 250.);
+ settings->setOptionRaw("FluidSynth/Gain", ui->vsMasterVol->value());
}
void qmpMainWindow::on_pbStop_clicked()
{
- if(!stopped)
- {
- timer->stop();stopped=true;playing=false;
- invokeCallback("main.stop",nullptr);
- player->playerDeinit();
- setFuncEnabled("Render",stopped);setFuncEnabled("ReloadSynth",stopped);
- player->playerPanic(true);
- if(playerTh){playerTh->join();delete playerTh;playerTh=nullptr;}
- chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
- ui->pbPlayPause->setIcon(QIcon(getThemedIcon(":/img/play.svg")));
- ui->hsTimer->setValue(0);
- ui->lbCurPoly->setText("00000");ui->lbMaxPoly->setText("00000");
- ui->lbCurTime->setText("00:00");
- }
+ if (!stopped)
+ {
+ timer->stop();
+ stopped = true;
+ playing = false;
+ invokeCallback("main.stop", nullptr);
+ player->playerDeinit();
+ setFuncEnabled("Render", stopped);
+ setFuncEnabled("ReloadSynth", stopped);
+ player->playerPanic(true);
+ if (playerTh)
+ {
+ playerTh->join();
+ delete playerTh;
+ playerTh = nullptr;
+ }
+ chnlw->on_pbUnmute_clicked();
+ chnlw->on_pbUnsolo_clicked();
+ ui->pbPlayPause->setIcon(QIcon(getThemedIcon(":/img/play.svg")));
+ ui->hsTimer->setValue(0);
+ ui->lbCurPoly->setText("00000");
+ ui->lbMaxPoly->setText("00000");
+ ui->lbCurTime->setText("00:00");
+ }
}
void qmpMainWindow::dialogClosed()
{
- if(!settingsw->isVisible())ui->pbSettings->setChecked(false);
+ if (!settingsw->isVisible())
+ ui->pbSettings->setChecked(false);
}
void qmpMainWindow::on_pbPrev_clicked()
{
- switchTrack(plistw->getPrevItem());
+ switchTrack(plistw->getPrevItem());
}
void qmpMainWindow::on_pbNext_clicked()
{
- switchTrack(plistw->getNextItem());
+ switchTrack(plistw->getNextItem());
}
void qmpMainWindow::selectionChanged()
{
- switchTrack(plistw->getSelectedItem());
+ switchTrack(plistw->getSelectedItem());
}
void qmpMainWindow::on_lbFileName_customContextMenuRequested(const QPoint &pos)
{
- QMenu menu(ui->lbFileName);
- menu.addActions(ui->lbFileName->actions());
- menu.exec(this->pos()+ui->lbFileName->pos()+pos);
+ QMenu menu(ui->lbFileName);
+ menu.addActions(ui->lbFileName->actions());
+ menu.exec(this->pos() + ui->lbFileName->pos() + pos);
}
void qmpMainWindow::onfnChanged()
{
- if(!ui->lbFileName->text().length())return;
- QFont f=ui->lbFileName->font();f.setPointSize(18);
- QFontMetrics fm(f);
- QSize size=fm.size(0,ui->lbFileName->text());
- double fw=ui->lbFileName->width()/(double)size.width();
- double fh=ui->lbFileName->height()/(double)size.height();
- double ps=floor(f.pointSizeF()*(fw<fh?fw:fh));if(ps<6)ps=6;
- f.setPointSizeF(ps>18?18:ps);
- ui->lbFileName->setFont(f);
+ if (!ui->lbFileName->text().length())
+ return;
+ QFont f = ui->lbFileName->font();
+ f.setPointSize(18);
+ QFontMetrics fm(f);
+ QSize size = fm.size(0, ui->lbFileName->text());
+ double fw = ui->lbFileName->width() / (double)size.width();
+ double fh = ui->lbFileName->height() / (double)size.height();
+ double ps = floor(f.pointSizeF() * (fw < fh ? fw : fh));
+ if (ps < 6)
+ ps = 6;
+ f.setPointSizeF(ps > 18 ? 18 : ps);
+ ui->lbFileName->setFont(f);
}
-int qmpMainWindow::registerUIHook(std::string e,ICallBack *callback,void* userdat)
+int qmpMainWindow::registerUIHook(std::string e, ICallBack *callback, void *userdat)
{
- std::map<int,std::pair<qmpCallBack,void*>>& m=muicb[e];
- int id=0;
- if(m.size())id=m.rbegin()->first+1;
- m[id]=std::make_pair(qmpCallBack(callback),userdat);
- return id;
+ std::map<int, std::pair<qmpCallBack, void *>> &m = muicb[e];
+ int id = 0;
+ if (m.size())
+ id = m.rbegin()->first + 1;
+ m[id] = std::make_pair(qmpCallBack(callback), userdat);
+ return id;
}
-int qmpMainWindow::registerUIHook(std::string e,callback_t callback,void *userdat)
+int qmpMainWindow::registerUIHook(std::string e, callback_t callback, void *userdat)
{
- std::map<int,std::pair<qmpCallBack,void*>>& m=muicb[e];
- int id=0;
- if(m.size())id=m.rbegin()->first+1;
- m[id]=std::make_pair(qmpCallBack(callback),userdat);
- return id;
+ std::map<int, std::pair<qmpCallBack, void *>> &m = muicb[e];
+ int id = 0;
+ if (m.size())
+ id = m.rbegin()->first + 1;
+ m[id] = std::make_pair(qmpCallBack(callback), userdat);
+ return id;
}
-void qmpMainWindow::unregisterUIHook(std::string e,int hook)
+void qmpMainWindow::unregisterUIHook(std::string e, int hook)
{
- std::map<int,std::pair<qmpCallBack,void*>>& m=muicb[e];
- m.erase(hook);
+ std::map<int, std::pair<qmpCallBack, void *>> &m = muicb[e];
+ m.erase(hook);
}
-void qmpMainWindow::registerFunctionality(qmpFuncBaseIntf *i,std::string name,std::string desc,const char *icon,int iconlen,bool checkable)
+void qmpMainWindow::registerFunctionality(qmpFuncBaseIntf *i, std::string name, std::string desc, const char *icon, int iconlen, bool checkable)
{
- if(mfunc.find(name)!=mfunc.end())return;
- mfunc[name]=qmpFuncPrivate(i,desc,icon,iconlen,checkable);
+ if (mfunc.find(name) != mfunc.end())
+ return;
+ mfunc[name] = qmpFuncPrivate(i, desc, icon, iconlen, checkable);
}
void qmpMainWindow::unregisterFunctionality(std::string name)
{
- mfunc.erase(name);
- for(auto i=enabled_actions.begin();i!=enabled_actions.end();++i)
- if(*i==name){enabled_actions.erase(i);break;}
- for(auto i=enabled_buttons.begin();i!=enabled_buttons.end();++i)
- if(*i==name){enabled_buttons.erase(i);break;}
- setupWidget();
+ mfunc.erase(name);
+ for (auto i = enabled_actions.begin(); i != enabled_actions.end(); ++i)
+ if (*i == name)
+ {
+ enabled_actions.erase(i);
+ break;
+ }
+ for (auto i = enabled_buttons.begin(); i != enabled_buttons.end(); ++i)
+ if (*i == name)
+ {
+ enabled_buttons.erase(i);
+ break;
+ }
+ setupWidget();
}
-void qmpMainWindow::setFuncState(std::string name,bool state)
-{mfunc[name].setChecked(state);}
-void qmpMainWindow::setFuncEnabled(std::string name,bool enable)
-{mfunc[name].setEnabled(enable);}
+void qmpMainWindow::setFuncState(std::string name, bool state)
+{
+ mfunc[name].setChecked(state);
+}
+void qmpMainWindow::setFuncEnabled(std::string name, bool enable)
+{
+ mfunc[name].setEnabled(enable);
+}
bool qmpMainWindow::isDarkTheme()
{
- if(!settings->getOptionEnumInt("Behavior/IconTheme"))
- {
- return ui->centralWidget->palette().color(QPalette::Background).lightness()<128;
- }
- else return 2-settings->getOptionEnumInt("Behavior/IconTheme");
+ if (!settings->getOptionEnumInt("Behavior/IconTheme"))
+ {
+ return ui->centralWidget->palette().color(QPalette::Background).lightness() < 128;
+ }
+ else return 2 - settings->getOptionEnumInt("Behavior/IconTheme");
}
void qmpMainWindow::startRender()
{
#ifdef _WIN32
- char* ofstr=wcsto8bit((plistw->getSelectedItem()+QString(".wav")).toStdWString().c_str());
- char* ifstr=wcsto8bit(plistw->getSelectedItem().toStdWString().c_str());
- fluidrenderer=new qmpFileRendererFluid(ifstr,ofstr);
- playerSetup(fluidrenderer);
- fluidrenderer->renderInit();
- free(ofstr);free(ifstr);
+ char *ofstr = wcsto8bit((plistw->getSelectedItem() + QString(".wav")).toStdWString().c_str());
+ char *ifstr = wcsto8bit(plistw->getSelectedItem().toStdWString().c_str());
+ fluidrenderer = new qmpFileRendererFluid(ifstr, ofstr);
+ playerSetup(fluidrenderer);
+ fluidrenderer->renderInit();
+ free(ofstr);
+ free(ifstr);
#else
- fluidrenderer=new qmpFileRendererFluid(
- plistw->getSelectedItem().toStdString().c_str(),
- (plistw->getSelectedItem()+QString(".wav")).toStdString().c_str()
- );
- playerSetup(fluidrenderer);
- fluidrenderer->renderInit();
+ fluidrenderer = new qmpFileRendererFluid(
+ plistw->getSelectedItem().toStdString().c_str(),
+ (plistw->getSelectedItem() + QString(".wav")).toStdString().c_str()
+ );
+ playerSetup(fluidrenderer);
+ fluidrenderer->renderInit();
#endif
- loadSoundFont(fluidrenderer);
- ui->centralWidget->setEnabled(false);
- fluidrenderer->setGain(ui->vsMasterVol->value()/250.);
- efxw->sendEfxChange(fluidrenderer);timer->start(UPDATE_INTERVAL);
- renderTh=new std::thread(&qmpFileRendererFluid::renderWorker,fluidrenderer);
+ loadSoundFont(fluidrenderer);
+ ui->centralWidget->setEnabled(false);
+ fluidrenderer->setGain(ui->vsMasterVol->value() / 250.);
+ efxw->sendEfxChange(fluidrenderer);
+ timer->start(UPDATE_INTERVAL);
+ renderTh = new std::thread(&qmpFileRendererFluid::renderWorker, fluidrenderer);
}
void qmpMainWindow::reloadSynth()
{
- ui->centralWidget->setEnabled(false);
- std::future<void> f=std::async(std::launch::async,
- [this]
- {
- internalfluid->deviceDeinit(true);
- playerSetup(internalfluid);
- internalfluid->deviceInit();
- loadSoundFont(internalfluid);
- }
- );
- while(f.wait_for(std::chrono::milliseconds(100))==std::future_status::timeout)
- QApplication::processEvents();
- ui->centralWidget->setEnabled(true);
+ ui->centralWidget->setEnabled(false);
+ std::future<void> f = std::async(std::launch::async,
+ [this]
+ {
+ internalfluid->deviceDeinit(true);
+ playerSetup(internalfluid);
+ internalfluid->deviceInit();
+ loadSoundFont(internalfluid);
+ }
+ );
+ while (f.wait_for(std::chrono::milliseconds(100)) == std::future_status::timeout)
+ QApplication::processEvents();
+ ui->centralWidget->setEnabled(true);
}
-std::map<std::string,qmpFuncPrivate>& qmpMainWindow::getFunc()
-{return mfunc;}
+std::map<std::string, qmpFuncPrivate> &qmpMainWindow::getFunc()
+{
+ return mfunc;
+}
void qmpMainWindow::setupWidget()
{
- for(auto i=mfunc.begin();i!=mfunc.end();++i)
- {
- i->second.setAssignedControl(static_cast<QReflectiveAction*>(nullptr));
- i->second.setAssignedControl(static_cast<QReflectivePushButton*>(nullptr));
- }
- QVariant *v=static_cast<QVariant*>(settings->getOptionCustom("Behavior/Toolbar"));
- enabled_buttons.clear();
- for(auto i:v->toList())
- enabled_buttons.push_back(i.toString().toStdString());
- delete v;
- v=static_cast<QVariant*>(settings->getOptionCustom("Behavior/Actions"));
- enabled_actions.clear();
- for(auto i:v->toList())
- enabled_actions.push_back(i.toString().toStdString());
- delete v;
- QList<QWidget*>w=ui->buttonwidget->findChildren<QWidget*>("",Qt::FindDirectChildrenOnly);
- qDeleteAll(w);
- QList<QAction*>a=ui->lbFileName->actions();
- for(int i=0;i<a.size();++i)
- {
- ui->lbFileName->removeAction(a[i]);
- delete a[i];
- }
- for(unsigned i=0;i<enabled_buttons.size();++i)
- {
- if(mfunc.find(enabled_buttons[i])==mfunc.end())continue;
- QReflectivePushButton *pb=new QReflectivePushButton(
- mfunc[enabled_buttons[i]].icon(),
- tr(mfunc[enabled_buttons[i]].desc().c_str()),
- enabled_buttons[i]
- );
- setButtonHeight(pb,32);
- //!!TODO
- if(settings->getOptionBool("Behavior/ShowButtonLabel"))
- {
- pb->setText(tr(mfunc[enabled_buttons[i]].desc().c_str()));
- pb->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
- }
- else
- setButtonWidth(pb,32);
- pb->setIconSize(QSize(16,16));
- ui->buttonwidget->layout()->addWidget(pb);
- mfunc[enabled_buttons[i]].setAssignedControl(pb);
- connect(pb,&QReflectivePushButton::onClick,this,&qmpMainWindow::funcReflector);
- }
- for(unsigned i=0;i<enabled_actions.size();++i)
- {
- if(mfunc.find(enabled_actions[i])==mfunc.end())continue;
- QReflectiveAction *a=new QReflectiveAction(
- mfunc[enabled_actions[i]].icon(),
- tr(mfunc[enabled_actions[i]].desc().c_str()),
- enabled_actions[i]
- );
- ui->lbFileName->addAction(a);
- mfunc[enabled_actions[i]].setAssignedControl(a);
- connect(a,&QReflectiveAction::onClick,this,&qmpMainWindow::funcReflector);
- }
- ui->buttonwidget->layout()->setAlignment(Qt::AlignLeft);
-}
-
-void qmpMainWindow::invokeCallback(std::string cat,void* callerdat)
-{
- std::map<int,std::pair<qmpCallBack,void*>> *mp;
- mp=&muicb[cat];
- for(auto&i:*mp)
- i.second.first(callerdat,i.second.second);
+ for (auto i = mfunc.begin(); i != mfunc.end(); ++i)
+ {
+ i->second.setAssignedControl(static_cast<QReflectiveAction *>(nullptr));
+ i->second.setAssignedControl(static_cast<QReflectivePushButton *>(nullptr));
+ }
+ QVariant *v = static_cast<QVariant *>(settings->getOptionCustom("Behavior/Toolbar"));
+ enabled_buttons.clear();
+ for (auto i : v->toList())
+ enabled_buttons.push_back(i.toString().toStdString());
+ delete v;
+ v = static_cast<QVariant *>(settings->getOptionCustom("Behavior/Actions"));
+ enabled_actions.clear();
+ for (auto i : v->toList())
+ enabled_actions.push_back(i.toString().toStdString());
+ delete v;
+ QList<QWidget *>w = ui->buttonwidget->findChildren<QWidget *>("", Qt::FindDirectChildrenOnly);
+ qDeleteAll(w);
+ QList<QAction *>a = ui->lbFileName->actions();
+ for (int i = 0; i < a.size(); ++i)
+ {
+ ui->lbFileName->removeAction(a[i]);
+ delete a[i];
+ }
+ for (unsigned i = 0; i < enabled_buttons.size(); ++i)
+ {
+ if (mfunc.find(enabled_buttons[i]) == mfunc.end())
+ continue;
+ QReflectivePushButton *pb = new QReflectivePushButton(
+ mfunc[enabled_buttons[i]].icon(),
+ tr(mfunc[enabled_buttons[i]].desc().c_str()),
+ enabled_buttons[i]
+ );
+ setButtonHeight(pb, 32);
+ //!!TODO
+ if (settings->getOptionBool("Behavior/ShowButtonLabel"))
+ {
+ pb->setText(tr(mfunc[enabled_buttons[i]].desc().c_str()));
+ pb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ }
+ else
+ setButtonWidth(pb, 32);
+ pb->setIconSize(QSize(16, 16));
+ ui->buttonwidget->layout()->addWidget(pb);
+ mfunc[enabled_buttons[i]].setAssignedControl(pb);
+ connect(pb, &QReflectivePushButton::onClick, this, &qmpMainWindow::funcReflector);
+ }
+ for (unsigned i = 0; i < enabled_actions.size(); ++i)
+ {
+ if (mfunc.find(enabled_actions[i]) == mfunc.end())
+ continue;
+ QReflectiveAction *a = new QReflectiveAction(
+ mfunc[enabled_actions[i]].icon(),
+ tr(mfunc[enabled_actions[i]].desc().c_str()),
+ enabled_actions[i]
+ );
+ ui->lbFileName->addAction(a);
+ mfunc[enabled_actions[i]].setAssignedControl(a);
+ connect(a, &QReflectiveAction::onClick, this, &qmpMainWindow::funcReflector);
+ }
+ ui->buttonwidget->layout()->setAlignment(Qt::AlignLeft);
+}
+
+void qmpMainWindow::invokeCallback(std::string cat, void *callerdat)
+{
+ std::map<int, std::pair<qmpCallBack, void *>> *mp;
+ mp = &muicb[cat];
+ for (auto &i : *mp)
+ i.second.first(callerdat, i.second.second);
}
void qmpMainWindow::on_pbSettings_clicked()
{
- if(ui->pbSettings->isChecked())settingsw->show();else settingsw->close();
+ if (ui->pbSettings->isChecked())
+ settingsw->show();
+ else settingsw->close();
}
void qmpMainWindow::funcReflector(std::string reflt)
{
- if(mfunc[reflt].isCheckable())
- {
- mfunc[reflt].setChecked(!mfunc[reflt].isChecked());
- if(mfunc[reflt].isChecked())
- mfunc[reflt].i()->show();
- else
- mfunc[reflt].i()->close();
- }
- else mfunc[reflt].i()->show();
+ if (mfunc[reflt].isCheckable())
+ {
+ mfunc[reflt].setChecked(!mfunc[reflt].isChecked());
+ if (mfunc[reflt].isChecked())
+ mfunc[reflt].i()->show();
+ else
+ mfunc[reflt].i()->close();
+ }
+ else mfunc[reflt].i()->show();
}
void qmpMainWindow::on_pushButton_clicked()
{
- helpw->show();
+ helpw->show();
}
-qmpFuncPrivate::qmpFuncPrivate(qmpFuncBaseIntf *i,std::string _desc,const char *icon,int iconlen,bool checkable):
- _i(i),des(_desc),_checkable(checkable)
+qmpFuncPrivate::qmpFuncPrivate(qmpFuncBaseIntf *i, std::string _desc, const char *icon, int iconlen, bool checkable):
+ _i(i), des(_desc), _checkable(checkable)
{
- if(icon)
- {
- QImage img;
- if(icon[0]==':'&&icon[1]=='/'||icon[0]=='q'&&icon[1]=='r'&&icon[2]=='c')
- img=QImage(QString(icon));
- else
- img.loadFromData((uchar*)icon,iconlen);
- QPixmap pixm;pixm.convertFromImage(img);
- _icon=QIcon(pixm);
- }else _icon=QIcon();
- checked=false;
- asgna=nullptr;asgnb=nullptr;
+ if (icon)
+ {
+ QImage img;
+ if (icon[0] == ':' && icon[1] == '/' || icon[0] == 'q' && icon[1] == 'r' && icon[2] == 'c')
+ img = QImage(QString(icon));
+ else
+ img.loadFromData((uchar *)icon, iconlen);
+ QPixmap pixm;
+ pixm.convertFromImage(img);
+ _icon = QIcon(pixm);
+ }
+ else _icon = QIcon();
+ checked = false;
+ asgna = nullptr;
+ asgnb = nullptr;
}
void qmpMainWindow::on_pbAdd_clicked()
{
- if(plistw->on_pbAdd_clicked())
- switchTrack(plistw->getLastItem());
+ if (plistw->on_pbAdd_clicked())
+ switchTrack(plistw->getLastItem());
}
diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp
index d98029d..28fb82c 100644
--- a/qmidiplayer-desktop/qmpmainwindow.hpp
+++ b/qmidiplayer-desktop/qmpmainwindow.hpp
@@ -33,79 +33,122 @@
#define getThemedIcon(x) (qmpMainWindow::getInstance()->isDarkTheme()?QString(x).insert(QString(x).lastIndexOf('.'),"_i"):QString(x))
#define getThemedIconc(x) ((qmpMainWindow::getInstance()->isDarkTheme()?QString(x).insert(QString(x).lastIndexOf('.'),"_i"):QString(x)).toStdString().c_str())
-namespace Ui {
- class qmpMainWindow;
+namespace Ui
+{
+class qmpMainWindow;
}
-class QClickableSlider:public QSlider
+class QClickableSlider : public QSlider
{
- Q_OBJECT
- public:
- explicit QClickableSlider(QWidget *parent=0):QSlider(parent){}
- protected:
- void mouseReleaseEvent(QMouseEvent *e)
- {
- QSlider::mouseReleaseEvent(e);
- if(e->buttons()^Qt::LeftButton)
- {
- double p=e->pos().x()/(double)width();
- setValue(p*(maximum()-minimum())+minimum());
- emit sliderReleased();
- }
- }
+ Q_OBJECT
+public:
+ explicit QClickableSlider(QWidget *parent = 0) : QSlider(parent) {}
+protected:
+ void mouseReleaseEvent(QMouseEvent *e)
+ {
+ QSlider::mouseReleaseEvent(e);
+ if (e->buttons()^Qt::LeftButton)
+ {
+ double p = e->pos().x() / (double)width();
+ setValue(p * (maximum() - minimum()) + minimum());
+ emit sliderReleased();
+ }
+ }
};
-class QReflectiveAction:public QAction
+class QReflectiveAction : public QAction
{
- Q_OBJECT
- private:
- std::string reflt;
- signals:
- void onClick(std::string s);
- public:
- explicit QReflectiveAction(const QIcon& icon,const QString& text,const std::string& ref):
- QAction(icon,text,nullptr),reflt(ref){
- connect(this,&QAction::triggered,std::bind(&QReflectiveAction::onClick,this,reflt));
- }
+ Q_OBJECT
+private:
+ std::string reflt;
+signals:
+ void onClick(std::string s);
+public:
+ explicit QReflectiveAction(const QIcon &icon, const QString &text, const std::string &ref):
+ QAction(icon, text, nullptr), reflt(ref)
+ {
+ connect(this, &QAction::triggered, std::bind(&QReflectiveAction::onClick, this, reflt));
+ }
};
-class QReflectivePushButton:public QPushButton
+class QReflectivePushButton : public QPushButton
{
- Q_OBJECT
- private:
- std::string reflt;
- signals:
- void onClick(std::string s);
- public:
- explicit QReflectivePushButton(const QIcon& icon,const QString& text,const std::string& ref):
- QPushButton(icon,""),reflt(ref){
- connect(this,&QPushButton::clicked,std::bind(&QReflectivePushButton::onClick,this,reflt));
- setToolTip(text);
- }
+ Q_OBJECT
+private:
+ std::string reflt;
+signals:
+ void onClick(std::string s);
+public:
+ explicit QReflectivePushButton(const QIcon &icon, const QString &text, const std::string &ref):
+ QPushButton(icon, QString()), reflt(ref)
+ {
+ connect(this, &QPushButton::clicked, std::bind(&QReflectivePushButton::onClick, this, reflt));
+ setToolTip(text);
+ }
};
class qmpFuncPrivate
{
- private:
- qmpFuncBaseIntf* _i=nullptr;
- QIcon _icon;
- std::string des;
- bool _checkable,checked;
- QReflectiveAction* asgna=nullptr;
- QReflectivePushButton* asgnb=nullptr;
- public:
- qmpFuncPrivate(){}
- qmpFuncPrivate(qmpFuncBaseIntf* i,std::string _desc,const char* icon,int iconlen,bool checkable);
- ~qmpFuncPrivate(){asgna=nullptr;asgnb=nullptr;}
- qmpFuncBaseIntf* i(){return _i;}
- void setAssignedControl(QReflectiveAction* a){asgna=a;if(!a)return;asgna->setCheckable(_checkable);asgna->setChecked(checked);}
- void setAssignedControl(QReflectivePushButton* a){asgnb=a;if(!a)return;asgnb->setCheckable(_checkable);asgnb->setChecked(checked);}
- const QIcon& icon(){return _icon;}
- const std::string& desc(){return des;}
- bool isCheckable(){return _checkable;}
- bool isChecked(){return checked;}
- void setEnabled(bool e){if(asgna)asgna->setEnabled(e);if(asgnb)asgnb->setEnabled(e);}
- void setChecked(bool _c){checked=_c;if(asgna)asgna->setChecked(checked);if(asgnb)asgnb->setChecked(checked);}
+private:
+ qmpFuncBaseIntf *_i = nullptr;
+ QIcon _icon;
+ std::string des;
+ bool _checkable, checked;
+ QReflectiveAction *asgna = nullptr;
+ QReflectivePushButton *asgnb = nullptr;
+public:
+ qmpFuncPrivate() {}
+ qmpFuncPrivate(qmpFuncBaseIntf *i, std::string _desc, const char *icon, int iconlen, bool checkable);
+ ~qmpFuncPrivate()
+ {
+ asgna = nullptr;
+ asgnb = nullptr;
+ }
+ qmpFuncBaseIntf *i()
+ {
+ return _i;
+ }
+ void setAssignedControl(QReflectiveAction *a)
+ {
+ asgna = a;
+ if (!a)return;
+ asgna->setCheckable(_checkable);
+ asgna->setChecked(checked);
+ }
+ void setAssignedControl(QReflectivePushButton *a)
+ {
+ asgnb = a;
+ if (!a)return;
+ asgnb->setCheckable(_checkable);
+ asgnb->setChecked(checked);
+ }
+ const QIcon &icon()
+ {
+ return _icon;
+ }
+ const std::string &desc()
+ {
+ return des;
+ }
+ bool isCheckable()
+ {
+ return _checkable;
+ }
+ bool isChecked()
+ {
+ return checked;
+ }
+ void setEnabled(bool e)
+ {
+ if (asgna)asgna->setEnabled(e);
+ if (asgnb)asgnb->setEnabled(e);
+ }
+ void setChecked(bool _c)
+ {
+ checked = _c;
+ if (asgna)asgna->setChecked(checked);
+ if (asgnb)asgnb->setChecked(checked);
+ }
};
class qmpRenderFunc;
@@ -114,144 +157,196 @@ class qmpReloadSynthFunc;
class qmpCallBack
{
- private:
- int t;
- ICallBack* cbc;
- callback_t cbf;
- public:
- qmpCallBack(){t=-1;cbc=nullptr;cbf=nullptr;}
- qmpCallBack(ICallBack* _cb){t=0;cbc=_cb;cbf=nullptr;}
- qmpCallBack(callback_t _cb){t=1;cbf=_cb;cbc=nullptr;}
- void operator ()(void* cbd,void* usrd)
- {
- if(t<0)return;
- if(t)cbf(cbd,usrd);
- else cbc->callBack(cbd,usrd);
- }
+private:
+ int t;
+ ICallBack *cbc;
+ callback_t cbf;
+public:
+ qmpCallBack()
+ {
+ t = -1;
+ cbc = nullptr;
+ cbf = nullptr;
+ }
+ qmpCallBack(ICallBack *_cb)
+ {
+ t = 0;
+ cbc = _cb;
+ cbf = nullptr;
+ }
+ qmpCallBack(callback_t _cb)
+ {
+ t = 1;
+ cbf = _cb;
+ cbc = nullptr;
+ }
+ void operator()(void *cbd, void *usrd)
+ {
+ if (t < 0)return;
+ if (t)cbf(cbd, usrd);
+ else cbc->callBack(cbd, usrd);
+ }
};
-class qmpMainWindow:public QMainWindow
+class qmpMainWindow: public QMainWindow
{
- Q_OBJECT
+ Q_OBJECT
- public:
- explicit qmpMainWindow(QCommandLineParser *clp,QWidget *parent=nullptr);
- void init();
- void closeEvent(QCloseEvent *event);
- void dropEvent(QDropEvent *event);
- void dragEnterEvent(QDragEnterEvent *event);
- ~qmpMainWindow();
- CMidiPlayer* getPlayer(){return player;}
- qmpMidiOutFluid* getFluid(){return internalfluid;}
- qmpSettings* getSettings(){return settings.get();}
- QTimer* getTimer(){return timer;}
- bool isFinalizing(){return fin;}
- QString getFileName();
- void switchTrack(QString s,bool interrupt=true);
- std::string getTitle();
- std::wstring getWTitle();
- uint32_t getPlaybackPercentage();
- void playerSeek(uint32_t percentage);
- int parseArgs();
- void registerFunctionality(qmpFuncBaseIntf* i,std::string name,std::string desc,const char* icon,int iconlen,bool checkable);
- void unregisterFunctionality(std::string name);
- int registerUIHook(std::string e,ICallBack* callback,void* userdat);
- int registerUIHook(std::string e,callback_t callback,void* userdat);
- void unregisterUIHook(std::string e,int hook);
- void setFuncState(std::string name,bool state);
- void setFuncEnabled(std::string name,bool enable);
- bool isDarkTheme();
- void startRender();
- void reloadSynth();
- void setupWidget();
- void invokeCallback(std::string cat,void *callerdat);
- std::map<std::string,qmpFuncPrivate>& getFunc();
+public:
+ explicit qmpMainWindow(QCommandLineParser *clp, QWidget *parent = nullptr);
+ void init();
+ void closeEvent(QCloseEvent *event);
+ void dropEvent(QDropEvent *event);
+ void dragEnterEvent(QDragEnterEvent *event);
+ ~qmpMainWindow();
+ CMidiPlayer *getPlayer()
+ {
+ return player;
+ }
+ qmpMidiOutFluid *getFluid()
+ {
+ return internalfluid;
+ }
+ qmpSettings *getSettings()
+ {
+ return settings.get();
+ }
+ QTimer *getTimer()
+ {
+ return timer;
+ }
+ bool isFinalizing()
+ {
+ return fin;
+ }
+ QString getFileName();
+ void switchTrack(QString s, bool interrupt = true);
+ std::string getTitle();
+ std::wstring getWTitle();
+ uint32_t getPlaybackPercentage();
+ void playerSeek(uint32_t percentage);
+ int parseArgs();
+ void registerFunctionality(qmpFuncBaseIntf *i, std::string name, std::string desc, const char *icon, int iconlen, bool checkable);
+ void unregisterFunctionality(std::string name);
+ int registerUIHook(std::string e, ICallBack *callback, void *userdat);
+ int registerUIHook(std::string e, callback_t callback, void *userdat);
+ void unregisterUIHook(std::string e, int hook);
+ void setFuncState(std::string name, bool state);
+ void setFuncEnabled(std::string name, bool enable);
+ bool isDarkTheme();
+ void startRender();
+ void reloadSynth();
+ void setupWidget();
+ void invokeCallback(std::string cat, void *callerdat);
+ std::map<std::string, qmpFuncPrivate> &getFunc();
- private slots:
- void on_pbPlayPause_clicked();
- void updateWidgets();
- void on_hsTimer_sliderPressed();
- void on_hsTimer_sliderReleased();
- void on_vsMasterVol_valueChanged();
- void on_pbStop_clicked();
- void on_pbPrev_clicked();
- void on_pbNext_clicked();
- void on_lbFileName_customContextMenuRequested(const QPoint &pos);
- void on_pbSettings_clicked();
- void funcReflector(std::string reflt);
- void on_pushButton_clicked();
- void on_pbAdd_clicked();
+private slots:
+ void on_pbPlayPause_clicked();
+ void updateWidgets();
+ void on_hsTimer_sliderPressed();
+ void on_hsTimer_sliderReleased();
+ void on_vsMasterVol_valueChanged();
+ void on_pbStop_clicked();
+ void on_pbPrev_clicked();
+ void on_pbNext_clicked();
+ void on_lbFileName_customContextMenuRequested(const QPoint &pos);
+ void on_pbSettings_clicked();
+ void funcReflector(std::string reflt);
+ void on_pushButton_clicked();
+ void on_pbAdd_clicked();
- public slots:
- void dialogClosed();
- void selectionChanged();
+public slots:
+ void dialogClosed();
+ void selectionChanged();
- private:
- Ui::qmpMainWindow *ui;
- QTimer *timer;
- bool playing,stopped,dragging,fin;
- std::thread *playerTh=nullptr;
- std::thread *renderTh=nullptr;
- std::chrono::steady_clock::time_point st;
- double offset;
- CMidiPlayer *player;
- qmpMidiOutFluid *internalfluid;
- qmpFileRendererFluid *fluidrenderer;
- qmpPluginManager *pmgr;
- QPointer<qmpPlistWindow> plistw;
- QPointer<qmpChannelsWindow> chnlw;
- QPointer<qmpEfxWindow> efxw;
- QPointer<qmpInfoWindow> infow;
- QPointer<qmpHelpWindow> helpw;
- std::unique_ptr<qmpSettings> settings;
- QPointer<qmpSettingsWindow> settingsw;
- std::map<std::string,qmpFuncPrivate> mfunc;
- std::unordered_map<std::string,std::map<int,std::pair<qmpCallBack,void*>>> muicb;
- qmpRenderFunc* renderf;
- qmpPanicFunc* panicf;
- qmpReloadSynthFunc* reloadsynf;
- std::vector<std::string> enabled_buttons,enabled_actions;
- std::vector<QString> argfiles;
- QCommandLineParser *clp;
+private:
+ Ui::qmpMainWindow *ui;
+ QTimer *timer;
+ bool playing, stopped, dragging, fin;
+ std::thread *playerTh = nullptr;
+ std::thread *renderTh = nullptr;
+ std::chrono::steady_clock::time_point st;
+ double offset;
+ CMidiPlayer *player;
+ qmpMidiOutFluid *internalfluid;
+ qmpFileRendererFluid *fluidrenderer;
+ qmpPluginManager *pmgr;
+ QPointer<qmpPlistWindow> plistw;
+ QPointer<qmpChannelsWindow> chnlw;
+ QPointer<qmpEfxWindow> efxw;
+ QPointer<qmpInfoWindow> infow;
+ QPointer<qmpHelpWindow> helpw;
+ std::unique_ptr<qmpSettings> settings;
+ QPointer<qmpSettingsWindow> settingsw;
+ std::map<std::string, qmpFuncPrivate> mfunc;
+ std::unordered_map<std::string, std::map<int, std::pair<qmpCallBack, void *>>> muicb;
+ qmpRenderFunc *renderf;
+ qmpPanicFunc *panicf;
+ qmpReloadSynthFunc *reloadsynf;
+ std::vector<std::string> enabled_buttons, enabled_actions;
+ std::vector<QString> argfiles;
+ QCommandLineParser *clp;
- void onfnChanged();
- void playerSetup(IFluidSettings *fs);
- void loadSoundFont(IFluidSettings *fs);
- int loadFile(QString fns);
- void registerMidiOptions();
- void registerBehaviorOptions();
+ void onfnChanged();
+ void playerSetup(IFluidSettings *fs);
+ void loadSoundFont(IFluidSettings *fs);
+ int loadFile(QString fns);
+ void registerMidiOptions();
+ void registerBehaviorOptions();
- private:
- static qmpMainWindow* ref;
- public: static qmpMainWindow* getInstance(){return ref;}
+private:
+ static qmpMainWindow *ref;
+public:
+ static qmpMainWindow *getInstance()
+ {
+ return ref;
+ }
};
-class qmpRenderFunc:public qmpFuncBaseIntf
+class qmpRenderFunc: public qmpFuncBaseIntf
{
- private:
- qmpMainWindow *p;
- public:
- qmpRenderFunc(qmpMainWindow *par){p=par;}
- void show(){p->startRender();}
- void close(){}
+private:
+ qmpMainWindow *p;
+public:
+ qmpRenderFunc(qmpMainWindow *par)
+ {
+ p = par;
+ }
+ void show()
+ {
+ p->startRender();
+ }
+ void close() {}
};
-class qmpPanicFunc:public qmpFuncBaseIntf
+class qmpPanicFunc: public qmpFuncBaseIntf
{
- private:
- qmpMainWindow *p;
- public:
- qmpPanicFunc(qmpMainWindow *par){p=par;}
- void show(){p->getPlayer()->playerPanic();}
- void close(){}
+private:
+ qmpMainWindow *p;
+public:
+ qmpPanicFunc(qmpMainWindow *par)
+ {
+ p = par;
+ }
+ void show()
+ {
+ p->getPlayer()->playerPanic();
+ }
+ void close() {}
};
-class qmpReloadSynthFunc:public qmpFuncBaseIntf
+class qmpReloadSynthFunc: public qmpFuncBaseIntf
{
- private:
- qmpMainWindow *p;
- public:
- qmpReloadSynthFunc(qmpMainWindow *par){p=par;}
- void show(){p->reloadSynth();}
- void close(){}
+private:
+ qmpMainWindow *p;
+public:
+ qmpReloadSynthFunc(qmpMainWindow *par)
+ {
+ p = par;
+ }
+ void show()
+ {
+ p->reloadSynth();
+ }
+ void close() {}
};
#endif // QMPMAINWINDOW_H
diff --git a/qmidiplayer-desktop/qmpplistwindow.cpp b/qmidiplayer-desktop/qmpplistwindow.cpp
index 5b46fb6..55cc980 100644
--- a/qmidiplayer-desktop/qmpplistwindow.cpp
+++ b/qmidiplayer-desktop/qmpplistwindow.cpp
@@ -13,340 +13,378 @@
#define setButtonHeight(x,h) {x->setMaximumHeight(h*(logicalDpiY()/96.));x->setMinimumHeight(h*(logicalDpiY()/96.));}
qmpPlistWindow::qmpPlistWindow(QWidget *parent):
- QWidget(parent,Qt::Dialog),
- ui(new Ui::qmpPlistWindow)
+ QWidget(parent, Qt::Dialog),
+ ui(new Ui::qmpPlistWindow)
{
- ui->setupUi(this);
- setButtonHeight(ui->pbAdd,36);setButtonHeight(ui->pbAddFolder,36);
- setButtonHeight(ui->pbClear,36);setButtonHeight(ui->pbLoad,36);
- setButtonHeight(ui->pbRemove,36);setButtonHeight(ui->pbRepeat,36);
- setButtonHeight(ui->pbSave,36);setButtonHeight(ui->pbShuffle,36);
- connect(this,&qmpPlistWindow::selectionChanging,(qmpMainWindow*)parent,&qmpMainWindow::selectionChanged);
- repeat=0;shuffle=0;
- settings=qmpMainWindow::getInstance()->getSettings();
- if(settings->getOptionBool("Behavior/RestorePlaylist"))
- {
- QSettings* plist=new QSettings(QStandardPaths::writableLocation(QStandardPaths::StandardLocation::ConfigLocation)+QString("/qmpplist"),
- QSettings::IniFormat);
- int fc=plist->value("Playlist/FileCount",0).toInt();
- ui->lwFiles->clear();for(int i=0;i<fc;++i)
- ui->lwFiles->addItem(plist->value("Playlist/File"+QString("%1").arg(i,5,10,QChar('0')),"").toString());
- repeat=plist->value("Playlist/Repeat",0).toInt();
- shuffle=plist->value("Playlist/Shuffle",0).toInt();
- switch(shuffle)
- {
- case 1:
- ui->pbShuffle->setIcon(QIcon(getThemedIcon(":/img/shuffle.svg")));
- ui->pbShuffle->setText("Shuffle On");
- break;
- case 0:
- default:
- ui->pbShuffle->setIcon(QIcon(getThemedIcon(":/img/shuffle-off.svg")));
- ui->pbShuffle->setText("Shuffle Off");
- break;
- }
- switch(repeat)
- {
- case 0:
- ui->pbRepeat->setIcon(QIcon(getThemedIcon(":/img/repeat-non.svg")));
- ui->pbRepeat->setText("Repeat Off");
- break;
- case 1:
- ui->pbRepeat->setIcon(QIcon(getThemedIcon(":/img/repeat-one.svg")));
- ui->pbRepeat->setText("Repeat One");
- break;
- case 2:
- ui->pbRepeat->setIcon(QIcon(getThemedIcon(":/img/repeat-all.svg")));
- ui->pbRepeat->setText("Repeat All");
- break;
- }
- delete plist;
- }
- ui->pbAdd->setIcon(QIcon(getThemedIcon(":/img/add.svg")));
- ui->pbRemove->setIcon(QIcon(getThemedIcon(":/img/remove.svg")));
- ui->pbClear->setIcon(QIcon(getThemedIcon(":/img/clear.svg")));
- ui->pbAddFolder->setIcon(QIcon(getThemedIcon(":/img/addfolder.svg")));
- ui->pbSave->setIcon(QIcon(getThemedIcon(":/img/save.svg")));
- ui->pbLoad->setIcon(QIcon(getThemedIcon(":/img/load.svg")));
- qmpMainWindow::getInstance()->registerFunctionality(
- plistf=new qmpPlistFunc(this),
- std::string("Playlist"),
- tr("Playlist").toStdString(),
- getThemedIconc(":/img/list.svg"),
- 0,
- true
- );
- if(settings->getOptionRaw("DialogStatus/PListW",QRect(-999,-999,999,999)).toRect()!=QRect(-999,-999,999,999))
- setGeometry(settings->getOptionRaw("DialogStatus/PListW",QRect(-999,-999,999,999)).toRect());
- if(settings->getOptionRaw("DialogStatus/PListWShown",0).toInt())
- {show();qmpMainWindow::getInstance()->setFuncState("Playlist",true);}
+ ui->setupUi(this);
+ setButtonHeight(ui->pbAdd, 36);
+ setButtonHeight(ui->pbAddFolder, 36);
+ setButtonHeight(ui->pbClear, 36);
+ setButtonHeight(ui->pbLoad, 36);
+ setButtonHeight(ui->pbRemove, 36);
+ setButtonHeight(ui->pbRepeat, 36);
+ setButtonHeight(ui->pbSave, 36);
+ setButtonHeight(ui->pbShuffle, 36);
+ connect(this, &qmpPlistWindow::selectionChanging, (qmpMainWindow *)parent, &qmpMainWindow::selectionChanged);
+ repeat = 0;
+ shuffle = 0;
+ settings = qmpMainWindow::getInstance()->getSettings();
+ if (settings->getOptionBool("Behavior/RestorePlaylist"))
+ {
+ QSettings *plist = new QSettings(QStandardPaths::writableLocation(QStandardPaths::StandardLocation::ConfigLocation) + QString("/qmpplist"),
+ QSettings::IniFormat);
+ int fc = plist->value("Playlist/FileCount", 0).toInt();
+ ui->lwFiles->clear();
+ for (int i = 0; i < fc; ++i)
+ ui->lwFiles->addItem(plist->value("Playlist/File" + QString("%1").arg(i, 5, 10, QChar('0')), "").toString());
+ repeat = plist->value("Playlist/Repeat", 0).toInt();
+ shuffle = plist->value("Playlist/Shuffle", 0).toInt();
+ switch (shuffle)
+ {
+ case 1:
+ ui->pbShuffle->setIcon(QIcon(getThemedIcon(":/img/shuffle.svg")));
+ ui->pbShuffle->setText("Shuffle On");
+ break;
+ case 0:
+ default:
+ ui->pbShuffle->setIcon(QIcon(getThemedIcon(":/img/shuffle-off.svg")));
+ ui->pbShuffle->setText("Shuffle Off");
+ break;
+ }
+ switch (repeat)
+ {
+ case 0:
+ ui->pbRepeat->setIcon(QIcon(getThemedIcon(":/img/repeat-non.svg")));
+ ui->pbRepeat->setText("Repeat Off");
+ break;
+ case 1:
+ ui->pbRepeat->setIcon(QIcon(getThemedIcon(":/img/repeat-one.svg")));
+ ui->pbRepeat->setText("Repeat One");
+ break;
+ case 2:
+ ui->pbRepeat->setIcon(QIcon(getThemedIcon(":/img/repeat-all.svg")));
+ ui->pbRepeat->setText("Repeat All");
+ break;
+ }
+ delete plist;
+ }
+ ui->pbAdd->setIcon(QIcon(getThemedIcon(":/img/add.svg")));
+ ui->pbRemove->setIcon(QIcon(getThemedIcon(":/img/remove.svg")));
+ ui->pbClear->setIcon(QIcon(getThemedIcon(":/img/clear.svg")));
+ ui->pbAddFolder->setIcon(QIcon(getThemedIcon(":/img/addfolder.svg")));
+ ui->pbSave->setIcon(QIcon(getThemedIcon(":/img/save.svg")));
+ ui->pbLoad->setIcon(QIcon(getThemedIcon(":/img/load.svg")));
+ qmpMainWindow::getInstance()->registerFunctionality(
+ plistf = new qmpPlistFunc(this),
+ std::string("Playlist"),
+ tr("Playlist").toStdString(),
+ getThemedIconc(":/img/list.svg"),
+ 0,
+ true
+ );
+ if (settings->getOptionRaw("DialogStatus/PListW", QRect(-999, -999, 999, 999)).toRect() != QRect(-999, -999, 999, 999))
+ setGeometry(settings->getOptionRaw("DialogStatus/PListW", QRect(-999, -999, 999, 999)).toRect());
+ if (settings->getOptionRaw("DialogStatus/PListWShown", 0).toInt())
+ {
+ show();
+ qmpMainWindow::getInstance()->setFuncState("Playlist", true);
+ }
}
qmpPlistWindow::~qmpPlistWindow()
{
- qmpMainWindow::getInstance()->unregisterFunctionality("Playlist");
- delete plistf;
- delete ui;
+ qmpMainWindow::getInstance()->unregisterFunctionality("Playlist");
+ delete plistf;
+ delete ui;
}
void qmpPlistWindow::showEvent(QShowEvent *event)
{
- if(settings->getOptionBool("Behavior/DialogStatus"))
- {
- settings->setOptionRaw("DialogStatus/PListWShown",1);
- }
- if(settings->getOptionRaw("DialogStatus/PListW",QRect(-999,-999,999,999)).toRect()!=QRect(-999,-999,999,999))
- setGeometry(settings->getOptionRaw("DialogStatus/PListW",QRect(-999,-999,999,999)).toRect());
- event->accept();
+ if (settings->getOptionBool("Behavior/DialogStatus"))
+ {
+ settings->setOptionRaw("DialogStatus/PListWShown", 1);
+ }
+ if (settings->getOptionRaw("DialogStatus/PListW", QRect(-999, -999, 999, 999)).toRect() != QRect(-999, -999, 999, 999))
+ setGeometry(settings->getOptionRaw("DialogStatus/PListW", QRect(-999, -999, 999, 999)).toRect());
+ event->accept();
}
void qmpPlistWindow::closeEvent(QCloseEvent *event)
{
- if(settings->getOptionBool("Behavior/DialogStatus"))
- {
- settings->setOptionRaw("DialogStatus/PListW",geometry());
- }
- setVisible(false);
- if(!qmpMainWindow::getInstance()->isFinalizing())
- while(ui->lwFiles->count()>1)delete ui->lwFiles->item(0);
- if(!qmpMainWindow::getInstance()->isFinalizing()&&settings->getOptionBool("Behavior/DialogStatus"))
- {
- settings->setOptionRaw("DialogStatus/PListWShown",0);
- }
- if(qmpMainWindow::getInstance()->isFinalizing()&&settings->getOptionBool("Behavior/RestorePlaylist"))
- {
- QSettings* plist=new QSettings(QStandardPaths::writableLocation(QStandardPaths::StandardLocation::ConfigLocation)+QString("/qmpplist"),
- QSettings::IniFormat);
- plist->setValue("Playlist/FileCount",ui->lwFiles->count());
- for(int i=0;i<ui->lwFiles->count();++i)
- plist->setValue("Playlist/File"+QString("%1").arg(i,5,10,QChar('0')),ui->lwFiles->item(i)->text());
- plist->setValue("Playlist/Repeat",repeat);
- plist->setValue("Playlist/Shuffle",shuffle);
- plist->sync();
- delete plist;
- }
- qmpMainWindow::getInstance()->setFuncState("Playlist",false);
- event->accept();
+ if (settings->getOptionBool("Behavior/DialogStatus"))
+ {
+ settings->setOptionRaw("DialogStatus/PListW", geometry());
+ }
+ setVisible(false);
+ if (!qmpMainWindow::getInstance()->isFinalizing())
+ while (ui->lwFiles->count() > 1)
+ delete ui->lwFiles->item(0);
+ if (!qmpMainWindow::getInstance()->isFinalizing() && settings->getOptionBool("Behavior/DialogStatus"))
+ {
+ settings->setOptionRaw("DialogStatus/PListWShown", 0);
+ }
+ if (qmpMainWindow::getInstance()->isFinalizing() && settings->getOptionBool("Behavior/RestorePlaylist"))
+ {
+ QSettings *plist = new QSettings(QStandardPaths::writableLocation(QStandardPaths::StandardLocation::ConfigLocation) + QString("/qmpplist"),
+ QSettings::IniFormat);
+ plist->setValue("Playlist/FileCount", ui->lwFiles->count());
+ for (int i = 0; i < ui->lwFiles->count(); ++i)
+ plist->setValue("Playlist/File" + QString("%1").arg(i, 5, 10, QChar('0')), ui->lwFiles->item(i)->text());
+ plist->setValue("Playlist/Repeat", repeat);
+ plist->setValue("Playlist/Shuffle", shuffle);
+ plist->sync();
+ delete plist;
+ }
+ qmpMainWindow::getInstance()->setFuncState("Playlist", false);
+ event->accept();
}
void qmpPlistWindow::dropEvent(QDropEvent *event)
{
- QList<QUrl> l=event->mimeData()->urls();
- QStringList sl;
- for(int i=0;i<l.size();++i)
- sl.push_back(l.at(i).toLocalFile());
- insertItems(sl);
+ QList<QUrl> l = event->mimeData()->urls();
+ QStringList sl;
+ for (int i = 0; i < l.size(); ++i)
+ sl.push_back(l.at(i).toLocalFile());
+ insertItems(sl);
}
void qmpPlistWindow::dragEnterEvent(QDragEnterEvent *event)
{
- //if(event->mimeData()->hasFormat("application/x-midi"))
- event->acceptProposedAction();
+ //if(event->mimeData()->hasFormat("application/x-midi"))
+ event->acceptProposedAction();
}
void qmpPlistWindow::emptyList()
{
- ui->lwFiles->clear();
+ ui->lwFiles->clear();
}
void qmpPlistWindow::insertItem(QString i)
{
- ui->lwFiles->addItem(new QListWidgetItem(i));
+ ui->lwFiles->addItem(new QListWidgetItem(i));
}
void qmpPlistWindow::insertItems(QStringList il)
{
- ui->lwFiles->addItems(il);
+ ui->lwFiles->addItems(il);
}
int qmpPlistWindow::on_pbAdd_clicked()
{
- QStringList sl;
- if(settings->getOptionBool("Behavior/DialogStatus"))
- sl=QFileDialog::getOpenFileNames(this,"Add File",settings->getOptionRaw("DialogStatus/FileDialogPath","").toString(),"Midi files (*.mid *.midi)");
- else
- sl=QFileDialog::getOpenFileNames(this,"Add File","","Midi files (*.mid *.midi *.rmi)");
- if(sl.empty())return 0;
- for(int i=0;i<sl.size();++i)
- ui->lwFiles->addItem(new QListWidgetItem(sl.at(i)));
- if(!isVisible())while(ui->lwFiles->count()>1)delete ui->lwFiles->item(0);
- if(settings->getOptionBool("Behavior/DialogStatus"))
- settings->setOptionRaw("DialogStatus/FileDialogPath",
- QUrl(sl.at(0)).toString(QUrl::RemoveFilename));
- return 1;
+ QStringList sl;
+ if (settings->getOptionBool("Behavior/DialogStatus"))
+ sl = QFileDialog::getOpenFileNames(this, "Add File", settings->getOptionRaw("DialogStatus/FileDialogPath", "").toString(), "Midi files (*.mid *.midi)");
+ else
+ sl = QFileDialog::getOpenFileNames(this, "Add File", "", "Midi files (*.mid *.midi *.rmi)");
+ if (sl.empty())
+ return 0;
+ for (int i = 0; i < sl.size(); ++i)
+ ui->lwFiles->addItem(new QListWidgetItem(sl.at(i)));
+ if (!isVisible())
+ while (ui->lwFiles->count() > 1)
+ delete ui->lwFiles->item(0);
+ if (settings->getOptionBool("Behavior/DialogStatus"))
+ settings->setOptionRaw("DialogStatus/FileDialogPath",
+ QUrl(sl.at(0)).toString(QUrl::RemoveFilename));
+ return 1;
}
void qmpPlistWindow::on_pbAddFolder_clicked()
{
- QDirIterator di(QFileDialog::getExistingDirectory(this,"Add Folder"));
- while(di.hasNext())
- {
- QString c=di.next();
- if((c.endsWith(".mid")||c.endsWith(".midi")||c.endsWith(".rmi"))&&fluid_is_midifile(c.toStdString().c_str()))
- ui->lwFiles->addItem(new QListWidgetItem(c));
- }
+ QDirIterator di(QFileDialog::getExistingDirectory(this, "Add Folder"));
+ while (di.hasNext())
+ {
+ QString c = di.next();
+ if ((c.endsWith(".mid") || c.endsWith(".midi") || c.endsWith(".rmi")) && fluid_is_midifile(c.toStdString().c_str()))
+ ui->lwFiles->addItem(new QListWidgetItem(c));
+ }
}
void qmpPlistWindow::on_pbRemove_clicked()
{
- QList<QListWidgetItem*> sl=ui->lwFiles->selectedItems();
- for(int i=0;i<sl.size();++i)
- {
- ui->lwFiles->removeItemWidget(sl.at(i));
- delete sl.at(i);
- }
+ QList<QListWidgetItem *> sl = ui->lwFiles->selectedItems();
+ for (int i = 0; i < sl.size(); ++i)
+ {
+ ui->lwFiles->removeItemWidget(sl.at(i));
+ delete sl.at(i);
+ }
}
void qmpPlistWindow::on_pbClear_clicked()
{
- while(ui->lwFiles->count()>0)
- {
- QListWidgetItem *d=ui->lwFiles->item(0);
- ui->lwFiles->removeItemWidget(d);
- delete d;
- }
+ while (ui->lwFiles->count() > 0)
+ {
+ QListWidgetItem *d = ui->lwFiles->item(0);
+ ui->lwFiles->removeItemWidget(d);
+ delete d;
+ }
}
void qmpPlistWindow::on_pbRepeat_clicked()
{
- ++repeat;repeat%=3;
- switch(repeat)
- {
- case 0:
- ui->pbRepeat->setIcon(QIcon(getThemedIcon(":/img/repeat-non.svg")));
- ui->pbRepeat->setText(tr("Repeat Off"));
- break;
- case 1:
- ui->pbRepeat->setIcon(QIcon(getThemedIcon(":/img/repeat-one.svg")));
- ui->pbRepeat->setText(tr("Repeat One"));
- break;
- case 2:
- ui->pbRepeat->setIcon(QIcon(getThemedIcon(":/img/repeat-all.svg")));
- ui->pbRepeat->setText(tr("Repeat All"));
- break;
- }
+ ++repeat;
+ repeat %= 3;
+ switch (repeat)
+ {
+ case 0:
+ ui->pbRepeat->setIcon(QIcon(getThemedIcon(":/img/repeat-non.svg")));
+ ui->pbRepeat->setText(tr("Repeat Off"));
+ break;
+ case 1:
+ ui->pbRepeat->setIcon(QIcon(getThemedIcon(":/img/repeat-one.svg")));
+ ui->pbRepeat->setText(tr("Repeat One"));
+ break;
+ case 2:
+ ui->pbRepeat->setIcon(QIcon(getThemedIcon(":/img/repeat-all.svg")));
+ ui->pbRepeat->setText(tr("Repeat All"));
+ break;
+ }
}
void qmpPlistWindow::on_pbShuffle_clicked()
{
- shuffle=1-shuffle;
- switch(shuffle)
- {
- case 1:
- ui->pbShuffle->setIcon(QIcon(getThemedIcon(":/img/shuffle.svg")));
- ui->pbShuffle->setText(tr("Shuffle On"));
- break;
- case 0:
- default:
- ui->pbShuffle->setIcon(QIcon(getThemedIcon(":/img/shuffle-off.svg")));
- ui->pbShuffle->setText(tr("Shuffle Off"));
- break;
- }
+ shuffle = 1 - shuffle;
+ switch (shuffle)
+ {
+ case 1:
+ ui->pbShuffle->setIcon(QIcon(getThemedIcon(":/img/shuffle.svg")));
+ ui->pbShuffle->setText(tr("Shuffle On"));
+ break;
+ case 0:
+ default:
+ ui->pbShuffle->setIcon(QIcon(getThemedIcon(":/img/shuffle-off.svg")));
+ ui->pbShuffle->setText(tr("Shuffle Off"));
+ break;
+ }
}
QString qmpPlistWindow::getFirstItem(bool a)
{
- if(ui->lwFiles->count()==0)return QString();
- int id=0;
- if(shuffle&&!a)id=rand()%ui->lwFiles->count();
- ui->lwFiles->setCurrentRow(id);
- return ui->lwFiles->item(id)->text();
+ if (ui->lwFiles->count() == 0)
+ return QString();
+ int id = 0;
+ if (shuffle && !a)
+ id = rand() % ui->lwFiles->count();
+ ui->lwFiles->setCurrentRow(id);
+ return ui->lwFiles->item(id)->text();
}
QString qmpPlistWindow::getLastItem(bool a)
{
- if(ui->lwFiles->count()==0)return QString();
- int id=ui->lwFiles->count()-1;
- if(shuffle&&!a)id=rand()%ui->lwFiles->count();
- ui->lwFiles->setCurrentRow(id);
- return ui->lwFiles->item(id)->text();
+ if (ui->lwFiles->count() == 0)
+ return QString();
+ int id = ui->lwFiles->count() - 1;
+ if (shuffle && !a)
+ id = rand() % ui->lwFiles->count();
+ ui->lwFiles->setCurrentRow(id);
+ return ui->lwFiles->item(id)->text();
}
QString qmpPlistWindow::getNextItem()
{
- if(ui->lwFiles->count()==0)return QString();
- if(repeat==1)return ui->lwFiles->item(ui->lwFiles->currentRow())->text();
- int id=ui->lwFiles->currentRow();++id;id%=ui->lwFiles->count();
- if(shuffle)id=rand()%ui->lwFiles->count();
- ui->lwFiles->setCurrentRow(id);
- return ui->lwFiles->item(id)->text();
+ if (ui->lwFiles->count() == 0)
+ return QString();
+ if (repeat == 1)
+ return ui->lwFiles->item(ui->lwFiles->currentRow())->text();
+ int id = ui->lwFiles->currentRow();
+ ++id;
+ id %= ui->lwFiles->count();
+ if (shuffle)
+ id = rand() % ui->lwFiles->count();
+ ui->lwFiles->setCurrentRow(id);
+ return ui->lwFiles->item(id)->text();
}
QString qmpPlistWindow::getPrevItem()
{
- if(ui->lwFiles->count()==0)return QString();
- if(repeat==1)return ui->lwFiles->item(ui->lwFiles->currentRow())->text();
- int id=ui->lwFiles->currentRow();--id;
- id<0?id+=ui->lwFiles->count():0;
- if(shuffle)id=rand()%ui->lwFiles->count();
- ui->lwFiles->setCurrentRow(id);
- return ui->lwFiles->item(id)->text();
+ if (ui->lwFiles->count() == 0)
+ return QString();
+ if (repeat == 1)
+ return ui->lwFiles->item(ui->lwFiles->currentRow())->text();
+ int id = ui->lwFiles->currentRow();
+ --id;
+ id < 0 ? id += ui->lwFiles->count() : 0;
+ if (shuffle)
+ id = rand() % ui->lwFiles->count();
+ ui->lwFiles->setCurrentRow(id);
+ return ui->lwFiles->item(id)->text();
}
QString qmpPlistWindow::getSelectedItem()
{
- if(ui->lwFiles->count()==0)return QString();
- return ui->lwFiles->item(ui->lwFiles->currentRow())->text();
+ if (ui->lwFiles->count() == 0)
+ return QString();
+ return ui->lwFiles->item(ui->lwFiles->currentRow())->text();
+}
+int qmpPlistWindow::getRepeat()
+{
+ return repeat;
}
-int qmpPlistWindow::getRepeat(){return repeat;}
void qmpPlistWindow::on_lwFiles_itemDoubleClicked()
{
- emit selectionChanging();
+ emit selectionChanging();
}
void qmpPlistWindow::on_pbSave_clicked()
{
- QSettings* plist=new QSettings(QFileDialog::getSaveFileName(this,tr("Save playlist"),""),
- QSettings::IniFormat);
- plist->setValue("Playlist/FileCount",ui->lwFiles->count());
- for(int i=0;i<ui->lwFiles->count();++i)
- plist->setValue("Playlist/File"+QString("%1").arg(i,5,10,QChar('0')),ui->lwFiles->item(i)->text());
- plist->setValue("Playlist/Repeat",repeat);
- plist->setValue("Playlist/Shuffle",shuffle);
- plist->sync();
- delete plist;
+ QSettings *plist = new QSettings(QFileDialog::getSaveFileName(this, tr("Save playlist"), ""),
+ QSettings::IniFormat);
+ plist->setValue("Playlist/FileCount", ui->lwFiles->count());
+ for (int i = 0; i < ui->lwFiles->count(); ++i)
+ plist->setValue("Playlist/File" + QString("%1").arg(i, 5, 10, QChar('0')), ui->lwFiles->item(i)->text());
+ plist->setValue("Playlist/Repeat", repeat);
+ plist->setValue("Playlist/Shuffle", shuffle);
+ plist->sync();
+ delete plist;
}
void qmpPlistWindow::on_pbLoad_clicked()
{
- QSettings* plist=new QSettings(QFileDialog::getOpenFileName(this,tr("Load playlist"),""),
- QSettings::IniFormat);
- int fc=plist->value("Playlist/FileCount",0).toInt();
- if(!fc){delete plist;return;}
- ui->lwFiles->clear();for(int i=0;i<fc;++i)
- ui->lwFiles->addItem(plist->value("Playlist/File"+QString("%1").arg(i,5,10,QChar('0')),"").toString());
- repeat=plist->value("Playlist/Repeat",0).toInt();
- shuffle=plist->value("Playlist/Shuffle",0).toInt();
- switch(shuffle)
- {
- case 1:
- ui->pbShuffle->setIcon(QIcon(":/img/shuffle.svg"));
- ui->pbShuffle->setText(tr("Shuffle On"));
- break;
- case 0:
- default:
- ui->pbShuffle->setIcon(QIcon(":/img/shuffle-off.svg"));
- ui->pbShuffle->setText(tr("Shuffle Off"));
- break;
- }
- switch(repeat)
- {
- case 0:
- ui->pbRepeat->setIcon(QIcon(":/img/repeat-non.svg"));
- ui->pbRepeat->setText(tr("Repeat Off"));
- break;
- case 1:
- ui->pbRepeat->setIcon(QIcon(":/img/repeat-one.svg"));
- ui->pbRepeat->setText(tr("Repeat One"));
- break;
- case 2:
- ui->pbRepeat->setIcon(QIcon(":/img/repeat-all.svg"));
- ui->pbRepeat->setText(tr("Repeat All"));
- break;
- }
- delete plist;
+ QSettings *plist = new QSettings(QFileDialog::getOpenFileName(this, tr("Load playlist"), ""),
+ QSettings::IniFormat);
+ int fc = plist->value("Playlist/FileCount", 0).toInt();
+ if (!fc)
+ {
+ delete plist;
+ return;
+ }
+ ui->lwFiles->clear();
+ for (int i = 0; i < fc; ++i)
+ ui->lwFiles->addItem(plist->value("Playlist/File" + QString("%1").arg(i, 5, 10, QChar('0')), "").toString());
+ repeat = plist->value("Playlist/Repeat", 0).toInt();
+ shuffle = plist->value("Playlist/Shuffle", 0).toInt();
+ switch (shuffle)
+ {
+ case 1:
+ ui->pbShuffle->setIcon(QIcon(":/img/shuffle.svg"));
+ ui->pbShuffle->setText(tr("Shuffle On"));
+ break;
+ case 0:
+ default:
+ ui->pbShuffle->setIcon(QIcon(":/img/shuffle-off.svg"));
+ ui->pbShuffle->setText(tr("Shuffle Off"));
+ break;
+ }
+ switch (repeat)
+ {
+ case 0:
+ ui->pbRepeat->setIcon(QIcon(":/img/repeat-non.svg"));
+ ui->pbRepeat->setText(tr("Repeat Off"));
+ break;
+ case 1:
+ ui->pbRepeat->setIcon(QIcon(":/img/repeat-one.svg"));
+ ui->pbRepeat->setText(tr("Repeat One"));
+ break;
+ case 2:
+ ui->pbRepeat->setIcon(QIcon(":/img/repeat-all.svg"));
+ ui->pbRepeat->setText(tr("Repeat All"));
+ break;
+ }
+ delete plist;
}
qmpPlistFunc::qmpPlistFunc(qmpPlistWindow *par)
-{p=par;}
+{
+ p = par;
+}
void qmpPlistFunc::show()
{
- p->show();
+ p->show();
}
void qmpPlistFunc::close()
{
- p->close();
+ p->close();
}
diff --git a/qmidiplayer-desktop/qmpplistwindow.hpp b/qmidiplayer-desktop/qmpplistwindow.hpp
index afd3ae3..7d93345 100644
--- a/qmidiplayer-desktop/qmpplistwindow.hpp
+++ b/qmidiplayer-desktop/qmpplistwindow.hpp
@@ -10,63 +10,64 @@
#include <QListWidgetItem>
#include "../include/qmpcorepublic.hpp"
-namespace Ui {
- class qmpPlistWindow;
+namespace Ui
+{
+class qmpPlistWindow;
}
class qmpPlistWindow;
class qmpSettings;
-class qmpPlistFunc:public qmpFuncBaseIntf
+class qmpPlistFunc: public qmpFuncBaseIntf
{
- private:
- qmpPlistWindow* p;
- public:
- qmpPlistFunc(qmpPlistWindow *par);
- void show();
- void close();
+private:
+ qmpPlistWindow *p;
+public:
+ qmpPlistFunc(qmpPlistWindow *par);
+ void show();
+ void close();
};
-class qmpPlistWindow:public QWidget
+class qmpPlistWindow: public QWidget
{
- Q_OBJECT
+ Q_OBJECT
- public:
- explicit qmpPlistWindow(QWidget *parent=0);
- ~qmpPlistWindow();
- void showEvent(QShowEvent *event);
- void closeEvent(QCloseEvent *event);
- void dropEvent(QDropEvent *event);
- void dragEnterEvent(QDragEnterEvent *event);
- int getRepeat();
- QString getFirstItem(bool a=false);
- QString getLastItem(bool a=false);
- QString getNextItem();
- QString getPrevItem();
- QString getSelectedItem();
- void emptyList();
- void insertItem(QString i);
- void insertItems(QStringList il);
- signals:
- void selectionChanging();
+public:
+ explicit qmpPlistWindow(QWidget *parent = 0);
+ ~qmpPlistWindow();
+ void showEvent(QShowEvent *event);
+ void closeEvent(QCloseEvent *event);
+ void dropEvent(QDropEvent *event);
+ void dragEnterEvent(QDragEnterEvent *event);
+ int getRepeat();
+ QString getFirstItem(bool a = false);
+ QString getLastItem(bool a = false);
+ QString getNextItem();
+ QString getPrevItem();
+ QString getSelectedItem();
+ void emptyList();
+ void insertItem(QString i);
+ void insertItems(QStringList il);
+signals:
+ void selectionChanging();
- public slots:
- int on_pbAdd_clicked();
- private slots:
- void on_pbAddFolder_clicked();
- void on_pbRemove_clicked();
- void on_pbClear_clicked();
- void on_pbRepeat_clicked();
- void on_pbShuffle_clicked();
- void on_lwFiles_itemDoubleClicked();
- void on_pbSave_clicked();
- void on_pbLoad_clicked();
+public slots:
+ int on_pbAdd_clicked();
+private slots:
+ void on_pbAddFolder_clicked();
+ void on_pbRemove_clicked();
+ void on_pbClear_clicked();
+ void on_pbRepeat_clicked();
+ void on_pbShuffle_clicked();
+ void on_lwFiles_itemDoubleClicked();
+ void on_pbSave_clicked();
+ void on_pbLoad_clicked();
- private:
- qmpPlistFunc* plistf;
- Ui::qmpPlistWindow *ui;
- int shuffle,repeat;//rep 0=off 1=one 2=all
- qmpSettings* settings;
+private:
+ qmpPlistFunc *plistf;
+ Ui::qmpPlistWindow *ui;
+ int shuffle, repeat; //rep 0=off 1=one 2=all
+ qmpSettings *settings;
};
#endif // QMPPLISTWINDOW_H
diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp
index 9cd1f35..cdea00c 100644
--- a/qmidiplayer-desktop/qmpplugin.cpp
+++ b/qmidiplayer-desktop/qmpplugin.cpp
@@ -9,265 +9,461 @@
#include "qmpplugin.hpp"
#include "qmpmainwindow.hpp"
#include "qmpsettingswindow.hpp"
-qmpPluginAPIImpl* qmpPluginManager::pluginAPI=nullptr;
-qmpMainWindow* qmpPluginManager::mainwindow=nullptr;
+qmpPluginAPIImpl *qmpPluginManager::pluginAPI = nullptr;
+qmpMainWindow *qmpPluginManager::mainwindow = nullptr;
#ifdef _WIN32
#include <codecvt>
#include <locale>
std::string wstr2str(std::wstring s)
{
- std::wstring_convert<std::codecvt_utf8<wchar_t>,wchar_t> wsc;
- return wsc.to_bytes(s);
+ std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> wsc;
+ return wsc.to_bytes(s);
}
void qmpPluginManager::scanPlugins(const std::vector<std::string> &pp)
{
- QDirIterator *dir;
- std::vector<std::wstring> cpluginpaths;
- std::wstring_convert<std::codecvt_utf8<wchar_t>,wchar_t> wsc;
- for(auto p:pp)cpluginpaths.push_back(wsc.from_bytes(p));
- dir=new QDirIterator(QCoreApplication::applicationDirPath()+"/plugins/");
- while(dir->hasNext())
- {
- dir->next();
- if(dir->fileInfo().suffix()=="dll")
- cpluginpaths.push_back(QCoreApplication::applicationDirPath().toStdWString()+std::wstring(L"/plugins/")+dir->fileName().toStdWString());
- }
- delete dir;
- for(unsigned i=0;i<cpluginpaths.size();++i)
- {
- HMODULE hso=LoadLibraryW(cpluginpaths[i].c_str());
- if(!hso){fprintf(stderr,"Error while loading library: %d\n",GetLastError());continue;}
- FARPROC hndi=GetProcAddress(hso,"qmpPluginGetInterface");
- if(!hndi){fprintf(stderr,"plugin %s doesn't seem to be a qmidiplayer plugin.\n",wstr2str(cpluginpaths[i]).c_str());continue;}
- FARPROC hndiv=GetProcAddress(hso,"qmpPluginGetAPIRev");
- if(!hndiv){fprintf(stderr,"plugin %s is incompatible with this version of qmidiplayer.\n",wstr2str(cpluginpaths[i]).c_str());continue;}
- qmpPluginAPIRevEntry getv=(qmpPluginAPIRevEntry)hndiv;
- if(strcmp(getv(),QMP_PLUGIN_API_REV))
- {fprintf(stderr,"plugin %s is incompatible with this version of qmidiplayer.\n",wstr2str(cpluginpaths[i]).c_str());continue;}
- qmpPluginEntry e=(qmpPluginEntry)hndi;
- qmpPluginIntf* intf=e(pluginAPI);
- plugins.push_back(qmpPlugin(std::string(intf->pluginGetName()),std::string(intf->pluginGetVersion()),wstr2str(cpluginpaths[i]),intf));
- }
+ QDirIterator *dir;
+ std::vector<std::wstring> cpluginpaths;
+ std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> wsc;
+ for (auto p : pp)
+ cpluginpaths.push_back(wsc.from_bytes(p));
+ dir = new QDirIterator(QCoreApplication::applicationDirPath() + "/plugins/");
+ while (dir->hasNext())
+ {
+ dir->next();
+ if (dir->fileInfo().suffix() == "dll")
+ cpluginpaths.push_back(QCoreApplication::applicationDirPath().toStdWString() + std::wstring(L"/plugins/") + dir->fileName().toStdWString());
+ }
+ delete dir;
+ for (unsigned i = 0; i < cpluginpaths.size(); ++i)
+ {
+ HMODULE hso = LoadLibraryW(cpluginpaths[i].c_str());
+ if (!hso)
+ {
+ fprintf(stderr, "Error while loading library: %d\n", GetLastError());
+ continue;
+ }
+ FARPROC hndi = GetProcAddress(hso, "qmpPluginGetInterface");
+ if (!hndi)
+ {
+ fprintf(stderr, "plugin %s doesn't seem to be a qmidiplayer plugin.\n", wstr2str(cpluginpaths[i]).c_str());
+ continue;
+ }
+ FARPROC hndiv = GetProcAddress(hso, "qmpPluginGetAPIRev");
+ if (!hndiv)
+ {
+ fprintf(stderr, "plugin %s is incompatible with this version of qmidiplayer.\n", wstr2str(cpluginpaths[i]).c_str());
+ continue;
+ }
+ qmpPluginAPIRevEntry getv = (qmpPluginAPIRevEntry)hndiv;
+ if (strcmp(getv(), QMP_PLUGIN_API_REV))
+ {
+ fprintf(stderr, "plugin %s is incompatible with this version of qmidiplayer.\n", wstr2str(cpluginpaths[i]).c_str());
+ continue;
+ }
+ qmpPluginEntry e = (qmpPluginEntry)hndi;
+ qmpPluginIntf *intf = e(pluginAPI);
+ plugins.push_back(qmpPlugin(std::string(intf->pluginGetName()), std::string(intf->pluginGetVersion()), wstr2str(cpluginpaths[i]), intf));
+ }
}
#else
void qmpPluginManager::scanPlugins(const std::vector<std::string> &pp)
{
- QDirIterator *dir;
- std::vector<std::string> cpluginpaths(pp);
+ QDirIterator *dir;
+ std::vector<std::string> cpluginpaths(pp);
#ifdef NON_PORTABLE
- QString pdir=QString(QT_STRINGIFY(INSTALL_PREFIX))+"/lib/qmidiplayer/";
- dir=new QDirIterator(pdir);
- while(dir->hasNext())
- {
- dir->next();
- if(dir->fileInfo().suffix()=="so")
- cpluginpaths.push_back((pdir+dir->fileName()).toStdString());
- }
- delete dir;
+ QString pdir = QString(QT_STRINGIFY(INSTALL_PREFIX)) + "/lib/qmidiplayer/";
+ dir = new QDirIterator(pdir);
+ while (dir->hasNext())
+ {
+ dir->next();
+ if (dir->fileInfo().suffix() == "so")
+ cpluginpaths.push_back((pdir + dir->fileName()).toStdString());
+ }
+ delete dir;
#endif
- dir=new QDirIterator(QCoreApplication::applicationDirPath()+"/plugins/");
- while(dir->hasNext())
- {
- dir->next();
- if(dir->fileInfo().suffix()=="so")
- cpluginpaths.push_back(QCoreApplication::applicationDirPath().toStdString()+std::string("/plugins/")+dir->fileName().toStdString());
- }
- delete dir;
- for(unsigned i=0;i<cpluginpaths.size();++i)
- {
- void* hso=dlopen(cpluginpaths[i].c_str(),RTLD_LAZY);
- if(!hso){fprintf(stderr,"%s\n",dlerror());continue;}
- void* hndi=dlsym(hso,"qmpPluginGetInterface");
- if(!hndi){fprintf(stderr,"file %s doesn't seem to be a qmidiplayer plugin.\n",cpluginpaths[i].c_str());continue;}
- void* hndiv=dlsym(hso,"qmpPluginGetAPIRev");
- if(!hndiv){fprintf(stderr,"file %s is incompatible with this version of qmidiplayer.\n",cpluginpaths[i].c_str());continue;}
- qmpPluginAPIRevEntry getv=(qmpPluginAPIRevEntry)hndiv;
- if(strcmp(getv(),QMP_PLUGIN_API_REV))
- {fprintf(stderr,"file %s is incompatible with this version of qmidiplayer.\n",cpluginpaths[i].c_str());continue;}
- qmpPluginEntry e=(qmpPluginEntry)hndi;
- qmpPluginIntf* intf=e(pluginAPI);
- plugins.push_back(qmpPlugin(std::string(intf->pluginGetName()),std::string(intf->pluginGetVersion()),std::string(cpluginpaths[i]),intf));
- }
+ dir = new QDirIterator(QCoreApplication::applicationDirPath() + "/plugins/");
+ while (dir->hasNext())
+ {
+ dir->next();
+ if (dir->fileInfo().suffix() == "so")
+ cpluginpaths.push_back(QCoreApplication::applicationDirPath().toStdString() + std::string("/plugins/") + dir->fileName().toStdString());
+ }
+ delete dir;
+ for (unsigned i = 0; i < cpluginpaths.size(); ++i)
+ {
+ void *hso = dlopen(cpluginpaths[i].c_str(), RTLD_LAZY);
+ if (!hso)
+ {
+ fprintf(stderr, "%s\n", dlerror());
+ continue;
+ }
+ void *hndi = dlsym(hso, "qmpPluginGetInterface");
+ if (!hndi)
+ {
+ fprintf(stderr, "file %s doesn't seem to be a qmidiplayer plugin.\n", cpluginpaths[i].c_str());
+ continue;
+ }
+ void *hndiv = dlsym(hso, "qmpPluginGetAPIRev");
+ if (!hndiv)
+ {
+ fprintf(stderr, "file %s is incompatible with this version of qmidiplayer.\n", cpluginpaths[i].c_str());
+ continue;
+ }
+ qmpPluginAPIRevEntry getv = (qmpPluginAPIRevEntry)hndiv;
+ if (strcmp(getv(), QMP_PLUGIN_API_REV))
+ {
+ fprintf(stderr, "file %s is incompatible with this version of qmidiplayer.\n", cpluginpaths[i].c_str());
+ continue;
+ }
+ qmpPluginEntry e = (qmpPluginEntry)hndi;
+ qmpPluginIntf *intf = e(pluginAPI);
+ plugins.push_back(qmpPlugin(std::string(intf->pluginGetName()), std::string(intf->pluginGetVersion()), std::string(cpluginpaths[i]), intf));
+ }
}
#endif
qmpPluginManager::qmpPluginManager()
{
- mainwindow=qmpMainWindow::getInstance();
- pluginAPI=new qmpPluginAPIImpl();
+ mainwindow = qmpMainWindow::getInstance();
+ pluginAPI = new qmpPluginAPIImpl();
}
qmpPluginManager::~qmpPluginManager()
{
- for(unsigned i=0;i<plugins.size();++i)
- {
- if(plugins[i].initialized)plugins[i].pinterface->deinit();
- delete plugins[i].pinterface;
- }
- mainwindow=nullptr;delete pluginAPI;
+ for (unsigned i = 0; i < plugins.size(); ++i)
+ {
+ if (plugins[i].initialized)
+ plugins[i].pinterface->deinit();
+ delete plugins[i].pinterface;
+ }
+ mainwindow = nullptr;
+ delete pluginAPI;
}
std::vector<qmpPlugin> *qmpPluginManager::getPlugins()
{
- return &plugins;
+ return &plugins;
}
void qmpPluginManager::initPlugins()
{
- for(unsigned i=0;i<plugins.size();++i)
- {
- if(!plugins[i].enabled)continue;
- fprintf(stderr,"Loaded plugin: %s\n",plugins[i].path.c_str());
- plugins[i].pinterface->init();plugins[i].initialized=true;
- }
+ for (unsigned i = 0; i < plugins.size(); ++i)
+ {
+ if (!plugins[i].enabled)
+ continue;
+ fprintf(stderr, "Loaded plugin: %s\n", plugins[i].path.c_str());
+ plugins[i].pinterface->init();
+ plugins[i].initialized = true;
+ }
}
void qmpPluginManager::deinitPlugins()
{
- for(unsigned i=0;i<plugins.size();++i)
- {
- if(plugins[i].initialized)plugins[i].pinterface->deinit();
- plugins[i].enabled=plugins[i].initialized=false;
- }
+ for (unsigned i = 0; i < plugins.size(); ++i)
+ {
+ if (plugins[i].initialized)
+ plugins[i].pinterface->deinit();
+ plugins[i].enabled = plugins[i].initialized = false;
+ }
}
-qmpPluginAPIImpl::qmpPluginAPIImpl(){}
-qmpPluginAPIImpl::~qmpPluginAPIImpl(){}
+qmpPluginAPIImpl::qmpPluginAPIImpl() {}
+qmpPluginAPIImpl::~qmpPluginAPIImpl() {}
#define qmw qmpPluginManager::mainwindow
uint32_t qmpPluginAPIImpl::getDivision()
-{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getDivision():0;}
+{
+ return qmw && qmw->getPlayer() ? qmw->getPlayer()->getDivision() : 0;
+}
uint32_t qmpPluginAPIImpl::getRawTempo()
-{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getRawTempo():0;}
+{
+ return qmw && qmw->getPlayer() ? qmw->getPlayer()->getRawTempo() : 0;
+}
double qmpPluginAPIImpl::getRealTempo()
-{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getTempo():0;}
+{
+ return qmw && qmw->getPlayer() ? qmw->getPlayer()->getTempo() : 0;
+}
uint32_t qmpPluginAPIImpl::getTimeSig()
-{int n,d=0,t;qmw&&qmw->getPlayer()?qmw->getPlayer()->getCurrentTimeSignature(&n,&t):void(0);for(;t>>=1;++d);return n<<8|d;}
+{
+ int n, d = 0, t;
+ qmw &&qmw->getPlayer() ? qmw->getPlayer()->getCurrentTimeSignature(&n, &t) : void(0);
+ for (; t >>= 1; ++d);
+ return n << 8 | d;
+}
int qmpPluginAPIImpl::getKeySig()
-{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getCurrentKeySignature():0;}
+{
+ return qmw && qmw->getPlayer() ? qmw->getPlayer()->getCurrentKeySignature() : 0;
+}
uint32_t qmpPluginAPIImpl::getNoteCount()
-{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getFileNoteCount():0;}
+{
+ return qmw && qmw->getPlayer() ? qmw->getPlayer()->getFileNoteCount() : 0;
+}
uint32_t qmpPluginAPIImpl::getMaxTick()
-{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getMaxTick():0;}
+{
+ return qmw && qmw->getPlayer() ? qmw->getPlayer()->getMaxTick() : 0;
+}
uint32_t qmpPluginAPIImpl::getCurrentPolyphone()
-{return qmw&&qmw->getPlayer()?qmw->getFluid()->getPolyphone():0;}
+{
+ return qmw && qmw->getPlayer() ? qmw->getFluid()->getPolyphone() : 0;
+}
uint32_t qmpPluginAPIImpl::getMaxPolyphone()
-{return qmw&&qmw->getPlayer()?qmw->getFluid()->getMaxPolyphone():0;}
+{
+ return qmw && qmw->getPlayer() ? qmw->getFluid()->getMaxPolyphone() : 0;
+}
uint32_t qmpPluginAPIImpl::getCurrentTimeStamp()
-{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getTick():0;}
+{
+ return qmw && qmw->getPlayer() ? qmw->getPlayer()->getTick() : 0;
+}
uint32_t qmpPluginAPIImpl::getCurrentPlaybackPercentage()
-{return qmw?qmw->getPlaybackPercentage():0;}
-int qmpPluginAPIImpl::getChannelCC(int ch,int cc)
-{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getCC(ch,cc):0;}
+{
+ return qmw ? qmw->getPlaybackPercentage() : 0;
+}
+int qmpPluginAPIImpl::getChannelCC(int ch, int cc)
+{
+ return qmw && qmw->getPlayer() ? qmw->getPlayer()->getCC(ch, cc) : 0;
+}
int qmpPluginAPIImpl::getChannelPreset(int ch)
{
- uint16_t b;uint8_t p;std::string nm;
- if(qmw&&qmw->getPlayer())
- {
- if(qmw->getPlayer()->getChannelOutputDevice(ch)->getChannelPreset(ch,&b,&p,nm))return p;
- return qmw->getPlayer()->getCC(ch,128);
- }
- return 0;
+ uint16_t b;
+ uint8_t p;
+ std::string nm;
+ if (qmw && qmw->getPlayer())
+ {
+ if (qmw->getPlayer()->getChannelOutputDevice(ch)->getChannelPreset(ch, &b, &p, nm))
+ return p;
+ return qmw->getPlayer()->getCC(ch, 128);
+ }
+ return 0;
}
void qmpPluginAPIImpl::playerSeek(uint32_t percentage)
-{if(qmw)qmw->playerSeek(percentage);}
+{
+ if (qmw)
+ qmw->playerSeek(percentage);
+}
double qmpPluginAPIImpl::getPitchBend(int ch)
-{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getPitchBend(ch):0;}
-void qmpPluginAPIImpl::getPitchBendRaw(int ch,uint32_t *pb,uint32_t *pbr)
{
- if(qmw&&qmw->getPlayer())
- qmw->getPlayer()->getPitchBendRaw(ch,pb,pbr);
+ return qmw && qmw->getPlayer() ? qmw->getPlayer()->getPitchBend(ch) : 0;
+}
+void qmpPluginAPIImpl::getPitchBendRaw(int ch, uint32_t *pb, uint32_t *pbr)
+{
+ if (qmw && qmw->getPlayer())
+ qmw->getPlayer()->getPitchBendRaw(ch, pb, pbr);
}
bool qmpPluginAPIImpl::getChannelMask(int ch)
-{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getChannelMask(ch):false;}
+{
+ return qmw && qmw->getPlayer() ? qmw->getPlayer()->getChannelMask(ch) : false;
+}
std::string qmpPluginAPIImpl::getTitle()
-{return qmw?qmw->getTitle():"";}
+{
+ return qmw ? qmw->getTitle() : "";
+}
std::wstring qmpPluginAPIImpl::getWTitle()
-{return qmw?qmw->getWTitle():L"";}
+{
+ return qmw ? qmw->getWTitle() : L"";
+}
std::string qmpPluginAPIImpl::getChannelPresetString(int ch)
{
- uint16_t b;uint8_t p;char ret[320];ret[0]=0;
- std::string nm;
- if(qmw&&qmw->getPlayer())
- {
- int r=qmw->getPlayer()->getChannelOutputDevice(ch)->getChannelPreset(ch,&b,&p,nm);
- if(!r)
- {
- b=qmw->getPlayer()->getCC(ch,0)<<7|qmw->getPlayer()->getCC(ch,32);
- p=qmw->getPlayer()->getCC(ch,128);
- nm=qmw->getPlayer()->getChannelOutputDevice(ch)->getPresetName(b,p);
- }
- snprintf(ret,320,"%03d:%03d %s",b,p,nm.c_str());
- }
- return std::string(ret);
-}
-bool qmpPluginAPIImpl::isDarkTheme(){return qmw?qmw->isDarkTheme():false;}
-void* qmpPluginAPIImpl::getMainWindow(){return (void*)qmw;}
+ uint16_t b;
+ uint8_t p;
+ char ret[320];
+ ret[0] = 0;
+ std::string nm;
+ if (qmw && qmw->getPlayer())
+ {
+ int r = qmw->getPlayer()->getChannelOutputDevice(ch)->getChannelPreset(ch, &b, &p, nm);
+ if (!r)
+ {
+ b = qmw->getPlayer()->getCC(ch, 0) << 7 | qmw->getPlayer()->getCC(ch, 32);
+ p = qmw->getPlayer()->getCC(ch, 128);
+ nm = qmw->getPlayer()->getChannelOutputDevice(ch)->getPresetName(b, p);
+ }
+ snprintf(ret, 320, "%03d:%03d %s", b, p, nm.c_str());
+ }
+ return std::string(ret);
+}
+bool qmpPluginAPIImpl::isDarkTheme()
+{
+ return qmw ? qmw->isDarkTheme() : false;
+}
+void *qmpPluginAPIImpl::getMainWindow()
+{
+ return (void *)qmw;
+}
-void qmpPluginAPIImpl::discardCurrentEvent(){if(qmw&&qmw->getPlayer())qmw->getPlayer()->discardCurrentEvent();}
-void qmpPluginAPIImpl::commitEventChange(SEvent d){if(qmw&&qmw->getPlayer())qmw->getPlayer()->commitEventChange(d);}
-void qmpPluginAPIImpl::callEventReaderCB(SEvent d){if(qmw&&qmw->getPlayer())qmw->getPlayer()->callEventReaderCB(d);}
-void qmpPluginAPIImpl::setFuncState(std::string name,bool state){if(qmw)qmw->setFuncState(name,state);}
-void qmpPluginAPIImpl::setFuncEnabled(std::string name,bool enable){if(qmw)qmw->setFuncEnabled(name,enable);}
+void qmpPluginAPIImpl::discardCurrentEvent()
+{
+ if (qmw && qmw->getPlayer())
+ qmw->getPlayer()->discardCurrentEvent();
+}
+void qmpPluginAPIImpl::commitEventChange(SEvent d)
+{
+ if (qmw && qmw->getPlayer())
+ qmw->getPlayer()->commitEventChange(d);
+}
+void qmpPluginAPIImpl::callEventReaderCB(SEvent d)
+{
+ if (qmw && qmw->getPlayer())
+ qmw->getPlayer()->callEventReaderCB(d);
+}
+void qmpPluginAPIImpl::setFuncState(std::string name, bool state)
+{
+ if (qmw)
+ qmw->setFuncState(name, state);
+}
+void qmpPluginAPIImpl::setFuncEnabled(std::string name, bool enable)
+{
+ if (qmw)
+ qmw->setFuncEnabled(name, enable);
+}
void qmpPluginAPIImpl::registerMidiOutDevice(qmpMidiOutDevice *dev, std::string name)
-{qmw->getPlayer()->registerMidiOutDevice(dev,name);}
+{
+ qmw->getPlayer()->registerMidiOutDevice(dev, name);
+}
void qmpPluginAPIImpl::unregisterMidiOutDevice(std::string name)
-{qmw->getPlayer()->unregisterMidiOutDevice(name);}
-int qmpPluginAPIImpl::registerEventHandlerIntf(ICallBack *cb,void *userdata)
-{return qmw->getPlayer()->setEventHandlerCB(cb,userdata);}
+{
+ qmw->getPlayer()->unregisterMidiOutDevice(name);
+}
+int qmpPluginAPIImpl::registerEventHandlerIntf(ICallBack *cb, void *userdata)
+{
+ return qmw->getPlayer()->setEventHandlerCB(cb, userdata);
+}
void qmpPluginAPIImpl::unregisterEventHandlerIntf(int intfhandle)
-{qmw->getPlayer()->unsetEventHandlerCB(intfhandle);}
-int qmpPluginAPIImpl::registerEventReaderIntf(ICallBack *cb,void *userdata)
-{return qmw->getPlayer()->setEventReaderCB(cb,userdata);}
+{
+ qmw->getPlayer()->unsetEventHandlerCB(intfhandle);
+}
+int qmpPluginAPIImpl::registerEventReaderIntf(ICallBack *cb, void *userdata)
+{
+ return qmw->getPlayer()->setEventReaderCB(cb, userdata);
+}
void qmpPluginAPIImpl::unregisterEventReaderIntf(int intfhandle)
-{qmw->getPlayer()->unsetEventReaderCB(intfhandle);}
-int qmpPluginAPIImpl::registerUIHook(std::string e,ICallBack* cb,void* userdat)
-{return qmw->registerUIHook(e,cb,userdat);}
-int qmpPluginAPIImpl::registerUIHook(std::string e,callback_t cb,void* userdat)
-{return qmw->registerUIHook(e,cb,userdat);}
-void qmpPluginAPIImpl::unregisterUIHook(std::string e,int hook)
-{qmw->unregisterUIHook(e,hook);}
-void qmpPluginAPIImpl::registerFunctionality(qmpFuncBaseIntf *i,std::string name,std::string desc,const char *icon,int iconlen,bool checkable)
-{qmw->registerFunctionality(i,name,desc,icon,iconlen,checkable);}
+{
+ qmw->getPlayer()->unsetEventReaderCB(intfhandle);
+}
+int qmpPluginAPIImpl::registerUIHook(std::string e, ICallBack *cb, void *userdat)
+{
+ return qmw->registerUIHook(e, cb, userdat);
+}
+int qmpPluginAPIImpl::registerUIHook(std::string e, callback_t cb, void *userdat)
+{
+ return qmw->registerUIHook(e, cb, userdat);
+}
+void qmpPluginAPIImpl::unregisterUIHook(std::string e, int hook)
+{
+ qmw->unregisterUIHook(e, hook);
+}
+void qmpPluginAPIImpl::registerFunctionality(qmpFuncBaseIntf *i, std::string name, std::string desc, const char *icon, int iconlen, bool checkable)
+{
+ qmw->registerFunctionality(i, name, desc, icon, iconlen, checkable);
+}
void qmpPluginAPIImpl::unregisterFunctionality(std::string name)
-{qmw->unregisterFunctionality(name);}
-int qmpPluginAPIImpl::registerFileReadFinishedHandlerIntf(ICallBack* cb,void* userdata)
-{return qmw->getPlayer()->setFileReadFinishedCB(cb,userdata);}
+{
+ qmw->unregisterFunctionality(name);
+}
+int qmpPluginAPIImpl::registerFileReadFinishedHandlerIntf(ICallBack *cb, void *userdata)
+{
+ return qmw->getPlayer()->setFileReadFinishedCB(cb, userdata);
+}
void qmpPluginAPIImpl::unregisterFileReadFinishedHandlerIntf(int intfhandle)
-{qmw->getPlayer()->unsetFileReadFinishedCB(intfhandle);}
-void qmpPluginAPIImpl::registerFileReader(qmpFileReader* reader,std::string name)
-{qmw->getPlayer()->registerReader(reader,name);}
+{
+ qmw->getPlayer()->unsetFileReadFinishedCB(intfhandle);
+}
+void qmpPluginAPIImpl::registerFileReader(qmpFileReader *reader, std::string name)
+{
+ qmw->getPlayer()->registerReader(reader, name);
+}
void qmpPluginAPIImpl::unregisterFileReader(std::string name)
-{qmw->getPlayer()->unregisterReader(name);}
-int qmpPluginAPIImpl::registerEventHandler(callback_t cb,void *userdata,bool post)
-{return qmw->getPlayer()->registerEventHandler(cb,userdata,post);}
+{
+ qmw->getPlayer()->unregisterReader(name);
+}
+int qmpPluginAPIImpl::registerEventHandler(callback_t cb, void *userdata, bool post)
+{
+ return qmw->getPlayer()->registerEventHandler(cb, userdata, post);
+}
void qmpPluginAPIImpl::unregisterEventHandler(int id)
-{qmw->getPlayer()->unregisterEventHandler(id);}
-int qmpPluginAPIImpl::registerEventReadHandler(callback_t cb,void *userdata)
-{return qmw->getPlayer()->registerEventReadHandler(cb,userdata);}
+{
+ qmw->getPlayer()->unregisterEventHandler(id);
+}
+int qmpPluginAPIImpl::registerEventReadHandler(callback_t cb, void *userdata)
+{
+ return qmw->getPlayer()->registerEventReadHandler(cb, userdata);
+}
void qmpPluginAPIImpl::unregisterEventReadHandler(int id)
-{qmw->getPlayer()->unregisterEventReadHandler(id);}
-int qmpPluginAPIImpl::registerFileReadFinishHook(callback_t cb,void *userdata)
-{return qmw->getPlayer()->registerFileReadFinishHook(cb,userdata);}
+{
+ qmw->getPlayer()->unregisterEventReadHandler(id);
+}
+int qmpPluginAPIImpl::registerFileReadFinishHook(callback_t cb, void *userdata)
+{
+ return qmw->getPlayer()->registerFileReadFinishHook(cb, userdata);
+}
void qmpPluginAPIImpl::unregisterFileReadFinishHook(int id)
-{qmw->getPlayer()->unregisterFileReadFinishHook(id);}
+{
+ qmw->getPlayer()->unregisterFileReadFinishHook(id);
+}
-void qmpPluginAPIImpl::registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval)
-{qmw->getSettings()->registerOptionInt(tab,desc,key,min,max,defaultval);}
-int qmpPluginAPIImpl::getOptionInt(std::string key){return qmw->getSettings()->getOptionInt(key);}
-void qmpPluginAPIImpl::setOptionInt(std::string key,int val){qmw->getSettings()->setOptionInt(key,val);}
-void qmpPluginAPIImpl::registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval)
-{qmw->getSettings()->registerOptionUint(tab,desc,key,min,max,defaultval);}
-unsigned qmpPluginAPIImpl::getOptionUint(std::string key){return qmw->getSettings()->getOptionUint(key);}
-void qmpPluginAPIImpl::setOptionUint(std::string key,unsigned val){qmw->getSettings()->setOptionUint(key,val);}
-void qmpPluginAPIImpl::registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval)
-{qmw->getSettings()->registerOptionBool(tab,desc,key,defaultval);}
-bool qmpPluginAPIImpl::getOptionBool(std::string key){return qmw->getSettings()->getOptionBool(key);}
-void qmpPluginAPIImpl::setOptionBool(std::string key,bool val){qmw->getSettings()->setOptionBool(key,val);}
-void qmpPluginAPIImpl::registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval)
-{qmw->getSettings()->registerOptionDouble(tab,desc,key,min,max,defaultval);}
-double qmpPluginAPIImpl::getOptionDouble(std::string key){return qmw->getSettings()->getOptionDouble(key);}
-void qmpPluginAPIImpl::setOptionDouble(std::string key,double val){qmw->getSettings()->setOptionDouble(key,val);}
-void qmpPluginAPIImpl::registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval,bool ispath)
-{qmw->getSettings()->registerOptionString(tab,desc,key,defaultval,ispath);}
-std::string qmpPluginAPIImpl::getOptionString(std::string key){return qmw->getSettings()->getOptionString(key);}
-void qmpPluginAPIImpl::setOptionString(std::string key,std::string val){return qmw->getSettings()->setOptionString(key,val);}
-void qmpPluginAPIImpl::registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> options,int defaultval)
-{qmw->getSettings()->registerOptionEnumInt(tab,desc,key,options,defaultval);}
-int qmpPluginAPIImpl::getOptionEnumInt(std::string key){return qmw->getSettings()->getOptionEnumInt(key);}
-void qmpPluginAPIImpl::setOptionEnumInt(std::string key,int val){return qmw->getSettings()->setOptionEnumInt(key,val);}
+void qmpPluginAPIImpl::registerOptionInt(std::string tab, std::string desc, std::string key, int min, int max, int defaultval)
+{
+ qmw->getSettings()->registerOptionInt(tab, desc, key, min, max, defaultval);
+}
+int qmpPluginAPIImpl::getOptionInt(std::string key)
+{
+ return qmw->getSettings()->getOptionInt(key);
+}
+void qmpPluginAPIImpl::setOptionInt(std::string key, int val)
+{
+ qmw->getSettings()->setOptionInt(key, val);
+}
+void qmpPluginAPIImpl::registerOptionUint(std::string tab, std::string desc, std::string key, unsigned min, unsigned max, unsigned defaultval)
+{
+ qmw->getSettings()->registerOptionUint(tab, desc, key, min, max, defaultval);
+}
+unsigned qmpPluginAPIImpl::getOptionUint(std::string key)
+{
+ return qmw->getSettings()->getOptionUint(key);
+}
+void qmpPluginAPIImpl::setOptionUint(std::string key, unsigned val)
+{
+ qmw->getSettings()->setOptionUint(key, val);
+}
+void qmpPluginAPIImpl::registerOptionBool(std::string tab, std::string desc, std::string key, bool defaultval)
+{
+ qmw->getSettings()->registerOptionBool(tab, desc, key, defaultval);
+}
+bool qmpPluginAPIImpl::getOptionBool(std::string key)
+{
+ return qmw->getSettings()->getOptionBool(key);
+}
+void qmpPluginAPIImpl::setOptionBool(std::string key, bool val)
+{
+ qmw->getSettings()->setOptionBool(key, val);
+}
+void qmpPluginAPIImpl::registerOptionDouble(std::string tab, std::string desc, std::string key, double min, double max, double defaultval)
+{
+ qmw->getSettings()->registerOptionDouble(tab, desc, key, min, max, defaultval);
+}
+double qmpPluginAPIImpl::getOptionDouble(std::string key)
+{
+ return qmw->getSettings()->getOptionDouble(key);
+}
+void qmpPluginAPIImpl::setOptionDouble(std::string key, double val)
+{
+ qmw->getSettings()->setOptionDouble(key, val);
+}
+void qmpPluginAPIImpl::registerOptionString(std::string tab, std::string desc, std::string key, std::string defaultval, bool ispath)
+{
+ qmw->getSettings()->registerOptionString(tab, desc, key, defaultval, ispath);
+}
+std::string qmpPluginAPIImpl::getOptionString(std::string key)
+{
+ return qmw->getSettings()->getOptionString(key);
+}
+void qmpPluginAPIImpl::setOptionString(std::string key, std::string val)
+{
+ return qmw->getSettings()->setOptionString(key, val);
+}
+void qmpPluginAPIImpl::registerOptionEnumInt(std::string tab, std::string desc, std::string key, std::vector<std::string> options, int defaultval)
+{
+ qmw->getSettings()->registerOptionEnumInt(tab, desc, key, options, defaultval);
+}
+int qmpPluginAPIImpl::getOptionEnumInt(std::string key)
+{
+ return qmw->getSettings()->getOptionEnumInt(key);
+}
+void qmpPluginAPIImpl::setOptionEnumInt(std::string key, int val)
+{
+ return qmw->getSettings()->setOptionEnumInt(key, val);
+}
diff --git a/qmidiplayer-desktop/qmpplugin.hpp b/qmidiplayer-desktop/qmpplugin.hpp
index 99dedcd..778f90f 100644
--- a/qmidiplayer-desktop/qmpplugin.hpp
+++ b/qmidiplayer-desktop/qmpplugin.hpp
@@ -7,104 +7,110 @@
#include "../include/qmpcorepublic.hpp"
struct qmpPlugin
{
- std::string name,version,path;
- qmpPluginIntf* pinterface;
- bool enabled,initialized;
- qmpPlugin(std::string _n,std::string _v,std::string _p,qmpPluginIntf* _i)
- {name=_n;version=_v;path=_p;pinterface=_i;enabled=initialized=false;}
+ std::string name, version, path;
+ qmpPluginIntf *pinterface;
+ bool enabled, initialized;
+ qmpPlugin(std::string _n, std::string _v, std::string _p, qmpPluginIntf *_i)
+ {
+ name = _n;
+ version = _v;
+ path = _p;
+ pinterface = _i;
+ enabled = initialized = false;
+ }
};
class qmpMainWindow;
class qmpSettings;
-class qmpPluginAPIImpl:public qmpPluginAPI
+class qmpPluginAPIImpl: public qmpPluginAPI
{
public:
- qmpPluginAPIImpl();
- ~qmpPluginAPIImpl();
- uint32_t getDivision();
- uint32_t getRawTempo();
- double getRealTempo();
- uint32_t getTimeSig();
- int getKeySig();
- uint32_t getNoteCount();
- uint32_t getMaxTick();
- uint32_t getCurrentPolyphone();
- uint32_t getMaxPolyphone();
- uint32_t getCurrentTimeStamp();
- uint32_t getCurrentPlaybackPercentage();
- int getChannelCC(int ch,int cc);
- int getChannelPreset(int ch);
- void playerSeek(uint32_t percentage);
- double getPitchBend(int ch);
- void getPitchBendRaw(int ch,uint32_t *pb,uint32_t *pbr);
- bool getChannelMask(int ch);
- std::string getTitle();
- std::wstring getWTitle();
- std::string getChannelPresetString(int ch);
- bool isDarkTheme();
- void* getMainWindow();
+ qmpPluginAPIImpl();
+ ~qmpPluginAPIImpl();
+ uint32_t getDivision();
+ uint32_t getRawTempo();
+ double getRealTempo();
+ uint32_t getTimeSig();
+ int getKeySig();
+ uint32_t getNoteCount();
+ uint32_t getMaxTick();
+ uint32_t getCurrentPolyphone();
+ uint32_t getMaxPolyphone();
+ uint32_t getCurrentTimeStamp();
+ uint32_t getCurrentPlaybackPercentage();
+ int getChannelCC(int ch, int cc);
+ int getChannelPreset(int ch);
+ void playerSeek(uint32_t percentage);
+ double getPitchBend(int ch);
+ void getPitchBendRaw(int ch, uint32_t *pb, uint32_t *pbr);
+ bool getChannelMask(int ch);
+ std::string getTitle();
+ std::wstring getWTitle();
+ std::string getChannelPresetString(int ch);
+ bool isDarkTheme();
+ void *getMainWindow();
- void discardCurrentEvent();
- void commitEventChange(SEvent d);
- void callEventReaderCB(SEvent d);
- void setFuncState(std::string name,bool state);
- void setFuncEnabled(std::string name,bool enable);
+ void discardCurrentEvent();
+ void commitEventChange(SEvent d);
+ void callEventReaderCB(SEvent d);
+ void setFuncState(std::string name, bool state);
+ void setFuncEnabled(std::string name, bool enable);
- void registerFunctionality(qmpFuncBaseIntf* i,std::string name,std::string desc,const char* icon,int iconlen,bool checkable);
- void unregisterFunctionality(std::string name);
- int registerUIHook(std::string e,ICallBack* cb,void* userdat);
- int registerUIHook(std::string e,callback_t cb,void* userdat);
- void unregisterUIHook(std::string e,int hook);
- void registerMidiOutDevice(qmpMidiOutDevice* dev,std::string name);
- void unregisterMidiOutDevice(std::string name);
- int registerEventReaderIntf(ICallBack* cb,void* userdata);
- void unregisterEventReaderIntf(int intfhandle);
- int registerEventHandlerIntf(ICallBack* cb,void* userdata);
- void unregisterEventHandlerIntf(int intfhandle);
- int registerFileReadFinishedHandlerIntf(ICallBack* cb,void* userdata);
- void unregisterFileReadFinishedHandlerIntf(int intfhandle);
- int registerEventHandler(callback_t cb,void *userdata,bool post=false);
- void unregisterEventHandler(int id);
- int registerEventReadHandler(callback_t cb,void *userdata);
- void unregisterEventReadHandler(int id);
- int registerFileReadFinishHook(callback_t cb,void *userdata);
- void unregisterFileReadFinishHook(int id);
- void registerFileReader(qmpFileReader* reader,std::string name);
- void unregisterFileReader(std::string name);
+ void registerFunctionality(qmpFuncBaseIntf *i, std::string name, std::string desc, const char *icon, int iconlen, bool checkable);
+ void unregisterFunctionality(std::string name);
+ int registerUIHook(std::string e, ICallBack *cb, void *userdat);
+ int registerUIHook(std::string e, callback_t cb, void *userdat);
+ void unregisterUIHook(std::string e, int hook);
+ void registerMidiOutDevice(qmpMidiOutDevice *dev, std::string name);
+ void unregisterMidiOutDevice(std::string name);
+ int registerEventReaderIntf(ICallBack *cb, void *userdata);
+ void unregisterEventReaderIntf(int intfhandle);
+ int registerEventHandlerIntf(ICallBack *cb, void *userdata);
+ void unregisterEventHandlerIntf(int intfhandle);
+ int registerFileReadFinishedHandlerIntf(ICallBack *cb, void *userdata);
+ void unregisterFileReadFinishedHandlerIntf(int intfhandle);
+ int registerEventHandler(callback_t cb, void *userdata, bool post = false);
+ void unregisterEventHandler(int id);
+ int registerEventReadHandler(callback_t cb, void *userdata);
+ void unregisterEventReadHandler(int id);
+ int registerFileReadFinishHook(callback_t cb, void *userdata);
+ void unregisterFileReadFinishHook(int id);
+ void registerFileReader(qmpFileReader *reader, std::string name);
+ void unregisterFileReader(std::string name);
- void registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval);
- int getOptionInt(std::string key);
- void setOptionInt(std::string key,int val);
- void registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval);
- unsigned getOptionUint(std::string key);
- void setOptionUint(std::string key,unsigned val);
- void registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval);
- bool getOptionBool(std::string key);
- void setOptionBool(std::string key,bool val);
- void registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval);
- double getOptionDouble(std::string key);
- void setOptionDouble(std::string key,double val);
- void registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval,bool ispath=false);
- std::string getOptionString(std::string key);
- void setOptionString(std::string key,std::string val);
- void registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> options,int defaultval);
- int getOptionEnumInt(std::string key);
- void setOptionEnumInt(std::string key,int val);
+ void registerOptionInt(std::string tab, std::string desc, std::string key, int min, int max, int defaultval);
+ int getOptionInt(std::string key);
+ void setOptionInt(std::string key, int val);
+ void registerOptionUint(std::string tab, std::string desc, std::string key, unsigned min, unsigned max, unsigned defaultval);
+ unsigned getOptionUint(std::string key);
+ void setOptionUint(std::string key, unsigned val);
+ void registerOptionBool(std::string tab, std::string desc, std::string key, bool defaultval);
+ bool getOptionBool(std::string key);
+ void setOptionBool(std::string key, bool val);
+ void registerOptionDouble(std::string tab, std::string desc, std::string key, double min, double max, double defaultval);
+ double getOptionDouble(std::string key);
+ void setOptionDouble(std::string key, double val);
+ void registerOptionString(std::string tab, std::string desc, std::string key, std::string defaultval, bool ispath = false);
+ std::string getOptionString(std::string key);
+ void setOptionString(std::string key, std::string val);
+ void registerOptionEnumInt(std::string tab, std::string desc, std::string key, std::vector<std::string> options, int defaultval);
+ int getOptionEnumInt(std::string key);
+ void setOptionEnumInt(std::string key, int val);
};
class qmpPluginManager
{
- private:
- std::vector<qmpPlugin> plugins;
- static qmpPluginAPIImpl* pluginAPI;
- static qmpMainWindow* mainwindow;
- static qmpSettings* settings;
- public:
- qmpPluginManager();
- ~qmpPluginManager();
- std::vector<qmpPlugin> *getPlugins();
- void scanPlugins(const std::vector<std::string> &pp);
- void initPlugins();
- void deinitPlugins();
- friend class qmpPluginAPIImpl;
- friend class qmpMainWindow;
+private:
+ std::vector<qmpPlugin> plugins;
+ static qmpPluginAPIImpl *pluginAPI;
+ static qmpMainWindow *mainwindow;
+ static qmpSettings *settings;
+public:
+ qmpPluginManager();
+ ~qmpPluginManager();
+ std::vector<qmpPlugin> *getPlugins();
+ void scanPlugins(const std::vector<std::string> &pp);
+ void initPlugins();
+ void deinitPlugins();
+ friend class qmpPluginAPIImpl;
+ friend class qmpMainWindow;
};
#endif // QMPPLUGIN_H
diff --git a/qmidiplayer-desktop/qmppresetselect.cpp b/qmidiplayer-desktop/qmppresetselect.cpp
index 821eced..51bb7d4 100644
--- a/qmidiplayer-desktop/qmppresetselect.cpp
+++ b/qmidiplayer-desktop/qmppresetselect.cpp
@@ -4,132 +4,153 @@
#include "qmpmainwindow.hpp"
qmpPresetSelector::qmpPresetSelector(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::qmpPresetSelector)
+ QDialog(parent),
+ ui(new Ui::qmpPresetSelector)
{
- ui->setupUi(this);
+ ui->setupUi(this);
}
qmpPresetSelector::~qmpPresetSelector()
{
- delete ui;
+ delete ui;
}
void qmpPresetSelector::showEvent(QShowEvent *e)
{
- memset(presets,0,sizeof(presets));
- if(!qmpMainWindow::getInstance()->getFluid()->getSFCount())return e->ignore();
- ui->lwBankSelect->clear();
- ui->lwPresetSelect->clear();
- e->accept();
+ memset(presets, 0, sizeof(presets));
+ if (!qmpMainWindow::getInstance()->getFluid()->getSFCount())
+ return e->ignore();
+ ui->lwBankSelect->clear();
+ ui->lwPresetSelect->clear();
+ e->accept();
}
void qmpPresetSelector::setupWindow(int chid)
{
- CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer();
- ch=chid;int r;char name[256];
- uint16_t b;uint8_t p;
- std::string pstname;
- sprintf(name,"Preset Selection - Channel #%d",ch+1);
- setWindowTitle(name);
- r=plyr->getChannelOutputDevice(ch)->getChannelPreset(ch,&b,&p,pstname);
- if(!r){b=plyr->getCC(ch,0)<<7|plyr->getCC(ch,32);p=plyr->getCC(ch,128);}
- ui->lwBankSelect->blockSignals(true);
- ui->lwBankSelect->clear();
- ui->lwPresetSelect->clear();
- ui->lwBankSelect->blockSignals(false);
- if(plyr->getChannelOutputDevice(ch)->getBankList().empty()){
- ui->lwPresetSelect->setEnabled(false);
- ui->lwBankSelect->setEnabled(false);
- ui->spCustomLSB->setEnabled(true);
- ui->spCustomMSB->setEnabled(true);
- ui->spCustomPC->setEnabled(true);
- ui->spCustomMSB->setValue(plyr->getCC(chid,0));
- ui->spCustomLSB->setValue(plyr->getCC(chid,32));
- ui->spCustomPC->setValue(p);
- }
- else{
- ui->lwPresetSelect->setEnabled(true);
- ui->lwBankSelect->setEnabled(true);
- ui->spCustomLSB->setEnabled(false);
- ui->spCustomMSB->setEnabled(false);
- ui->spCustomPC->setEnabled(false);
- ui->lwBankSelect->blockSignals(true);
- for(auto&i:plyr->getChannelOutputDevice(ch)->getBankList())
- {
- snprintf(name,256,"%03d %s",i.first,i.second.c_str());
- ui->lwBankSelect->addItem(name);
- if(i.first==b)ui->lwBankSelect->setCurrentRow(ui->lwBankSelect->count()-1);
- }
- ui->lwBankSelect->blockSignals(false);
- for(auto&i:plyr->getChannelOutputDevice(ch)->getPresets(b))
- {
- snprintf(name,256,"%03d %s",i.first,i.second.c_str());
- ui->lwPresetSelect->addItem(name);
- if(i.first==p)ui->lwPresetSelect->setCurrentRow(ui->lwPresetSelect->count()-1);
- }
- }
+ CMidiPlayer *plyr = qmpMainWindow::getInstance()->getPlayer();
+ ch = chid;
+ int r;
+ char name[256];
+ uint16_t b;
+ uint8_t p;
+ std::string pstname;
+ sprintf(name, "Preset Selection - Channel #%d", ch + 1);
+ setWindowTitle(name);
+ r = plyr->getChannelOutputDevice(ch)->getChannelPreset(ch, &b, &p, pstname);
+ if (!r)
+ {
+ b = plyr->getCC(ch, 0) << 7 | plyr->getCC(ch, 32);
+ p = plyr->getCC(ch, 128);
+ }
+ ui->lwBankSelect->blockSignals(true);
+ ui->lwBankSelect->clear();
+ ui->lwPresetSelect->clear();
+ ui->lwBankSelect->blockSignals(false);
+ if (plyr->getChannelOutputDevice(ch)->getBankList().empty())
+ {
+ ui->lwPresetSelect->setEnabled(false);
+ ui->lwBankSelect->setEnabled(false);
+ ui->spCustomLSB->setEnabled(true);
+ ui->spCustomMSB->setEnabled(true);
+ ui->spCustomPC->setEnabled(true);
+ ui->spCustomMSB->setValue(plyr->getCC(chid, 0));
+ ui->spCustomLSB->setValue(plyr->getCC(chid, 32));
+ ui->spCustomPC->setValue(p);
+ }
+ else
+ {
+ ui->lwPresetSelect->setEnabled(true);
+ ui->lwBankSelect->setEnabled(true);
+ ui->spCustomLSB->setEnabled(false);
+ ui->spCustomMSB->setEnabled(false);
+ ui->spCustomPC->setEnabled(false);
+ ui->lwBankSelect->blockSignals(true);
+ for (auto &i : plyr->getChannelOutputDevice(ch)->getBankList())
+ {
+ snprintf(name, 256, "%03d %s", i.first, i.second.c_str());
+ ui->lwBankSelect->addItem(name);
+ if (i.first == b)
+ ui->lwBankSelect->setCurrentRow(ui->lwBankSelect->count() - 1);
+ }
+ ui->lwBankSelect->blockSignals(false);
+ for (auto &i : plyr->getChannelOutputDevice(ch)->getPresets(b))
+ {
+ snprintf(name, 256, "%03d %s", i.first, i.second.c_str());
+ ui->lwPresetSelect->addItem(name);
+ if (i.first == p)
+ ui->lwPresetSelect->setCurrentRow(ui->lwPresetSelect->count() - 1);
+ }
+ }
}
void qmpPresetSelector::on_pbCancel_clicked()
{
- close();
+ close();
}
void qmpPresetSelector::on_pbOk_clicked()
{
- CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer();
- if(plyr->getChannelOutput(ch)){
- if(ui->spCustomMSB->isEnabled())
- plyr->setChannelPreset(ch,(ui->spCustomMSB->value()<<7)|ui->spCustomLSB->value(),ui->spCustomPC->value());
- else
- {
- if(!ui->lwBankSelect->currentItem()||!ui->lwPresetSelect->currentItem())return (void)close();
- int b=ui->lwBankSelect->currentItem()->text().split(' ').first().toInt();
- int p=ui->lwPresetSelect->currentItem()->text().split(' ').first().toInt();
- plyr->setChannelPreset(ch,b,p);
- }
- }
- else{
- if(!ui->lwBankSelect->currentItem()||!ui->lwPresetSelect->currentItem())return (void)close();
- int b,p;
- b=ui->lwBankSelect->currentItem()->text().toInt();
- p=ui->lwPresetSelect->currentItem()->text().split(' ').first().toInt();
- std::string s=qmpMainWindow::getInstance()->getSettings()->getOptionEnumIntOptName("FluidSynth/BankSelect");
- if(s=="XG"){
- if(b==128)b=127<<7;
- }
- else if(s=="GS")b<<=7;
- plyr->setChannelPreset(ch,b,p);
- }
- qmpMainWindow::getInstance()->invokeCallback("preset.set",nullptr);
- close();
+ CMidiPlayer *plyr = qmpMainWindow::getInstance()->getPlayer();
+ if (plyr->getChannelOutput(ch))
+ {
+ if (ui->spCustomMSB->isEnabled())
+ plyr->setChannelPreset(ch, (ui->spCustomMSB->value() << 7) | ui->spCustomLSB->value(), ui->spCustomPC->value());
+ else
+ {
+ if (!ui->lwBankSelect->currentItem() || !ui->lwPresetSelect->currentItem())
+ return (void)close();
+ int b = ui->lwBankSelect->currentItem()->text().split(' ').first().toInt();
+ int p = ui->lwPresetSelect->currentItem()->text().split(' ').first().toInt();
+ plyr->setChannelPreset(ch, b, p);
+ }
+ }
+ else
+ {
+ if (!ui->lwBankSelect->currentItem() || !ui->lwPresetSelect->currentItem())
+ return (void)close();
+ int b, p;
+ b = ui->lwBankSelect->currentItem()->text().toInt();
+ p = ui->lwPresetSelect->currentItem()->text().split(' ').first().toInt();
+ std::string s = qmpMainWindow::getInstance()->getSettings()->getOptionEnumIntOptName("FluidSynth/BankSelect");
+ if (s == "XG")
+ {
+ if (b == 128)
+ b = 127 << 7;
+ }
+ else if (s == "GS")
+ b <<= 7;
+ plyr->setChannelPreset(ch, b, p);
+ }
+ qmpMainWindow::getInstance()->invokeCallback("preset.set", nullptr);
+ close();
}
void qmpPresetSelector::on_lwPresetSelect_itemDoubleClicked()
{
- on_pbOk_clicked();
+ on_pbOk_clicked();
}
void qmpPresetSelector::on_lwBankSelect_currentRowChanged()
{
- ui->lwPresetSelect->clear();
- if(!ui->lwBankSelect->currentItem())return;
- char name[256];int b;
- sscanf(ui->lwBankSelect->currentItem()->text().toStdString().c_str(),"%d",&b);
- CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer();
- for(auto&i:plyr->getChannelOutputDevice(ch)->getPresets(b))
- {
- snprintf(name,256,"%03d %s",i.first,i.second.c_str());
- ui->lwPresetSelect->addItem(name);
- }
+ ui->lwPresetSelect->clear();
+ if (!ui->lwBankSelect->currentItem())
+ return;
+ char name[256];
+ int b;
+ sscanf(ui->lwBankSelect->currentItem()->text().toStdString().c_str(), "%d", &b);
+ CMidiPlayer *plyr = qmpMainWindow::getInstance()->getPlayer();
+ for (auto &i : plyr->getChannelOutputDevice(ch)->getPresets(b))
+ {
+ snprintf(name, 256, "%03d %s", i.first, i.second.c_str());
+ ui->lwPresetSelect->addItem(name);
+ }
}
void qmpPresetSelector::on_buttonBox_accepted()
{
- on_pbOk_clicked();
+ on_pbOk_clicked();
}
void qmpPresetSelector::on_buttonBox_rejected()
{
- on_pbCancel_clicked();
+ on_pbCancel_clicked();
}
diff --git a/qmidiplayer-desktop/qmppresetselect.hpp b/qmidiplayer-desktop/qmppresetselect.hpp
index 0186578..6eaf2bf 100644
--- a/qmidiplayer-desktop/qmppresetselect.hpp
+++ b/qmidiplayer-desktop/qmppresetselect.hpp
@@ -4,36 +4,37 @@
#include <QDialog>
#include <QShowEvent>
-namespace Ui {
- class qmpPresetSelector;
+namespace Ui
+{
+class qmpPresetSelector;
}
-class qmpPresetSelector:public QDialog
+class qmpPresetSelector: public QDialog
{
- Q_OBJECT
+ Q_OBJECT
- public:
- explicit qmpPresetSelector(QWidget *parent = 0);
- ~qmpPresetSelector();
- void showEvent(QShowEvent* e);
- void setupWindow(int chid);
+public:
+ explicit qmpPresetSelector(QWidget *parent = 0);
+ ~qmpPresetSelector();
+ void showEvent(QShowEvent *e);
+ void setupWindow(int chid);
- private slots:
+private slots:
- void on_lwBankSelect_currentRowChanged();
+ void on_lwBankSelect_currentRowChanged();
- void on_lwPresetSelect_itemDoubleClicked();
+ void on_lwPresetSelect_itemDoubleClicked();
- void on_buttonBox_accepted();
+ void on_buttonBox_accepted();
- void on_buttonBox_rejected();
+ void on_buttonBox_rejected();
- private:
- Ui::qmpPresetSelector *ui;
- char presets[129][128][24];
- void on_pbCancel_clicked();
- void on_pbOk_clicked();
- int ch;
+private:
+ Ui::qmpPresetSelector *ui;
+ char presets[129][128][24];
+ void on_pbCancel_clicked();
+ void on_pbOk_clicked();
+ int ch;
};
#endif // QMPPRESETSELECT_H
diff --git a/qmidiplayer-desktop/qmpsettings.cpp b/qmidiplayer-desktop/qmpsettings.cpp
index cdc96b8..8ba0d5e 100644
--- a/qmidiplayer-desktop/qmpsettings.cpp
+++ b/qmidiplayer-desktop/qmpsettings.cpp
@@ -4,245 +4,245 @@
#define QMP_CONFIGURATION_FILE_REV 1
-QSettings* qmpSettings::settings=nullptr;
+QSettings *qmpSettings::settings = nullptr;
qmpSettings::qmpSettings()
{
- qRegisterMetaTypeStreamOperators<QPair<QString,QString>>();
- QString confpath=QStandardPaths::writableLocation(QStandardPaths::StandardLocation::ConfigLocation)+QString("/qmprc");
- settings=new QSettings(confpath,QSettings::IniFormat);
- if(settings->value("ConfigurationFileRevision").toInt()!=QMP_CONFIGURATION_FILE_REV&&
- QFile::exists(confpath))
- {
- qWarning("Your current configuration file is not compatible with this version of QMidiPlayer. "
- "QMidiPlayer will start with its default configuration. A backup of the old configuration "
- "is automatically saved as qmprc.old.");
- QFile::remove(confpath+".old");
- QFile::copy(confpath,confpath+".old");
- settings->clear();
- settings->setValue("ConfigurationFileRevision",QMP_CONFIGURATION_FILE_REV);
- }
+ qRegisterMetaTypeStreamOperators<QPair<QString, QString>>();
+ QString confpath = QStandardPaths::writableLocation(QStandardPaths::StandardLocation::ConfigLocation) + QString("/qmprc");
+ settings = new QSettings(confpath, QSettings::IniFormat);
+ if (settings->value("ConfigurationFileRevision").toInt() != QMP_CONFIGURATION_FILE_REV &&
+ QFile::exists(confpath))
+ {
+ qWarning("Your current configuration file is not compatible with this version of QMidiPlayer. "
+ "QMidiPlayer will start with its default configuration. A backup of the old configuration "
+ "is automatically saved as qmprc.old.");
+ QFile::remove(confpath + ".old");
+ QFile::copy(confpath, confpath + ".old");
+ settings->clear();
+ settings->setValue("ConfigurationFileRevision", QMP_CONFIGURATION_FILE_REV);
+ }
}
qmpSettings::~qmpSettings()
{
- delete settings;
- settings=nullptr;
+ delete settings;
+ settings = nullptr;
}
-void qmpSettings::registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval)
+void qmpSettings::registerOptionInt(std::string tab, std::string desc, std::string key, int min, int max, int defaultval)
{
- optionlist.push_back(key);
- options[key]=qmpOption(tab,desc,qmpOption::ParameterType::parameter_int,nullptr,defaultval,min,max);
+ optionlist.push_back(key);
+ options[key] = qmpOption(tab, desc, qmpOption::ParameterType::parameter_int, nullptr, defaultval, min, max);
}
int qmpSettings::getOptionInt(std::string key)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOption::ParameterType::parameter_int)
- return settings->value(QString(key.c_str()),options[key].defaultval).toInt();
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
- return options[key].defaultval.toInt();
+ if (options.find(key) != options.end() && options[key].type == qmpOption::ParameterType::parameter_int)
+ return settings->value(QString(key.c_str()), options[key].defaultval).toInt();
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
+ return options[key].defaultval.toInt();
}
-void qmpSettings::setOptionInt(std::string key,int val)
+void qmpSettings::setOptionInt(std::string key, int val)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOption::ParameterType::parameter_int)
- settings->setValue(QString(key.c_str()),val);
- else
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
- //call qmpSettingsWindow::load(key)?
+ if (options.find(key) != options.end() && options[key].type == qmpOption::ParameterType::parameter_int)
+ settings->setValue(QString(key.c_str()), val);
+ else
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
+ //call qmpSettingsWindow::load(key)?
}
-void qmpSettings::registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min, unsigned max,unsigned defaultval)
+void qmpSettings::registerOptionUint(std::string tab, std::string desc, std::string key, unsigned min, unsigned max, unsigned defaultval)
{
- optionlist.push_back(key);
- options[key]=qmpOption(tab,desc,qmpOption::ParameterType::parameter_uint,nullptr,defaultval,min,max);
+ optionlist.push_back(key);
+ options[key] = qmpOption(tab, desc, qmpOption::ParameterType::parameter_uint, nullptr, defaultval, min, max);
}
unsigned qmpSettings::getOptionUint(std::string key)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOption::ParameterType::parameter_uint)
- return settings->value(QString(key.c_str()),options[key].defaultval).toUInt();
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
- return options[key].defaultval.toUInt();
+ if (options.find(key) != options.end() && options[key].type == qmpOption::ParameterType::parameter_uint)
+ return settings->value(QString(key.c_str()), options[key].defaultval).toUInt();
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
+ return options[key].defaultval.toUInt();
}
-void qmpSettings::setOptionUint(std::string key,unsigned val)
+void qmpSettings::setOptionUint(std::string key, unsigned val)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOption::ParameterType::parameter_uint)
- settings->setValue(QString(key.c_str()),val);
- else
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
+ if (options.find(key) != options.end() && options[key].type == qmpOption::ParameterType::parameter_uint)
+ settings->setValue(QString(key.c_str()), val);
+ else
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
}
-void qmpSettings::registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval)
+void qmpSettings::registerOptionBool(std::string tab, std::string desc, std::string key, bool defaultval)
{
- optionlist.push_back(key);
- options[key]=qmpOption(tab,desc,qmpOption::ParameterType::parameter_bool,nullptr,defaultval);
+ optionlist.push_back(key);
+ options[key] = qmpOption(tab, desc, qmpOption::ParameterType::parameter_bool, nullptr, defaultval);
}
bool qmpSettings::getOptionBool(std::string key)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOption::ParameterType::parameter_bool)
- return settings->value(QString(key.c_str()),options[key].defaultval).toBool();
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
- return options[key].defaultval.toBool();
+ if (options.find(key) != options.end() && options[key].type == qmpOption::ParameterType::parameter_bool)
+ return settings->value(QString(key.c_str()), options[key].defaultval).toBool();
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
+ return options[key].defaultval.toBool();
}
-void qmpSettings::setOptionBool(std::string key,bool val)
+void qmpSettings::setOptionBool(std::string key, bool val)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOption::ParameterType::parameter_bool)
- settings->setValue(QString(key.c_str()),val);
- else
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
+ if (options.find(key) != options.end() && options[key].type == qmpOption::ParameterType::parameter_bool)
+ settings->setValue(QString(key.c_str()), val);
+ else
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
}
void qmpSettings::registerOptionDouble(std::string tab, std::string desc, std::string key, double min, double max, double defaultval)
{
- optionlist.push_back(key);
- options[key]=qmpOption(tab,desc,qmpOption::ParameterType::parameter_double,nullptr,defaultval,min,max);
+ optionlist.push_back(key);
+ options[key] = qmpOption(tab, desc, qmpOption::ParameterType::parameter_double, nullptr, defaultval, min, max);
}
double qmpSettings::getOptionDouble(std::string key)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOption::ParameterType::parameter_double)
- return settings->value(QString(key.c_str()),options[key].defaultval).toDouble();
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
- return options[key].defaultval.toDouble();
+ if (options.find(key) != options.end() && options[key].type == qmpOption::ParameterType::parameter_double)
+ return settings->value(QString(key.c_str()), options[key].defaultval).toDouble();
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
+ return options[key].defaultval.toDouble();
}
-void qmpSettings::setOptionDouble(std::string key,double val)
+void qmpSettings::setOptionDouble(std::string key, double val)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOption::ParameterType::parameter_double)
- settings->setValue(QString(key.c_str()),val);
- else
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
+ if (options.find(key) != options.end() && options[key].type == qmpOption::ParameterType::parameter_double)
+ settings->setValue(QString(key.c_str()), val);
+ else
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
}
-void qmpSettings::registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval,bool is_url)
+void qmpSettings::registerOptionString(std::string tab, std::string desc, std::string key, std::string defaultval, bool is_url)
{
- optionlist.push_back(key);
- options[key]=qmpOption(tab,desc,
- is_url?qmpOption::ParameterType::parameter_url:qmpOption::ParameterType::parameter_str,
- nullptr,QString(defaultval.c_str()));
+ optionlist.push_back(key);
+ options[key] = qmpOption(tab, desc,
+ is_url ? qmpOption::ParameterType::parameter_url : qmpOption::ParameterType::parameter_str,
+ nullptr, QString(defaultval.c_str()));
}
std::string qmpSettings::getOptionString(std::string key)
{
- if(options.find(key)!=options.end()&&
- (options[key].type==qmpOption::ParameterType::parameter_str||options[key].type==qmpOption::ParameterType::parameter_url))
- return settings->value(QString(key.c_str()),options[key].defaultval).toString().toStdString();
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
- return options[key].defaultval.toString().toStdString();
+ if (options.find(key) != options.end() &&
+ (options[key].type == qmpOption::ParameterType::parameter_str || options[key].type == qmpOption::ParameterType::parameter_url))
+ return settings->value(QString(key.c_str()), options[key].defaultval).toString().toStdString();
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
+ return options[key].defaultval.toString().toStdString();
}
-void qmpSettings::setOptionString(std::string key,std::string val)
+void qmpSettings::setOptionString(std::string key, std::string val)
{
- if(options.find(key)!=options.end()&&
- (options[key].type==qmpOption::ParameterType::parameter_str||options[key].type==qmpOption::ParameterType::parameter_url))
- settings->setValue(QString(key.c_str()),QString(val.c_str()));
- else
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
+ if (options.find(key) != options.end() &&
+ (options[key].type == qmpOption::ParameterType::parameter_str || options[key].type == qmpOption::ParameterType::parameter_url))
+ settings->setValue(QString(key.c_str()), QString(val.c_str()));
+ else
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
}
-void qmpSettings::registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> enumlist,int defaultval)
+void qmpSettings::registerOptionEnumInt(std::string tab, std::string desc, std::string key, std::vector<std::string> enumlist, int defaultval)
{
- optionlist.push_back(key);
- options[key]=qmpOption(tab,desc,qmpOption::ParameterType::parameter_enum,nullptr,defaultval);
- options[key].enumlist=enumlist;
+ optionlist.push_back(key);
+ options[key] = qmpOption(tab, desc, qmpOption::ParameterType::parameter_enum, nullptr, defaultval);
+ options[key].enumlist = enumlist;
}
int qmpSettings::getOptionEnumInt(std::string key)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOption::ParameterType::parameter_enum)
- {
- std::string curitm=settings->value(QString(key.c_str()),options[key].defaultval).toString().toStdString();
- auto curidx=std::find(options[key].enumlist.begin(),options[key].enumlist.end(),curitm);
- if(curidx!=options[key].enumlist.end())
- return static_cast<int>(curidx-options[key].enumlist.begin());
- else
- {
- qWarning("Invalid value set for option \"%s\".",key.c_str());
- return options[key].defaultval.toInt();
- }
- }
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
- return options[key].defaultval.toInt();
+ if (options.find(key) != options.end() && options[key].type == qmpOption::ParameterType::parameter_enum)
+ {
+ std::string curitm = settings->value(QString(key.c_str()), options[key].defaultval).toString().toStdString();
+ auto curidx = std::find(options[key].enumlist.begin(), options[key].enumlist.end(), curitm);
+ if (curidx != options[key].enumlist.end())
+ return static_cast<int>(curidx - options[key].enumlist.begin());
+ else
+ {
+ qWarning("Invalid value set for option \"%s\".", key.c_str());
+ return options[key].defaultval.toInt();
+ }
+ }
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
+ return options[key].defaultval.toInt();
}
std::string qmpSettings::getOptionEnumIntOptName(std::string key)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOption::ParameterType::parameter_enum)
- {
- std::string curitm=settings->value(QString(key.c_str()),options[key].defaultval).toString().toStdString();
- auto curidx=std::find(options[key].enumlist.begin(),options[key].enumlist.end(),curitm);
- if(curidx!=options[key].enumlist.end())
- return curitm;
- else
- {
- qWarning("Invalid value set for option \"%s\".",key.c_str());
- return options[key].enumlist[static_cast<size_t>(options[key].defaultval.toInt())];
- }
- }
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
- return options[key].enumlist[static_cast<size_t>(options[key].defaultval.toInt())];
+ if (options.find(key) != options.end() && options[key].type == qmpOption::ParameterType::parameter_enum)
+ {
+ std::string curitm = settings->value(QString(key.c_str()), options[key].defaultval).toString().toStdString();
+ auto curidx = std::find(options[key].enumlist.begin(), options[key].enumlist.end(), curitm);
+ if (curidx != options[key].enumlist.end())
+ return curitm;
+ else
+ {
+ qWarning("Invalid value set for option \"%s\".", key.c_str());
+ return options[key].enumlist[static_cast<size_t>(options[key].defaultval.toInt())];
+ }
+ }
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
+ return options[key].enumlist[static_cast<size_t>(options[key].defaultval.toInt())];
}
-void qmpSettings::setOptionEnumInt(std::string key,int val)
+void qmpSettings::setOptionEnumInt(std::string key, int val)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOption::ParameterType::parameter_enum)
- {
- if(static_cast<size_t>(val)<options[key].enumlist.size())
- settings->setValue(QString(key.c_str()),QString(options[key].enumlist[static_cast<size_t>(val)].c_str()));
- else
- qWarning("Trying to set invalid value for option \"%s\".",key.c_str());
- }
- else
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
+ if (options.find(key) != options.end() && options[key].type == qmpOption::ParameterType::parameter_enum)
+ {
+ if (static_cast<size_t>(val) < options[key].enumlist.size())
+ settings->setValue(QString(key.c_str()), QString(options[key].enumlist[static_cast<size_t>(val)].c_str()));
+ else
+ qWarning("Trying to set invalid value for option \"%s\".", key.c_str());
+ }
+ else
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
}
-void qmpSettings::setOptionEnumIntOptName(std::string key,std::string valname)
+void qmpSettings::setOptionEnumIntOptName(std::string key, std::string valname)
{
- if(options.find(key)!=options.end()&&options[key].type==qmpOption::ParameterType::parameter_enum)
- {
- auto curidx=std::find(options[key].enumlist.begin(),options[key].enumlist.end(),valname);
- if(curidx!=options[key].enumlist.end())
- settings->setValue(QString(key.c_str()),QString(valname.c_str()));
- else
- qWarning("Trying to set invalid value for option \"%s\".",key.c_str());
- }
- else
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
+ if (options.find(key) != options.end() && options[key].type == qmpOption::ParameterType::parameter_enum)
+ {
+ auto curidx = std::find(options[key].enumlist.begin(), options[key].enumlist.end(), valname);
+ if (curidx != options[key].enumlist.end())
+ settings->setValue(QString(key.c_str()), QString(valname.c_str()));
+ else
+ qWarning("Trying to set invalid value for option \"%s\".", key.c_str());
+ }
+ else
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
}
-void qmpSettings::registerOptionCustom(std::string tab,std::string desc,std::string key,void* widget, void* defaultval,std::function<void*()> save_func,std::function<void(void*)> load_func)
+void qmpSettings::registerOptionCustom(std::string tab, std::string desc, std::string key, void *widget, void *defaultval, std::function<void *()> save_func, std::function<void(void *)> load_func)
{
- optionlist.push_back(key);
- options[key]=qmpOption(tab,desc,qmpOption::parameter_custom,
- static_cast<QWidget*>(widget),
- *static_cast<QVariant*>(defaultval),
- QVariant(),QVariant(),save_func,load_func);
+ optionlist.push_back(key);
+ options[key] = qmpOption(tab, desc, qmpOption::parameter_custom,
+ static_cast<QWidget *>(widget),
+ *static_cast<QVariant *>(defaultval),
+ QVariant(), QVariant(), save_func, load_func);
}
-void* qmpSettings::getOptionCustom(std::string key)
+void *qmpSettings::getOptionCustom(std::string key)
{
- if(options.find(key)!=options.end()||options[key].type!=qmpOption::ParameterType::parameter_custom)
- return static_cast<void*>(new QVariant(settings->value(QString(key.c_str()),options[key].defaultval)));
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
- return nullptr;
+ if (options.find(key) != options.end() || options[key].type != qmpOption::ParameterType::parameter_custom)
+ return static_cast<void *>(new QVariant(settings->value(QString(key.c_str()), options[key].defaultval)));
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
+ return nullptr;
}
-void qmpSettings::setOptionCustom(std::string key,void *val)
+void qmpSettings::setOptionCustom(std::string key, void *val)
{
- if(options.find(key)!=options.end()||options[key].type!=qmpOption::ParameterType::parameter_custom)
- settings->setValue(QString(key.c_str()),*static_cast<QVariant*>(val));
- else
- qWarning("Unregistered option or mismatching option type: %s.",key.c_str());
+ if (options.find(key) != options.end() || options[key].type != qmpOption::ParameterType::parameter_custom)
+ settings->setValue(QString(key.c_str()), *static_cast<QVariant *>(val));
+ else
+ qWarning("Unregistered option or mismatching option type: %s.", key.c_str());
}
-void qmpSettings::setOptionRaw(QString key,QVariant val)
+void qmpSettings::setOptionRaw(QString key, QVariant val)
{
- settings->setValue(key,val);
+ settings->setValue(key, val);
}
-QVariant qmpSettings::getOptionRaw(QString key,QVariant defval)
+QVariant qmpSettings::getOptionRaw(QString key, QVariant defval)
{
- return settings->value(key,defval);
+ return settings->value(key, defval);
}
-QDataStream &operator<<(QDataStream &out,const QPair<QString,QString> &o)
+QDataStream &operator<<(QDataStream &out, const QPair<QString, QString> &o)
{
- out<<o.first<<o.second;
- return out;
+ out << o.first << o.second;
+ return out;
}
-QDataStream &operator>>(QDataStream &in,QPair<QString,QString> &o)
+QDataStream &operator>>(QDataStream &in, QPair<QString, QString> &o)
{
- in>>o.first>>o.second;
- return in;
+ in >> o.first >> o.second;
+ return in;
}
diff --git a/qmidiplayer-desktop/qmpsettings.hpp b/qmidiplayer-desktop/qmpsettings.hpp
index ff46970..2fb894f 100644
--- a/qmidiplayer-desktop/qmpsettings.hpp
+++ b/qmidiplayer-desktop/qmpsettings.hpp
@@ -10,79 +10,80 @@
struct qmpOption
{
- enum ParameterType{
- parameter_int=0,
- parameter_uint,
- parameter_bool,
- parameter_double,
- parameter_str,
- parameter_enum,
- parameter_url,
- parameter_custom=0x100
- };
+ enum ParameterType
+ {
+ parameter_int = 0,
+ parameter_uint,
+ parameter_bool,
+ parameter_double,
+ parameter_str,
+ parameter_enum,
+ parameter_url,
+ parameter_custom = 0x100
+ };
- std::string tab;
- std::string desc;
- ParameterType type;
- QWidget* widget;
- QVariant defaultval,minv,maxv;
- std::function<void*()> save_func;
- std::function<void(void*)> load_func;
- std::vector<std::string> enumlist;
+ std::string tab;
+ std::string desc;
+ ParameterType type;
+ QWidget *widget;
+ QVariant defaultval, minv, maxv;
+ std::function<void *()> save_func;
+ std::function<void(void *)> load_func;
+ std::vector<std::string> enumlist;
- qmpOption():widget(nullptr){}
- qmpOption(std::string _tab,std::string _desc,
- ParameterType _t,QWidget* _w=nullptr,
- QVariant _def=QVariant(),QVariant _min=QVariant(),QVariant _max=QVariant(),
- std::function<void*()> _save=nullptr,std::function<void(void*)> _load=nullptr):
- tab(_tab),
- desc(_desc),
- type(_t),
- widget(_w),
- defaultval(_def),
- minv(_min),
- maxv(_max),
- save_func(_save),
- load_func(_load){}
+ qmpOption(): widget(nullptr) {}
+ qmpOption(std::string _tab, std::string _desc,
+ ParameterType _t, QWidget *_w = nullptr,
+ QVariant _def = QVariant(), QVariant _min = QVariant(), QVariant _max = QVariant(),
+ std::function<void *()> _save = nullptr, std::function<void(void *)> _load = nullptr):
+ tab(_tab),
+ desc(_desc),
+ type(_t),
+ widget(_w),
+ defaultval(_def),
+ minv(_min),
+ maxv(_max),
+ save_func(_save),
+ load_func(_load) {}
};
class qmpSettings
{
- public:
- qmpSettings();
- ~qmpSettings();
- void registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval);
- int getOptionInt(std::string key);
- void setOptionInt(std::string key,int val);
- void registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval);
- unsigned getOptionUint(std::string key);
- void setOptionUint(std::string key,unsigned val);
- void registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval);
- bool getOptionBool(std::string key);
- void setOptionBool(std::string key,bool val);
- void registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval);
- double getOptionDouble(std::string key);
- void setOptionDouble(std::string key,double val);
- void registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval,bool is_url);
- std::string getOptionString(std::string key);
- void setOptionString(std::string key,std::string val);
- void registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> enumlist,int defaultval);
- int getOptionEnumInt(std::string key);
- std::string getOptionEnumIntOptName(std::string key);
- void setOptionEnumInt(std::string key,int val);
- void setOptionEnumIntOptName(std::string key,std::string valname);
- void registerOptionCustom(std::string tab,std::string desc,std::string key,void* widget,void* defaultval,std::function<void*()> save_func,std::function<void(void*)> load_func);
- void* getOptionCustom(std::string key);
- void setOptionCustom(std::string key,void* val);
+public:
+ qmpSettings();
+ ~qmpSettings();
+ void registerOptionInt(std::string tab, std::string desc, std::string key, int min, int max, int defaultval);
+ int getOptionInt(std::string key);
+ void setOptionInt(std::string key, int val);
+ void registerOptionUint(std::string tab, std::string desc, std::string key, unsigned min, unsigned max, unsigned defaultval);
+ unsigned getOptionUint(std::string key);
+ void setOptionUint(std::string key, unsigned val);
+ void registerOptionBool(std::string tab, std::string desc, std::string key, bool defaultval);
+ bool getOptionBool(std::string key);
+ void setOptionBool(std::string key, bool val);
+ void registerOptionDouble(std::string tab, std::string desc, std::string key, double min, double max, double defaultval);
+ double getOptionDouble(std::string key);
+ void setOptionDouble(std::string key, double val);
+ void registerOptionString(std::string tab, std::string desc, std::string key, std::string defaultval, bool is_url);
+ std::string getOptionString(std::string key);
+ void setOptionString(std::string key, std::string val);
+ void registerOptionEnumInt(std::string tab, std::string desc, std::string key, std::vector<std::string> enumlist, int defaultval);
+ int getOptionEnumInt(std::string key);
+ std::string getOptionEnumIntOptName(std::string key);
+ void setOptionEnumInt(std::string key, int val);
+ void setOptionEnumIntOptName(std::string key, std::string valname);
+ void registerOptionCustom(std::string tab, std::string desc, std::string key, void *widget, void *defaultval, std::function<void *()> save_func, std::function<void(void *)> load_func);
+ void *getOptionCustom(std::string key);
+ void setOptionCustom(std::string key, void *val);
- void setOptionRaw(QString key,QVariant val);
- QVariant getOptionRaw(QString key,QVariant defval=QVariant());
+ void setOptionRaw(QString key, QVariant val);
+ QVariant getOptionRaw(QString key, QVariant defval = QVariant());
- private:
- static QSettings *settings;
- std::map<std::string,qmpOption> options;
- std::vector<std::string> optionlist;
+private:
+ static QSettings *settings;
+ std::map<std::string, qmpOption> options;
+ std::vector<std::string> optionlist;
- friend class qmpSettingsWindow;
+ friend class qmpSettingsWindow;
};
#endif
diff --git a/qmidiplayer-desktop/qmpsettingswindow.cpp b/qmidiplayer-desktop/qmpsettingswindow.cpp
index 8d4a964..03e4cd1 100644
--- a/qmidiplayer-desktop/qmpsettingswindow.cpp
+++ b/qmidiplayer-desktop/qmpsettingswindow.cpp
@@ -12,568 +12,593 @@
#include "ui_qmpsettingswindow.h"
#include "qmpmainwindow.hpp"
-qmpSettingsWindow::qmpSettingsWindow(qmpSettings *qmpsettings,QWidget *parent) :
- QDialog(parent),
- ui(new Ui::qmpSettingsWindow)
+qmpSettingsWindow::qmpSettingsWindow(qmpSettings *qmpsettings, QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::qmpSettingsWindow)
{
- ui->setupUi(this);customOptions.clear();customOptPages.clear();
- connect(this,&qmpSettingsWindow::dialogClosing,(qmpMainWindow*)parent,&qmpMainWindow::dialogClosed);
- settings=qmpsettings;
- cwt=new qmpCustomizeWindow(this);
- cwa=new qmpCustomizeWindow(this);
- dps=new qmpDevPropDialog(this);
- devpriod=new qmpDevicePriorityDialog(this);
+ ui->setupUi(this);
+ customOptions.clear();
+ customOptPages.clear();
+ connect(this, &qmpSettingsWindow::dialogClosing, (qmpMainWindow *)parent, &qmpMainWindow::dialogClosed);
+ settings = qmpsettings;
+ cwt = new qmpCustomizeWindow(this);
+ cwa = new qmpCustomizeWindow(this);
+ dps = new qmpDevPropDialog(this);
+ devpriod = new qmpDevicePriorityDialog(this);
}
qmpSettingsWindow::~qmpSettingsWindow()
{
- delete ui;
+ delete ui;
}
void qmpSettingsWindow::closeEvent(QCloseEvent *event)
{
- setVisible(false);
- loadOption();
- emit dialogClosing();
- event->accept();
+ setVisible(false);
+ loadOption();
+ emit dialogClosing();
+ event->accept();
}
void qmpSettingsWindow::hideEvent(QHideEvent *event)
{
- emit dialogClosing();
- event->accept();
+ emit dialogClosing();
+ event->accept();
}
void qmpSettingsWindow::on_buttonBox_accepted()
{
- saveOption();
- qmpMainWindow::getInstance()->setupWidget();
- emit dialogClosing();
+ saveOption();
+ qmpMainWindow::getInstance()->setupWidget();
+ emit dialogClosing();
}
void qmpSettingsWindow::on_buttonBox_rejected()
{
- loadOption();
- emit dialogClosing();
+ loadOption();
+ emit dialogClosing();
}
void qmpSettingsWindow::updatePluginList(qmpPluginManager *pmgr)
{
- std::vector<qmpPlugin> *plugins=pmgr->getPlugins();
- QVariant *data=static_cast<QVariant*>(settings->getOptionCustom("DisabledPlugins"));
- QList<QVariant> disabled_plugins_l=static_cast<QVariant*>(data)->toList();
- delete data;
- std::set<std::string> disabled_plugins_s;
- for(auto &i:disabled_plugins_l)
- disabled_plugins_s.insert(i.toString().toStdString());
- for(unsigned i=0;i<plugins->size();++i)
- {
- bool enabled=disabled_plugins_s.find(plugins->at(i).name)==disabled_plugins_s.end();
- plugins->at(i).enabled=enabled;
- }
+ std::vector<qmpPlugin> *plugins = pmgr->getPlugins();
+ QVariant *data = static_cast<QVariant *>(settings->getOptionCustom("DisabledPlugins"));
+ QList<QVariant> disabled_plugins_l = static_cast<QVariant *>(data)->toList();
+ delete data;
+ std::set<std::string> disabled_plugins_s;
+ for (auto &i : disabled_plugins_l)
+ disabled_plugins_s.insert(i.toString().toStdString());
+ for (unsigned i = 0; i < plugins->size(); ++i)
+ {
+ bool enabled = disabled_plugins_s.find(plugins->at(i).name) == disabled_plugins_s.end();
+ plugins->at(i).enabled = enabled;
+ }
}
void qmpSettingsWindow::postInit()
{
- setupWidgets();
- int sf=0;
- QVariant *data=static_cast<QVariant*>(settings->getOptionCustom("FluidSynth/SoundFonts"));
- for(auto i:data->toList())
- if(!i.toString().startsWith('#'))
- {
- sf=1;
- break;
- }
- delete data;
- std::string selecteddev;
- std::vector<std::string> devs=qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices();
- std::set<std::string> devset;
- for(auto dev:devs)devset.insert(dev);
- QVariant *devpriov=static_cast<QVariant*>(qmpMainWindow::getInstance()->getSettings()->getOptionCustom("Midi/DevicePriority"));
- QList<QVariant> devprio=devpriov->toList();
- delete devpriov;
- for(auto &setdev:devprio)
- if(devset.find(setdev.toString().toStdString())!=devset.end())
- {
- selecteddev=setdev.toString().toStdString();
- break;
- }
- if(selecteddev=="Internal FluidSynth"&&!sf)
- {
- if(QMessageBox::question(this,
- tr("No soundfont loaded"),
- tr("Internal fluidsynth is the only available MIDI output but it has no soundfont set. "
- "Would you like to setup soundfonts now? You may have to reload the internal synth afterwards."))==QMessageBox::Yes)
- {
- show();
- ui->tabWidget->setCurrentWidget(qobject_cast<QWidget*>(pageForTab("SoundFonts")->parent()));
- }
- }
+ setupWidgets();
+ int sf = 0;
+ QVariant *data = static_cast<QVariant *>(settings->getOptionCustom("FluidSynth/SoundFonts"));
+ for (auto i : data->toList())
+ if (!i.toString().startsWith('#'))
+ {
+ sf = 1;
+ break;
+ }
+ delete data;
+ std::string selecteddev;
+ std::vector<std::string> devs = qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices();
+ std::set<std::string> devset;
+ for (auto dev : devs)
+ devset.insert(dev);
+ QVariant *devpriov = static_cast<QVariant *>(qmpMainWindow::getInstance()->getSettings()->getOptionCustom("Midi/DevicePriority"));
+ QList<QVariant> devprio = devpriov->toList();
+ delete devpriov;
+ for (auto &setdev : devprio)
+ if (devset.find(setdev.toString().toStdString()) != devset.end())
+ {
+ selecteddev = setdev.toString().toStdString();
+ break;
+ }
+ if (selecteddev == "Internal FluidSynth" && !sf)
+ {
+ if (QMessageBox::question(this,
+ tr("No soundfont loaded"),
+ tr("Internal fluidsynth is the only available MIDI output but it has no soundfont set. "
+ "Would you like to setup soundfonts now? You may have to reload the internal synth afterwards.")) == QMessageBox::Yes)
+ {
+ show();
+ ui->tabWidget->setCurrentWidget(qobject_cast<QWidget *>(pageForTab("SoundFonts")->parent()));
+ }
+ }
}
void qmpSettingsWindow::registerCustomizeWidgetOptions()
{
- QPushButton *pbCustomizeToolbar=new QPushButton(tr("Customize..."));
- QPushButton *pbCustomizeActions=new QPushButton(tr("Customize..."));
- QVariant toolbar_def_val=QList<QVariant>({"Channel","Playlist","Effects","Visualization"});
- QVariant actions_def_val=QList<QVariant>({"FileInfo","Render","Panic","ReloadSynth"});
- settings->registerOptionCustom("Behavior","Customize toolbar","Behavior/Toolbar",pbCustomizeToolbar,&toolbar_def_val,std::bind(&qmpCustomizeWindow::save,cwt),std::bind(&qmpCustomizeWindow::load,cwt,std::placeholders::_1));
- settings->registerOptionCustom("Behavior","Customize actions","Behavior/Actions",pbCustomizeActions,&actions_def_val,std::bind(&qmpCustomizeWindow::save,cwa),std::bind(&qmpCustomizeWindow::load,cwa,std::placeholders::_1));
- connect(pbCustomizeToolbar,&QPushButton::clicked,[this]{loadOption("Behavior/Toolbar");cwt->show();});
- connect(pbCustomizeActions,&QPushButton::clicked,[this]{loadOption("Behavior/Actions");cwa->show();});
- connect(cwt,&QDialog::accepted,[this]{saveOption("Behavior/Toolbar");qmpMainWindow::getInstance()->setupWidget();});
- connect(cwa,&QDialog::accepted,[this]{saveOption("Behavior/Actions");qmpMainWindow::getInstance()->setupWidget();});
- connect(cwt,&QDialog::rejected,[this]{loadOption("Behavior/Toolbar");});
- connect(cwa,&QDialog::rejected,[this]{loadOption("Behavior/Actions");});
- qmpMainWindow::getInstance()->setupWidget();
+ QPushButton *pbCustomizeToolbar = new QPushButton(tr("Customize..."));
+ QPushButton *pbCustomizeActions = new QPushButton(tr("Customize..."));
+ QVariant toolbar_def_val = QList<QVariant>({"Channel", "Playlist", "Effects", "Visualization"});
+ QVariant actions_def_val = QList<QVariant>({"FileInfo", "Render", "Panic", "ReloadSynth"});
+ settings->registerOptionCustom("Behavior", "Customize toolbar", "Behavior/Toolbar", pbCustomizeToolbar, &toolbar_def_val, std::bind(&qmpCustomizeWindow::save, cwt), std::bind(&qmpCustomizeWindow::load, cwt, std::placeholders::_1));
+ settings->registerOptionCustom("Behavior", "Customize actions", "Behavior/Actions", pbCustomizeActions, &actions_def_val, std::bind(&qmpCustomizeWindow::save, cwa), std::bind(&qmpCustomizeWindow::load, cwa, std::placeholders::_1));
+ connect(pbCustomizeToolbar, &QPushButton::clicked, [this] {loadOption("Behavior/Toolbar"); cwt->show();});
+ connect(pbCustomizeActions, &QPushButton::clicked, [this] {loadOption("Behavior/Actions"); cwa->show();});
+ connect(cwt, &QDialog::accepted, [this] {saveOption("Behavior/Toolbar"); qmpMainWindow::getInstance()->setupWidget();});
+ connect(cwa, &QDialog::accepted, [this] {saveOption("Behavior/Actions"); qmpMainWindow::getInstance()->setupWidget();});
+ connect(cwt, &QDialog::rejected, [this] {loadOption("Behavior/Toolbar");});
+ connect(cwa, &QDialog::rejected, [this] {loadOption("Behavior/Actions");});
+ qmpMainWindow::getInstance()->setupWidget();
}
void qmpSettingsWindow::registerSoundFontOption()
{
- QWidget *sfpanel=new QWidget();
- sfpanel->setLayout(new QVBoxLayout);
- sfpanel->layout()->setMargin(0);
- QTableWidget *twsf=new QTableWidget();
- twsf->setColumnCount(2);
- twsf->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
- twsf->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
- twsf->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
- twsf->setHorizontalHeaderLabels({tr("E"),tr("Path")});
- twsf->setHorizontalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
- twsf->setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
- sfpanel->layout()->addWidget(twsf);
- QWidget *controls=new QWidget();
- controls->setLayout(new QHBoxLayout);
- controls->layout()->setMargin(0);
- QPushButton *pbsfadd=new QPushButton(style()->standardIcon(QStyle::StandardPixmap::SP_DialogOpenButton),QString());
- QPushButton *pbsfrem=new QPushButton(style()->standardIcon(QStyle::StandardPixmap::SP_DialogDiscardButton),QString());
- QPushButton *pbsfmup=new QPushButton(style()->standardIcon(QStyle::StandardPixmap::SP_ArrowUp),QString());
- QPushButton *pbsfmdn=new QPushButton(style()->standardIcon(QStyle::StandardPixmap::SP_ArrowDown),QString());
- controls->layout()->addWidget(pbsfadd);
- controls->layout()->addWidget(pbsfrem);
- controls->layout()->addWidget(pbsfmup);
- controls->layout()->addWidget(pbsfmdn);
- sfpanel->layout()->addWidget(controls);
+ QWidget *sfpanel = new QWidget();
+ sfpanel->setLayout(new QVBoxLayout);
+ sfpanel->layout()->setMargin(0);
+ QTableWidget *twsf = new QTableWidget();
+ twsf->setColumnCount(2);
+ twsf->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
+ twsf->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
+ twsf->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
+ twsf->setHorizontalHeaderLabels({tr("E"), tr("Path")});
+ twsf->setHorizontalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
+ twsf->setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
+ sfpanel->layout()->addWidget(twsf);
+ QWidget *controls = new QWidget();
+ controls->setLayout(new QHBoxLayout);
+ controls->layout()->setMargin(0);
+ QPushButton *pbsfadd = new QPushButton(style()->standardIcon(QStyle::StandardPixmap::SP_DialogOpenButton), QString());
+ QPushButton *pbsfrem = new QPushButton(style()->standardIcon(QStyle::StandardPixmap::SP_DialogDiscardButton), QString());
+ QPushButton *pbsfmup = new QPushButton(style()->standardIcon(QStyle::StandardPixmap::SP_ArrowUp), QString());
+ QPushButton *pbsfmdn = new QPushButton(style()->standardIcon(QStyle::StandardPixmap::SP_ArrowDown), QString());
+ controls->layout()->addWidget(pbsfadd);
+ controls->layout()->addWidget(pbsfrem);
+ controls->layout()->addWidget(pbsfmup);
+ controls->layout()->addWidget(pbsfmdn);
+ sfpanel->layout()->addWidget(controls);
- connect(pbsfadd,&QPushButton::clicked,[twsf,this]{
- QStringList sl=QFileDialog::getOpenFileNames(this,"Add File","","SoundFont files (*.sf2)");
- for(int i=0;i<sl.size();++i){
- twsf->insertRow(twsf->rowCount());
- QTableWidgetItem *sfn,*sfe;
- twsf->setItem(twsf->rowCount()-1,1,sfn=new QTableWidgetItem(sl[i]));
- twsf->setItem(twsf->rowCount()-1,0,sfe=new QTableWidgetItem());
- sfe->setCheckState(Qt::CheckState::Unchecked);
- sfn->setFlags(Qt::ItemFlag::ItemIsEnabled|Qt::ItemFlag::ItemIsSelectable);
- sfe->setFlags(Qt::ItemFlag::ItemIsEnabled|Qt::ItemFlag::ItemIsSelectable|Qt::ItemFlag::ItemIsUserCheckable);
- }
- });
- connect(pbsfrem,&QPushButton::clicked,[twsf]{
- QList<QTableWidgetItem*> sl=twsf->selectedItems();
- for(int i=0;i<sl.size();++i)
- twsf->removeRow(twsf->row(sl[i]));
- });
- connect(pbsfmup,&QPushButton::clicked,[twsf]{
- int cid=twsf->currentRow();if(!cid)return;
- QTableWidgetItem *ci=twsf->takeItem(cid,1);
- QTableWidgetItem *ce=twsf->takeItem(cid,0);
- twsf->removeRow(cid);
- twsf->insertRow(cid-1);
- twsf->setItem(cid-1,0,ce);
- twsf->setItem(cid-1,1,ci);
- twsf->setCurrentCell(cid-1,1);
- });
- connect(pbsfmdn,&QPushButton::clicked,[twsf]{
- int cid=twsf->currentRow();if(cid==twsf->rowCount()-1)return;
- QTableWidgetItem *ci=twsf->takeItem(cid,1);
- QTableWidgetItem *ce=twsf->takeItem(cid,0);
- twsf->removeRow(cid);
- twsf->insertRow(cid+1);
- twsf->setItem(cid+1,0,ce);
- twsf->setItem(cid+1,1,ci);
- twsf->setCurrentCell(cid+1,1);
- });
+ connect(pbsfadd, &QPushButton::clicked, [twsf, this]
+ {
+ QStringList sl = QFileDialog::getOpenFileNames(this, "Add File", "", "SoundFont files (*.sf2)");
+ for (int i = 0; i < sl.size(); ++i)
+ {
+ twsf->insertRow(twsf->rowCount());
+ QTableWidgetItem *sfn, *sfe;
+ twsf->setItem(twsf->rowCount() - 1, 1, sfn = new QTableWidgetItem(sl[i]));
+ twsf->setItem(twsf->rowCount() - 1, 0, sfe = new QTableWidgetItem());
+ sfe->setCheckState(Qt::CheckState::Unchecked);
+ sfn->setFlags(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable);
+ sfe->setFlags(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable | Qt::ItemFlag::ItemIsUserCheckable);
+ }
+ });
+ connect(pbsfrem, &QPushButton::clicked, [twsf]
+ {
+ QList<QTableWidgetItem *> sl = twsf->selectedItems();
+ for (int i = 0; i < sl.size(); ++i)
+ twsf->removeRow(twsf->row(sl[i]));
+ });
+ connect(pbsfmup, &QPushButton::clicked, [twsf]
+ {
+ int cid = twsf->currentRow();
+ if (!cid)
+ return;
+ QTableWidgetItem *ci = twsf->takeItem(cid, 1);
+ QTableWidgetItem *ce = twsf->takeItem(cid, 0);
+ twsf->removeRow(cid);
+ twsf->insertRow(cid - 1);
+ twsf->setItem(cid - 1, 0, ce);
+ twsf->setItem(cid - 1, 1, ci);
+ twsf->setCurrentCell(cid - 1, 1);
+ });
+ connect(pbsfmdn, &QPushButton::clicked, [twsf]
+ {
+ int cid = twsf->currentRow(); if (cid == twsf->rowCount() - 1)
+ return;
+ QTableWidgetItem *ci = twsf->takeItem(cid, 1);
+ QTableWidgetItem *ce = twsf->takeItem(cid, 0);
+ twsf->removeRow(cid);
+ twsf->insertRow(cid + 1);
+ twsf->setItem(cid + 1, 0, ce);
+ twsf->setItem(cid + 1, 1, ci);
+ twsf->setCurrentCell(cid + 1, 1);
+ });
- QVariant sf_def_val=QList<QVariant>();
- auto save_func=[twsf]()->void*{
- QList<QVariant> sflist;
- for(int i=0;i<twsf->rowCount();++i)
- {
- QString sfs=twsf->item(i,1)->text();
- if(twsf->item(i,0)->checkState()==Qt::CheckState::Unchecked)
- sfs="#"+sfs;
- sflist.push_back(sfs);
- }
- return new QVariant(sflist);
- };
- auto load_func=[twsf](void* data){
- QList<QVariant> sflist=static_cast<QVariant*>(data)->toList();
- twsf->clearContents();
- twsf->setRowCount(0);
- for(int i=0;i<sflist.size();++i)
- {
- twsf->insertRow(i);
- QTableWidgetItem *sfn,*sfe;
- QString sf=sflist[i].toString();
- bool enabled=!sf.startsWith('#');
- if(!enabled)sf=sf.mid(1);
- twsf->setItem(i,1,sfn=new QTableWidgetItem(sf));
- twsf->setItem(i,0,sfe=new QTableWidgetItem());
- sfn->setFlags(Qt::ItemFlag::ItemIsEnabled|Qt::ItemFlag::ItemIsSelectable);
- sfe->setFlags(Qt::ItemFlag::ItemIsEnabled|Qt::ItemFlag::ItemIsSelectable|Qt::ItemFlag::ItemIsUserCheckable);
- sfe->setCheckState(enabled?Qt::CheckState::Checked:Qt::CheckState::Unchecked);
- }
- };
- settings->registerOptionCustom("SoundFonts","","FluidSynth/SoundFonts",sfpanel,&sf_def_val,save_func,load_func);
+ QVariant sf_def_val = QList<QVariant>();
+ auto save_func = [twsf]()->void *
+ {
+ QList<QVariant> sflist;
+ for (int i = 0; i < twsf->rowCount(); ++i)
+ {
+ QString sfs = twsf->item(i, 1)->text();
+ if (twsf->item(i, 0)->checkState() == Qt::CheckState::Unchecked)
+ sfs = "#" + sfs;
+ sflist.push_back(sfs);
+ }
+ return new QVariant(sflist);
+ };
+ auto load_func = [twsf](void *data)
+ {
+ QList<QVariant> sflist = static_cast<QVariant *>(data)->toList();
+ twsf->clearContents();
+ twsf->setRowCount(0);
+ for (int i = 0; i < sflist.size(); ++i)
+ {
+ twsf->insertRow(i);
+ QTableWidgetItem *sfn, *sfe;
+ QString sf = sflist[i].toString();
+ bool enabled = !sf.startsWith('#');
+ if (!enabled)
+ sf = sf.mid(1);
+ twsf->setItem(i, 1, sfn = new QTableWidgetItem(sf));
+ twsf->setItem(i, 0, sfe = new QTableWidgetItem());
+ sfn->setFlags(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable);
+ sfe->setFlags(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable | Qt::ItemFlag::ItemIsUserCheckable);
+ sfe->setCheckState(enabled ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
+ }
+ };
+ settings->registerOptionCustom("SoundFonts", "", "FluidSynth/SoundFonts", sfpanel, &sf_def_val, save_func, load_func);
}
void qmpSettingsWindow::registerPluginOption(qmpPluginManager *pmgr)
{
- QTableWidget *twplugins=new QTableWidget();
- twplugins->setColumnCount(4);
- twplugins->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
- twplugins->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
- twplugins->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
- twplugins->setHorizontalHeaderLabels({tr("E"),tr("Plugin Name"),tr("Version"),tr("Path")});
- twplugins->setHorizontalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
- twplugins->setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
- QVariant ep_def_val=QList<QVariant>();
- auto save_func=[twplugins,this]()->void*{
- QVariant *data=static_cast<QVariant*>(settings->getOptionCustom("DisabledPlugins"));
- QList<QVariant> disabled_plugins_ol=static_cast<QVariant*>(data)->toList();
- delete data;
- std::set<std::string> disabled_plugins_s;
- for(auto &i:disabled_plugins_ol)
- disabled_plugins_s.insert(i.toString().toStdString());
- for(int i=0;i<twplugins->rowCount();++i)
- {
- QString pn=twplugins->item(i,1)->text();
- if(twplugins->item(i,0)->checkState()==Qt::CheckState::Unchecked)
- disabled_plugins_s.insert(pn.toStdString());
- else
- disabled_plugins_s.erase(pn.toStdString());
- }
- QList<QVariant> disabled_plugins;
- for(auto &i:disabled_plugins_s)
- disabled_plugins.push_back(QString(i.c_str()));
- return new QVariant(disabled_plugins);
- };
- auto load_func=[twplugins,pmgr](void* data){
- QList<QVariant> disabled_plugins_l=static_cast<QVariant*>(data)->toList();
- std::set<std::string> disabled_plugins;
- for(auto i:disabled_plugins_l)
- disabled_plugins.insert(i.toString().toStdString());
+ QTableWidget *twplugins = new QTableWidget();
+ twplugins->setColumnCount(4);
+ twplugins->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
+ twplugins->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
+ twplugins->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
+ twplugins->setHorizontalHeaderLabels({tr("E"), tr("Plugin Name"), tr("Version"), tr("Path")});
+ twplugins->setHorizontalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
+ twplugins->setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
+ QVariant ep_def_val = QList<QVariant>();
+ auto save_func = [twplugins, this]()->void *
+ {
+ QVariant *data = static_cast<QVariant *>(settings->getOptionCustom("DisabledPlugins"));
+ QList<QVariant> disabled_plugins_ol = static_cast<QVariant *>(data)->toList();
+ delete data;
+ std::set<std::string> disabled_plugins_s;
+ for (auto &i : disabled_plugins_ol)
+ disabled_plugins_s.insert(i.toString().toStdString());
+ for (int i = 0; i < twplugins->rowCount(); ++i)
+ {
+ QString pn = twplugins->item(i, 1)->text();
+ if (twplugins->item(i, 0)->checkState() == Qt::CheckState::Unchecked)
+ disabled_plugins_s.insert(pn.toStdString());
+ else
+ disabled_plugins_s.erase(pn.toStdString());
+ }
+ QList<QVariant> disabled_plugins;
+ for (auto &i : disabled_plugins_s)
+ disabled_plugins.push_back(QString(i.c_str()));
+ return new QVariant(disabled_plugins);
+ };
+ auto load_func = [twplugins, pmgr](void *data)
+ {
+ QList<QVariant> disabled_plugins_l = static_cast<QVariant *>(data)->toList();
+ std::set<std::string> disabled_plugins;
+ for (auto i : disabled_plugins_l)
+ disabled_plugins.insert(i.toString().toStdString());
- twplugins->clearContents();
- twplugins->setRowCount(0);
+ twplugins->clearContents();
+ twplugins->setRowCount(0);
- std::vector<qmpPlugin> *plugins=pmgr->getPlugins();
- for(int i=0;static_cast<size_t>(i)<plugins->size();++i)
- {
- twplugins->insertRow(i);
- qmpPlugin &p=plugins->at(static_cast<size_t>(i));
- QTableWidgetItem *icb;
- twplugins->setItem(i,0,icb=new QTableWidgetItem());
- bool enabled=disabled_plugins.find(p.name)==disabled_plugins.end();
- icb->setCheckState(enabled?Qt::CheckState::Checked:Qt::CheckState::Unchecked);
- icb->setFlags(Qt::ItemFlag::ItemIsEnabled|Qt::ItemFlag::ItemIsSelectable|Qt::ItemFlag::ItemIsUserCheckable);
- twplugins->setItem(i,1,new QTableWidgetItem(p.name.c_str()));
- twplugins->setItem(i,2,new QTableWidgetItem(p.version.c_str()));
- twplugins->setItem(i,3,new QTableWidgetItem(p.path.c_str()));
- for(int j=1;j<=3;++j)
- twplugins->item(i,j)->setFlags(Qt::ItemFlag::ItemIsEnabled|Qt::ItemFlag::ItemIsSelectable);
- }
- };
- settings->registerOptionCustom("Plugins","","DisabledPlugins",twplugins,&ep_def_val,save_func,load_func);
+ std::vector<qmpPlugin> *plugins = pmgr->getPlugins();
+ for (int i = 0; static_cast<size_t>(i) < plugins->size(); ++i)
+ {
+ twplugins->insertRow(i);
+ qmpPlugin &p = plugins->at(static_cast<size_t>(i));
+ QTableWidgetItem *icb;
+ twplugins->setItem(i, 0, icb = new QTableWidgetItem());
+ bool enabled = disabled_plugins.find(p.name) == disabled_plugins.end();
+ icb->setCheckState(enabled ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
+ icb->setFlags(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable | Qt::ItemFlag::ItemIsUserCheckable);
+ twplugins->setItem(i, 1, new QTableWidgetItem(p.name.c_str()));
+ twplugins->setItem(i, 2, new QTableWidgetItem(p.version.c_str()));
+ twplugins->setItem(i, 3, new QTableWidgetItem(p.path.c_str()));
+ for (int j = 1; j <= 3; ++j)
+ twplugins->item(i, j)->setFlags(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable);
+ }
+ };
+ settings->registerOptionCustom("Plugins", "", "DisabledPlugins", twplugins, &ep_def_val, save_func, load_func);
}
void qmpSettingsWindow::registerExtraMidiOptions()
{
- QPushButton *pbDevPrio=new QPushButton("...");
- connect(pbDevPrio,&QPushButton::clicked,[this]{loadOption("Midi/DevicePriority");devpriod->show();});
- connect(devpriod,&QDialog::accepted,[this]{saveOption("Midi/DevicePriority");});
- connect(devpriod,&QDialog::rejected,[this]{loadOption("Midi/DevicePriority");});
- QVariant devprio_def_val=QList<QVariant>({"Internal FluidSynth"});
- settings->registerOptionCustom("MIDI","Select MIDI output devices","Midi/DevicePriority",pbDevPrio,&devprio_def_val,std::bind(&qmpDevicePriorityDialog::save,devpriod),std::bind(&qmpDevicePriorityDialog::load,devpriod,std::placeholders::_1));
+ QPushButton *pbDevPrio = new QPushButton("...");
+ connect(pbDevPrio, &QPushButton::clicked, [this] {loadOption("Midi/DevicePriority"); devpriod->show();});
+ connect(devpriod, &QDialog::accepted, [this] {saveOption("Midi/DevicePriority");});
+ connect(devpriod, &QDialog::rejected, [this] {loadOption("Midi/DevicePriority");});
+ QVariant devprio_def_val = QList<QVariant>({"Internal FluidSynth"});
+ settings->registerOptionCustom("MIDI", "Select MIDI output devices", "Midi/DevicePriority", pbDevPrio, &devprio_def_val, std::bind(&qmpDevicePriorityDialog::save, devpriod), std::bind(&qmpDevicePriorityDialog::load, devpriod, std::placeholders::_1));
- QPushButton *pbDevProp=new QPushButton("...");
- connect(pbDevProp,&QPushButton::clicked,[this]{loadOption("Midi/DeviceInitializationFiles");dps->show();});
- connect(dps,&QDialog::accepted,[this]{saveOption("Midi/DeviceInitializationFiles");});
- connect(dps,&QDialog::rejected,[this]{loadOption("Midi/DeviceInitializationFiles");});
- QVariant devprop_def_val=QList<QVariant>({});
- settings->registerOptionCustom("MIDI","External MIDI device setup","Midi/DeviceInitializationFiles",pbDevProp,&devprop_def_val,std::bind(&qmpDevPropDialog::save,dps),std::bind(&qmpDevPropDialog::load,dps,std::placeholders::_1));
+ QPushButton *pbDevProp = new QPushButton("...");
+ connect(pbDevProp, &QPushButton::clicked, [this] {loadOption("Midi/DeviceInitializationFiles"); dps->show();});
+ connect(dps, &QDialog::accepted, [this] {saveOption("Midi/DeviceInitializationFiles");});
+ connect(dps, &QDialog::rejected, [this] {loadOption("Midi/DeviceInitializationFiles");});
+ QVariant devprop_def_val = QList<QVariant>({});
+ settings->registerOptionCustom("MIDI", "External MIDI device setup", "Midi/DeviceInitializationFiles", pbDevProp, &devprop_def_val, std::bind(&qmpDevPropDialog::save, dps), std::bind(&qmpDevPropDialog::load, dps, std::placeholders::_1));
}
void qmpSettingsWindow::saveOption(std::string key)
{
- auto save_opt=[this](std::string& key)->QVariant
- {
- qmpOption &o=settings->options[key];
- QVariant ret;
- switch(o.type)
- {
- case qmpOption::ParameterType::parameter_int:
- {
- QSpinBox *sb=qobject_cast<QSpinBox*>(o.widget);
- if(sb)
- ret=sb->value();
- }
- break;
- case qmpOption::ParameterType::parameter_uint:
- {
- QHexSpinBox *sb=qobject_cast<QHexSpinBox*>(o.widget);
- if(sb)
- {
- int val=sb->value();
- ret=reinterpret_cast<unsigned&>(val);
- }
- }
- break;
- case qmpOption::ParameterType::parameter_bool:
- {
- QCheckBox *cb=qobject_cast<QCheckBox*>(o.widget);
- if(cb)
- ret=cb->isChecked();
- }
- break;
- case qmpOption::ParameterType::parameter_double:
- {
- QDoubleSpinBox *sb=qobject_cast<QDoubleSpinBox*>(o.widget);
- if(sb)
- ret=sb->value();
- }
- break;
- case qmpOption::ParameterType::parameter_str:
- {
- QLineEdit *le=qobject_cast<QLineEdit*>(o.widget);
- if(le)
- ret=le->text();
- }
- break;
- case qmpOption::ParameterType::parameter_enum:
- {
- QComboBox *cb=qobject_cast<QComboBox*>(o.widget);
- if(cb)
- ret=cb->currentText();
- }
- break;
- case qmpOption::ParameterType::parameter_url:
- {
- QFileEdit *fe=qobject_cast<QFileEdit*>(o.widget);
- if(fe)
- ret=fe->text();
- }
- break;
- default:
- if(o.save_func)
- {
- QVariant* var=static_cast<QVariant*>(o.save_func());
- ret=QVariant(*var);
- delete var;
- }
- break;
- }
- return ret;
- };
- if(key.length())
- {
- QVariant r=save_opt(key);
- if(r.isValid())
- settings->settings->setValue(QString(key.c_str()),r);
- }
- else for(std::string& key:settings->optionlist)
- {
- QVariant r=save_opt(key);
- if(r.isValid())
- settings->settings->setValue(QString(key.c_str()),r);
- }
- settings->settings->sync();
+ auto save_opt = [this](std::string & key)->QVariant
+ {
+ qmpOption &o = settings->options[key];
+ QVariant ret;
+ switch (o.type)
+ {
+ case qmpOption::ParameterType::parameter_int:
+ {
+ QSpinBox *sb = qobject_cast<QSpinBox *>(o.widget);
+ if (sb)
+ ret = sb->value();
+ }
+ break;
+ case qmpOption::ParameterType::parameter_uint:
+ {
+ QHexSpinBox *sb = qobject_cast<QHexSpinBox *>(o.widget);
+ if (sb)
+ {
+ int val = sb->value();
+ ret = reinterpret_cast<unsigned &>(val);
+ }
+ }
+ break;
+ case qmpOption::ParameterType::parameter_bool:
+ {
+ QCheckBox *cb = qobject_cast<QCheckBox *>(o.widget);
+ if (cb)
+ ret = cb->isChecked();
+ }
+ break;
+ case qmpOption::ParameterType::parameter_double:
+ {
+ QDoubleSpinBox *sb = qobject_cast<QDoubleSpinBox *>(o.widget);
+ if (sb)
+ ret = sb->value();
+ }
+ break;
+ case qmpOption::ParameterType::parameter_str:
+ {
+ QLineEdit *le = qobject_cast<QLineEdit *>(o.widget);
+ if (le)
+ ret = le->text();
+ }
+ break;
+ case qmpOption::ParameterType::parameter_enum:
+ {
+ QComboBox *cb = qobject_cast<QComboBox *>(o.widget);
+ if (cb)
+ ret = cb->currentText();
+ }
+ break;
+ case qmpOption::ParameterType::parameter_url:
+ {
+ QFileEdit *fe = qobject_cast<QFileEdit *>(o.widget);
+ if (fe)
+ ret = fe->text();
+ }
+ break;
+ default:
+ if (o.save_func)
+ {
+ QVariant *var = static_cast<QVariant *>(o.save_func());
+ ret = QVariant(*var);
+ delete var;
+ }
+ break;
+ }
+ return ret;
+ };
+ if (key.length())
+ {
+ QVariant r = save_opt(key);
+ if (r.isValid())
+ settings->settings->setValue(QString(key.c_str()), r);
+ }
+ else for (std::string &key : settings->optionlist)
+ {
+ QVariant r = save_opt(key);
+ if (r.isValid())
+ settings->settings->setValue(QString(key.c_str()), r);
+ }
+ settings->settings->sync();
}
void qmpSettingsWindow::loadOption(std::string key)
{
- auto load_opt=[this](std::string& key)
- {
- qmpOption &o=settings->options[key];
- switch(o.type)
- {
- case qmpOption::ParameterType::parameter_int:
- {
- QSpinBox *sb=qobject_cast<QSpinBox*>(o.widget);
- if(sb)
- sb->setValue(settings->getOptionInt(key));
- }
- break;
- case qmpOption::ParameterType::parameter_uint:
- {
- QHexSpinBox *sb=qobject_cast<QHexSpinBox*>(o.widget);
- if(sb)
- sb->setValue(settings->getOptionUint(key));
- }
- break;
- case qmpOption::ParameterType::parameter_bool:
- {
- QCheckBox *cb=qobject_cast<QCheckBox*>(o.widget);
- if(cb)
- cb->setChecked(settings->getOptionBool(key));
- }
- break;
- case qmpOption::ParameterType::parameter_double:
- {
- QDoubleSpinBox *sb=qobject_cast<QDoubleSpinBox*>(o.widget);
- if(sb)
- sb->setValue(settings->getOptionDouble(key));
- }
- break;
- case qmpOption::ParameterType::parameter_str:
- {
- QLineEdit *le=qobject_cast<QLineEdit*>(o.widget);
- if(le)
- le->setText(QString(settings->getOptionString(key).c_str()));
- }
- break;
- case qmpOption::ParameterType::parameter_enum:
- {
- QComboBox *cb=qobject_cast<QComboBox*>(o.widget);
- if(cb)
- cb->setCurrentIndex(settings->getOptionEnumInt(key));
- }
- break;
- case qmpOption::ParameterType::parameter_url:
- {
- QFileEdit *fe=qobject_cast<QFileEdit*>(o.widget);
- if(fe)
- fe->setText(QString(settings->getOptionString(key).c_str()));
- }
- break;
- default:
- if(o.load_func)
- {
- void *var=settings->getOptionCustom(key);
- o.load_func(var);
- delete static_cast<QVariant*>(var);
- }
- break;
- }
- };
- if(key.length())load_opt(key);
- else for(std::string& key:settings->optionlist)
- load_opt(key);
+ auto load_opt = [this](std::string & key)
+ {
+ qmpOption &o = settings->options[key];
+ switch (o.type)
+ {
+ case qmpOption::ParameterType::parameter_int:
+ {
+ QSpinBox *sb = qobject_cast<QSpinBox *>(o.widget);
+ if (sb)
+ sb->setValue(settings->getOptionInt(key));
+ }
+ break;
+ case qmpOption::ParameterType::parameter_uint:
+ {
+ QHexSpinBox *sb = qobject_cast<QHexSpinBox *>(o.widget);
+ if (sb)
+ sb->setValue(settings->getOptionUint(key));
+ }
+ break;
+ case qmpOption::ParameterType::parameter_bool:
+ {
+ QCheckBox *cb = qobject_cast<QCheckBox *>(o.widget);
+ if (cb)
+ cb->setChecked(settings->getOptionBool(key));
+ }
+ break;
+ case qmpOption::ParameterType::parameter_double:
+ {
+ QDoubleSpinBox *sb = qobject_cast<QDoubleSpinBox *>(o.widget);
+ if (sb)
+ sb->setValue(settings->getOptionDouble(key));
+ }
+ break;
+ case qmpOption::ParameterType::parameter_str:
+ {
+ QLineEdit *le = qobject_cast<QLineEdit *>(o.widget);
+ if (le)
+ le->setText(QString(settings->getOptionString(key).c_str()));
+ }
+ break;
+ case qmpOption::ParameterType::parameter_enum:
+ {
+ QComboBox *cb = qobject_cast<QComboBox *>(o.widget);
+ if (cb)
+ cb->setCurrentIndex(settings->getOptionEnumInt(key));
+ }
+ break;
+ case qmpOption::ParameterType::parameter_url:
+ {
+ QFileEdit *fe = qobject_cast<QFileEdit *>(o.widget);
+ if (fe)
+ fe->setText(QString(settings->getOptionString(key).c_str()));
+ }
+ break;
+ default:
+ if (o.load_func)
+ {
+ void *var = settings->getOptionCustom(key);
+ o.load_func(var);
+ delete static_cast<QVariant *>(var);
+ }
+ break;
+ }
+ };
+ if (key.length())
+ load_opt(key);
+ else for (std::string &key : settings->optionlist)
+ load_opt(key);
}
void qmpSettingsWindow::setupWidgets()
{
- for(std::string& key:settings->optionlist)
- {
- if(!settings->options[key].desc.length()&&settings->options[key].type!=qmpOption::ParameterType::parameter_custom)
- continue;
- QWidget *optw=nullptr;
- qmpOption &o=settings->options[key];
- switch(o.type)
- {
- case qmpOption::ParameterType::parameter_int:
- {
- QSpinBox *sb=new QSpinBox;
- sb->setMinimum(o.minv.toInt());
- sb->setMaximum(o.maxv.toInt());
- sb->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
- optw=sb;
- }
- break;
- case qmpOption::ParameterType::parameter_uint:
- {
- QHexSpinBox *sb=new QHexSpinBox;
- sb->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
- optw=sb;
- }
- break;
- case qmpOption::ParameterType::parameter_bool:
- {
- QCheckBox *cb=new QCheckBox(QString(o.desc.c_str()));
- cb->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
- optw=cb;
- }
- break;
- case qmpOption::ParameterType::parameter_double:
- {
- QDoubleSpinBox *sb=new QDoubleSpinBox;
- sb->setMinimum(o.minv.toDouble());
- sb->setMaximum(o.maxv.toDouble());
- sb->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
- optw=sb;
- }
- break;
- case qmpOption::ParameterType::parameter_str:
- {
- QLineEdit* te=new QLineEdit();
- te->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
- optw=te;
- }
- break;
- case qmpOption::ParameterType::parameter_enum:
- {
- QComboBox* cb=new QComboBox();
- for(std::string& item:o.enumlist)cb->addItem(QString(item.c_str()));
- cb->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
- optw=cb;
- }
- break;
- case qmpOption::ParameterType::parameter_url:
- {
- QFileEdit* fe=new QFileEdit();
- fe->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
- optw=fe;
- }
- break;
- default:
- optw=o.widget;
- break;
- }
- o.widget=optw;
- QGridLayout* page=pageForTab(o.tab);
- if(o.type==qmpOption::ParameterType::parameter_bool||
- (o.type==qmpOption::parameter_custom&&!o.desc.length()))
- {
- int row=page->rowCount();
- page->addWidget(o.widget,row,0,1,2);
- }
- else
- {
- QLabel* lb=new QLabel(o.desc.c_str(),page->parentWidget());
- lb->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
- int row=page->rowCount();
- page->addWidget(lb,row,0);
- page->addWidget(o.widget,row,1);
- }
- }
- loadOption();
+ for (std::string &key : settings->optionlist)
+ {
+ if (!settings->options[key].desc.length() && settings->options[key].type != qmpOption::ParameterType::parameter_custom)
+ continue;
+ QWidget *optw = nullptr;
+ qmpOption &o = settings->options[key];
+ switch (o.type)
+ {
+ case qmpOption::ParameterType::parameter_int:
+ {
+ QSpinBox *sb = new QSpinBox;
+ sb->setMinimum(o.minv.toInt());
+ sb->setMaximum(o.maxv.toInt());
+ sb->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ optw = sb;
+ }
+ break;
+ case qmpOption::ParameterType::parameter_uint:
+ {
+ QHexSpinBox *sb = new QHexSpinBox;
+ sb->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ optw = sb;
+ }
+ break;
+ case qmpOption::ParameterType::parameter_bool:
+ {
+ QCheckBox *cb = new QCheckBox(QString(o.desc.c_str()));
+ cb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ optw = cb;
+ }
+ break;
+ case qmpOption::ParameterType::parameter_double:
+ {
+ QDoubleSpinBox *sb = new QDoubleSpinBox;
+ sb->setMinimum(o.minv.toDouble());
+ sb->setMaximum(o.maxv.toDouble());
+ sb->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ optw = sb;
+ }
+ break;
+ case qmpOption::ParameterType::parameter_str:
+ {
+ QLineEdit *te = new QLineEdit();
+ te->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ optw = te;
+ }
+ break;
+ case qmpOption::ParameterType::parameter_enum:
+ {
+ QComboBox *cb = new QComboBox();
+ for (std::string &item : o.enumlist)
+ cb->addItem(QString(item.c_str()));
+ cb->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ optw = cb;
+ }
+ break;
+ case qmpOption::ParameterType::parameter_url:
+ {
+ QFileEdit *fe = new QFileEdit();
+ fe->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ optw = fe;
+ }
+ break;
+ default:
+ optw = o.widget;
+ break;
+ }
+ o.widget = optw;
+ QGridLayout *page = pageForTab(o.tab);
+ if (o.type == qmpOption::ParameterType::parameter_bool ||
+ (o.type == qmpOption::parameter_custom && !o.desc.length()))
+ {
+ int row = page->rowCount();
+ page->addWidget(o.widget, row, 0, 1, 2);
+ }
+ else
+ {
+ QLabel *lb = new QLabel(o.desc.c_str(), page->parentWidget());
+ lb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ int row = page->rowCount();
+ page->addWidget(lb, row, 0);
+ page->addWidget(o.widget, row, 1);
+ }
+ }
+ loadOption();
}
-QGridLayout* qmpSettingsWindow::pageForTab(std::string tab)
+QGridLayout *qmpSettingsWindow::pageForTab(std::string tab)
{
- if(customOptPages.find(tab)!=customOptPages.end())
- return customOptPages[tab];
- QWidget* w=new QWidget;
- QGridLayout* page=new QGridLayout(w);
- w->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
- ui->tabWidget->addTab(w,QString(tab.c_str()));
- customOptPages[tab]=page;
- return page;
+ if (customOptPages.find(tab) != customOptPages.end())
+ return customOptPages[tab];
+ QWidget *w = new QWidget;
+ QGridLayout *page = new QGridLayout(w);
+ w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ ui->tabWidget->addTab(w, QString(tab.c_str()));
+ customOptPages[tab] = page;
+ return page;
}
-QFileEdit::QFileEdit(QWidget *par):QWidget(par)
+QFileEdit::QFileEdit(QWidget *par): QWidget(par)
{
- QHBoxLayout *layout=new QHBoxLayout(this);
- layout->setMargin(0);
- le=new QLineEdit(this);
- layout->addWidget(le);
- tb=new QToolButton(this);
- tb->setText("...");
- layout->addWidget(tb);
- connect(tb,&QToolButton::clicked,this,&QFileEdit::chooseFile);
+ QHBoxLayout *layout = new QHBoxLayout(this);
+ layout->setMargin(0);
+ le = new QLineEdit(this);
+ layout->addWidget(le);
+ tb = new QToolButton(this);
+ tb->setText("...");
+ layout->addWidget(tb);
+ connect(tb, &QToolButton::clicked, this, &QFileEdit::chooseFile);
+}
+QString QFileEdit::text()
+{
+ return le->text();
+}
+void QFileEdit::setText(const QString &s)
+{
+ le->setText(s);
}
-QString QFileEdit::text(){return le->text();}
-void QFileEdit::setText(const QString& s){le->setText(s);}
void QFileEdit::chooseFile()
{
- QString s=QFileDialog::getOpenFileName(nullptr,tr("Select a file"),QFileInfo(text()).dir().absolutePath());
- if(s.length())setText(s);
+ QString s = QFileDialog::getOpenFileName(nullptr, tr("Select a file"), QFileInfo(text()).dir().absolutePath());
+ if (s.length())
+ setText(s);
}
diff --git a/qmidiplayer-desktop/qmpsettingswindow.hpp b/qmidiplayer-desktop/qmpsettingswindow.hpp
index 5243ca9..c564c01 100644
--- a/qmidiplayer-desktop/qmpsettingswindow.hpp
+++ b/qmidiplayer-desktop/qmpsettingswindow.hpp
@@ -17,98 +17,108 @@
#include "qmpcustomizewindow.hpp"
#include "qmpdevpropdialog.hpp"
-namespace Ui {
- class qmpSettingsWindow;
+namespace Ui
+{
+class qmpSettingsWindow;
}
class QLineEdit;
class QToolButton;
-class QFileEdit:public QWidget
+class QFileEdit : public QWidget
{
- Q_OBJECT
- private:
- QLineEdit *le;
- QToolButton *tb;
- private slots:
- void chooseFile();
- public:
- QFileEdit(QWidget* par=nullptr);
- QString text();
- void setText(const QString& s);
+ Q_OBJECT
+private:
+ QLineEdit *le;
+ QToolButton *tb;
+private slots:
+ void chooseFile();
+public:
+ QFileEdit(QWidget *par = nullptr);
+ QString text();
+ void setText(const QString &s);
};
-class QHexSpinBox:public QSpinBox
+class QHexSpinBox: public QSpinBox
{
- Q_OBJECT
- public:
- QHexSpinBox(QWidget *parent=0):QSpinBox(parent)
- {
- setPrefix("0x");
- setDisplayIntegerBase(16);
- setRange(-0x80000000,0x7FFFFFFF);
- }
- protected:
- QString textFromValue(int value)const
- {
- return QString::number(u(value),16).toUpper();
- }
- int valueFromText(const QString &text)const
- {
- return i(text.toUInt(nullptr,16));
- }
- QValidator::State validate(QString &input,int &pos)const
- {
- QString t=input;
- if(t.startsWith("0x"))t.remove(0,2);
- pos-=t.size()-t.trimmed().size();t=t.trimmed();
- if(t.isEmpty())return QValidator::Intermediate;
- input=QString("0x")+t.toUpper();
- bool okay;t.toUInt(&okay,16);
- if(!okay)return QValidator::Invalid;
- return QValidator::Acceptable;
- }
- inline unsigned int u(int i)const
- {return reinterpret_cast<unsigned&>(i);}
- inline int i(unsigned int u)const
- {return reinterpret_cast<int&>(u);}
+ Q_OBJECT
+public:
+ QHexSpinBox(QWidget *parent = nullptr) : QSpinBox(parent)
+ {
+ setPrefix("0x");
+ setDisplayIntegerBase(16);
+ setRange(-0x80000000, 0x7FFFFFFF);
+ }
+protected:
+ QString textFromValue(int value)const
+ {
+ return QString::number(u(value), 16).toUpper();
+ }
+ int valueFromText(const QString &text)const
+ {
+ return i(text.toUInt(nullptr, 16));
+ }
+ QValidator::State validate(QString &input, int &pos)const
+ {
+ QString t = input;
+ if (t.startsWith("0x"))
+ t.remove(0, 2);
+ pos -= t.size() - t.trimmed().size();
+ t = t.trimmed();
+ if (t.isEmpty())
+ return QValidator::Intermediate;
+ input = QString("0x") + t.toUpper();
+ bool okay;
+ t.toUInt(&okay, 16);
+ if (!okay)
+ return QValidator::Invalid;
+ return QValidator::Acceptable;
+ }
+ inline unsigned int u(int i)const
+ {
+ return reinterpret_cast<unsigned &>(i);
+ }
+ inline int i(unsigned int u)const
+ {
+ return reinterpret_cast<int &>(u);
+ }
};
class qmpDevicePriorityDialog;
-class qmpSettingsWindow:public QDialog
+class qmpSettingsWindow : public QDialog
{
- Q_OBJECT
+ Q_OBJECT
- public:
- explicit qmpSettingsWindow(qmpSettings *qmpsettings,QWidget *parent=nullptr);
- ~qmpSettingsWindow();
- void closeEvent(QCloseEvent *event);
- void hideEvent(QHideEvent *event);
- void updatePluginList(qmpPluginManager *pmgr);
- void postInit();
- void registerCustomizeWidgetOptions();
- void registerSoundFontOption();
- void registerPluginOption(qmpPluginManager *pmgr);
- void registerExtraMidiOptions();
- signals:
- void dialogClosing();
+public:
+ explicit qmpSettingsWindow(qmpSettings *qmpsettings, QWidget *parent = nullptr);
+ ~qmpSettingsWindow();
+ void closeEvent(QCloseEvent *event);
+ void hideEvent(QHideEvent *event);
+ void updatePluginList(qmpPluginManager *pmgr);
+ void postInit();
+ void registerCustomizeWidgetOptions();
+ void registerSoundFontOption();
+ void registerPluginOption(qmpPluginManager *pmgr);
+ void registerExtraMidiOptions();
+signals:
+ void dialogClosing();
- private slots:
- void on_buttonBox_accepted();
- void on_buttonBox_rejected();
+private slots:
+ void on_buttonBox_accepted();
+ void on_buttonBox_rejected();
- private:
- Ui::qmpSettingsWindow *ui;
- std::map<std::string,qmpOption> customOptions;
- std::map<std::string,QGridLayout*> customOptPages;
- void saveOption(std::string key=std::string());
- void loadOption(std::string key=std::string());
- void setupWidgets();
- QGridLayout* pageForTab(std::string tab);
- qmpCustomizeWindow *cwt,*cwa;
- qmpDevPropDialog *dps;
- qmpDevicePriorityDialog *devpriod;
- qmpSettings *settings;
+private:
+ Ui::qmpSettingsWindow *ui;
+ std::map<std::string, qmpOption> customOptions;
+ std::map<std::string, QGridLayout *> customOptPages;
+ void saveOption(std::string key = std::string());
+ void loadOption(std::string key = std::string());
+ void setupWidgets();
+ QGridLayout *pageForTab(std::string tab);
+ qmpCustomizeWindow *cwt, *cwa;
+ qmpDevPropDialog *dps;
+ qmpDevicePriorityDialog *devpriod;
+ qmpSettings *settings;
};
#endif // QMPSETTINGSWINDOW_H