Commits

Anonymous committed 1e24978

Library window opens faster

Comments (0)

Files changed (6)

 
 #include "mainwindow.h"
 
-Library::Library(QWidget *parent) :
+Library::Library(char names[24][32], QWidget *parent) :
     QDialog(parent),
     ui(new Ui::Library)
 {
     ui->listWidget->setFont(font);
     ui->listWidget_2->setFont(font);
 
+    for(int i = 0; i < 24; i++)
+    {
+        ui->listWidget->addItem(QString("%1").arg(names[i]));
+    }
+
     ui->spinBox->setValue(font.pointSize());
     ui->fontComboBox->setCurrentFont(font);
 
     delete ui;
 }
 
-void Library::get_names(char names[24][32])
-{
-    for(int i = 0; i < 24; i++)
-    {
-        ui->listWidget->addItem(QString("%1").arg(names[i]));
-    }
-}
-
 void Library::load_slot(int slot)
 {
     if(slot < 0)
     Q_OBJECT
 
 public:
-    explicit Library(QWidget *parent = 0);
+    explicit Library(char names[24][32], QWidget *parent = 0);
     ~Library();
-    void get_names(char [24][32]);
 
 private:
     Ui::Library *ui;

plug/mainwindow.cpp

     int x;
     struct amp_settings amplifier_set;
     struct fx_pedal_settings effects_set[4];
-    char name[32], names[24][32];
+    char name[32];
 
     ui->statusBar->showMessage(tr("Connecting..."));
     this->repaint();  // this should not be needed!
 {
     int ret;
 
+    if(!connected)
+        return -1;
+
     ret = amp_ops->save_on_amp(name, slot);
 
     if(name[0] == 0x00)
         setWindowTitle(QString(tr("PLUG: %1")).arg(name));
 
     current_name=name;
+    memcpy(names[slot], name, 32);
 
     return ret;
 }
     struct fx_pedal_settings effects_set[4];
     char name[32];
 
+    if(!connected)
+        return -1;
+
     amp_ops->load_memory_bank(slot, name, &amplifier_set, effects_set);
 
     if(name[0] == 0x00)
 
 void MainWindow::show_library()
 {
-    ui->statusBar->showMessage(QString(tr("Working...")), 3000);
-    this->repaint();
     QSettings settings;
-    char names[24][32];
     bool previous = settings.value("Settings/popupChangedWindows").toBool();
 
     settings.setValue("Settings/popupChangedWindows", false);
 
-    library = new Library(this);
-    amp_ops->get_current_names(names);
-    library->get_names(names);
+    library = new Library(names, this);
     effect1->close();
     effect2->close();
     effect3->close();

plug/mainwindow.h

 
     // pointers to objects
     QString current_name;
+    char  names[24][32];
     bool manual_check, connected;
     Mustang *amp_ops;
     Amplifier *amp;
     return 0;
 }
 
-int Mustang::get_current_names(char names[][32])
-{
-    int recieved, ret;
-    unsigned char array[LENGTH], recieved_data[142][LENGTH];
-    memset(array, 0x00, LENGTH);
-    memset(recieved_data, 0x00, 142*LENGTH);
-
-    array[0] = 0xff;
-    array[1] = 0xc1;
-    ret = libusb_interrupt_transfer(amp_hand, 0x01, array, LENGTH, &recieved, TMOUT);
-    if(ret)
-        return ret;
-
-    for(int i = 0; recieved; i++)
-    {
-        libusb_interrupt_transfer(amp_hand, 0x81, array, LENGTH, &recieved, TMOUT);
-        memcpy(recieved_data[i], array, LENGTH);
-    }
-
-    for(int i = 0, j = 0; i<48; i+=2, j++)
-        memcpy(names[j], recieved_data[i]+16, 32);
-
-    return 0;
-}
-
 int Mustang::update(char *filename)
 {
     int ret, recieved;
     int save_on_amp(char *, int);
     int load_memory_bank(int, char *name=NULL, struct amp_settings *amp_set=NULL, struct fx_pedal_settings *effects_set=NULL);
     int save_effects(int , char *, int , struct fx_pedal_settings *);
-    int get_current_names(char names[][32]);
     int update(char *);
 
 private: