Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions src/controllers/dlgprefcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,24 @@ QString DlgPrefController::presetManualLink(
return url;
}

QString DlgPrefController::presetScriptFileLinks(
QString DlgPrefController::presetFileLinks(
const ControllerPresetPointer pPreset) const {
if (!pPreset || pPreset->getScriptFiles().empty()) {
return tr("No Scripts");
if (!pPreset) {
return QString();
}

const QString builtinFileSuffix = QStringLiteral(" (") + tr("built-in") + QStringLiteral(")");
QString systemPresetPath = resourcePresetsPath(m_pConfig);
QStringList linkList;
QString xmlFileName = QFileInfo(pPreset->filePath()).fileName();
QString xmlFileLink = QStringLiteral("<a href=\"") +
pPreset->filePath() + QStringLiteral("\">") +
xmlFileName + QStringLiteral("</a>");
if (pPreset->filePath().startsWith(systemPresetPath)) {
xmlFileLink += builtinFileSuffix;
}
linkList << xmlFileLink;

for (const auto& script : pPreset->getScriptFiles()) {
QString scriptFileLink = QStringLiteral("<a href=\"") +
script.file.absoluteFilePath() + QStringLiteral("\">") +
Expand All @@ -289,8 +299,7 @@ QString DlgPrefController::presetScriptFileLinks(
QStringLiteral(" (") + tr("missing") + QStringLiteral(")");
} else if (script.file.absoluteFilePath().startsWith(
systemPresetPath)) {
scriptFileLink +=
QStringLiteral(" (") + tr("built-in") + QStringLiteral(")");
scriptFileLink += builtinFileSuffix;
}

linkList << scriptFileLink;
Expand Down Expand Up @@ -475,7 +484,7 @@ void DlgPrefController::slotPresetSelected(int chosenIndex) {
applyPresetChanges();
if (m_pPreset && m_pPreset->isDirty()) {
if (QMessageBox::question(this,
tr("Preset has been edited"),
tr("Mapping has been edited"),
tr("Do you want to save the changes?")) ==
QMessageBox::Yes) {
savePreset();
Expand All @@ -498,7 +507,7 @@ void DlgPrefController::savePreset() {
}

if (!m_pPreset->isDirty()) {
qDebug() << "Preset has not been edited, no need to save it.";
qDebug() << "Mapping is not dirty, no need to save it.";
return;
}

Expand Down Expand Up @@ -556,13 +565,13 @@ void DlgPrefController::savePreset() {
if (!saveAsNew) {
newFilePath = oldFilePath;
} else {
QString savePresetTitle = tr("Save user preset");
QString savePresetLabel = tr("Enter the name for saving the preset to the user folder.");
QString savingFailedTitle = tr("Saving preset failed");
QString savePresetTitle = tr("Save user mapping");
QString savePresetLabel = tr("Enter the name for saving the mapping to the user folder.");
QString savingFailedTitle = tr("Saving mapping failed");
QString invalidNameLabel =
tr("A preset cannot have a blank name and may not contain "
tr("A mapping cannot have a blank name and may not contain "
"special characters.");
QString fileExistsLabel = tr("A preset file with that name already exists.");
QString fileExistsLabel = tr("A mapping file with that name already exists.");
// Only allow the name to contain letters, numbers, whitespaces and _-+()/
const QRegExp rxRemove = QRegExp("[^[(a-zA-Z0-9\\_\\-\\+\\(\\)\\/|\\s]");

Expand Down Expand Up @@ -600,14 +609,14 @@ void DlgPrefController::savePreset() {
validPresetName = true;
}
m_pPreset->setName(presetName);
qDebug() << "Preset renamed to" << m_pPreset->name();
qDebug() << "Mapping renamed to" << m_pPreset->name();
}

if (!m_pPreset->savePreset(newFilePath)) {
qDebug() << "Failed to save preset as" << newFilePath;
qDebug() << "Failed to save mapping as" << newFilePath;
return;
}
qDebug() << "Preset saved as" << newFilePath;
qDebug() << "Mapping saved as" << newFilePath;

m_pPreset->setFilePath(newFilePath);
m_pPreset->setDirty(false);
Expand Down Expand Up @@ -666,8 +675,8 @@ void DlgPrefController::slotShowPreset(ControllerPresetPointer preset) {
QString support = supportLinks.join("&nbsp;&nbsp;");
m_ui.labelLoadedPresetSupportLinks->setText(support);

QString scriptFiles = presetScriptFileLinks(preset);
m_ui.labelLoadedPresetScriptFileLinks->setText(scriptFiles);
QString mappingFileLinks = presetFileLinks(preset);
m_ui.labelLoadedPresetScriptFileLinks->setText(mappingFileLinks);

// We mutate this preset so keep a reference to it while we are using it.
// TODO(rryan): Clone it? Technically a waste since nothing else uses this
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/dlgprefcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class DlgPrefController : public DlgPreferencePage {
QString presetForumLink(const ControllerPresetPointer pPreset) const;
QString presetManualLink(const ControllerPresetPointer pPreset) const;
QString presetWikiLink(const ControllerPresetPointer pPreset) const;
QString presetScriptFileLinks(const ControllerPresetPointer pPreset) const;
QString presetFileLinks(const ControllerPresetPointer pPreset) const;
void applyPresetChanges();
void savePreset();
void initTableView(QTableView* pTable);
Expand Down
18 changes: 9 additions & 9 deletions src/controllers/dlgprefcontrollerdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</size>
</property>
<property name="text">
<string>Load Preset:</string>
<string>Load Mapping:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
Expand Down Expand Up @@ -145,11 +145,11 @@
<item row="10" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Preset Info</string>
<string>Mapping Info</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_presetName">
<widget class="QLabel" name="labelPresetName">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -182,7 +182,7 @@
<string notr="true"/>
</property>
<property name="text">
<string notr="true">(preset name goes here)</string>
<string notr="true">(mapping name goes here)</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand Down Expand Up @@ -214,7 +214,7 @@
</sizepolicy>
</property>
<property name="text">
<string notr="true">(preset author goes here)</string>
<string notr="true">(mapping author goes here)</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -255,7 +255,7 @@
<string notr="true"/>
</property>
<property name="text">
<string notr="true">(preset description goes here) even when it is a damn long text which should wrap but does not</string>
<string notr="true">(mapping description goes here) even when it is a damn long text which should wrap but does not</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
Expand Down Expand Up @@ -299,7 +299,7 @@
<set>Qt::ImhUrlCharactersOnly</set>
</property>
<property name="text">
<string notr="true">(forum link for preset goes here)</string>
<string notr="true">(forum link for mapping goes here)</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
Expand All @@ -318,7 +318,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Script Files:</string>
<string>Mapping Files:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
Expand All @@ -343,7 +343,7 @@
<set>Qt::ImhUrlCharactersOnly</set>
</property>
<property name="text">
<string notr="true">(links to loaded preset script files go here)</string>
<string notr="true">(links to loaded mapping script files go here)</string>
</property>
<property name="openExternalLinks">
<bool>false</bool>
Expand Down
8 changes: 4 additions & 4 deletions src/controllers/dlgprefcontrollersdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Presets</string>
<string>Mappings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
Expand All @@ -88,7 +88,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Mixxx uses &quot;presets&quot; to connect messages from your controller to controls in Mixxx. If you do not see a preset for your controller in the "Load Preset" menu when you click on your controller on the left sidebar, you may be able to download one online from the &lt;a href=&quot;https://mixxx.discourse.group/c/controller-mappings/10&quot;&gt;Mixxx Forum&lt;/a&gt;. Place the XML (.xml) and Javascript (.js) file(s) in the &quot;User Preset Folder&quot; then restart Mixxx. If you download a mapping in a ZIP file, extract the XML and Javascript file(s) from the ZIP file to your &quot;User Preset Folder&quot; then restart Mixxx:</string>
<string>Mixxx uses &quot;mappings&quot; to connect messages from your controller to controls in Mixxx. If you do not see a mapping for your controller in the "Load Mapping" menu when you click on your controller on the left sidebar, you may be able to download one online from the &lt;a href=&quot;https://mixxx.discourse.group/c/controller-mappings/10&quot;&gt;Mixxx Forum&lt;/a&gt;. Place the XML (.xml) and Javascript (.js) file(s) in the &quot;User Mapping Folder&quot; then restart Mixxx. If you download a mapping in a ZIP file, extract the XML and Javascript file(s) from the ZIP file to your &quot;User Mapping Folder&quot; then restart Mixxx:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand All @@ -107,7 +107,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Open User Preset Folder</string>
<string>Open User Mapping Folder</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -159,7 +159,7 @@
<item row="1" column="0">
<widget class="QLabel" name="txtControllerPresetFormat">
<property name="text">
<string>&lt;a href=&quot;https://github.com/mixxxdj/mixxx/wiki/Midi-Controller-Mapping-File-Format&quot;&gt;MIDI Preset File Format&lt;/a&gt;</string>
<string>&lt;a href=&quot;https://github.com/mixxxdj/mixxx/wiki/Midi-Controller-Mapping-File-Format&quot;&gt;MIDI Mapping File Format&lt;/a&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
Expand Down