aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2018-09-16 19:58:23 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2018-09-16 19:58:23 +0000
commitf873e408d97f494837f9ec2ef0e00ad484f3b88b (patch)
treed3a22068026b191717e1337655097275fa01142d
parent58ca82ebbd83ddcc1d2ff0f512327cdf45c999bf (diff)
downloadqmmp-f873e408d97f494837f9ec2ef0e00ad484f3b88b.tar.gz
qmmp-f873e408d97f494837f9ec2ef0e00ad484f3b88b.tar.bz2
qmmp-f873e408d97f494837f9ec2ef0e00ad484f3b88b.zip
cover editor: implemented remaining functions
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8305 90c681e8-e032-0410-971d-27865f9a5e38
-rw-r--r--src/qmmpui/covereditor.cpp6
-rw-r--r--src/qmmpui/coverviewer.cpp44
-rw-r--r--src/qmmpui/coverviewer_p.h4
3 files changed, 49 insertions, 5 deletions
diff --git a/src/qmmpui/covereditor.cpp b/src/qmmpui/covereditor.cpp
index cf17635ac..12d538dda 100644
--- a/src/qmmpui/covereditor.cpp
+++ b/src/qmmpui/covereditor.cpp
@@ -56,7 +56,7 @@ bool CoverEditor::isEditable() const
void CoverEditor::save()
{
-
+ m_viewer->hasPixmap() ? m_model->setCover(m_viewer->pixmap()) : m_model->removeCover();
}
void CoverEditor::on_sourceComboBox_activated(int index)
@@ -79,12 +79,12 @@ void CoverEditor::on_sourceComboBox_activated(int index)
void CoverEditor::on_loadButton_clicked()
{
-
+ m_viewer->load();
}
void CoverEditor::on_deleteButton_clicked()
{
-
+ m_viewer->clear();
}
void CoverEditor::on_saveAsButton_clicked()
diff --git a/src/qmmpui/coverviewer.cpp b/src/qmmpui/coverviewer.cpp
index 5de87cbf3..bec263bf0 100644
--- a/src/qmmpui/coverviewer.cpp
+++ b/src/qmmpui/coverviewer.cpp
@@ -21,6 +21,11 @@
#include <QPainter>
#include <QPaintEvent>
#include <QAction>
+#include <QSettings>
+#include <QStandardPaths>
+#include <QVariant>
+#include <QFileInfo>
+#include <qmmp/qmmp.h>
#include "filedialog.h"
#include "coverviewer_p.h"
@@ -31,10 +36,16 @@ CoverViewer::CoverViewer(QWidget *parent)
connect(saveAsAction, SIGNAL(triggered()), SLOT(saveAs()));
addAction(saveAsAction);
setContextMenuPolicy(Qt::ActionsContextMenu);
+ QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
+ m_lastDir = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
+ m_lastDir = settings.value("CoverEditor/last_dir", m_lastDir).toString();
}
CoverViewer::~CoverViewer()
-{}
+{
+ QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
+ settings.setValue("CoverEditor/last_dir", m_lastDir);
+}
void CoverViewer::setPixmap(const QPixmap &pixmap)
{
@@ -47,14 +58,43 @@ bool CoverViewer::hasPixmap() const
return !m_pixmap.isNull();
}
+const QPixmap &CoverViewer::pixmap() const
+{
+ return m_pixmap;
+}
+
void CoverViewer::saveAs()
{
QString path = FileDialog::getSaveFileName(this, tr("Save Cover As"),
- QDir::homePath() + "/cover.jpg",
+ m_lastDir + "/cover.jpg",
tr("Images") +" (*.png *.jpg)");
if (!path.isEmpty())
+ {
+ m_lastDir = QFileInfo(path).absoluteDir().path();
m_pixmap.save(path);
+ }
+}
+
+void CoverViewer::load()
+{
+ QString path = FileDialog::getOpenFileName(this, tr("Open Image"),
+ m_lastDir,
+ tr("Images") +" (*.png *.jpg)");
+ if(!path.isEmpty())
+ {
+ m_lastDir = QFileInfo(path).absoluteDir().path();
+ m_pixmap.load(path);
+ if(m_pixmap.width() > 512)
+ m_pixmap = m_pixmap.scaled(512, 512, Qt::KeepAspectRatio);
+ }
+ update();
+}
+
+void CoverViewer::clear()
+{
+ m_pixmap = QPixmap();
+ update();
}
void CoverViewer::paintEvent(QPaintEvent *)
diff --git a/src/qmmpui/coverviewer_p.h b/src/qmmpui/coverviewer_p.h
index 53d7702ad..dbe3ba65b 100644
--- a/src/qmmpui/coverviewer_p.h
+++ b/src/qmmpui/coverviewer_p.h
@@ -40,13 +40,17 @@ public:
void setPixmap(const QPixmap&);
bool hasPixmap() const;
+ const QPixmap &pixmap() const;
public slots:
void saveAs();
+ void load();
+ void clear();
private:
void paintEvent(QPaintEvent *);
QPixmap m_pixmap;
+ QString m_lastDir;
};
#endif