1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844
|
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
memset(names, 0x00, 100*32);
// load window size
QSettings settings;
restoreGeometry(settings.value("Windows/mainWindowGeometry").toByteArray());
restoreState(settings.value("Windows/mainWindowState").toByteArray());
// setting default values if there was none
if(!settings.contains("Settings/checkForUpdates"))
settings.setValue("Settings/checkForUpdates", true);
if(!settings.contains("Settings/connectOnStartup"))
settings.setValue("Settings/connectOnStartup", true);
if(!settings.contains("Settings/oneSetToSetThemAll"))
settings.setValue("Settings/oneSetToSetThemAll", false);
if(!settings.contains("Settings/keepWindowsOpen"))
settings.setValue("Settings/keepWindowsOpen", false);
if(!settings.contains("Settings/popupChangedWindows"))
settings.setValue("Settings/popupChangedWindows", true);
if(!settings.contains("Settings/defaultEffectValues"))
settings.setValue("Settings/defaultEffectValues", true);
// create child objects
amp_ops = new Mustang();
amp = new Amplifier(this);
effect1 = new Effect(this, 0);
effect2 = new Effect(this, 1);
effect3 = new Effect(this, 2);
effect4 = new Effect(this, 3);
about_window = new About(this);
save = new SaveOnAmp(this);
load = new LoadFromAmp(this);
seffects = new SaveEffects(this);
settings_win = new Settings(this);
saver = new SaveToFile(this);
quickpres = new QuickPresets(this);
connected = false;
// connect buttons to slots
connect(ui->Amplifier, SIGNAL(clicked()), amp, SLOT(show()));
connect(ui->EffectButton1, SIGNAL(clicked()), effect1, SLOT(show()));
connect(ui->EffectButton2, SIGNAL(clicked()), effect2, SLOT(show()));
connect(ui->EffectButton3, SIGNAL(clicked()), effect3, SLOT(show()));
connect(ui->EffectButton4, SIGNAL(clicked()), effect4, SLOT(show()));
connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(start_amp()));
connect(ui->actionDisconnect, SIGNAL(triggered()), this, SLOT(stop_amp()));
connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
connect(ui->actionAbout, SIGNAL(triggered()), about_window, SLOT(open()));
connect(ui->actionSave_to_amplifier, SIGNAL(triggered()), save, SLOT(show()));
connect(ui->action_Load_from_amplifier, SIGNAL(triggered()), load, SLOT(show()));
connect(ui->actionSave_effects, SIGNAL(triggered()), seffects, SLOT(open()));
connect(ui->actionCheck_for_Updates, SIGNAL(triggered()), this, SLOT(check_for_updates()));
connect(ui->action_Options, SIGNAL(triggered()), settings_win, SLOT(show()));
connect(ui->actionL_oad_from_file, SIGNAL(triggered()), this, SLOT(loadfile()));
connect(ui->actionS_ave_to_file, SIGNAL(triggered()), saver, SLOT(show()));
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);
QShortcut *showfx2 = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_2), this, 0, 0, Qt::ApplicationShortcut);
QShortcut *showfx3 = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_3), this, 0, 0, Qt::ApplicationShortcut);
QShortcut *showfx4 = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_4), this, 0, 0, Qt::ApplicationShortcut);
QShortcut *showamp = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_5), this, 0, 0, Qt::ApplicationShortcut);
connect(showfx1, SIGNAL(activated()), this, SLOT(show_fx1()));
connect(showfx2, SIGNAL(activated()), this, SLOT(show_fx2()));
connect(showfx3, SIGNAL(activated()), this, SLOT(show_fx3()));
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()));
// connect the functions if needed
if(settings.value("Settings/checkForUpdates").toBool())
connect(this, SIGNAL(started()), this, SLOT(check_for_updates()));
if(settings.value("Settings/connectOnStartup").toBool())
connect(this, SIGNAL(started()), this, SLOT(start_amp()));
this->show();
this->repaint();
emit started();
}
MainWindow::~MainWindow()
{
QSettings settings;
settings.setValue("Windows/mainWindowGeometry", saveGeometry());
settings.setValue("Windows/mainWindowState", saveState());
delete amp_ops; // stop the communication before exiting
delete ui;
}
void MainWindow::start_amp()
{
QSettings settings;
int x;
struct amp_settings amplifier_set;
struct fx_pedal_settings effects_set[4];
char name[32];
ui->statusBar->showMessage(tr("Connecting..."));
this->repaint(); // this should not be needed!
x = amp_ops->start_amp(names, name, &lifier_set, effects_set); // request initialization of communication
if(x != 0) // if request succeded
{
if(x == -100)
ui->statusBar->showMessage(tr("Suitable device not found!"), 5000);
else
ui->statusBar->showMessage(QString(tr("Error: %1")).arg(x), 5000);
return;
}
load->load_names(names);
save->load_names(names);
quickpres->load_names(names);
if(name[0] == 0x00)
{
setWindowTitle(QString(tr("PLUG: NONE")));
setAccessibleName(QString(tr("Main window: NONE")));
}
else
{
setWindowTitle(QString(tr("PLUG: %1")).arg(name));
setAccessibleName(QString(tr("Main window: %1")).arg(name));
}
current_name = name;
amp->load(amplifier_set);
if(settings.value("Settings/popupChangedWindows").toBool())
amp->show();
for(int i = 0; i < 4; i++)
{
switch(effects_set[i].fx_slot)
{
case 0x00:
case 0x04:
effect1->load(effects_set[i]);
if(effects_set[i].effect_num)
if(settings.value("Settings/popupChangedWindows").toBool())
effect1->show();
break;
case 0x01:
case 0x05:
effect2->load(effects_set[i]);
if(effects_set[i].effect_num)
if(settings.value("Settings/popupChangedWindows").toBool())
effect2->show();
break;
case 0x02:
case 0x06:
effect3->load(effects_set[i]);
if(effects_set[i].effect_num)
if(settings.value("Settings/popupChangedWindows").toBool())
effect3->show();
break;
case 0x03:
case 0x07:
effect4->load(effects_set[i]);
if(effects_set[i].effect_num)
if(settings.value("Settings/popupChangedWindows").toBool())
effect4->show();
break;
}
}
// activate buttons
amp->enable_set_button(true);
effect1->enable_set_button(true);
effect2->enable_set_button(true);
effect3->enable_set_button(true);
effect4->enable_set_button(true);
ui->actionConnect->setDisabled(true);
ui->actionDisconnect->setDisabled(false);
ui->actionSave_to_amplifier->setDisabled(false);
ui->action_Load_from_amplifier->setDisabled(false);
ui->actionSave_effects->setDisabled(false);
ui->action_Library_view->setDisabled(false);
ui->statusBar->showMessage(tr("Connected"), 3000); // show message on the status bar
connected = true;
}
void MainWindow::stop_amp()
{
int x;
save->delete_items();
load->delete_items();
quickpres->delete_items();
x = amp_ops->stop_amp();
if(x == 0) // if request succeded
{
// deactivate buttons
amp->enable_set_button(false);
effect1->enable_set_button(false);
effect2->enable_set_button(false);
effect3->enable_set_button(false);
effect4->enable_set_button(false);
ui->actionConnect->setDisabled(false);
ui->actionDisconnect->setDisabled(true);
ui->actionSave_to_amplifier->setDisabled(true);
ui->action_Load_from_amplifier->setDisabled(true);
ui->actionSave_effects->setDisabled(true);
ui->action_Library_view->setDisabled(true);
setWindowTitle(QString(tr("PLUG")));
setAccessibleName(QString(tr("Main window: None")));
ui->statusBar->showMessage(tr("Disconnected"), 5000); // show message on the status bar
connected = false;
}
else // if request failed
ui->statusBar->showMessage(QString(tr("Error: %1")).arg(x), 5000);
}
// pass the message to the amp
int MainWindow::set_effect(struct fx_pedal_settings pedal)
{
QSettings settings;
if(!connected)
return 0;
if(!settings.value("Settings/oneSetToSetThemAll").toBool())
return amp_ops->set_effect(pedal);
amp->send_amp();
return 0;
}
int MainWindow::set_amplifier(struct amp_settings amp_settings)
{
QSettings settings;
if(!connected)
return 0;
if(settings.value("Settings/oneSetToSetThemAll").toBool())
{
struct fx_pedal_settings pedal;
if(effect1->get_changed())
{
effect1->get_settings(pedal);
amp_ops->set_effect(pedal);
}
if(effect2->get_changed())
{
effect2->get_settings(pedal);
amp_ops->set_effect(pedal);
}
if(effect3->get_changed())
{
effect3->get_settings(pedal);
amp_ops->set_effect(pedal);
}
if(effect4->get_changed())
{
effect4->get_settings(pedal);
amp_ops->set_effect(pedal);
}
}
return amp_ops->set_amplifier(amp_settings);
}
int MainWindow::save_on_amp(char *name, int slot)
{
int ret;
if(!connected)
return -1;
ret = amp_ops->save_on_amp(name, slot);
if(name[0] == 0x00)
{
setWindowTitle(QString(tr("PLUG: NONE")));
setAccessibleName(QString(tr("Main window: NONE")));
}
else
{
setWindowTitle(QString(tr("PLUG: %1")).arg(name));
setAccessibleName(QString(tr("Main window: %1")).arg(name));
}
current_name=name;
memcpy(names[slot], name, 32);
return ret;
}
int MainWindow::load_from_amp(int slot)
{
QSettings settings;
struct amp_settings amplifier_set;
struct fx_pedal_settings effects_set[4];
char name[32];
if(!connected)
return -1;
amp_ops->load_memory_bank(slot, name, &lifier_set, effects_set);
if(name[0] == 0x00)
{
setWindowTitle(QString(tr("PLUG: NONE")));
setAccessibleName(QString(tr("Main window: NONE")));
}
else
{
setWindowTitle(QString(tr("PLUG: %1")).arg(name));
setAccessibleName(QString(tr("Main window: %1")).arg(name));
}
current_name=name;
amp->load(amplifier_set);
if(settings.value("Settings/popupChangedWindows").toBool())
amp->show();
for(int i = 0; i < 4; i++)
{
switch(effects_set[i].fx_slot)
{
case 0x00:
case 0x04:
effect1->load(effects_set[i]);
if(effects_set[i].effect_num)
if(settings.value("Settings/popupChangedWindows").toBool())
effect1->show();
break;
case 0x01:
case 0x05:
effect2->load(effects_set[i]);
if(effects_set[i].effect_num)
if(settings.value("Settings/popupChangedWindows").toBool())
effect2->show();
break;
case 0x02:
case 0x06:
effect3->load(effects_set[i]);
if(effects_set[i].effect_num)
if(settings.value("Settings/popupChangedWindows").toBool())
effect3->show();
break;
case 0x03:
case 0x07:
effect4->load(effects_set[i]);
if(effects_set[i].effect_num)
if(settings.value("Settings/popupChangedWindows").toBool())
effect4->show();
break;
}
}
return 0;
}
// activate buttons
void MainWindow::enable_buttons(void)
{
amp->enable_set_button(true);
effect1->enable_set_button(true);
effect2->enable_set_button(true);
effect3->enable_set_button(true);
effect4->enable_set_button(true);
ui->actionConnect->setDisabled(false);
ui->actionDisconnect->setDisabled(false);
ui->actionSave_to_amplifier->setDisabled(false);
ui->action_Load_from_amplifier->setDisabled(false);
ui->actionSave_effects->setDisabled(false);
ui->action_Library_view->setDisabled(false);
}
void MainWindow::check_for_updates()
{
if(sender() == ui->actionCheck_for_Updates)
manual_check = true;
else
manual_check = false;
QNetworkAccessManager *qnam = new QNetworkAccessManager(this);
reply = qnam->get(QNetworkRequest((QUrl)"http://piorekf.org/plug/VERSION"));
connect(reply, SIGNAL(finished()), this, SLOT(httpReadyRead()));
}
void MainWindow::httpReadyRead()
{
if(reply->readAll() > VERSION)
{
QLabel *label = new QLabel(tr("<b>Update available!</b>"), this);
ui->statusBar->addWidget(label);
QMessageBox::information(this, "Update", "<b>Update available!</b><br/><br/>Check homepage for new version.");
}
else if(manual_check)
ui->statusBar->showMessage(tr("You are using the newest version"), 5000);
}
void MainWindow::change_name(int slot, QString *name)
{
load->change_name(slot, name);
quickpres->change_name(slot, name);
}
void MainWindow::set_index(int value)
{
save->change_index(value, current_name);
}
void MainWindow::save_effects(int slot, char *name, int fx_num, bool mod, bool dly, bool rev)
{
struct fx_pedal_settings effects[2];
if(fx_num == 1)
{
if(mod)
{
effect2->get_settings(effects[0]);
set_effect(effects[0]);
}
else if(dly)
{
effect3->get_settings(effects[0]);
set_effect(effects[0]);
}
else if(rev)
{
effect4->get_settings(effects[0]);
set_effect(effects[0]);
}
}
else
{
effect3->get_settings(effects[0]);
set_effect(effects[0]);
effect4->get_settings(effects[1]);
set_effect(effects[1]);
}
amp_ops->save_effects(slot, name, fx_num, effects);
}
void MainWindow::loadfile(QString filename)
{
QSettings settings;
if(filename.isEmpty())
filename = QFileDialog::getOpenFileName(this, tr("Open..."), settings.value("LoadFile/lastDirectory", QDir::homePath()).toString(), tr("FUSE files (*.fuse *.xml)"));
if(filename.isEmpty())
return;
settings.setValue("LoadFile/lastDirectory", QFileInfo(filename).absolutePath());
QFile *file = new QFile(filename, this);
if(file->exists())
{
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;
}
struct amp_settings amplifier_set;
struct fx_pedal_settings effects_set[4];
QString name;
LoadFromFile *loader = new LoadFromFile(file, &name, &lifier_set, effects_set);
loader->loadfile();
file->close();
delete loader;
delete file;
change_title(name);
amp->load(amplifier_set);
if(connected)
amp->send_amp();
if(settings.value("Settings/popupChangedWindows").toBool())
amp->show();
for(int i = 0; i < 4; i++)
{
switch(effects_set[i].fx_slot)
{
case 0x00:
effect1->load(effects_set[i]);
if(connected)
effect1->send_fx();
if(effects_set[i].effect_num)
if(settings.value("Settings/popupChangedWindows").toBool())
effect1->show();
break;
case 0x01:
effect2->load(effects_set[i]);
if(connected)
effect2->send_fx();
if(effects_set[i].effect_num)
if(settings.value("Settings/popupChangedWindows").toBool())
effect2->show();
break;
case 0x02:
effect3->load(effects_set[i]);
if(connected)
effect3->send_fx();
if(effects_set[i].effect_num)
if(settings.value("Settings/popupChangedWindows").toBool())
effect3->show();
break;
case 0x03:
effect4->load(effects_set[i]);
if(connected)
effect4->send_fx();
if(effects_set[i].effect_num)
if(settings.value("Settings/popupChangedWindows").toBool())
effect4->show();
break;
}
}
}
void MainWindow::get_settings(struct amp_settings *amplifier_settings, struct fx_pedal_settings fx_settings[4])
{
if(amplifier_settings != NULL)
amp->get_settings(amplifier_settings);
if(fx_settings != NULL)
{
effect1->get_settings(fx_settings[0]);
effect2->get_settings(fx_settings[1]);
effect3->get_settings(fx_settings[2]);
effect4->get_settings(fx_settings[3]);
}
}
void MainWindow::change_title(QString name)
{
current_name = name;
if(current_name.isEmpty())
{
setWindowTitle(QString(tr("PLUG: NONE")));
setAccessibleName(QString(tr("Main window: NONE")));
}
else
{
setWindowTitle(QString(tr("PLUG: %1")).arg(current_name));
setAccessibleName(QString(tr("Main window: %1")).arg(name));
}
}
void MainWindow::show_fx1()
{
if(!effect1->isVisible())
effect1->show();
effect1->activateWindow();
}
void MainWindow::show_fx2()
{
if(!effect2->isVisible())
effect2->show();
effect2->activateWindow();
}
void MainWindow::show_fx3()
{
if(!effect3->isVisible())
effect3->show();
effect3->activateWindow();
}
void MainWindow::show_fx4()
{
if(!effect4->isVisible())
effect4->show();
effect4->activateWindow();
}
void MainWindow::show_amp()
{
if(!amp->isVisible())
amp->show();
amp->activateWindow();
}
void MainWindow::show_library()
{
QSettings settings;
bool previous = settings.value("Settings/popupChangedWindows").toBool();
settings.setValue("Settings/popupChangedWindows", false);
library = new Library(names, this);
effect1->close();
effect2->close();
effect3->close();
effect4->close();
amp->close();
this->close();
library->exec();
settings.setValue("Settings/popupChangedWindows", previous);
this->show();
delete library;
}
void MainWindow::update_firmware()
{
// if(QMessageBox::warning(this, "Danger!", "This function may destroy your amplifier!<br><u><b>You are using it at you own risk!</b></u>", QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Cancel)
// return;
QString filename;
int ret = 0;
QMessageBox::information(this, "Prepare", "Please power off the amplifier, then power it back on while holding down:<ul><li>The \"Save\" button (Mustang I and II)</li><li>The Data Wheel (Mustang III, IV and IV)</li></ul>After pressing \"OK\" choose firmware file and then update will begin.It will take about one minute. You will be notified when it's finished.");
filename = QFileDialog::getOpenFileName(this, tr("Open..."), QDir::homePath(), tr("Mustang firmware (*.upd)"));
if(filename.isEmpty())
return;
if(connected)
this->stop_amp();
ui->statusBar->showMessage("Updating firmware. Please wait...");
ui->centralWidget->setDisabled(true);
ui->menuBar->setDisabled(true);
this->repaint();
ret = amp_ops->update(filename.toAscii().data()); // magic part
ui->centralWidget->setDisabled(false);
ui->menuBar->setDisabled(false);
ui->statusBar->showMessage("", 1);
if(ret == -100)
{
ui->statusBar->showMessage(tr("Error: Suitable device not found!"), 5000);
return;
}
else if(ret)
{
ui->statusBar->showMessage(QString(tr("Communication error: %1")).arg(ret), 5000);
return;
}
QMessageBox::information(this, "Update finished", "<b>Update finished</b><br>If \"Exit\" button is lit - update was succesful<br>If \"Save\" button is lit - update failed<br><br>Power off the amplifier and then back on to finish the process.");
}
void MainWindow::show_default_effects()
{
deffx = new DefaultEffects(this);
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;
}
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());
}
|