aboutsummaryrefslogtreecommitdiff
path: root/src/qmmpui/covereditor.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2018-09-16 10:47:33 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2018-09-16 10:47:33 +0000
commitb7c2393ecb906cb529c16e23e62550ebf09fb2ef (patch)
tree725ead31c506a17ea2bf66a7000b1c3e39aa30d6 /src/qmmpui/covereditor.cpp
parentad93adc50b21179c082da72c63812a2316587277 (diff)
downloadqmmp-b7c2393ecb906cb529c16e23e62550ebf09fb2ef.tar.gz
qmmp-b7c2393ecb906cb529c16e23e62550ebf09fb2ef.tar.bz2
qmmp-b7c2393ecb906cb529c16e23e62550ebf09fb2ef.zip
partial cover editor form implementation
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8296 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui/covereditor.cpp')
-rw-r--r--src/qmmpui/covereditor.cpp63
1 files changed, 62 insertions, 1 deletions
diff --git a/src/qmmpui/covereditor.cpp b/src/qmmpui/covereditor.cpp
index c6f59acea..07241ffc9 100644
--- a/src/qmmpui/covereditor.cpp
+++ b/src/qmmpui/covereditor.cpp
@@ -18,10 +18,71 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
+#include <QVBoxLayout>
+#include "coverviewer_p.h"
#include "covereditor_p.h"
-CoverEditor::CoverEditor(QWidget *parent) :
+CoverEditor::CoverEditor(MetaDataModel *model, const QString &coverPath, QWidget *parent) :
QWidget(parent)
{
m_ui.setupUi(this);
+ m_model = model;
+ m_coverPath = coverPath;
+ m_editable = m_model && (m_model->dialogHints() & MetaDataModel::IS_COVER_EDITABLE) && !m_model->isReadOnly();
+
+ m_ui.sourceComboBox->addItem(tr("External file"));
+ m_ui.sourceComboBox->addItem(tr("Tag"));
+
+ m_viewer = new CoverViewer(this);
+ QVBoxLayout *layout = new QVBoxLayout();
+ layout->addWidget(m_viewer);
+ m_ui.frame->setLayout(layout);
+
+ if(m_model && !m_model->cover().isNull())
+ m_ui.sourceComboBox->setCurrentIndex(1);
+ else
+ m_ui.sourceComboBox->setCurrentIndex(0);
+
+ on_sourceComboBox_activated(m_ui.sourceComboBox->currentIndex());
+
+ if(!m_model || m_coverPath.isEmpty() || (!m_editable && m_model->cover().isNull()))
+ m_ui.sourceComboBox->setEnabled(false);
+}
+
+bool CoverEditor::isEditable() const
+{
+ return m_editable;
+}
+
+void CoverEditor::on_sourceComboBox_activated(int index)
+{
+ if(index == 0)
+ {
+ m_viewer->setPixmap(QPixmap(m_coverPath));
+ m_ui.loadButton->setEnabled(false);
+ m_ui.deleteButton->setEnabled(false);
+ m_ui.saveAsButton->setEnabled(m_viewer->hasPixmap());
+ }
+ else if(index == 1)
+ {
+ m_viewer->setPixmap(m_model->cover());
+ m_ui.loadButton->setEnabled(m_editable);
+ m_ui.deleteButton->setEnabled(m_editable && m_viewer->hasPixmap());
+ m_ui.saveAsButton->setEnabled(m_viewer->hasPixmap());
+ }
+}
+
+void CoverEditor::on_loadButton_clicked()
+{
+
+}
+
+void CoverEditor::on_deleteButton_clicked()
+{
+
+}
+
+void CoverEditor::on_saveAsButton_clicked()
+{
+ m_viewer->saveAs();
}