Commits

piorekf  committed b26ea5f

Added quick preset loading

  • Participants
  • Parent commits 6ebb8c8

Comments (0)

Files changed (7)

File plug/mainwindow.cpp

     seffects = new SaveEffects(this);
     settings_win = new Settings(this);
     saver = new SaveToFile(this);
+    quickpres = new QuickPresets(this);
 
     connected = false;
 
     connect(ui->action_Library_view, SIGNAL(triggered()), this, SLOT(show_library()));
     connect(ui->action_Update_firmware, SIGNAL(triggered()), this, SLOT(update_firmware()));
     connect(ui->action_Default_effects, SIGNAL(triggered()), this, SLOT(show_default_effects()));
+    connect(ui->action_Quick_presets, SIGNAL(triggered()), quickpres, SLOT(show()));
 
     // shortcuts to activate effect windows
     QShortcut *showfx1 = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_1), this, 0, 0, Qt::ApplicationShortcut);
     connect(showfx4, SIGNAL(activated()), this, SLOT(show_fx4()));
     connect(showamp, SIGNAL(activated()), this, SLOT(show_amp()));
 
+    // shortcuts for quick loading presets
+    QShortcut *loadpres0 = new QShortcut(QKeySequence(Qt::Key_0), this, 0, 0, Qt::ApplicationShortcut);
+    QShortcut *loadpres1 = new QShortcut(QKeySequence(Qt::Key_1), this, 0, 0, Qt::ApplicationShortcut);
+    QShortcut *loadpres2 = new QShortcut(QKeySequence(Qt::Key_2), this, 0, 0, Qt::ApplicationShortcut);
+    QShortcut *loadpres3 = new QShortcut(QKeySequence(Qt::Key_3), this, 0, 0, Qt::ApplicationShortcut);
+    QShortcut *loadpres4 = new QShortcut(QKeySequence(Qt::Key_4), this, 0, 0, Qt::ApplicationShortcut);
+    QShortcut *loadpres5 = new QShortcut(QKeySequence(Qt::Key_5), this, 0, 0, Qt::ApplicationShortcut);
+    QShortcut *loadpres6 = new QShortcut(QKeySequence(Qt::Key_6), this, 0, 0, Qt::ApplicationShortcut);
+    QShortcut *loadpres7 = new QShortcut(QKeySequence(Qt::Key_7), this, 0, 0, Qt::ApplicationShortcut);
+    QShortcut *loadpres8 = new QShortcut(QKeySequence(Qt::Key_8), this, 0, 0, Qt::ApplicationShortcut);
+    QShortcut *loadpres9 = new QShortcut(QKeySequence(Qt::Key_9), this, 0, 0, Qt::ApplicationShortcut);
+    connect(loadpres0, SIGNAL(activated()), this, SLOT(load_presets0()));
+    connect(loadpres1, SIGNAL(activated()), this, SLOT(load_presets1()));
+    connect(loadpres2, SIGNAL(activated()), this, SLOT(load_presets2()));
+    connect(loadpres3, SIGNAL(activated()), this, SLOT(load_presets3()));
+    connect(loadpres4, SIGNAL(activated()), this, SLOT(load_presets4()));
+    connect(loadpres5, SIGNAL(activated()), this, SLOT(load_presets5()));
+    connect(loadpres6, SIGNAL(activated()), this, SLOT(load_presets6()));
+    connect(loadpres7, SIGNAL(activated()), this, SLOT(load_presets7()));
+    connect(loadpres8, SIGNAL(activated()), this, SLOT(load_presets8()));
+    connect(loadpres9, SIGNAL(activated()), this, SLOT(load_presets9()));
+
     // shortcut to activate buttons
     QShortcut *shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_A), this);
     connect(shortcut, SIGNAL(activated()), this, SLOT(enable_buttons()));
 
     load->load_names(names);
     save->load_names(names);
+    quickpres->load_names(names);
 
     if(name[0] == 0x00)
         setWindowTitle(QString(tr("PLUG: NONE")));
 
     save->delete_items();
     load->delete_items();
+    quickpres->delete_items();
 
     x = amp_ops->stop_amp();
     if(x == 0)    // if request succeded
 void MainWindow::change_name(int slot, QString *name)
 {
     load->change_name(slot, name);
+    quickpres->change_name(slot, name);
 }
 
 void MainWindow::set_index(int value)
 
     return 0;
 }
+
+void MainWindow::load_presets0()
+{
+  QSettings settings;
+
+  if(settings.contains("DefaultPresets/Preset0"))
+      load_from_amp(settings.value("DefaultPresets/Preset0").toInt());
+}
+
+void MainWindow::load_presets1()
+{
+  QSettings settings;
+
+  if(settings.contains("DefaultPresets/Preset1"))
+      load_from_amp(settings.value("DefaultPresets/Preset1").toInt());
+}
+
+void MainWindow::load_presets2()
+{
+  QSettings settings;
+
+  if(settings.contains("DefaultPresets/Preset2"))
+      load_from_amp(settings.value("DefaultPresets/Preset2").toInt());
+}
+
+void MainWindow::load_presets3()
+{
+  QSettings settings;
+
+  if(settings.contains("DefaultPresets/Preset3"))
+      load_from_amp(settings.value("DefaultPresets/Preset3").toInt());
+}
+
+void MainWindow::load_presets4()
+{
+  QSettings settings;
+
+  if(settings.contains("DefaultPresets/Preset4"))
+      load_from_amp(settings.value("DefaultPresets/Preset4").toInt());
+}
+
+void MainWindow::load_presets5()
+{
+  QSettings settings;
+
+  if(settings.contains("DefaultPresets/Preset5"))
+      load_from_amp(settings.value("DefaultPresets/Preset5").toInt());
+}
+
+void MainWindow::load_presets6()
+{
+  QSettings settings;
+
+  if(settings.contains("DefaultPresets/Preset6"))
+      load_from_amp(settings.value("DefaultPresets/Preset6").toInt());
+}
+
+void MainWindow::load_presets7()
+{
+  QSettings settings;
+
+  if(settings.contains("DefaultPresets/Preset7"))
+      load_from_amp(settings.value("DefaultPresets/Preset7").toInt());
+}
+
+void MainWindow::load_presets8()
+{
+  QSettings settings;
+
+  if(settings.contains("DefaultPresets/Preset8"))
+      load_from_amp(settings.value("DefaultPresets/Preset8").toInt());
+}
+
+void MainWindow::load_presets9()
+{
+  QSettings settings;
+
+  if(settings.contains("DefaultPresets/Preset9"))
+      load_from_amp(settings.value("DefaultPresets/Preset9").toInt());
+}

File plug/mainwindow.h

 #include "savetofile.h"
 #include "library.h"
 #include "defaulteffects.h"
+#include "quickpresets.h"
 
 #define VERSION "0.7.999"
 
     SaveToFile *saver;
     Library *library;
     DefaultEffects *deffx;
+    QuickPresets *quickpres;
 
     QNetworkReply *reply;
 
     void show_library();
     void show_default_effects();
     int check_fx_family(int);
+    void load_presets0();
+    void load_presets1();
+    void load_presets2();
+    void load_presets3();
+    void load_presets4();
+    void load_presets5();
+    void load_presets6();
+    void load_presets7();
+    void load_presets8();
+    void load_presets9();
 
 
 signals:

File plug/mainwindow.ui

     <addaction name="actionSave_to_amplifier"/>
     <addaction name="separator"/>
     <addaction name="actionSave_effects"/>
+    <addaction name="action_Library_view"/>
     <addaction name="separator"/>
     <addaction name="action_Update_firmware"/>
     <addaction name="separator"/>
     <property name="title">
      <string>&amp;Settings</string>
     </property>
+    <addaction name="action_Quick_presets"/>
     <addaction name="action_Default_effects"/>
-    <addaction name="action_Library_view"/>
     <addaction name="action_Options"/>
    </widget>
    <addaction name="menuFile"/>
     <enum>Qt::ApplicationShortcut</enum>
    </property>
   </action>
+  <action name="action_Quick_presets">
+   <property name="text">
+    <string>&amp;Quick presets</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+P</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources/>

File plug/plug.pro

     loadfromfile.cpp \
     savetofile.cpp \
     library.cpp \
-    defaulteffects.cpp
+    defaulteffects.cpp \
+    quickpresets.cpp
 
 HEADERS  += mainwindow.h \
     effect.h \
     loadfromfile.h \
     savetofile.h \
     library.h \
-    defaulteffects.h
+    defaulteffects.h \
+    quickpresets.h
 
 FORMS    += mainwindow.ui \
     effect.ui \
     settings.ui \
     savetofile.ui \
     library.ui \
-    defaulteffects.ui
+    defaulteffects.ui \
+    quickpresets.ui
 
 LIBS += -lusb-1.0
 

File plug/quickpresets.cpp

+#include "quickpresets.h"
+#include "ui_quickpresets.h"
+
+QuickPresets::QuickPresets(QWidget *parent) :
+  QDialog(parent),
+  ui(new Ui::QuickPresets)
+{
+  ui->setupUi(this);
+
+  connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(close()));
+
+  connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setDefaultPreset0(int)));
+  connect(ui->comboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(setDefaultPreset1(int)));
+  connect(ui->comboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(setDefaultPreset2(int)));
+  connect(ui->comboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(setDefaultPreset3(int)));
+  connect(ui->comboBox_5, SIGNAL(currentIndexChanged(int)), this, SLOT(setDefaultPreset4(int)));
+  connect(ui->comboBox_6, SIGNAL(currentIndexChanged(int)), this, SLOT(setDefaultPreset5(int)));
+  connect(ui->comboBox_7, SIGNAL(currentIndexChanged(int)), this, SLOT(setDefaultPreset6(int)));
+  connect(ui->comboBox_8, SIGNAL(currentIndexChanged(int)), this, SLOT(setDefaultPreset7(int)));
+  connect(ui->comboBox_9, SIGNAL(currentIndexChanged(int)), this, SLOT(setDefaultPreset8(int)));
+  connect(ui->comboBox_10, SIGNAL(currentIndexChanged(int)), this, SLOT(setDefaultPreset9(int)));
+}
+
+QuickPresets::~QuickPresets()
+{
+  delete ui;
+}
+
+void QuickPresets::load_names(char names[][32])
+{
+  for(int i = 0; i < 100; i++)
+  {
+    if(names[i][0] == 0x00)
+      break;
+    ui->comboBox->addItem(QString("[%1] %2").arg(i+1).arg(names[i]));
+    ui->comboBox_2->addItem(QString("[%1] %2").arg(i+1).arg(names[i]));
+    ui->comboBox_3->addItem(QString("[%1] %2").arg(i+1).arg(names[i]));
+    ui->comboBox_4->addItem(QString("[%1] %2").arg(i+1).arg(names[i]));
+    ui->comboBox_5->addItem(QString("[%1] %2").arg(i+1).arg(names[i]));
+    ui->comboBox_6->addItem(QString("[%1] %2").arg(i+1).arg(names[i]));
+    ui->comboBox_7->addItem(QString("[%1] %2").arg(i+1).arg(names[i]));
+    ui->comboBox_8->addItem(QString("[%1] %2").arg(i+1).arg(names[i]));
+    ui->comboBox_9->addItem(QString("[%1] %2").arg(i+1).arg(names[i]));
+    ui->comboBox_10->addItem(QString("[%1] %2").arg(i+1).arg(names[i]));
+  }
+}
+
+void QuickPresets::delete_items()
+{
+  int j = ui->comboBox->count();
+  for(int i = 0; i < j; i++)
+  {
+    ui->comboBox->removeItem(0);
+    ui->comboBox_2->removeItem(0);
+    ui->comboBox_3->removeItem(0);
+    ui->comboBox_4->removeItem(0);
+    ui->comboBox_5->removeItem(0);
+    ui->comboBox_6->removeItem(0);
+    ui->comboBox_7->removeItem(0);
+    ui->comboBox_8->removeItem(0);
+    ui->comboBox_9->removeItem(0);
+    ui->comboBox_10->removeItem(0);
+  }
+}
+
+void QuickPresets::change_name(int slot, QString *name)
+{
+  ui->comboBox->setItemText(slot, *name);
+  ui->comboBox->setCurrentIndex(slot);
+
+  ui->comboBox_2->setItemText(slot, *name);
+  ui->comboBox_2->setCurrentIndex(slot);
+
+  ui->comboBox_3->setItemText(slot, *name);
+  ui->comboBox_3->setCurrentIndex(slot);
+
+  ui->comboBox_4->setItemText(slot, *name);
+  ui->comboBox_4->setCurrentIndex(slot);
+
+  ui->comboBox_5->setItemText(slot, *name);
+  ui->comboBox_5->setCurrentIndex(slot);
+
+  ui->comboBox_6->setItemText(slot, *name);
+  ui->comboBox_6->setCurrentIndex(slot);
+
+  ui->comboBox_7->setItemText(slot, *name);
+  ui->comboBox_7->setCurrentIndex(slot);
+
+  ui->comboBox_8->setItemText(slot, *name);
+  ui->comboBox_8->setCurrentIndex(slot);
+
+  ui->comboBox_9->setItemText(slot, *name);
+  ui->comboBox_9->setCurrentIndex(slot);
+
+  ui->comboBox_10->setItemText(slot, *name);
+  ui->comboBox_10->setCurrentIndex(slot);
+}
+
+void QuickPresets::setDefaultPreset0(int slot)
+{
+  QSettings settings;
+  settings.setValue("DefaultPresets/Preset0", slot);
+}
+
+void QuickPresets::setDefaultPreset1(int slot)
+{
+  QSettings settings;
+  settings.setValue("DefaultPresets/Preset1", slot);
+}
+
+void QuickPresets::setDefaultPreset2(int slot)
+{
+  QSettings settings;
+  settings.setValue("DefaultPresets/Preset2", slot);
+}
+
+void QuickPresets::setDefaultPreset3(int slot)
+{
+  QSettings settings;
+  settings.setValue("DefaultPresets/Preset3", slot);
+}
+
+void QuickPresets::setDefaultPreset4(int slot)
+{
+  QSettings settings;
+  settings.setValue("DefaultPresets/Preset4", slot);
+}
+
+void QuickPresets::setDefaultPreset5(int slot)
+{
+  QSettings settings;
+  settings.setValue("DefaultPresets/Preset5", slot);
+}
+
+void QuickPresets::setDefaultPreset6(int slot)
+{
+  QSettings settings;
+  settings.setValue("DefaultPresets/Preset6", slot);
+}
+
+void QuickPresets::setDefaultPreset7(int slot)
+{
+  QSettings settings;
+  settings.setValue("DefaultPresets/Preset7", slot);
+}
+
+void QuickPresets::setDefaultPreset8(int slot)
+{
+  QSettings settings;
+  settings.setValue("DefaultPresets/Preset8", slot);
+}
+
+void QuickPresets::setDefaultPreset9(int slot)
+{
+  QSettings settings;
+  settings.setValue("DefaultPresets/Preset9", slot);
+}
+
+void QuickPresets::changeEvent(QEvent *e)
+{
+  QDialog::changeEvent(e);
+  switch (e->type()) {
+  case QEvent::LanguageChange:
+    ui->retranslateUi(this);
+    break;
+  default:
+    break;
+  }
+}

File plug/quickpresets.h

+#ifndef QUICKPRESETS_H
+#define QUICKPRESETS_H
+
+#include <QDialog>
+#include <QSettings>
+
+namespace Ui {
+class QuickPresets;
+}
+
+class QuickPresets : public QDialog
+{
+  Q_OBJECT
+
+public:
+  explicit QuickPresets(QWidget *parent = 0);
+  ~QuickPresets();
+  void load_names(char names[][32]);
+  void delete_items();
+  void change_name(int, QString *);
+
+protected:
+  void changeEvent(QEvent *e);
+
+private:
+  Ui::QuickPresets *ui;
+
+private slots:
+  void setDefaultPreset0(int);
+  void setDefaultPreset1(int);
+  void setDefaultPreset2(int);
+  void setDefaultPreset3(int);
+  void setDefaultPreset4(int);
+  void setDefaultPreset5(int);
+  void setDefaultPreset6(int);
+  void setDefaultPreset7(int);
+  void setDefaultPreset8(int);
+  void setDefaultPreset9(int);
+};
+
+#endif // QUICKPRESETS_H

File plug/quickpresets.ui

+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QuickPresets</class>
+ <widget class="QDialog" name="QuickPresets">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>375</width>
+    <height>350</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Default preset for button &quot;0&quot;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="comboBox"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Default preset for button &quot;1&quot;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="comboBox_2"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QLabel" name="label_3">
+       <property name="text">
+        <string>Default preset for button &quot;2&quot;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="comboBox_3"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_4">
+     <item>
+      <widget class="QLabel" name="label_4">
+       <property name="text">
+        <string>Default preset for button &quot;3&quot;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="comboBox_4"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_5">
+     <item>
+      <widget class="QLabel" name="label_5">
+       <property name="text">
+        <string>Default preset for button &quot;4&quot;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="comboBox_5"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_6">
+     <item>
+      <widget class="QLabel" name="label_6">
+       <property name="text">
+        <string>Default preset for button &quot;5&quot;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="comboBox_6"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_7">
+     <item>
+      <widget class="QLabel" name="label_7">
+       <property name="text">
+        <string>Default preset for button &quot;6&quot;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="comboBox_7"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_8">
+     <item>
+      <widget class="QLabel" name="label_8">
+       <property name="text">
+        <string>Default preset for button &quot;7&quot;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="comboBox_8"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_9">
+     <item>
+      <widget class="QLabel" name="label_9">
+       <property name="text">
+        <string>Default preset for button &quot;8&quot;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="comboBox_9"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_10">
+     <item>
+      <widget class="QLabel" name="label_10">
+       <property name="text">
+        <string>Default preset for button &quot;9&quot;</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="comboBox_10"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_11">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="pushButton">
+       <property name="text">
+        <string>&amp;OK</string>
+       </property>
+       <property name="shortcut">
+        <string>Return</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>