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(); }
// from neolib::timer virtual void ready() { check_for_updates(true); }
static boolean title_key(context *ctx, int *key) { const struct config_info *conf = get_config(); struct game_context *title = (struct game_context *)ctx; struct world *mzx_world = ctx->world; // NOTE: disabled due to joystick support. See IKEY_RETURN and IKEY_ESCAPE. //int key_status = get_key_status(keycode_internal_wrt_numlock, *key); boolean exit_status = get_exit_status(); boolean reload_curr_file_in_editor = true; boolean confirm_exit = false; switch(*key) { #ifdef CONFIG_HELPSYS case IKEY_h: { // Help system alternate binding. *key = IKEY_F1; break; } #endif case IKEY_s: { // Configure alternate binding. *key = IKEY_F2; break; } case IKEY_F3: case IKEY_l: { if(conf->standalone_mode) return true; load_world_title_selection(title); return true; } case IKEY_F4: { // ALT+F4 - do nothing. if(get_alt_status(keycode_internal)) break; } /* fallthrough */ case IKEY_r: { // Restore saved game if(conf->standalone_mode && !get_counter(mzx_world, "LOAD_MENU", 0)) return true; if(load_savegame_selection(title)) { play_game(ctx, &(title->fade_in)); title->need_reload = true; } return true; } case IKEY_F5: case IKEY_p: { // Play game if(mzx_world->active) { if(mzx_world->only_from_swap) { error("You can only play this game via a swap from another game", ERROR_T_WARNING, ERROR_OPT_OK, 0x3101); return true; } if(load_world_gameplay(title, curr_file)) { play_game(ctx, NULL); title->need_reload = true; } } return true; } case IKEY_F7: case IKEY_u: { if(check_for_updates) { // FIXME this is garbage int current_music_vol = audio_get_music_volume(); int current_pcs_vol = audio_get_pcs_volume(); audio_set_music_volume(0); audio_set_pcs_volume(0); if(mzx_world->active) audio_set_module_volume(0); check_for_updates(ctx, false); audio_set_pcs_volume(current_pcs_vol); audio_set_music_volume(current_music_vol); if(mzx_world->active) audio_set_module_volume(mzx_world->current_board->volume); } return true; } case IKEY_F8: case IKEY_n: { reload_curr_file_in_editor = false; } /* fallthrough */ case IKEY_F9: case IKEY_e: { if(edit_world) { // Editor sfx_clear_queue(); vquick_fadeout(); title->need_reload = true; title->fade_in = true; edit_world(ctx, reload_curr_file_in_editor); } return true; } // Quickload saved game case IKEY_F10: { struct stat file_info; if(conf->standalone_mode && !get_counter(mzx_world, "LOAD_MENU", 0)) return true; if(!stat(curr_sav, &file_info) && load_savegame(title, curr_sav)) { play_game(ctx, &(title->fade_in)); title->need_reload = true; } return true; } case IKEY_RETURN: // Enter { // Ignore if this isn't a fresh press // NOTE: disabled because it breaks the joystick actions. //if(key_status != 1) //return true; if(!conf->standalone_mode || get_counter(mzx_world, "ENTER_MENU", 0)) main_menu(ctx); return true; } case IKEY_ESCAPE: { // Ignore if this isn't a fresh press // NOTE: disabled because it breaks the joystick actions. //if(key_status != 1) //return true; // ESCAPE_MENU (2.90+) only works on the title screen if the // standalone_mode config option is set if(mzx_world->version < V290 || !conf->standalone_mode || get_counter(mzx_world, "ESCAPE_MENU", 0)) confirm_exit = true; break; } } // Quit if(exit_status || confirm_exit) { // Special behaviour in standalone- only escape exits // ask for confirmation. Exit events instead terminate MegaZeux. if(conf->standalone_mode && !confirm_exit) { core_full_exit(ctx); } else { if(!confirm(mzx_world, "Exit MegaZeux - Are you sure?")) destroy_context(ctx); } return true; } return false; }
int main(int argc, char **argv) { QApplication app(argc, argv); KComponentData cd("kingston_update_notifier"); test_window_t* test_window = new test_window_t(); update_worker_t* update_worker = new update_worker_t(); QObject::connect(test_window,SIGNAL(check_for_updates_requested()),update_worker,SLOT(check_for_updates())); QObject::connect(update_worker,SIGNAL(updates_available(int,int)),test_window,SLOT(show_new_updates(int,int))); QObject::connect(update_worker,SIGNAL(error(QString,update_worker_t::error_code_t)),test_window,SLOT(show_error_message(QString,update_worker_t::error_code_t))); update_listener_t* update_listener = new update_listener_t(); QObject::connect(update_listener,SIGNAL(please_check_for_updates()),update_worker,SLOT(check_for_updates())); notifier_t* notifier = new notifier_t(cd); QObject::connect(update_worker,SIGNAL(updates_available(int,int)),notifier,SLOT(notify_new_updates(int,int))); test_window->show(); update_worker->check_for_updates(); reboot_listener_t* reboot_listener = new reboot_listener_t(); QObject::connect(reboot_listener,SIGNAL(request_reboot()),notifier,SLOT(notify_reboot())); reboot_listener->check_for_reboot(); return app.exec(); }