aboutsummaryrefslogtreecommitdiff
path: root/qmpplistwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qmpplistwindow.cpp')
-rw-r--r--qmpplistwindow.cpp125
1 files changed, 125 insertions, 0 deletions
diff --git a/qmpplistwindow.cpp b/qmpplistwindow.cpp
index e0c52db..695afa0 100644
--- a/qmpplistwindow.cpp
+++ b/qmpplistwindow.cpp
@@ -1,6 +1,7 @@
#include <cstdlib>
#include <ctime>
#include <QFileDialog>
+#include <QSettings>
#include "qmpplistwindow.hpp"
#include "ui_qmpplistwindow.h"
#include "qmpmainwindow.hpp"
@@ -13,6 +14,44 @@ qmpPlistWindow::qmpPlistWindow(QWidget *parent) :
connect(this,SIGNAL(dialogClosing()),parent,SLOT(dialogClosed()));
connect(this,SIGNAL(selectionChanging()),parent,SLOT(selectionChanged()));
repeat=0;shuffle=0;
+ if(qmpSettingsWindow::getSettingsIntf()->value("Behavior/RestorePlaylist","").toInt())
+ {
+ QSettings* plist=new QSettings(QString(getenv("HOME"))+QString("/.config/qmpplist"),
+ QSettings::IniFormat);
+ int fc=plist->value("Playlist/FileCount",0).toInt();
+ ui->lwFiles->clear();for(int i=1;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.png"));
+ ui->pbShuffle->setText("Shuffle On");
+ break;
+ case 0:
+ default:
+ ui->pbShuffle->setIcon(QIcon(":/img/shuffle-off.png"));
+ ui->pbShuffle->setText("Shuffle Off");
+ break;
+ }
+ switch(repeat)
+ {
+ case 0:
+ ui->pbRepeat->setIcon(QIcon(":/img/repeat-non.png"));
+ ui->pbRepeat->setText("Repeat Off");
+ break;
+ case 1:
+ ui->pbRepeat->setIcon(QIcon(":/img/repeat-one.png"));
+ ui->pbRepeat->setText("Repeat One");
+ break;
+ case 2:
+ ui->pbRepeat->setIcon(QIcon(":/img/repeat-all.png"));
+ ui->pbRepeat->setText("Repeat All");
+ break;
+ }
+ delete plist;
+ }
}
qmpPlistWindow::~qmpPlistWindow()
@@ -20,13 +59,46 @@ qmpPlistWindow::~qmpPlistWindow()
delete ui;
}
+void qmpPlistWindow::showEvent(QShowEvent *event)
+{
+ if(qmpSettingsWindow::getSettingsIntf()->value("Behavior/DialogStatus","").toInt())
+ {
+ qmpSettingsWindow::getSettingsIntf()->setValue("DialogStatus/PListWShown",1);
+ }
+ event->accept();
+}
+
void qmpPlistWindow::closeEvent(QCloseEvent *event)
{
setVisible(false);
+ if(!qmpMainWindow::getInstance()->isFinalizing()&&qmpSettingsWindow::getSettingsIntf()->value("Behavior/DialogStatus","").toInt())
+ {
+ qmpSettingsWindow::getSettingsIntf()->setValue("DialogStatus/PListWShown",0);
+ }
+ if(qmpMainWindow::getInstance()->isFinalizing()&&qmpSettingsWindow::getSettingsIntf()->value("Behavior/RestorePlaylist","").toInt())
+ {
+ QSettings* plist=new QSettings(QString(getenv("HOME"))+QString("/.config/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+1,5,10,QChar('0')),ui->lwFiles->item(i)->text());
+ plist->setValue("Playlist/Repeat",repeat);
+ plist->setValue("Playlist/Shuffle",shuffle);
+ plist->sync();
+ delete plist;
+ }
emit dialogClosing();
event->accept();
}
+void qmpPlistWindow::moveEvent(QMoveEvent *event)
+{
+ if(qmpSettingsWindow::getSettingsIntf()->value("Behavior/DialogStatus","").toInt())
+ {
+ qmpSettingsWindow::getSettingsIntf()->setValue("DialogStatus/PListW",event->pos());
+ }
+}
+
void qmpPlistWindow::on_pbAdd_clicked()
{
QStringList sl=QFileDialog::getOpenFileNames(this,"Add File","","Midi files (*.mid *.midi)");
@@ -137,3 +209,56 @@ void qmpPlistWindow::on_lwFiles_itemDoubleClicked()
{
emit selectionChanging();
}
+
+void qmpPlistWindow::on_pbSave_clicked()
+{
+ QSettings* plist=new QSettings(QFileDialog::getSaveFileName(this,"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+1,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,"Load playlist",""),
+ QSettings::IniFormat);
+ int fc=plist->value("Playlist/FileCount",0).toInt();
+ if(!fc)return;
+ ui->lwFiles->clear();for(int i=1;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.png"));
+ ui->pbShuffle->setText("Shuffle On");
+ break;
+ case 0:
+ default:
+ ui->pbShuffle->setIcon(QIcon(":/img/shuffle-off.png"));
+ ui->pbShuffle->setText("Shuffle Off");
+ break;
+ }
+ switch(repeat)
+ {
+ case 0:
+ ui->pbRepeat->setIcon(QIcon(":/img/repeat-non.png"));
+ ui->pbRepeat->setText("Repeat Off");
+ break;
+ case 1:
+ ui->pbRepeat->setIcon(QIcon(":/img/repeat-one.png"));
+ ui->pbRepeat->setText("Repeat One");
+ break;
+ case 2:
+ ui->pbRepeat->setIcon(QIcon(":/img/repeat-all.png"));
+ ui->pbRepeat->setText("Repeat All");
+ break;
+ }
+ delete plist;
+}