diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2021-01-31 21:21:14 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2021-01-31 21:21:14 +0000 |
| commit | 53efb5d8ff3a1fa08adb334a415dba5be6e45505 (patch) | |
| tree | 33b63badec68898f4a707cf1ee16c1f5611018cc /src/qmmpui | |
| parent | b6d8148a8db5b5e22cf373ed9b464135d9e3e151 (diff) | |
| download | qmmp-53efb5d8ff3a1fa08adb334a415dba5be6e45505.tar.gz qmmp-53efb5d8ff3a1fa08adb334a415dba5be6e45505.tar.bz2 qmmp-53efb5d8ff3a1fa08adb334a415dba5be6e45505.zip | |
prepare for cue editor implementation
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9672 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui')
| -rw-r--r-- | src/qmmpui/cueeditor.cpp | 85 | ||||
| -rw-r--r-- | src/qmmpui/cueeditor_p.h | 53 | ||||
| -rw-r--r-- | src/qmmpui/detailsdialog.cpp | 12 | ||||
| -rw-r--r-- | src/qmmpui/forms/cueeditor.ui | 75 | ||||
| -rw-r--r-- | src/qmmpui/qmmpui.pro | 9 |
5 files changed, 231 insertions, 3 deletions
diff --git a/src/qmmpui/cueeditor.cpp b/src/qmmpui/cueeditor.cpp new file mode 100644 index 000000000..ae93ec6e2 --- /dev/null +++ b/src/qmmpui/cueeditor.cpp @@ -0,0 +1,85 @@ +/*************************************************************************** + * Copyright (C) 2021 by Ilya Kotov * + * forkotov02@ya.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include <QFile> +#include <QSettings> +#include <QFileInfo> +#include <QDir> +#include <qmmp/metadatamodel.h> +#include "cueeditor_p.h" +#include "filedialog.h" +#include "ui_cueeditor.h" + +CueEditor::CueEditor(MetaDataModel *model, QWidget *parent) : + QWidget(parent), + m_ui(new Ui::CueEditor), + m_model(model) +{ + m_ui->setupUi(this); + m_ui->plainTextEdit->setPlainText(model->cue()); + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + m_lastDir = settings.value("CueEditor/last_dir", QDir::homePath()).toString(); +} + +CueEditor::~CueEditor() +{ + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + settings.setValue("CueEditor/last_dir", m_lastDir); + + delete m_ui; +} + +void CueEditor::save() +{ + QString data = m_ui->plainTextEdit->toPlainText().trimmed(); + if(data.isEmpty()) + { + m_model->removeCue(); + } + else + { + data.append(QChar::LineFeed); + m_model->setCue(data); + } +} + +void CueEditor::on_loadButton_clicked() +{ + QString path = FileDialog::getOpenFileName(this, tr("Open CUE File"), + m_lastDir, + tr("CUE Files") +" (*.cue)"); + if(!path.isEmpty()) + { + m_lastDir = QFileInfo(path).absoluteDir().path(); + QFile file(path); + file.open(QIODevice::ReadOnly); + m_ui->plainTextEdit->setPlainText(QString::fromUtf8(file.readAll())); + } +} + +void CueEditor::on_deleteButton_clicked() +{ + m_ui->plainTextEdit->clear(); +} + +void CueEditor::on_saveAsButton_clicked() +{ + +} diff --git a/src/qmmpui/cueeditor_p.h b/src/qmmpui/cueeditor_p.h new file mode 100644 index 000000000..f0a9d4075 --- /dev/null +++ b/src/qmmpui/cueeditor_p.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2021 by Ilya Kotov * + * forkotov02@ya.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef CUEEDITOR_P_H +#define CUEEDITOR_P_H + +#include <QWidget> + +namespace Ui { +class CueEditor; +} + +class MetaDataModel; + +class CueEditor : public QWidget +{ + Q_OBJECT + +public: + explicit CueEditor(MetaDataModel *model, QWidget *parent = nullptr); + ~CueEditor(); + + void save(); + +private slots: + void on_loadButton_clicked(); + void on_deleteButton_clicked(); + void on_saveAsButton_clicked(); + +private: + Ui::CueEditor *m_ui; + MetaDataModel *m_model; + QString m_lastDir; +}; + +#endif // CUEEDITOR_P_H diff --git a/src/qmmpui/detailsdialog.cpp b/src/qmmpui/detailsdialog.cpp index 2b44fae60..8e423305b 100644 --- a/src/qmmpui/detailsdialog.cpp +++ b/src/qmmpui/detailsdialog.cpp @@ -32,6 +32,7 @@ #include "playlisttrack.h" #include "tageditor_p.h" #include "covereditor_p.h" +#include "cueeditor_p.h" #include "detailsdialog.h" DetailsDialog::DetailsDialog(const QList<PlayListTrack *> &tracks, QWidget *parent) @@ -82,6 +83,7 @@ void DetailsDialog::on_buttonBox_clicked(QAbstractButton *button) { TagEditor *tagEditor = qobject_cast<TagEditor *>(m_ui->tabWidget->currentWidget()); CoverEditor *coverEditor = nullptr; + CueEditor *cueEditor = nullptr; if(tagEditor) tagEditor->save(); else if((coverEditor = qobject_cast<CoverEditor *>(m_ui->tabWidget->currentWidget()))) @@ -89,6 +91,10 @@ void DetailsDialog::on_buttonBox_clicked(QAbstractButton *button) coverEditor->save(); MetaDataManager::instance()->clearCoverCache(); } + else if((cueEditor = qobject_cast<CueEditor *>(m_ui->tabWidget->currentWidget()))) + { + cueEditor->save(); + } } else { @@ -206,6 +212,12 @@ void DetailsDialog::updatePage() m_ui->tabWidget->addTab(coverEditor, tr("Cover")); } + if(m_metaDataModel && (m_metaDataModel->dialogHints() & MetaDataModel::IsCueEditable)) + { + CueEditor *cueEditor = new CueEditor(m_metaDataModel, this); + m_ui->tabWidget->addTab(cueEditor, "CUE"); + } + if(m_metaDataModel) { for(TagModel *tagModel : m_metaDataModel->tags()) diff --git a/src/qmmpui/forms/cueeditor.ui b/src/qmmpui/forms/cueeditor.ui new file mode 100644 index 000000000..90fdebc5f --- /dev/null +++ b/src/qmmpui/forms/cueeditor.ui @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CueEditor</class> + <widget class="QWidget" name="CueEditor"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>420</width> + <height>347</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0" rowspan="5"> + <widget class="QPlainTextEdit" name="plainTextEdit"> + <property name="plainText"> + <string/> + </property> + </widget> + </item> + <item row="0" column="1"> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>74</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="1"> + <widget class="QPushButton" name="loadButton"> + <property name="text"> + <string>Load</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QPushButton" name="deleteButton"> + <property name="text"> + <string>Delete</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QPushButton" name="saveAsButton"> + <property name="text"> + <string>Save as...</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>150</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/qmmpui/qmmpui.pro b/src/qmmpui/qmmpui.pro index 41f2a2a03..c8e4ca2f4 100644 --- a/src/qmmpui/qmmpui.pro +++ b/src/qmmpui/qmmpui.pro @@ -74,7 +74,8 @@ HEADERS += general.h \ metadataformattermenu.h \ qmmpui_export.h \ covereditor_p.h \ - commandlinehandler.h + commandlinehandler.h \ + cueeditor_p.h SOURCES += general.cpp \ playlistparser.cpp \ @@ -116,7 +117,8 @@ SOURCES += general.cpp \ metadataformattermenu.cpp \ covereditor.cpp \ commandlinehandler.cpp \ - generalfactory.cpp + generalfactory.cpp \ + cueeditor.cpp FORMS += forms/detailsdialog.ui \ forms/tageditor.ui \ @@ -126,7 +128,8 @@ FORMS += forms/detailsdialog.ui \ forms/aboutdialog.ui \ forms/addurldialog.ui \ forms/columneditor.ui \ - forms/covereditor.ui + forms/covereditor.ui \ + forms/cueeditor.ui unix:DESTDIR = . RESOURCES += translations/libqmmpui_locales.qrc \ |
