Commits

piorekf committed 5a2a201

Added checking whether the other slots have the effect of the same
family

Comments (0)

Files changed (5)

 
 void Effect::choose_fx(int value)
 {
+    ui->comboBox->setCurrentIndex(value);
+    if(value != 0)
+        ((MainWindow*)parent())->empty_other(value, this);
+
     QSettings settings;
     effect_num = value;
     set_changed(true);

plug/mainwindow.cpp

     ui->action_Load_from_amplifier->setDisabled(false);
     ui->actionSave_effects->setDisabled(false);
     ui->action_Library_view->setDisabled(false);
-
-    connected = true;
 }
 
 void MainWindow::check_for_updates()
 
     QFile *file = new QFile(filename, this);
 
-    if (!file->open(QFile::ReadOnly | QFile::Text))
+    if(file->exists())
     {
-        QMessageBox::critical(this, tr("Error!"), tr("Could not open file"));
+        if (!file->open(QFile::ReadOnly | QFile::Text))
+        {
+            QMessageBox::critical(this, tr("Error!"), tr("Could not open file"));
+            return;
+        }
+    }
+    else
+    {
+        QMessageBox::critical(this, tr("Error!"), tr("No such file"));
         return;
     }
 
     deffx->exec();
     delete deffx;
 }
+
+void MainWindow::empty_other(int value, Effect *caller)
+{
+    struct fx_pedal_settings settings;
+    int fx_family = check_fx_family(value);
+
+    if(caller != effect1)
+    {
+        effect1->get_settings(settings);
+        if(check_fx_family(settings.effect_num) == fx_family)
+        {
+            effect1->choose_fx(0);
+            effect1->send_fx();
+        }
+    }
+
+    if(caller != effect2)
+    {
+        effect2->get_settings(settings);
+        if(check_fx_family(settings.effect_num) == fx_family)
+        {
+            effect2->choose_fx(0);
+            effect2->send_fx();
+        }
+    }
+
+    if(caller != effect3)
+    {
+        effect3->get_settings(settings);
+        if(check_fx_family(settings.effect_num) == fx_family)
+        {
+            effect3->choose_fx(0);
+            effect3->send_fx();
+        }
+    }
+
+    if(caller != effect4)
+    {
+        effect4->get_settings(settings);
+        if(check_fx_family(settings.effect_num) == fx_family)
+        {
+            effect4->choose_fx(0);
+            effect4->send_fx();
+        }
+    }
+}
+
+int MainWindow::check_fx_family(int value)
+{
+    if(value == 0)
+        return 0;
+    if(value >= 1 && value <= 7)
+        return 1;
+    if(value >= 8 && value <= 18)
+        return 2;
+    if(value >= 19 && value <= 27)
+        return 3;
+    if(value >= 28 && value <= 37)
+        return 4;
+
+    return 0;
+}

plug/mainwindow.h

     void get_settings(struct amp_settings*, struct fx_pedal_settings[4]);
     void change_title(QString);
     void update_firmware();
+    void empty_other(int, Effect*);
 
 private:
     Ui::MainWindow *ui;
     void show_amp();
     void show_library();
     void show_default_effects();
+    int check_fx_family(int);
 
 
 signals:
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
     };
 
-    if(value.put_post_amp)    // put effect in a slot after amplifier
-        slot = value.fx_slot + 4;
-    else
-        slot = value.fx_slot;
-
     // clear effect on previous DSP before setting a new one
     int k=0;
     for (int i = 0; i < 4; i++)
     if(value.effect_num == EMPTY)
         return ret;
 
+    if(value.put_post_amp)    // put effect in a slot after amplifier
+        slot = value.fx_slot + 4;
+    else
+        slot = value.fx_slot;
+
     // fill the form with data
     array[FXSLOT] = slot;
     array[KNOB1] = value.knob1;
    <item>
     <widget class="QCheckBox" name="checkBox_6">
      <property name="text">
-      <string>Set default values on effect load</string>
+      <string>Set default knob values when choosing effect</string>
      </property>
      <property name="checked">
       <bool>true</bool>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.