Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:wolfi323:branches:KDE:Frameworks5
kaudiocreator5
0001-Add-KCddbWidgets-classes-from-KCddb.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Add-KCddbWidgets-classes-from-KCddb.patch of Package kaudiocreator5
From 40eb3ac08a73ccf174d44a5c3802a9a7df01e259 Mon Sep 17 00:00:00 2001 From: Wolfgang Bauer <wbauer@tmo.at> Date: Wed, 28 Jul 2021 15:10:01 +0200 Subject: [PATCH] Add KCddbWidgets classes from KCddb KCddbWidgets was dropped from libkcddb in 2020. But kaudiocreator uses them, so add them here instead. --- CMakeLists.txt | 8 +- cdinfodialog.cpp | 313 +++++++++++++++++++++++++++++++++++++++ cdinfodialog.h | 65 ++++++++ cdinfodialog.ui | 264 +++++++++++++++++++++++++++++++++ cdinfoencodingwidget.cpp | 67 +++++++++ cdinfoencodingwidget.h | 46 ++++++ cdinfoencodingwidget.ui | 91 ++++++++++++ tracksimp.cpp | 2 +- 8 files changed, 854 insertions(+), 2 deletions(-) create mode 100644 cdinfodialog.cpp create mode 100644 cdinfodialog.h create mode 100644 cdinfodialog.ui create mode 100644 cdinfoencodingwidget.cpp create mode 100644 cdinfoencodingwidget.h create mode 100644 cdinfoencodingwidget.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index c396b0b..efbc226 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,9 @@ set(kaudiocreator_SRCS general.cpp audiocd.cpp wizard.cpp + # from KCddbWidgets + cdinfodialog.cpp + cdinfoencodingwidget.cpp ) ki18n_wrap_ui(kaudiocreator_SRCS @@ -112,6 +115,9 @@ ki18n_wrap_ui(kaudiocreator_SRCS encoderoutput.ui ripconfig.ui cdconfig.ui + # from KCddbWidgets + cdinfodialog.ui + cdinfoencodingwidget.ui ) kconfig_add_kcfg_files(kaudiocreator_SRCS prefs.kcfgc encoder_prefs.kcfgc) @@ -120,7 +126,7 @@ qt5_add_resources(kaudiocreator_SRCS kaudiocreator.qrc) add_executable(kaudiocreator ${kaudiocreator_SRCS}) target_link_libraries(kaudiocreator - KF5::CddbWidgets + KF5::Cddb KF5::CompactDisc KF5::KCMUtils KF5::Solid diff --git a/cdinfodialog.cpp b/cdinfodialog.cpp new file mode 100644 index 0000000..8293a4f --- /dev/null +++ b/cdinfodialog.cpp @@ -0,0 +1,313 @@ +/* + Copyright (c) 2005 Shaheedur R. Haque <srhaque@iee.org> + Copyright (C) 2005 Richard Lärkäng <nouseforaname@home.se> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "cdinfodialog.h" + +#include "cdinfoencodingwidget.h" +#include "ui_cdinfodialog.h" + +#include <KCodecs/KCharsets> + +#include <QDebug> +#include <QStringList> +#include <QTextCodec> +#include <QTime> +#include <QStandardItemModel> +#include <QVBoxLayout> +#include <QDialogButtonBox> + +using KCDDB::TrackInfo; + +namespace KCDDB +{ + +class CDInfoDialog::Private +{ + public: + Private() + : ui(new Ui::CDInfoDialogBase) + { + } + + CDInfo info; + KCDDB::Genres genres; + KCDDB::Categories categories; + Ui::CDInfoDialogBase* ui; + static QLatin1String SEPARATOR; + static const unsigned TRACK_NUMBER = 0; + static const unsigned TRACK_TIME = 1; + static const unsigned TRACK_TITLE = 2; + static const unsigned TRACK_ARTIST = 3; + static const unsigned TRACK_COMMENT = 4; +}; + + QLatin1String CDInfoDialog::Private::SEPARATOR = QLatin1String( " / " ); + + CDInfoDialog::CDInfoDialog(QWidget* parent) + : QDialog(parent), + d(new Private) + { + QWidget* w = new QWidget(this); + d->ui->setupUi(w); + + QVBoxLayout* layout = new QVBoxLayout(this); + layout->addWidget(w); + + d->info.set(QLatin1String( "source" ), QLatin1String( "user" )); + + d->categories = KCDDB::Categories(); + d->ui->m_category->addItems(d->categories.i18nList()); + d->genres = KCDDB::Genres(); + d->ui->m_genre->addItems(d->genres.i18nList()); + + m_trackModel = new QStandardItemModel(0, 5, this); + d->ui->m_trackList->setModel(m_trackModel); + + // We want control over the visibility of this column. See artistChanged(). + d->ui->m_trackList->header()->setSectionResizeMode(Private::TRACK_ARTIST, QHeaderView::Interactive); + + connect( d->ui->m_trackList, &QAbstractItemView::activated, this, &CDInfoDialog::slotTrackSelected ); + connect( d->ui->m_trackList, &QAbstractItemView::doubleClicked, this, &CDInfoDialog::slotTrackDoubleClicked ); + connect( d->ui->m_artist, &QLineEdit::textChanged, this, &CDInfoDialog::artistChanged ); + connect( d->ui->m_genre, SIGNAL(textChanged(QString)), this, SLOT(genreChanged(QString)) ); + connect( d->ui->m_multiple, &QAbstractButton::toggled, this, &CDInfoDialog::slotMultipleArtists ); + + connect(d->ui->m_changeEncoding,&QAbstractButton::clicked,this, &CDInfoDialog::slotChangeEncoding); + + QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + layout->addWidget(bbox); + connect(bbox->button(QDialogButtonBox::Ok), &QAbstractButton::clicked, this, &QDialog::accept); + connect(bbox->button(QDialogButtonBox::Cancel), &QAbstractButton::clicked, this, &QWidget::close); + } + + void CDInfoDialog::slotTrackSelected( const QModelIndex &index ) + { + Q_EMIT play(index.data().toUInt()-1); + } + + + CDInfoDialog::~CDInfoDialog() + { + delete d->ui; + delete d; + } + + void CDInfoDialog::slotNextTrack() + { + QModelIndex index = d->ui->m_trackList->indexBelow(d->ui->m_trackList->currentIndex()); + if (index.isValid()) + { + d->ui->m_trackList->setCurrentIndex(index); + d->ui->m_trackList->scrollTo(index, QTreeView::EnsureVisible); + } + } + + void CDInfoDialog::slotTrackDoubleClicked(const QModelIndex &index) + { + d->ui->m_trackList->edit(index); + } + + void CDInfoDialog::setInfo( const KCDDB::CDInfo &info, const KCDDB::TrackOffsetList &trackStartFrames ) + { + d->info = info; + + d->ui->m_artist->setText(info.get(Artist).toString().trimmed()); + d->ui->m_title->setText(info.get(Title).toString().trimmed()); + d->ui->m_category->setItemText(d->ui->m_category->currentIndex(), d->categories.cddb2i18n(info.get(Category).toString())); + + // Make sure the revision is set before the genre to allow the genreChanged() handler to fire. + d->ui->m_revision->setText(QString::number(info.get(QLatin1String( "revision" )).toInt())); + d->ui->m_genre->setItemText(d->ui->m_genre->currentIndex(), d->genres.cddb2i18n(info.get(Genre).toString())); + d->ui->m_year->setValue(info.get(Year).toInt()); + d->ui->m_comment->setText(info.get(Comment).toString().trimmed()); + d->ui->m_id->setText(info.get(QLatin1String( "discid" )).toString().trimmed()); + + // Now do the individual tracks. + unsigned tracks = info.numberOfTracks(); + if (tracks > 0) + { + d->ui->m_length->setText(framesTime(trackStartFrames[tracks] - trackStartFrames[0])); + } + + m_trackModel->clear(); + QStringList labels; + labels << i18n("Track") << i18n("Length") << i18n("Title") << i18n("Artist") << i18n("Comment"); + m_trackModel->setHorizontalHeaderLabels(labels); + for (unsigned i = 0; i < tracks; ++i) { + QList<QStandardItem *> trackItems = QList<QStandardItem *>(); + TrackInfo ti(info.track(i)); + QStandardItem *trackNumberItem = new QStandardItem(QString::asprintf("%02d", i + 1)); + trackNumberItem->setEditable(false); + trackItems << trackNumberItem; + QStandardItem *trackLengthItem = new QStandardItem(framesTime(trackStartFrames[i + 1] - trackStartFrames[i])); + trackLengthItem->setEditable(false); + trackItems << trackLengthItem; + QStandardItem *trackTitleItem = new QStandardItem(ti.get(Title).toString()); + trackItems << trackTitleItem; + QStandardItem *trackArtistItem = new QStandardItem(ti.get(Artist).toString()); + trackItems << trackArtistItem; + QStandardItem *trackCommentItem = new QStandardItem(ti.get(Comment).toString()); + trackItems << trackCommentItem; + + m_trackModel->appendRow(trackItems); + } + // FIXME KDE4: handle playorder here too, once KCDDBInfo::CDInfo is updated. + + if (info.get(Artist).toString() == QLatin1String( "Various" ) || d->ui->m_multiple->isChecked()){ + d->ui->m_trackList->resizeColumnToContents(Private::TRACK_ARTIST); + } + } + + QString CDInfoDialog::framesTime(unsigned frames) + { + QTime time; + double ms; + + ms = frames * 1000 / 75.0; + time = time.addMSecs((int)ms); + + // Use ".zzz" for milliseconds... + QString temp2; + if (time.hour() > 0) + temp2 = time.toString(QLatin1String( "hh:mm:ss" )); + else + temp2 = time.toString(QLatin1String( "mm:ss" )); + return temp2; + } // framesTime + + KCDDB::CDInfo CDInfoDialog::info() const + { + KCDDB::CDInfo info = d->info; + + info.set(Artist, d->ui->m_artist->text().trimmed()); + info.set(Title, d->ui->m_title->text().trimmed()); + info.set(Category, d->categories.i18n2cddb(d->ui->m_category->currentText())); + info.set(Genre, d->genres.i18n2cddb(d->ui->m_genre->currentText())); + info.set(Year, d->ui->m_year->value()); + info.set(Comment, d->ui->m_comment->text().trimmed()); + info.set(QLatin1String( "revision" ), d->ui->m_revision->text().trimmed().toUInt()); + info.set(QLatin1String( "discid" ), d->ui->m_id->text().trimmed()); + + for (int t = 0; t < m_trackModel->rowCount(); ++t) { + TrackInfo& track = info.track(t); + track.set(Artist, m_trackModel->index(t, Private::TRACK_ARTIST).data().toString().trimmed()); + track.set(Title, m_trackModel->index(t, Private::TRACK_TITLE).data().toString().trimmed()); + track.set(Comment, m_trackModel->index(t, Private::TRACK_COMMENT).data().toString().trimmed()); + // FIXME KDE4: handle track lengths here too, once KCDDBInfo::CDInfo is updated. + } + // FIXME KDE4: handle playorder here too, once KCDDBInfo::CDInfo is updated. + return info; + } + + + void CDInfoDialog::artistChanged( const QString &newArtist ) + { + // Enable special handling of compilations. + if (newArtist.trimmed().compare(QLatin1String( "Various" ))) { + d->ui->m_multiple->setChecked(false); + } else { + d->ui->m_multiple->setChecked(true); + } + } + + void CDInfoDialog::genreChanged( const QString &newGenre ) + { + // Disable changes to category if the version number indicates that a record + // is already in the database, or if the genre is poorly set. The latter + // condition also provides a "back-door" override. + d->ui->m_category->setEnabled((d->ui->m_revision->text().trimmed().toUInt() < 1) || + (newGenre.compare(QLatin1String( "Unknown" )) == 0)); + } + + + void CDInfoDialog::slotMultipleArtists( bool hasMultipleArtist) + { + if (hasMultipleArtist) { + for (int t = 0; t < m_trackModel->rowCount(); ++t) { + QString title = m_trackModel->index(t, Private::TRACK_TITLE).data().toString(); + int separator = title.indexOf(Private::SEPARATOR); + if (separator != -1) { + // Artists probably entered already + m_trackModel->setData(m_trackModel->index(t, Private::TRACK_ARTIST), title.left(separator)); + m_trackModel->setData(m_trackModel->index(t, Private::TRACK_TITLE), title.mid(separator + 3)); + } + } + d->ui->m_trackList->resizeColumnToContents(Private::TRACK_ARTIST); + d->ui->m_trackList->resizeColumnToContents(Private::TRACK_TITLE); + } else { + for (int t = 0; t < m_trackModel->rowCount(); ++t) { + QString artist = m_trackModel->index(t, Private::TRACK_ARTIST).data().toString(); + if (!artist.isEmpty()) { + m_trackModel->setData(m_trackModel->index(t, Private::TRACK_ARTIST), QString()); + QString title = m_trackModel->index(t, Private::TRACK_TITLE).data().toString(); + m_trackModel->setData(m_trackModel->index(t, Private::TRACK_TITLE), QVariant(artist + Private::SEPARATOR + title)); + } + } + d->ui->m_trackList->hideColumn(Private::TRACK_ARTIST); + d->ui->m_trackList->resizeColumnToContents(Private::TRACK_TITLE); + } +} + + + void CDInfoDialog::slotChangeEncoding() + { + QDialog* dialog = new QDialog(this); + dialog->setWindowTitle(i18n("Change Encoding")); + dialog->setModal( true ); + + + QStringList songTitles; + for (int t = 0; t < m_trackModel->rowCount(); ++t) { + QString title = m_trackModel->index(t, Private::TRACK_ARTIST).data().toString().trimmed(); + if (!title.isEmpty()) + title.append(Private::SEPARATOR); + title.append(m_trackModel->index(t, Private::TRACK_TITLE).data().toString().trimmed()); + songTitles << title; + } + + KCDDB::CDInfoEncodingWidget* encWidget = new KCDDB::CDInfoEncodingWidget( + dialog, d->ui->m_artist->text(),d->ui->m_title->text(), songTitles); + + QVBoxLayout* layout = new QVBoxLayout(dialog); + layout->addWidget(encWidget); + + if (dialog->exec()) + { + KCharsets* charsets = KCharsets::charsets(); + QTextCodec* codec = charsets->codecForName(charsets->encodingForName(encWidget->selectedEncoding())); + + d->ui->m_artist->setText(codec->toUnicode(d->ui->m_artist->text().toLatin1())); + d->ui->m_title->setText(codec->toUnicode(d->ui->m_title->text().toLatin1())); + d->ui->m_genre->setItemText(d->ui->m_genre->currentIndex(), codec->toUnicode(d->ui->m_genre->currentText().toLatin1())); + d->ui->m_comment->setText(codec->toUnicode(d->ui->m_comment->text().toLatin1())); + + QModelIndex trackIndex = m_trackModel->index(0, 0, QModelIndex()); + int trackRows = m_trackModel->rowCount(trackIndex); + for (int t = 0; t < trackRows; ++t) { + QString artist = m_trackModel->index(t, Private::TRACK_ARTIST, trackIndex).data().toString(); + m_trackModel->setData(m_trackModel->index(t, Private::TRACK_ARTIST, trackIndex), codec->toUnicode(artist.toLatin1())); + QString title = m_trackModel->index(t, Private::TRACK_TITLE, trackIndex).data().toString(); + m_trackModel->setData(m_trackModel->index(t, Private::TRACK_TITLE, trackIndex), codec->toUnicode(title.toLatin1())); + QString comment = m_trackModel->index(t, Private::TRACK_COMMENT, trackIndex).data().toString(); + m_trackModel->setData(m_trackModel->index(t, Private::TRACK_COMMENT, trackIndex), codec->toUnicode(comment.toLatin1())); + } + } + } +} diff --git a/cdinfodialog.h b/cdinfodialog.h new file mode 100644 index 0000000..cc34f4c --- /dev/null +++ b/cdinfodialog.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2005 Richard Lärkäng <nouseforaname@home.se> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KCDDB_CDINFODIALOG_H +#define KCDDB_CDINFODIALOG_H + +#include <kcddb/cdinfo.h> +#include <kcddb/kcddb.h> + +#include <QDialog> + +class QStandardItemModel; +class QModelIndex; + +namespace KCDDB +{ + class CDInfoDialog : public QDialog + { + Q_OBJECT + public: + explicit CDInfoDialog(QWidget* parent); + virtual ~CDInfoDialog(); + + void setInfo( const KCDDB::CDInfo &info, const KCDDB::TrackOffsetList &trackStartFrames ); + KCDDB::CDInfo info() const; + + Q_SIGNALS: + void play( int ); + + private Q_SLOTS: + void slotTrackSelected( const QModelIndex &index ); + void slotNextTrack(); + void slotTrackDoubleClicked(const QModelIndex &index); + void artistChanged( const QString &newArtist ); + void genreChanged( const QString &newGenre ); + void slotMultipleArtists( bool hasMultipleArtist ); + void slotChangeEncoding(); + + private: + QString framesTime(unsigned frames); + QStandardItemModel *m_trackModel; + + class Private; + Private * const d; + } ; +} + +#endif // KCDDB_CDINFODIALOG_H diff --git a/cdinfodialog.ui b/cdinfodialog.ui new file mode 100644 index 0000000..06543ef --- /dev/null +++ b/cdinfodialog.ui @@ -0,0 +1,264 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CDInfoDialogBase</class> + <widget class="QWidget" name="CDInfoDialogBase"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>501</width> + <height>600</height> + </rect> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>10</number> + </property> + <item> + <layout class="QGridLayout"> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="5" column="2"> + <widget class="QLabel" name="lb_revision"> + <property name="text"> + <string>Revision:</string> + </property> + </widget> + </item> + <item row="1" column="1" colspan="3"> + <widget class="QLineEdit" name="m_title"> + <property name="toolTip"> + <string>Use the name of the artist if there is no title.</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="lb_category"> + <property name="text"> + <string>&Category:</string> + </property> + <property name="buddy"> + <cstring>m_category</cstring> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLabel" name="m_id"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="0" column="1" colspan="3"> + <widget class="QLineEdit" name="m_artist"> + <property name="toolTip"> + <string>Write names as "first last", not "last, first". Omit any leading "The". Use "Various" for compilations.</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="lb_artist"> + <property name="text"> + <string>&Artist:</string> + </property> + <property name="buddy"> + <cstring>m_artist</cstring> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="lb_year"> + <property name="text"> + <string>&Year:</string> + </property> + <property name="buddy"> + <cstring>m_year</cstring> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QLabel" name="lb_genre"> + <property name="text"> + <string>&Genre:</string> + </property> + <property name="buddy"> + <cstring>m_genre</cstring> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QComboBox" name="m_category"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>Disc Id values must be unique within a category.</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QSpinBox" name="m_year"> + <property name="maximum"> + <number>2100</number> + </property> + </widget> + </item> + <item row="6" column="0" colspan="2"> + <widget class="QCheckBox" name="m_multiple"> + <property name="text"> + <string>&Multiple artists</string> + </property> + </widget> + </item> + <item row="2" column="1" colspan="3"> + <widget class="QLineEdit" name="m_comment"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="lb_comment"> + <property name="text"> + <string>Comment:</string> + </property> + <property name="buddy"> + <cstring>m_comment</cstring> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="lb_title"> + <property name="text"> + <string>&Title:</string> + </property> + <property name="buddy"> + <cstring>m_title</cstring> + </property> + </widget> + </item> + <item row="4" column="3"> + <widget class="QComboBox" name="m_genre"> + <property name="toolTip"> + <string>Avoid custom values, as they will be written to CDDB as-is.</string> + </property> + <property name="editable"> + <bool>true</bool> + </property> + <property name="duplicatesEnabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="lb_id"> + <property name="text"> + <string>Disc Id:</string> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLabel" name="lb_length"> + <property name="text"> + <string>Length:</string> + </property> + </widget> + </item> + <item row="5" column="3"> + <widget class="QLabel" name="m_revision"/> + </item> + <item row="3" column="3"> + <widget class="QLabel" name="m_length"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QTreeView" name="m_trackList"> + <property name="toolTip"> + <string>For a CD-Extra, set title to "Data".</string> + </property> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> + <property name="itemsExpandable"> + <bool>false</bool> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <spacer> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>231</width> + <height>41</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="m_changeEncoding"> + <property name="text"> + <string>Change Encoding...</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="lb_playingOrder"> + <property name="text"> + <string>Playing order:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="m_playOrder"/> + </item> + </layout> + </widget> + <tabstops> + <tabstop>m_artist</tabstop> + <tabstop>m_title</tabstop> + <tabstop>m_comment</tabstop> + <tabstop>m_year</tabstop> + <tabstop>m_category</tabstop> + <tabstop>m_genre</tabstop> + <tabstop>m_trackList</tabstop> + <tabstop>m_playOrder</tabstop> + </tabstops> + <includes> + <include location="local">kcddb/cdinfo.h</include> + <include location="local">kcddb/kcddb.h</include> + <include location="local">kcddb/categories.h</include> + <include location="local">kcddb/genres.h</include> + </includes> + <resources/> + <connections/> +</ui> diff --git a/cdinfoencodingwidget.cpp b/cdinfoencodingwidget.cpp new file mode 100644 index 0000000..59aabef --- /dev/null +++ b/cdinfoencodingwidget.cpp @@ -0,0 +1,67 @@ +/* + Copyright (C) 2005 Richard Lärkäng <nouseforaname@home.se> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "cdinfoencodingwidget.h" + +#include <KCodecs/KCharsets> +#include <QTextCodec> + +namespace KCDDB +{ + CDInfoEncodingWidget::CDInfoEncodingWidget(QWidget* parent, const QString& artist, + const QString& title, const QStringList& songTitles) + : QWidget(parent), CDInfoEncodingWidgetBase(), m_artist(artist), m_title(title), + m_songTitles(songTitles) + { + setupUi(this); + + encodingCombo->addItems(KCharsets::charsets()->descriptiveEncodingNames()); + + slotEncodingChanged(encodingCombo->currentText()); + + connect(encodingCombo,SIGNAL(activated(QString)), + this,SLOT(slotEncodingChanged(QString))); + } + + QString CDInfoEncodingWidget::selectedEncoding() + { + return encodingCombo->currentText(); + } + + void CDInfoEncodingWidget::slotEncodingChanged(const QString& encoding) + { + KCharsets* charsets = KCharsets::charsets(); + + QTextCodec* codec = charsets->codecForName(charsets->encodingForName(encoding)); + + songsBox->clear(); + QStringList newTitles; + + for (QStringList::const_iterator it = m_songTitles.constBegin(); + it != m_songTitles.constEnd(); ++it) + newTitles << codec->toUnicode((*it).toLatin1().constData()); + + songsBox->clear(); + songsBox->addItems(newTitles); + + titleLabel->setText(i18nc("artist - cdtitle", "%1 - %2", + codec->toUnicode(m_artist.toLatin1()), codec->toUnicode(m_title.toLatin1().constData()))); + } +} + diff --git a/cdinfoencodingwidget.h b/cdinfoencodingwidget.h new file mode 100644 index 0000000..508ebdd --- /dev/null +++ b/cdinfoencodingwidget.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2005 Richard Lärkäng <nouseforaname@home.se> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KCDDB_CDINFOENCODINGWIDGET_H +#define KCDDB_CDINFOENCODINGWIDGET_H + +#include "ui_cdinfoencodingwidget.h" + +namespace KCDDB +{ + class CDInfoEncodingWidget : public QWidget, private Ui::CDInfoEncodingWidgetBase + { + Q_OBJECT + public: + CDInfoEncodingWidget(QWidget* parent, const QString& artist, const QString& title, + const QStringList& songTitles); + virtual ~CDInfoEncodingWidget() { } + + QString selectedEncoding(); + + private Q_SLOTS: + void slotEncodingChanged(const QString &); + + private: + QString m_artist, m_title; + QStringList m_songTitles; + } ; +} + +#endif // KCDDB_CDINFOENCODINGWIDGET_H diff --git a/cdinfoencodingwidget.ui b/cdinfoencodingwidget.ui new file mode 100644 index 0000000..53ca791 --- /dev/null +++ b/cdinfoencodingwidget.ui @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CDInfoEncodingWidgetBase</class> + <widget class="QWidget" name="CDInfoEncodingWidgetBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>350</width> + <height>372</height> + </rect> + </property> + <layout class="QGridLayout"> + <property name="leftMargin"> + <number>10</number> + </property> + <property name="topMargin"> + <number>10</number> + </property> + <property name="rightMargin"> + <number>10</number> + </property> + <property name="bottomMargin"> + <number>10</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="1"> + <widget class="QComboBox" name="encodingCombo"/> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QGroupBox" name="groupBox1"> + <property name="title"> + <string>Preview</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="leftMargin"> + <number>10</number> + </property> + <property name="topMargin"> + <number>10</number> + </property> + <property name="rightMargin"> + <number>10</number> + </property> + <property name="bottomMargin"> + <number>10</number> + </property> + <item> + <widget class="QLabel" name="titleLabel"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QListWidget" name="songsBox"> + <property name="minimumSize"> + <size> + <width>300</width> + <height>250</height> + </size> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="encodingLabel"> + <property name="text"> + <string>Encoding</string> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tracksimp.cpp b/tracksimp.cpp index bbfc552..88f31c9 100644 --- a/tracksimp.cpp +++ b/tracksimp.cpp @@ -28,7 +28,6 @@ #include <kapplication.h> #include <kcombobox.h> #include <KCddb/Genres> -#include <KCddb/CdinfoDialog> #include <kdebug.h> #include <solid/device.h> #include <solid/opticaldrive.h> @@ -38,6 +37,7 @@ #include "tracksimp.h" #include "defs.h" #include "prefs.h" +#include "cdinfodialog.h" using namespace KCDDB; -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor