diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index f35731cb8ffe..7ce6932b8825 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -43,15 +43,18 @@ void DlgPrefEffects::slotUpdate() { } void DlgPrefEffects::slotApply() { - // Nothing to apply. + for (EffectProfilePtr profile : m_pAvailableEffectsModel->profiles()) { + EffectManifest* pManifest = profile->getManifest(); + pManifest->setVisibility(profile->isVisible()); + m_pConfig->set(ConfigKey("[Visible Effects]", pManifest->id()), ConfigValue(profile->isVisible())); + } } void DlgPrefEffects::slotResetToDefaults() { - // Nothing to reset. + slotUpdate(); } void DlgPrefEffects::clear() { - availableEffectsList->clear(); effectName->clear(); effectAuthor->clear(); effectDescription->clear(); @@ -78,12 +81,4 @@ void DlgPrefEffects::availableEffectsListItemSelected(const QModelIndex& selecte } else { effectType->clear(); } - - // setValuesToProfile(m_pProfileListSelection); - // BroadcastProfilePtr profile = - // m_pSettingsModel->getProfileByName(selectedName); - // if(profile) { - // getValuesFromProfile(profile); - // m_pProfileListSelection = profile; - // } } diff --git a/src/preferences/dialog/dlgprefeffectsdlg.ui b/src/preferences/dialog/dlgprefeffectsdlg.ui index b8cfa7f5fc22..89f4e848fb0b 100644 --- a/src/preferences/dialog/dlgprefeffectsdlg.ui +++ b/src/preferences/dialog/dlgprefeffectsdlg.ui @@ -44,61 +44,39 @@ - - - - - - - - - - 300 16777215 - - - - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - Qt::NoPen - - - true - - - true - - - false - - - false - - - + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + Qt::NoPen + + + true + + + true + + + false + + + false + diff --git a/src/preferences/effectprofile.cpp b/src/preferences/effectprofile.cpp index d381d350d861..416f3cee106b 100644 --- a/src/preferences/effectprofile.cpp +++ b/src/preferences/effectprofile.cpp @@ -20,177 +20,33 @@ using namespace QKeychain; #include "preferences/effectprofile.h" namespace { -// const char* kDoctype = "Effectprofile"; -// const char* kDocumentRoot = "EffectProfile"; -// const char* kSecureCredentials = "SecureCredentialsStorage"; -// const char* kBitrate = "Bitrate"; -// const char* kChannels = "Channels"; -// const char* kCustomArtist = "CustomArtist"; -// const char* kCustomTitle = "CustomTitle"; -// const char* kEnableMetadata = "EnableMetadata"; -// const char* kEnableReconnect = "EnableReconnect"; -// const char* kEnabled = "Enabled"; -// const char* kFormat = "Format"; -// const char* kHost = "Host"; -// const char* kLimitReconnects = "LimitReconnects"; -// const char* kLogin = "Login"; -// const char* kMaximumRetries = "MaximumRetries"; -// const char* kMetadataCharset = "MetadataCharset"; -// const char* kMetadataFormat = "MetadataFormat"; -// const char* kMountPoint = "Mountpoint"; -// const char* kNoDelayFirstReconnect = "NoDelayFirstReconnect"; -// const char* kOggDynamicUpdate = "OggDynamicUpdate"; -// const char* kPassword = "Password"; -// const char* kPort = "Port"; -// const char* kReconnectFirstDelay = "ReconnectFirstDelay"; -// const char* kReconnectPeriod = "ReconnectPeriod"; -// const char* kServertype = "Servertype"; -// const char* kStreamDesc = "StreamDesc"; -// const char* kStreamGenre = "StreamGenre"; -// const char* kStreamName = "StreamName"; -// const char* kStreamPublic = "StreamPublic"; -// const char* kStreamWebsite = "StreamWebsite"; - -// #ifdef __QTKEYCHAIN__ -// const char* kKeychainPrefix = "Mixxx - "; -// #endif - -// const double kDefaultBitrate = 128; -// const int kDefaultChannels = 2; -// const bool kDefaultEnableMetadata = false; -// const bool kDefaultEnableReconnect = true; -// const bool kDefaultLimitReconnects = true; -// const int kDefaultMaximumRetries = 10; -// // No tr() here, see https://bugs.launchpad.net/mixxx/+bug/1419500 -// const QString kDefaultMetadataFormat("$artist - $title"); -// const bool kDefaultNoDelayFirstReconnect = true; -// const bool kDefaultOggDynamicupdate = false; -// double kDefaultReconnectFirstDelay = 0.0; -// double kDefaultReconnectPeriod = 5.0; -// const QString kDefaultStreamDesc = -// QObject::tr("This stream is online for testing purposes!"); -// const QString kDefaultStreamGenre = QObject::tr("Live Mix"); -// const bool kDefaultStreamPublic = false; - -// const QRegExp kForbiddenChars = -// QRegExp("[<>:\"\\/|?*\\\\]|(\\.\\.)" -// "|CON|AUX|PRN|COM(\\d+)|LPT(\\d+)|NUL"); - const mixxx::Logger kLogger("EffectProfile"); } // anonymous namespace EffectProfile::EffectProfile(EffectManifest &pManifest, QObject* parent) : QObject(parent) { - // adoptDefaultValues(); - // Direct assignment to avoid triggering the - // profileNameChanged signal - m_effectId = pManifest.id(); - m_displayName = pManifest.displayName(); m_isVisible = pManifest.isVisible(); - // m_pManifest = &pManifest; + m_pManifest = &pManifest; } -// bool EffectProfile::validName(const QString& str) { -// return !str.contains(kForbiddenChars); -// } - -// BroadcastProfilePtr EffectProfile::loadFromFile( -// const QString& filename) { -// QFileInfo xmlFile(filename); -// if(!xmlFile.exists()) -// return BroadcastProfilePtr(nullptr); - -// QString profileFilename = xmlFile.baseName(); -// // The profile filename (without extension) is used to create the instance -// // but the real profile name (with forbidden chars but suitable for -// // non-filesystem uses) will be fetched from the XML file and set in the -// // object during the call to loadValues() -// BroadcastProfilePtr profile(new EffectProfile(profileFilename)); -// profile->loadValues(filename); -// return profile; -// } - -// bool EffectProfile::equals(BroadcastProfilePtr other) { -// return ((getProfileName() == other->getProfileName()) -// && valuesEquals(other)); -// } - -// bool EffectProfile::valuesEquals(BroadcastProfilePtr other) { -// if(getEnabled() == other->getEnabled() -// && secureCredentialStorage() == other->secureCredentialStorage()) -// return true; -// } - -// return false; -// } - -// BroadcastProfilePtr EffectProfile::valuesCopy() { -// BroadcastProfilePtr newProfile( -// new EffectProfile(getProfileName())); -// copyValuesTo(newProfile); -// return newProfile; -// } - -// void EffectProfile::copyValuesTo(BroadcastProfilePtr other) { -// } - -// void EffectProfile::adoptDefaultValues() { -// } - -// bool EffectProfile::loadValues(const QString& filename) { - // Load from manifest -// } - -// bool EffectProfile::save(const QString& filename) { - // Save to effectManifest -// } - -// void EffectProfile::setProfileName(const QString &profileName) { -// QString oldName(m_profileName); -// m_profileName = QString(profileName); - -// emit profileNameChanged(oldName, m_profileName); -// } - QString EffectProfile::getEffectId() const { - return m_effectId; + return m_pManifest->id(); } QString EffectProfile::getDisplayName() const { - return m_displayName; + return m_pManifest->displayName(); } -// void EffectProfile::errorDialog(QString text, QString detailedError) { -// ErrorDialogProperties* props = ErrorDialogHandler::instance()->newDialogProperties(); -// props->setType(DLG_WARNING); -// props->setTitle(tr("Settings error")); -// props->setText(tr("Error with settings for '%1':
") -// .arg(getProfileName()) + text); -// props->setDetails(detailedError); -// props->setKey(detailedError); // To prevent multiple windows for the same error -// props->setDefaultButton(QMessageBox::Close); -// props->setModal(false); -// ErrorDialogHandler::instance()->requestErrorDialog(props); -// } - -// void EffectProfile::relayStatus(bool newStatus) { -// setEnabled(newStatus); -// } - -// // Used by BroadcastSettings to relay connection status -// // to copies in BroadcastSettingsModel -// void EffectProfile::relayConnectionStatus(int newConnectionStatus) { -// setConnectionStatus(newConnectionStatus); -// } - bool EffectProfile::isVisible() const { return m_isVisible; } void EffectProfile::setVisibility(bool value) { m_isVisible = value; - // TODO(Kshitij): Emit status changed - // emit statusChanged(m_enabled); +} + +EffectManifest* EffectProfile::getManifest() const { + return m_pManifest; } \ No newline at end of file diff --git a/src/preferences/effectprofile.h b/src/preferences/effectprofile.h index 0b1661e317f8..ac4e4c77a8f5 100644 --- a/src/preferences/effectprofile.h +++ b/src/preferences/effectprofile.h @@ -23,127 +23,11 @@ class EffectProfile : public QObject { QString getDisplayName() const; bool isVisible() const; void setVisibility(bool value); + EffectManifest* getManifest() const; private: - QString m_effectId; - QString m_displayName; bool m_isVisible; - // EffectManifest* m_pManifest; - - - // bool save(const QString& filename); - // bool equals(EffectProfilePtr other); - // bool valuesEquals(EffectProfilePtr other); - // EffectProfilePtr valuesCopy(); - // void copyValuesTo(EffectProfilePtr other); - - // static EffectProfilePtr loadFromFile(const QString& filename); - // static bool validName(const QString& str); - // static QString stripForbiddenChars(const QString& str); - - // void setConnectionStatus(int newState); - // int connectionStatus(); - - // void setSecureCredentialStorage(bool enabled); - // bool secureCredentialStorage(); - - // void setProfileName(const QString& profileName); - // QString getProfileName() const; - - // bool getEnabled() const; - // void setEnabled(bool value); - - // QString getHost() const; - // void setHost(const QString& value); - - // int getPort() const; - // void setPort(int value); - - // QString getServertype() const; - // void setServertype(const QString& value); - - // QString getLogin() const; - // void setLogin(const QString& value); - - // QString getPassword() const; - // void setPassword(const QString& value); - - // bool getEnableReconnect() const; - // void setEnableReconnect(bool value); - - // double getReconnectPeriod() const; - // void setReconnectPeriod(double value); - - // bool getLimitReconnects() const; - // void setLimitReconnects(bool value); - - // int getMaximumRetries() const; - // void setMaximumRetries(int value); - - // bool getNoDelayFirstReconnect() const; - // void setNoDelayFirstReconnect(bool value); - - // double getReconnectFirstDelay() const; - // void setReconnectFirstDelay(double value); - - // QString getFormat() const; - // void setFormat(const QString& value); - - // int getBitrate() const; - // void setBitrate(int value); - - // int getChannels() const; - // void setChannels(int value); - - // QString getMountpoint() const; - // void setMountPoint(const QString& value); - - // QString getStreamName() const; - // void setStreamName(const QString& value); - - // QString getStreamDesc() const; - // void setStreamDesc(const QString& value); - - // QString getStreamGenre() const; - // void setStreamGenre(const QString& value); - - // bool getStreamPublic() const; - // void setStreamPublic(bool value); - - // QString getStreamWebsite() const; - // void setStreamWebsite(const QString& value); - - // bool getEnableMetadata() const; - // void setEnableMetadata(bool value); - - // QString getMetadataCharset() const; - // void setMetadataCharset(const QString& value); - - // QString getCustomArtist() const; - // void setCustomArtist(const QString& value); - - // QString getCustomTitle() const; - // void setCustomTitle(const QString& value); - - // QString getMetadataFormat() const; - // void setMetadataFormat(const QString& value); - - // bool getOggDynamicUpdate() const; - // void setOggDynamicUpdate(bool value); - - // signals: - // void profileNameChanged(QString oldName, QString newName); - // void statusChanged(bool newStatus); - // void connectionStatusChanged(int newConnectionStatus); - - // public slots: - // void relayStatus(bool newStatus); - // void relayConnectionStatus(int newConnectionStatus); - - // private: - // void adoptDefaultValues(); - // bool loadValues(const QString& filename); - + EffectManifest* m_pManifest; }; #endif // EFFECTPROFILE_H diff --git a/src/preferences/effectsettingsmodel.cpp b/src/preferences/effectsettingsmodel.cpp index d72ad4b34c20..c1d0ff8745e6 100644 --- a/src/preferences/effectsettingsmodel.cpp +++ b/src/preferences/effectsettingsmodel.cpp @@ -24,13 +24,7 @@ void EffectSettingsModel::resetFromEffectManager(EffectsManager* pEffectsManager m_profiles.clear(); for(EffectManifestPointer pManifest : pEffectsManager->getAvailableEffectManifests()) { - qDebug() << "Manifest: " << pManifest->id(); - // EffectProfilePtr copy = profile->valuesCopy(); - // copy->setConnectionStatus(profile->connectionStatus()); - // connect(profile.data(), SIGNAL(statusChanged(bool)), - // copy.data(), SLOT(relayStatus(bool))); - // connect(profile.data(), SIGNAL(connectionStatusChanged(int)), - // copy.data(), SLOT(relayConnectionStatus(int))); + // qDebug() << "Manifest: " << pManifest->id(); addProfileToModel(EffectProfilePtr(new EffectProfile(*pManifest))); } } @@ -42,15 +36,6 @@ bool EffectSettingsModel::addProfileToModel(EffectProfilePtr profile) { int position = m_profiles.size(); beginInsertRows(QModelIndex(), position, position); -// // It is best to avoid using QSharedPointer::data(), especially when -// // passing it to another function, as it puts the associated pointer -// // at risk of being manually deleted. -// // However it's fine with Qt's connect because it can be trusted that -// // it won't delete the pointer. -// connect(profile.data(), SIGNAL(profileNameChanged(QString, QString)), -// this, SLOT(onProfileNameChanged(QString,QString))); -// connect(profile.data(), SIGNAL(connectionStatusChanged(int)), -// this, SLOT(onConnectionStatusChanged(int))); m_profiles.insert(profile->getEffectId(), EffectProfilePtr(profile)); endInsertRows(); @@ -69,11 +54,6 @@ void EffectSettingsModel::deleteProfileFromModel(EffectProfilePtr profile) { m_profiles.remove(profile->getEffectId()); } -// EffectProfilePtr EffectSettingsModel::getProfileByName( -// const QString& profileName) { -// return m_profiles.value(profileName, EffectProfilePtr()); -// } - int EffectSettingsModel::rowCount(const QModelIndex& parent) const { Q_UNUSED(parent); return m_profiles.size(); @@ -141,13 +121,6 @@ bool EffectSettingsModel::setData(const QModelIndex& index, const QVariant& valu if(index.column() == kColumnEnabled && role == Qt::CheckStateRole) { profile->setVisibility(value.toBool()); } - // if(index.column() == kColumnName && role == Qt::EditRole) { - // QString newName = value.toString(); - // newName = newName.trimmed(); - - // if(!newName.isNull() && !newName.isEmpty()) - // profile->setProfileName(newName); - // } } } return true; @@ -162,11 +135,3 @@ QAbstractItemDelegate* EffectSettingsModel::delegateForColumn(const int i, QObje bool EffectSettingsModel::isEmpty() const { return m_profiles.isEmpty(); } - -// void EffectSettingsModel::onVisibilityChange(bool newStatus) { -// Q_UNUSED(newStatus); -// // Refresh the whole visibility column -// QModelIndex start = this->index(0, kColumnEnabled); -// QModelIndex end = this->index(this->rowCount()-1, kColumnEnabled); -// emit dataChanged(start, end); -// } diff --git a/src/preferences/effectsettingsmodel.h b/src/preferences/effectsettingsmodel.h index 37a145eea00a..a7462d6564c5 100644 --- a/src/preferences/effectsettingsmodel.h +++ b/src/preferences/effectsettingsmodel.h @@ -22,7 +22,6 @@ class EffectSettingsModel : public QAbstractTableModel { bool addProfileToModel(EffectProfilePtr profile); void deleteProfileFromModel(EffectProfilePtr profile); - // EffectProfilePtr getProfileByName(const QString& profileName); QList profiles() { return m_profiles.values(); } @@ -38,8 +37,6 @@ class EffectSettingsModel : public QAbstractTableModel { QAbstractItemDelegate* delegateForColumn(const int i, QObject* parent); bool isEmpty() const; - // private slots: - // void onVisibilityChange(bool newStatus); private: QMap m_profiles;