Skip to content

Commit

Permalink
Cleaned code
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitij98 committed May 20, 2018
1 parent dff05c8 commit d62acfb
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 367 deletions.
17 changes: 6 additions & 11 deletions src/preferences/dialog/dlgprefeffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
// }
}
74 changes: 26 additions & 48 deletions src/preferences/dialog/dlgprefeffectsdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -44,61 +44,39 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTableView" name="availableEffectsList">


<!-- <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
-->

<!-- <property name="minimumSize"> -->
<!-- <size> -->
<!-- <width>0</width> -->
<!-- <height>0</height> -->
<!-- </size> -->
<!-- </property> -->
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<!-- <property name="alternatingRowColors">
<bool>false</bool>
<property name="styleSheet">
<string notr="true"/>
</property>
-->
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>true</bool>
</property>
<property name="gridStyle">
<enum>Qt::NoPen</enum>
</property>
<attribute name="horizontalHeaderHighlightSections">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderHighlightSections">
<bool>false</bool>
</attribute>


<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>true</bool>
</property>
<property name="gridStyle">
<enum>Qt::NoPen</enum>
</property>
<attribute name="horizontalHeaderHighlightSections">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderHighlightSections">
<bool>false</bool>
</attribute>
</widget>
</item>
<item>
Expand Down
158 changes: 7 additions & 151 deletions src/preferences/effectprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("<b>Error with settings for '%1':</b><br>")
// .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;
}
Loading

0 comments on commit d62acfb

Please sign in to comment.