diff options
author | Chris Xiong <chirs241097@gmail.com> | 2023-11-09 20:26:54 -0500 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2023-11-09 20:26:54 -0500 |
commit | 382d85b15ce9cc4580a2522b39f5dd4ce43a24b0 (patch) | |
tree | bebf1807cb7221a24b64e04dfab6baeb535b8e14 /qmidiplayer-desktop | |
parent | 095716fa21071a506605304db6a113f231ff0dcd (diff) | |
download | QMidiPlayer-382d85b15ce9cc4580a2522b39f5dd4ce43a24b0.tar.xz |
Don't use default playlist if started with files in args.
Diffstat (limited to 'qmidiplayer-desktop')
-rw-r--r-- | qmidiplayer-desktop/qmpmainwindow.cpp | 5 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpmainwindow.hpp | 1 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpplistwindow.cpp | 11 |
3 files changed, 12 insertions, 5 deletions
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp index a0a4539..cc498cb 100644 --- a/qmidiplayer-desktop/qmpmainwindow.cpp +++ b/qmidiplayer-desktop/qmpmainwindow.cpp @@ -223,6 +223,11 @@ int qmpMainWindow::parseArgs() return 0; } +bool qmpMainWindow::startedWithFiles() +{ + return !argfiles.empty(); +} + void qmpMainWindow::closeEvent(QCloseEvent *event) { if (settings->getOptionBool("Behavior/DialogStatus")) diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp index eb36ba8..99886ba 100644 --- a/qmidiplayer-desktop/qmpmainwindow.hpp +++ b/qmidiplayer-desktop/qmpmainwindow.hpp @@ -230,6 +230,7 @@ public: void playerSeek(uint32_t percentage); PlaybackStatus getPlaybackStatus(); int parseArgs(); + bool startedWithFiles(); 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); diff --git a/qmidiplayer-desktop/qmpplistwindow.cpp b/qmidiplayer-desktop/qmpplistwindow.cpp index aa708ae..b67f4e6 100644 --- a/qmidiplayer-desktop/qmpplistwindow.cpp +++ b/qmidiplayer-desktop/qmpplistwindow.cpp @@ -29,7 +29,7 @@ qmpPlistWindow::qmpPlistWindow(QWidget *parent): repeat = 0; shuffle = 0; settings = qmpMainWindow::getInstance()->getSettings(); - if (settings->getOptionBool("Behavior/RestorePlaylist")) + if (settings->getOptionBool("Behavior/RestorePlaylist") && !qmpMainWindow::getInstance()->startedWithFiles()) { QSettings *plist = new QSettings(QStandardPaths::writableLocation(QStandardPaths::StandardLocation::ConfigLocation) + QString("/qmpplist"), QSettings::IniFormat); @@ -116,14 +116,15 @@ void qmpPlistWindow::closeEvent(QCloseEvent *event) settings->setOptionRaw("DialogStatus/PListW", geometry()); } setVisible(false); - if (!qmpMainWindow::getInstance()->isFinalizing()) + auto mw = qmpMainWindow::getInstance(); + if (!mw->isFinalizing()) while (ui->lwFiles->count() > 1) delete ui->lwFiles->item(0); - if (!qmpMainWindow::getInstance()->isFinalizing() && settings->getOptionBool("Behavior/DialogStatus")) + if (!mw->isFinalizing() && settings->getOptionBool("Behavior/DialogStatus")) { settings->setOptionRaw("DialogStatus/PListWShown", 0); } - if (qmpMainWindow::getInstance()->isFinalizing() && settings->getOptionBool("Behavior/RestorePlaylist")) + if (mw->isFinalizing() && settings->getOptionBool("Behavior/RestorePlaylist") && !mw->startedWithFiles()) { QSettings *plist = new QSettings(QStandardPaths::writableLocation(QStandardPaths::StandardLocation::ConfigLocation) + QString("/qmpplist"), QSettings::IniFormat); @@ -135,7 +136,7 @@ void qmpPlistWindow::closeEvent(QCloseEvent *event) plist->sync(); delete plist; } - qmpMainWindow::getInstance()->setFuncState("Playlist", false); + mw->setFuncState("Playlist", false); event->accept(); } |