From bc28f1332bbbf9bad49bbad6fd01ef03b4ab99b9 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Thu, 9 Feb 2012 19:10:54 +0000 Subject: refactoring: add QmmpUiSettings class, removed deprecated code git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2588 90c681e8-e032-0410-971d-27865f9a5e38 --- src/qmmpui/CMakeLists.txt | 5 +- src/qmmpui/configdialog.cpp | 33 ++++---- src/qmmpui/fileloader.cpp | 4 +- src/qmmpui/mediaplayer.cpp | 2 + src/qmmpui/mediaplayer.h | 4 + src/qmmpui/playlistitem.cpp | 8 +- src/qmmpui/playlistmanager.cpp | 55 ------------- src/qmmpui/playlistmanager.h | 42 ---------- src/qmmpui/playlistmodel.cpp | 1 - src/qmmpui/playlistsettings.cpp | 91 --------------------- src/qmmpui/playlistsettings_p.h | 53 ------------ src/qmmpui/qmmpui.pro | 15 ++-- src/qmmpui/qmmpuisettings.cpp | 126 +++++++++++++++++++++++++++++ src/qmmpui/qmmpuisettings.h | 117 +++++++++++++++++++++++++++ src/qmmpui/translations/libqmmpui_cs.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_de.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_es.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_it.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_ja.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_lt.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_nl.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_pl_PL.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_pt_BR.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_ru.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_sk.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_tr.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_uk_UA.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_zh_CN.ts | 48 +++++------ src/qmmpui/translations/libqmmpui_zh_TW.ts | 48 +++++------ 29 files changed, 646 insertions(+), 630 deletions(-) delete mode 100644 src/qmmpui/playlistsettings.cpp delete mode 100644 src/qmmpui/playlistsettings_p.h create mode 100644 src/qmmpui/qmmpuisettings.cpp create mode 100644 src/qmmpui/qmmpuisettings.h (limited to 'src/qmmpui') diff --git a/src/qmmpui/CMakeLists.txt b/src/qmmpui/CMakeLists.txt index d37ce5c03..5e8171009 100644 --- a/src/qmmpui/CMakeLists.txt +++ b/src/qmmpui/CMakeLists.txt @@ -34,7 +34,6 @@ SET(libqmmpui_SRCS playlistmodel.cpp playlistitem.cpp mediaplayer.cpp - playlistsettings.cpp detailsdialog.cpp tageditor.cpp playlistmanager.cpp @@ -45,6 +44,7 @@ SET(libqmmpui_SRCS configdialog.cpp pluginitem.cpp aboutdialog.cpp + qmmpuisettings.cpp ) SET(libqmmpui_HDRS @@ -55,7 +55,6 @@ SET(libqmmpui_HDRS filedialogfactory.h playstate_p.h playlistitem.h - playlistsettings_p.h metadataformatter.h uiloader.h uifactory.h @@ -78,6 +77,7 @@ SET(libqmmpui_MOC_HDRS jumptotrackdialog_p.h configdialog.h aboutdialog_p.h + qmmpuisettings.h ) SET(libqmmpui_DEVEL_HDRS @@ -100,6 +100,7 @@ SET(libqmmpui_DEVEL_HDRS uiloader.h uifactory.h configdialog.h + qmmpuisettings.h ) diff --git a/src/qmmpui/configdialog.cpp b/src/qmmpui/configdialog.cpp index 2d6909b60..b9f426b19 100644 --- a/src/qmmpui/configdialog.cpp +++ b/src/qmmpui/configdialog.cpp @@ -48,6 +48,7 @@ #include "uiloader.h" #include "filedialog.h" #include "mediaplayer.h" +#include "qmmpuisettings.h" #include "playlistmodel.h" #include "configdialog.h" @@ -95,11 +96,14 @@ void ConfigDialog::readSettings() { if (MediaPlayer::instance()) { - MediaPlayer *player = MediaPlayer::instance(); - m_ui->formatLineEdit->setText(player->playListManager()->format()); - m_ui->metadataCheckBox->setChecked(player->playListManager()->useMetadata()); - m_ui->underscoresCheckBox->setChecked(player->playListManager()->convertUnderscore()); - m_ui->per20CheckBox->setChecked(player->playListManager()->convertTwenty()); + //playlist options + QmmpUiSettings *guis = QmmpUiSettings::instance(); + m_ui->formatLineEdit->setText(guis->format()); + m_ui->metadataCheckBox->setChecked(guis->useMetadata()); + m_ui->underscoresCheckBox->setChecked(guis->convertUnderscore()); + m_ui->per20CheckBox->setChecked(guis->convertTwenty()); + //resume playback on startup + m_ui->continuePlaybackCheckBox->setChecked(guis->resumeOnStartup()); } //proxy settings QmmpSettings *gs = QmmpSettings::instance(); @@ -115,9 +119,6 @@ void ConfigDialog::readSettings() m_ui->portLineEdit->setEnabled(m_ui->enableProxyCheckBox->isChecked()); m_ui->proxyUserLineEdit->setEnabled(m_ui->authProxyCheckBox->isChecked()); m_ui->proxyPasswLineEdit->setEnabled(m_ui->authProxyCheckBox->isChecked()); - //resume playback - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - m_ui->continuePlaybackCheckBox->setChecked(settings.value("General/resume_on_startup", false).toBool()); //file type determination m_ui->byContentCheckBox->setChecked(gs->determineFileTypeByContent()); //cover options @@ -135,6 +136,7 @@ void ConfigDialog::readSettings() m_ui->use16BitCheckBox->setChecked(gs->use16BitOutput()); m_ui->bufferSizeSpinBox->setValue(gs->bufferSize()); //geometry + QSettings settings (Qmmp::configFile(), QSettings::IniFormat); resize(settings.value("ConfigDialog/window_size", QSize(700,470)).toSize()); QList var_sizes = settings.value("ConfigDialog/splitter_sizes").toList(); if(var_sizes.count() != 2) @@ -309,12 +311,14 @@ void ConfigDialog::addTitleString(QAction * a) void ConfigDialog::saveSettings() { - if (MediaPlayer *player = MediaPlayer::instance()) + if (QmmpUiSettings *guis = QmmpUiSettings::instance()) { - player->playListManager()->setFormat(m_ui->formatLineEdit->text().trimmed()); - player->playListManager()->setUseMetadata(m_ui->metadataCheckBox->isChecked()); - player->playListManager()->setConvertUnderscore(m_ui->underscoresCheckBox->isChecked()); - player->playListManager()->setConvertTwenty(m_ui->per20CheckBox->isChecked()); + guis->setFormat(m_ui->formatLineEdit->text().trimmed()); + guis->setUseMetadata(m_ui->metadataCheckBox->isChecked()); + guis->setConvertUnderscore(m_ui->underscoresCheckBox->isChecked()); + guis->setConvertTwenty(m_ui->per20CheckBox->isChecked()); + guis->setResumeOnStartup(m_ui->continuePlaybackCheckBox->isChecked()); + guis->sync(); } FileDialog::setEnabled(FileDialog::registeredFactories().at(m_ui->fileDialogComboBox->currentIndex())); @@ -329,8 +333,6 @@ void ConfigDialog::saveSettings() m_ui->authProxyCheckBox->isChecked(), proxyUrl); - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - settings.setValue ("General/resume_on_startup", m_ui->continuePlaybackCheckBox->isChecked()); gs->setCoverSettings(m_ui->coverIncludeLineEdit->text().split(","), m_ui->coverExcludeLineEdit->text().split(","), m_ui->coverDepthSpinBox->value(), @@ -351,6 +353,7 @@ void ConfigDialog::saveSettings() QList var_sizes; var_sizes << m_ui->splitter->sizes().first() << m_ui->splitter->sizes().last(); + QSettings settings (Qmmp::configFile(), QSettings::IniFormat); settings.setValue("ConfigDialog/splitter_sizes", var_sizes); settings.setValue("ConfigDialog/window_size", size()); } diff --git a/src/qmmpui/fileloader.cpp b/src/qmmpui/fileloader.cpp index fa107c272..502b38401 100644 --- a/src/qmmpui/fileloader.cpp +++ b/src/qmmpui/fileloader.cpp @@ -20,7 +20,7 @@ #include #include "fileloader_p.h" -#include "playlistsettings_p.h" +#include "qmmpuisettings.h" #include "playlistitem.h" FileLoader::FileLoader(QObject *parent) : QThread(parent) @@ -33,7 +33,7 @@ FileLoader::~FileLoader() void FileLoader::addFile(const QString &path) { - bool use_meta = PlaylistSettings::instance()->useMetadata(); + bool use_meta = QmmpUiSettings::instance()->useMetadata(); QList playList = MetaDataManager::instance()->createPlayList(path, use_meta); foreach(FileInfo *info, playList) emit newPlayListItem(new PlayListItem(info)); diff --git a/src/qmmpui/mediaplayer.cpp b/src/qmmpui/mediaplayer.cpp index 97930191a..23fc01dc7 100644 --- a/src/qmmpui/mediaplayer.cpp +++ b/src/qmmpui/mediaplayer.cpp @@ -23,6 +23,7 @@ #include #include #include "playlistitem.h" +#include "qmmpuisettings.h" #include "mediaplayer.h" #define MAX_ERRORS 4 @@ -45,6 +46,7 @@ MediaPlayer::MediaPlayer(QObject *parent) translator->load(QString(":/libqmmpui_") + locale); qApp->installTranslator(translator); m_core = new SoundCore(this); + m_settings = new QmmpUiSettings(this); m_pl_manager = new PlayListManager(this); connect(m_core, SIGNAL(nextTrackRequest()), SLOT(updateNextUrl())); connect(m_core, SIGNAL(finished()), SLOT(playNext())); diff --git a/src/qmmpui/mediaplayer.h b/src/qmmpui/mediaplayer.h index 0af41412f..07a314a2b 100644 --- a/src/qmmpui/mediaplayer.h +++ b/src/qmmpui/mediaplayer.h @@ -25,6 +25,9 @@ #include "playlistmanager.h" +class QmmpUiSettings; + + /*! @brief The MediaPlayer class provides a simple way to use SoundCore and PlayListModel together. * @author Ilya Kotov */ @@ -107,6 +110,7 @@ private slots: void showMetaData(); private: + QmmpUiSettings *m_settings; PlayListManager *m_pl_manager; SoundCore *m_core; static MediaPlayer* m_instance; diff --git a/src/qmmpui/playlistitem.cpp b/src/qmmpui/playlistitem.cpp index 1ad06cd36..22ea294b6 100644 --- a/src/qmmpui/playlistitem.cpp +++ b/src/qmmpui/playlistitem.cpp @@ -20,7 +20,7 @@ #include #include #include "metadataformatter.h" -#include "playlistsettings_p.h" +#include "qmmpuisettings.h" #include "playlistitem.h" PlayListItem::PlayListItem() : QMap(), m_flag(FREE) @@ -144,7 +144,7 @@ const QString PlayListItem::url() const void PlayListItem::readMetadata() { - MetaDataFormatter f(PlaylistSettings::instance()->format()); + MetaDataFormatter f(QmmpUiSettings::instance()->format()); m_title = f.parse(this); //TODO rewrite this if (m_title.isEmpty()) @@ -155,8 +155,8 @@ void PlayListItem::readMetadata() if (m_info) delete m_info; m_info = 0; - if (PlaylistSettings::instance()->convertUnderscore()) + if (QmmpUiSettings::instance()->convertUnderscore()) m_title.replace("_", " "); - if (PlaylistSettings::instance()->convertTwenty()) + if (QmmpUiSettings::instance()->convertTwenty()) m_title.replace("%20", " "); } diff --git a/src/qmmpui/playlistmanager.cpp b/src/qmmpui/playlistmanager.cpp index d8915236c..08f1f1ad1 100644 --- a/src/qmmpui/playlistmanager.cpp +++ b/src/qmmpui/playlistmanager.cpp @@ -24,7 +24,6 @@ #include #include #include -#include "playlistsettings_p.h" #include "playlistmanager.h" @@ -48,7 +47,6 @@ PlayListManager::PlayListManager(QObject *parent) : QObject(parent) PlayListManager::~PlayListManager() { writePlayLists(); - delete PlaylistSettings::instance(); QSettings settings(Qmmp::configFile(), QSettings::IniFormat); settings.setValue("Playlist/repeatable", m_repeatable); settings.setValue("Playlist/shuffle", m_shuffle); @@ -249,59 +247,6 @@ PlayListModel *PlayListManager::playListAt(int i) const return 0; } -bool PlayListManager::convertUnderscore() const -{ - return PlaylistSettings::instance()->convertUnderscore(); -} - -bool PlayListManager::convertTwenty() const -{ - return PlaylistSettings::instance()->convertTwenty(); -} - -bool PlayListManager::useMetadata() const -{ - return PlaylistSettings::instance()->useMetadata(); -} - -const QString PlayListManager::format() const -{ - return PlaylistSettings::instance()->format(); -} - -void PlayListManager::setConvertUnderscore(bool yes) -{ - PlaylistSettings::instance()->setConvertUnderscore(yes); - emit settingsChanged(); -} - -void PlayListManager::setConvertTwenty(bool yes) -{ - PlaylistSettings::instance()->setConvertTwenty(yes); - emit settingsChanged(); -} - -void PlayListManager::setUseMetadata(bool yes) -{ - PlaylistSettings::instance()->setUseMetadata(yes); - emit settingsChanged(); -} - -void PlayListManager::setFormat(const QString &format) -{ - if(format != PlaylistSettings::instance()->format()) - { - PlaylistSettings::instance()->setFormat(format); - emit settingsChanged(); - foreach(PlayListModel *model, m_models) - { - foreach(PlayListItem *item, model->items()) - item->setText(QString()); - model->doCurrentVisibleRequest(); - } - } -} - bool PlayListManager::isRepeatableList() const { return m_repeatable; diff --git a/src/qmmpui/playlistmanager.h b/src/qmmpui/playlistmanager.h index 150964428..16bf5a7c6 100644 --- a/src/qmmpui/playlistmanager.h +++ b/src/qmmpui/playlistmanager.h @@ -80,42 +80,6 @@ public: * \b i must be a valid index position in the list (i.e., 0 <= i < count()). */ PlayListModel *playListAt(int i) const; - /*! - * Returns state of the "Convert underscores to blanks" option (\b true - enabled, \b false - disabled). - */ - bool convertUnderscore() const; - /*! - * Returns state of the "Convert %20 to blanks" option (\b true - enabled, \b false - disabled). - */ - bool convertTwenty() const; - /*! - * Returns the state of metadata usage (\b true - use, \b false - not use). - */ - bool useMetadata() const; - /*! - * Returns title format string. - */ - const QString format() const; - /*! - * Sets the "Convert underscores to blanks" option state to \b enabled - * @param enabled Option state (\b true - enabled, \b false - disabled) - */ - void setConvertUnderscore(bool enabled); - /*! - * Sets the "Convert %20 to blanks" option state to \b enabled - * @param enabled Option state (\b true - enabled, \b false - disabled) - */ - void setConvertTwenty(bool enabled); - /*! - * Sets metadata usage option state to \b enabled - * @param enabled Option state (\b true - enabled, \b false - disabled) - */ - void setUseMetadata(bool enabled); - /*! - * Sets short title template. - * @param format title template. \sa MetaDataFormatter - */ - void setFormat(const QString &format); /*! * Returns state of "Repeat All" option. */ @@ -125,7 +89,6 @@ public: */ bool isShuffle() const; - signals: /*! * Emitted when current playlist changes. @@ -165,10 +128,6 @@ signals: * @param state New state of the "Shuffle" option (\b true - enabled, \b false disabled) */ void shuffleChanged(bool state); - /*! - * Emitted when other settings (format, metadata, etc) have changed. - */ - void settingsChanged(); public slots: /*! @@ -298,7 +257,6 @@ public slots: */ void stopAfterSelected(); - private: void readPlayLists(); void writePlayLists(); diff --git a/src/qmmpui/playlistmodel.cpp b/src/qmmpui/playlistmodel.cpp index f1226d2e2..50ffe35b1 100644 --- a/src/qmmpui/playlistmodel.cpp +++ b/src/qmmpui/playlistmodel.cpp @@ -36,7 +36,6 @@ #include "playlistitem.h" #include "playstate_p.h" #include "detailsdialog.h" -#include "playlistsettings_p.h" #include "playlistmodel.h" diff --git a/src/qmmpui/playlistsettings.cpp b/src/qmmpui/playlistsettings.cpp deleted file mode 100644 index c1fa58174..000000000 --- a/src/qmmpui/playlistsettings.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 by Ilya Kotov * - * forkotov02@hotmail.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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include -#include -#include "playlistsettings_p.h" - -PlaylistSettings *PlaylistSettings::m_instance = 0; - -PlaylistSettings::PlaylistSettings() -{ - QSettings s (Qmmp::configFile(), QSettings::IniFormat); - m_format = s.value("PlayList/title_format", "%p%if(%p&%t, - ,)%t").toString(); - m_convertUnderscore = s.value ("PlayList/convert_underscore", true).toBool(); - m_convertTwenty = s.value ("PlayList/convert_twenty", true).toBool(); - m_useMetadata = s.value ("PlayList/load_metadata", true).toBool(); -} - -PlaylistSettings::~PlaylistSettings() -{ - m_instance = 0; - QSettings s(Qmmp::configFile(), QSettings::IniFormat); - s.setValue("PlayList/title_format", m_format); - s.setValue("PlayList/convert_underscore", m_convertUnderscore); - s.setValue("PlayList/convert_twenty", m_convertTwenty); - s.setValue("PlayList/load_metadata", m_useMetadata); -} - -PlaylistSettings *PlaylistSettings::instance() -{ - if (!m_instance) - m_instance = new PlaylistSettings(); - return m_instance; -} - -const QString PlaylistSettings::format() const -{ - return m_format; -} - -bool PlaylistSettings::convertUnderscore() -{ - return m_convertUnderscore; -} - -bool PlaylistSettings::convertTwenty() -{ - return m_convertTwenty; -} - -bool PlaylistSettings::useMetadata() -{ - return m_useMetadata; -} - -void PlaylistSettings::setConvertUnderscore(bool yes) -{ - m_convertUnderscore = yes; -} - -void PlaylistSettings::setConvertTwenty(bool yes) -{ - m_convertTwenty = yes; -} - -void PlaylistSettings::setFormat(const QString &format) -{ - m_format = format; -} - -void PlaylistSettings::setUseMetadata(bool yes) -{ - m_useMetadata = yes; -} diff --git a/src/qmmpui/playlistsettings_p.h b/src/qmmpui/playlistsettings_p.h deleted file mode 100644 index cce4f35e1..000000000 --- a/src/qmmpui/playlistsettings_p.h +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2009 by Ilya Kotov * - * forkotov02@hotmail.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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#ifndef PLAYLISTSETTINGS_H -#define PLAYLISTSETTINGS_H - -#include - -/*! @internal - * @author Ilya Kotov - */ -class PlaylistSettings -{ -public: - PlaylistSettings(); - - ~PlaylistSettings(); - - static PlaylistSettings* instance(); - bool convertUnderscore(); - bool convertTwenty(); - bool useMetadata(); - const QString format() const; - void setConvertUnderscore(bool); - void setConvertTwenty(bool); - void setFormat(const QString &format); - void setUseMetadata(bool); - -private: - static PlaylistSettings* m_instance; - bool m_convertUnderscore, m_convertTwenty; - bool m_useMetadata; - QString m_format; - -}; - -#endif diff --git a/src/qmmpui/qmmpui.pro b/src/qmmpui/qmmpui.pro index 6535208a5..c902f44bd 100644 --- a/src/qmmpui/qmmpui.pro +++ b/src/qmmpui/qmmpui.pro @@ -32,7 +32,6 @@ HEADERS += general.h \ playstate_p.h \ fileloader_p.h \ mediaplayer.h \ - playlistsettings_p.h \ detailsdialog.h \ tageditor_p.h \ playlistmanager.h \ @@ -44,7 +43,8 @@ HEADERS += general.h \ jumptotrackdialog_p.h \ configdialog.h \ pluginitem_p.h \ - aboutdialog_p.h + aboutdialog_p.h \ + qmmpuisettings.h SOURCES += general.cpp \ playlistparser.cpp \ commandlinemanager.cpp \ @@ -55,7 +55,6 @@ SOURCES += general.cpp \ playlistitem.cpp \ fileloader.cpp \ mediaplayer.cpp \ - playlistsettings.cpp \ detailsdialog.cpp \ tageditor.cpp \ playlistmanager.cpp \ @@ -66,7 +65,8 @@ SOURCES += general.cpp \ jumptotrackdialog.cpp \ configdialog.cpp \ pluginitem.cpp \ - aboutdialog.cpp + aboutdialog.cpp \ + qmmpuisettings.cpp FORMS += forms/detailsdialog.ui \ forms/tageditor.ui \ forms/templateeditor.ui \ @@ -110,8 +110,13 @@ unix { templateeditor.h \ uifactory.h \ uiloader.h \ - uihelper.h + uihelper.h \ + qmmpuisettings.h devel.path = /include/qmmpui INSTALLS += target \ devel } + + + + diff --git a/src/qmmpui/qmmpuisettings.cpp b/src/qmmpui/qmmpuisettings.cpp new file mode 100644 index 000000000..15d0b774b --- /dev/null +++ b/src/qmmpui/qmmpuisettings.cpp @@ -0,0 +1,126 @@ +/*************************************************************************** + * Copyright (C) 2012 by Ilya Kotov * + * forkotov02@hotmail.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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include +#include "playlistmanager.h" +#include "qmmpuisettings.h" + +QmmpUiSettings *QmmpUiSettings::m_instance = 0; + +QmmpUiSettings::QmmpUiSettings(QObject *parent) : QObject(parent) +{ + m_instance = this; + QSettings s (Qmmp::configFile(), QSettings::IniFormat); + m_format = s.value("PlayList/title_format", "%p%if(%p&%t, - ,)%t").toString(); + m_convertUnderscore = s.value ("PlayList/convert_underscore", true).toBool(); + m_convertTwenty = s.value ("PlayList/convert_twenty", true).toBool(); + m_useMetadata = s.value ("PlayList/load_metadata", true).toBool(); + m_resume_on_startup = s.value("General/resume_on_startup", false).toBool(); +} + +QmmpUiSettings::~QmmpUiSettings() +{ + m_instance = 0; + sync(); +} + +const QString QmmpUiSettings::format() const +{ + return m_format; +} + +bool QmmpUiSettings::convertUnderscore() const +{ + return m_convertUnderscore; +} + +bool QmmpUiSettings::convertTwenty() const +{ + return m_convertTwenty; +} + +bool QmmpUiSettings::useMetadata() const +{ + return m_useMetadata; +} + +void QmmpUiSettings::setConvertUnderscore(bool yes) +{ + m_convertUnderscore = yes; +} + +void QmmpUiSettings::setConvertTwenty(bool yes) +{ + m_convertTwenty = yes; +} + +void QmmpUiSettings::setFormat(const QString &format) +{ + m_format = format; + if(format != m_format) + { + m_format = format; + //emit settingsChanged(); + foreach(PlayListModel *model, PlayListManager::instance()->playLists()) + { + foreach(PlayListItem *item, model->items()) + item->setText(QString()); + model->doCurrentVisibleRequest(); + } + } +} + +void QmmpUiSettings::setUseMetadata(bool yes) +{ + m_useMetadata = yes; +} + +bool QmmpUiSettings::resumeOnStartup() const +{ + return m_resume_on_startup; +} + +void QmmpUiSettings::setResumeOnStartup(bool enabled) +{ + m_resume_on_startup = enabled; +} + +void QmmpUiSettings::sync() +{ + QSettings s(Qmmp::configFile(), QSettings::IniFormat); + s.setValue("PlayList/title_format", m_format); + s.setValue("PlayList/convert_underscore", m_convertUnderscore); + s.setValue("PlayList/convert_twenty", m_convertTwenty); + s.setValue("PlayList/load_metadata", m_useMetadata); + s.setValue("General/resume_on_startup", m_resume_on_startup); +} + +QmmpUiSettings * QmmpUiSettings::instance() +{ + if(!m_instance) + return new QmmpUiSettings(qApp); + return m_instance; +} + + + + diff --git a/src/qmmpui/qmmpuisettings.h b/src/qmmpui/qmmpuisettings.h new file mode 100644 index 000000000..f7cf65de2 --- /dev/null +++ b/src/qmmpui/qmmpuisettings.h @@ -0,0 +1,117 @@ +/*************************************************************************** + * Copyright (C) 2012 by Ilya Kotov * + * forkotov02@hotmail.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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef QMMPUISETTINGS_H +#define QMMPUISETTINGS_H + +#include + +/*! @brief The QmmpUiSettings class provides access to global libqmmpui library settings. + * @author Ilya Kotov + */ +class QmmpUiSettings : public QObject +{ + Q_OBJECT +public: + /*! + * Constructor. + * @param parent Parent object. + * This functions is for internal usage only, use QmmpSettings::instance() instead. + */ + explicit QmmpUiSettings(QObject *parent = 0); + /*! + * Destructor. + */ + virtual ~QmmpUiSettings(); + /*! + * Returns state of the "Convert underscores to blanks" option (\b true - enabled, \b false - disabled). + */ + bool convertUnderscore() const; + /*! + * Returns state of the "Convert %20 to blanks" option (\b true - enabled, \b false - disabled). + */ + bool convertTwenty() const; + /*! + * Returns the state of metadata usage (\b true - use, \b false - not use). + */ + bool useMetadata() const; + /*! + * Returns title format string. + */ + const QString format() const; + /*! + * Sets the "Convert underscores to blanks" option state to \b enabled + * @param enabled Option state (\b true - enabled, \b false - disabled) + */ + void setConvertUnderscore(bool enabled); + /*! + * Sets the "Convert %20 to blanks" option state to \b enabled + * @param enabled Option state (\b true - enabled, \b false - disabled) + */ + void setConvertTwenty(bool enabled); + /*! + * Sets short title template. + * @param format title template. \sa MetaDataFormatter + */ + void setFormat(const QString &format); + /*! + * Sets metadata usage option state to \b enabled + * @param enabled Option state (\b true - enabled, \b false - disabled) + */ + void setUseMetadata(bool enabled); + /*! + * Returns \b true if option "Resume On Startup" is enabled, otherwise returns \b false + */ + bool resumeOnStartup() const; + /*! + * Sets the "Resume on startup" option state to \b enabled + * @param enabled Option state (\b true - enabled, \b false - disabled) + */ + void setResumeOnStartup(bool enabled); + /*! + * Returns a pointer to the QmmpUiSettings instance. + */ + static QmmpUiSettings* instance(); + +signals: + /*! + * Emitted when other settings (format, metadata, etc) have changed. + */ + //void settingsChanged(); + +public slots: + /*! + * Writes all unsaved settings to configuration file + */ + void sync(); + + +private: + static QmmpUiSettings* m_instance; + //playlist + bool m_convertUnderscore, m_convertTwenty; + bool m_useMetadata; + QString m_format; + //general + bool m_resume_on_startup; + +}; + +#endif // QMMPUISETTINGS_H diff --git a/src/qmmpui/translations/libqmmpui_cs.ts b/src/qmmpui/translations/libqmmpui_cs.ts index b762a1c7c..5d189dd85 100644 --- a/src/qmmpui/translations/libqmmpui_cs.ts +++ b/src/qmmpui/translations/libqmmpui_cs.ts @@ -87,93 +87,93 @@ Soubor - + Artist Umělec - - + + Album Album - + Track Stopa - + Disabled Vypnuto - + Transports Protokoly - + Decoders Dekodéry - + Engines Přehrávače - + Title Název - + Track number Číslo stopy - + Two-digit track number Dvoumístné číslo stopy - + Disc number Číslo disku - + Condition Stav - + Composer Skladatel - + File name Název souboru - + File path Cesta k souboru - + Genre Žánr - + Year Rok - + Comment Poznámka @@ -389,17 +389,17 @@ Heslo: - + Visualization Vizualizace - + Effects Efekty - + General Obecné @@ -560,8 +560,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist Seznam skladeb diff --git a/src/qmmpui/translations/libqmmpui_de.ts b/src/qmmpui/translations/libqmmpui_de.ts index 6014b72bb..fe50fc46f 100644 --- a/src/qmmpui/translations/libqmmpui_de.ts +++ b/src/qmmpui/translations/libqmmpui_de.ts @@ -87,93 +87,93 @@ Dateiname - + Artist Interpret - - + + Album Album - + Track Stück - + Disabled Deaktiviert - + Transports Transporte - + Decoders Dekoder - + Engines - + Title Titel - + Track number Stücknummer - + Two-digit track number Zweistellige Stücknummer - + Disc number CD-Nummer - + Condition Zustand - + Genre Genre - + Composer Komponist - + File name Dateiname - + File path Dateipfad - + Year Jahr - + Comment Kommentar @@ -389,17 +389,17 @@ Passwort: - + Visualization Visualisierung - + Effects Effekte - + General Sonstige @@ -560,8 +560,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist Wiedergabeliste diff --git a/src/qmmpui/translations/libqmmpui_es.ts b/src/qmmpui/translations/libqmmpui_es.ts index 19e6117a5..5be6788a1 100644 --- a/src/qmmpui/translations/libqmmpui_es.ts +++ b/src/qmmpui/translations/libqmmpui_es.ts @@ -87,93 +87,93 @@ Nombre del archivo - + Artist Intérprete - - + + Album Album - + Track Pista - + Disabled Deshabilitado - + Transports Transportes - + Decoders Decodificadores - + Engines Motores - + Title Título - + Track number Número de pista - + Two-digit track number Número de pista con dos cifras - + Disc number Número de disco - + Condition Condición - + Genre Género - + Composer Compositor - + File name Nombre del archivo - + File path Ruta del archivo - + Year Año - + Comment Comentario @@ -242,17 +242,17 @@ Conectividad - + Visualization Visualización - + Effects Efectos - + General General @@ -560,8 +560,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist Lista de reproducción diff --git a/src/qmmpui/translations/libqmmpui_it.ts b/src/qmmpui/translations/libqmmpui_it.ts index 8c79a9ee9..b67aeebe3 100644 --- a/src/qmmpui/translations/libqmmpui_it.ts +++ b/src/qmmpui/translations/libqmmpui_it.ts @@ -87,93 +87,93 @@ File - + Artist Interprete - - + + Album Album - + Track Traccia - + Disabled Disabilitato - + Transports Protocolli di trasporto - + Decoders Decodificatori - + Engines Meccanismi - + Title Titolo - + Track number Traccia n° - + Two-digit track number Traccia n° a due cifre - + Disc number Disco n° - + Condition Condizione - + Genre Genere - + Composer Compositore - + File name Nome file - + File path Percorso file - + Year Anno - + Comment Commento @@ -242,17 +242,17 @@ Connettività - + Visualization Visualizzazione - + Effects Effetti - + General Generale @@ -560,8 +560,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist Lista esecuzione diff --git a/src/qmmpui/translations/libqmmpui_ja.ts b/src/qmmpui/translations/libqmmpui_ja.ts index 56f8b2bc2..5c32d3b85 100644 --- a/src/qmmpui/translations/libqmmpui_ja.ts +++ b/src/qmmpui/translations/libqmmpui_ja.ts @@ -319,108 +319,108 @@ 16ビット出力 - + Track トラック - - + + Album アルバム - + Disabled 無効 - + Transports 転送 - + Decoders デコーダー - + Engines エンジン - + Effects 音響効果 - + Visualization 視覚効果 - + General 一般 - + Artist アーティスト - + Title タイトル - + Track number トラック番号 - + Two-digit track number トラック番号 数字2桁 - + Genre ジャンル - + Comment コメント - + Composer 作曲者 - + Disc number ディスク番号 - + File name ファイル名 - + File path ファイルパス - + Year - + Condition 定番 @@ -560,8 +560,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist プレイリスト diff --git a/src/qmmpui/translations/libqmmpui_lt.ts b/src/qmmpui/translations/libqmmpui_lt.ts index 0f6eb236f..5ed04b867 100644 --- a/src/qmmpui/translations/libqmmpui_lt.ts +++ b/src/qmmpui/translations/libqmmpui_lt.ts @@ -87,93 +87,93 @@ Bylos pavadinimas - + Artist Atlikėjas - - + + Album Albumas - + Track Takelis - + Disabled Išjungta - + Transports Transportas - + Decoders Dekoderiai - + Engines Varikliai - + Title Pavadinimas - + Track number Takelio numeris - + Two-digit track number Dviejų skaičių takelio numeris - + Disc number Disko numeris - + Condition Būklė - + Composer Autorius - + File name Bylos pavadinimas - + File path Bylos kelias - + Genre Žanras - + Year Metai - + Comment Komentaras @@ -242,17 +242,17 @@ Tinklas - + Visualization Vizualizacija - + Effects Efektai - + General Bendri @@ -561,8 +561,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist Grojaraštis diff --git a/src/qmmpui/translations/libqmmpui_nl.ts b/src/qmmpui/translations/libqmmpui_nl.ts index 3acfa0c27..831a307b5 100644 --- a/src/qmmpui/translations/libqmmpui_nl.ts +++ b/src/qmmpui/translations/libqmmpui_nl.ts @@ -87,93 +87,93 @@ Bestandsnaam - + Artist Artiest - - + + Album Album - + Track Nummer - + Disabled Uitgeschakeld - + Transports Protocols - + Decoders Decoders - + Engines Engines - + Title Naam - + Track number Liednummer - + Two-digit track number Twee-getal liednummer - + Disc number CD nummer - + Condition Staat - + Composer Componist - + File name Bestandsnaam - + File path Pad - + Genre Genre - + Year Jaar - + Comment Commentaar @@ -389,17 +389,17 @@ Proxy wachtwoord: - + Visualization Visualisatie - + Effects Effecten - + General Algemeen @@ -560,8 +560,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist Afspeellijst diff --git a/src/qmmpui/translations/libqmmpui_pl_PL.ts b/src/qmmpui/translations/libqmmpui_pl_PL.ts index 60314728d..a7a468365 100644 --- a/src/qmmpui/translations/libqmmpui_pl_PL.ts +++ b/src/qmmpui/translations/libqmmpui_pl_PL.ts @@ -87,93 +87,93 @@ Nazwa pliku - + Artist Artysta - - + + Album Album - + Track Utwór - + Disabled Wyłączone - + Transports Transporty - + Decoders Dekodery - + Engines Silniki - + Title Tytuł - + Track number Numer utworu - + Two-digit track number Dwuznakowy numer utworu - + Disc number Numer albumu - + Condition Warunek - + Genre Gatunek - + Composer Kompozytor - + File name Nazwa pliku - + File path Lokalizacja - + Year Rok - + Comment Komentarz @@ -242,17 +242,17 @@ Sieć - + Visualization Wizualizacje - + Effects Efekty - + General Ogólne @@ -556,8 +556,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist Lista odtwarzania diff --git a/src/qmmpui/translations/libqmmpui_pt_BR.ts b/src/qmmpui/translations/libqmmpui_pt_BR.ts index dccd2488d..b90281ace 100644 --- a/src/qmmpui/translations/libqmmpui_pt_BR.ts +++ b/src/qmmpui/translations/libqmmpui_pt_BR.ts @@ -87,93 +87,93 @@ Nome do Arquivo - + Artist Artista - - + + Album Álbum - + Track - + Disabled - + Transports - + Decoders - + Engines - + Title Título - + Track number - + Two-digit track number - + Disc number - + Condition - + Genre Gênero - + Composer - + File name - + File path - + Year Ano - + Comment Comentário @@ -242,17 +242,17 @@ - + Visualization - + Effects - + General @@ -556,8 +556,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist Lista de músicas diff --git a/src/qmmpui/translations/libqmmpui_ru.ts b/src/qmmpui/translations/libqmmpui_ru.ts index c9b5101bd..f58524a86 100644 --- a/src/qmmpui/translations/libqmmpui_ru.ts +++ b/src/qmmpui/translations/libqmmpui_ru.ts @@ -87,93 +87,93 @@ Имя файла - + Artist Исполнитель - - + + Album Альбом - + Track Дорожка - + Disabled Отключено - + Transports Транспорты - + Decoders Декодеры - + Engines Внешние проигрыватели - + Title Название - + Track number Номер трека - + Two-digit track number 2-x разрядный номер трека - + Disc number Номер диска - + Condition Условие - + Genre Жанр - + Composer Композитор - + File name Имя файла - + File path Путь к файлу - + Year Год - + Comment Комментарий @@ -242,17 +242,17 @@ Сеть - + Visualization Визуализация - + Effects Эффекты - + General Общие @@ -556,8 +556,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist Список diff --git a/src/qmmpui/translations/libqmmpui_sk.ts b/src/qmmpui/translations/libqmmpui_sk.ts index 8705f2493..bfcd253a2 100644 --- a/src/qmmpui/translations/libqmmpui_sk.ts +++ b/src/qmmpui/translations/libqmmpui_sk.ts @@ -87,93 +87,93 @@ Názov súboru - + Artist Interprét - - + + Album Album - + Track Skladba - + Disabled Zakázané - + Transports Protokoly - + Decoders Dekodéry - + Engines Prehrávače - + Title Názov - + Track number Číslo skladby - + Two-digit track number Dvojmiestne číslo skladby - + Disc number Číslo disku - + Condition Stav - + Composer Skladateľ - + File name Názov súboru - + File path Cesta k súboru - + Genre Žáner - + Year Rok - + Comment Poznámka @@ -389,17 +389,17 @@ Proxy heslo: - + Visualization Vizualizácie - + Effects Efekty - + General Všeobecné @@ -556,8 +556,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist Playlist diff --git a/src/qmmpui/translations/libqmmpui_tr.ts b/src/qmmpui/translations/libqmmpui_tr.ts index 642b6e702..b94868f2d 100644 --- a/src/qmmpui/translations/libqmmpui_tr.ts +++ b/src/qmmpui/translations/libqmmpui_tr.ts @@ -87,93 +87,93 @@ Dosya adı - + Artist Sanatçı - - + + Album Albüm - + Track - + Disabled - + Transports - + Decoders - + Engines - + Title Başlık - + Track number - + Two-digit track number - + Disc number - + Condition - + Genre Tarz - + Composer - + File name - + File path - + Year Yıl - + Comment Yorum @@ -242,17 +242,17 @@ Bağlanırlık - + Visualization Görsellik - + Effects Efektler - + General Genel @@ -556,8 +556,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist Çalma Listesi diff --git a/src/qmmpui/translations/libqmmpui_uk_UA.ts b/src/qmmpui/translations/libqmmpui_uk_UA.ts index 10df37afc..a350888fe 100644 --- a/src/qmmpui/translations/libqmmpui_uk_UA.ts +++ b/src/qmmpui/translations/libqmmpui_uk_UA.ts @@ -87,93 +87,93 @@ Ім'я файлу - + Artist Виконавець - - + + Album Альбом - + Track Трек - + Disabled Вимкнено - + Transports Транспорти - + Decoders Декодери - + Engines Зовнішні програвачі - + Title Назва - + Track number Номер треку - + Two-digit track number 2- розрядний номер трека - + Disc number Номер диску - + Condition Умова - + Genre Жанр - + Composer Композитор - + File name Ім'я файлу - + File path Шлях файлу - + Year Рік - + Comment Коментар @@ -242,17 +242,17 @@ Мережа - + Visualization Візуалізація - + Effects Ефекти - + General Загальне @@ -556,8 +556,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist Список diff --git a/src/qmmpui/translations/libqmmpui_zh_CN.ts b/src/qmmpui/translations/libqmmpui_zh_CN.ts index 12c553196..3aeafe3d2 100644 --- a/src/qmmpui/translations/libqmmpui_zh_CN.ts +++ b/src/qmmpui/translations/libqmmpui_zh_CN.ts @@ -87,93 +87,93 @@ 文件名 - + Artist 艺术家 - - + + Album 专辑 - + Track 音轨 - + Disabled - + Transports - + Decoders - + Engines - + Title 标题 - + Track number 音轨编号 - + Two-digit track number 两位数音轨编号 - + Disc number 光盘编号 - + Condition 条件 - + Genre 流派 - + Composer 作曲 - + File name 文件名 - + File path 文件路径 - + Year 年代 - + Comment 备注 @@ -242,17 +242,17 @@ 连接 - + Visualization 可视化 - + Effects 特效 - + General 常规 @@ -556,8 +556,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist 播放列表 diff --git a/src/qmmpui/translations/libqmmpui_zh_TW.ts b/src/qmmpui/translations/libqmmpui_zh_TW.ts index 146ce2d1d..91e589b6d 100644 --- a/src/qmmpui/translations/libqmmpui_zh_TW.ts +++ b/src/qmmpui/translations/libqmmpui_zh_TW.ts @@ -87,93 +87,93 @@ 檔名 - + Artist 藝術家 - - + + Album 專輯 - + Track 音軌 - + Disabled - + Transports - + Decoders - + Engines - + Title 標題 - + Track number 音軌編號 - + Two-digit track number 兩位數音軌編號 - + Disc number 光槃編號 - + Condition 條件 - + Genre 流派 - + Composer 作曲 - + File name 文件名 - + File path 文件路徑 - + Year 年代 - + Comment 備註 @@ -242,17 +242,17 @@ 連線 - + Visualization 可視化 - + Effects 特效 - + General 常規 @@ -556,8 +556,8 @@ p, li { white-space: pre-wrap; } PlayListManager - - + + Playlist 播放清單 -- cgit v1.2.3-13-gbd6f