コード例 #1
0
ファイル: main.cpp プロジェクト: devinacker/bsnes-plus
MainWindow::MainWindow() {
  setObjectName("main-window");
  setWindowTitle(string() << SNES::Info::Name << " v" << SNES::Info::Version);
  setCloseOnEscape(false);
  setGeometryString(&config().geometry.mainWindow);
  application.windowList.append(this);

  //menu bar
  #if defined(PLATFORM_OSX)
  menuBar = new QMenuBar(0);
  #else
  menuBar = new QMenuBar;
  #endif

  system = menuBar->addMenu("&System");

  system_load = system->addAction("Load &Cartridge ...");

  system_loadSpecial = system->addMenu("Load &Special");

  system_loadSpecial_bsx = system_loadSpecial->addAction("Load &BS-X Cartridge ...");
  
  system_loadSpecial_bsxSlotted = system_loadSpecial->addAction("Load BS-X &Slotted Cartridge ...");

  system_loadSpecial_sufamiTurbo = system_loadSpecial->addAction("Load Sufami &Turbo Cartridge ...");

  system_loadSpecial_superGameBoy = system_loadSpecial->addAction("Load Super &Game Boy Cartridge ...");

  system_saveMemoryPack = system->addAction("Save Memory Pack ...");
  system_saveMemoryPack->setVisible(false);

  system_reload = system->addAction("Re&load");

  system->addSeparator();

  system->addAction(system_power = new CheckAction("&Power", 0));

  system_reset = system->addAction("&Reset");

  system->addSeparator();

  system_port1 = system->addMenu("Controller Port &1");
  system_port1->addAction(system_port1_none = new RadioAction("&None", 0));
  system_port1->addAction(system_port1_gamepad = new RadioAction("&Gamepad", 0));
  system_port1->addAction(system_port1_asciipad = new RadioAction("&asciiPad", 0));
  system_port1->addAction(system_port1_multitap = new RadioAction("&Multitap", 0));
  system_port1->addAction(system_port1_mouse = new RadioAction("&Mouse", 0));
  system_port1->addAction(system_port1_nttdatakeypad = new RadioAction("NTT Data &Keypad", 0));

  system_port2 = system->addMenu("Controller Port &2");
  system_port2->addAction(system_port2_none = new RadioAction("&None", 0));
  system_port2->addAction(system_port2_gamepad = new RadioAction("&Gamepad", 0));
  system_port2->addAction(system_port2_asciipad = new RadioAction("&asciiPad", 0));
  system_port2->addAction(system_port2_multitap = new RadioAction("&Multitap", 0));
  system_port2->addAction(system_port2_mouse = new RadioAction("&Mouse", 0));
  system_port2->addAction(system_port2_superscope = new RadioAction("&Super Scope", 0));
  system_port2->addAction(system_port2_justifier = new RadioAction("&Justifier", 0));
  system_port2->addAction(system_port2_justifiers = new RadioAction("Two &Justifiers", 0));

  #if !defined(PLATFORM_OSX)
  system->addSeparator();
  #endif

  system_exit = system->addAction("E&xit");
  system_exit->setMenuRole(QAction::QuitRole);

  settings = menuBar->addMenu("S&ettings");

  settings_videoMode = settings->addMenu("Video &Mode");

  settings_videoMode->addAction(settings_videoMode_1x = new RadioAction("Scale &1x", 0));

  settings_videoMode->addAction(settings_videoMode_2x = new RadioAction("Scale &2x", 0));

  settings_videoMode->addAction(settings_videoMode_3x = new RadioAction("Scale &3x", 0));

  settings_videoMode->addAction(settings_videoMode_4x = new RadioAction("Scale &4x", 0));

  settings_videoMode->addAction(settings_videoMode_5x = new RadioAction("Scale &5x", 0));

  settings_videoMode->addAction(settings_videoMode_max_normal = new RadioAction("Scale Max - &Normal", 0));

  settings_videoMode->addAction(settings_videoMode_max_wide = new RadioAction("Scale Max - &Wide", 0));

  settings_videoMode->addAction(settings_videoMode_max_wideZoom = new RadioAction("Scale Max - Wide &Zoom", 0));

  settings_videoMode->addSeparator();

  settings_videoMode->addAction(settings_videoMode_correctAspectRatio = new CheckAction("Correct &Aspect Ratio", 0));

  settings_videoMode->addSeparator();

  settings_videoMode->addAction(settings_videoMode_ntsc = new RadioAction("&NTSC", 0));
  settings_videoMode->addAction(settings_videoMode_pal = new RadioAction("&PAL", 0));

  if(filter.opened()) {
    settings_videoFilter = settings->addMenu("Video &Filter");

    settings_videoFilter_configure = settings_videoFilter->addAction("&Configure Active Filter ...");
    settings_videoFilter->addSeparator();

    settings_videoFilter->addAction(settings_videoFilter_none = new RadioAction("&None", 0));
    settings_videoFilter_list.append(settings_videoFilter_none);

    lstring filterlist;
    filterlist.split(";", filter.dl_supported());
    for(unsigned i = 0; i < filterlist.size(); i++) {
      RadioAction *action = new RadioAction(filterlist[i], 0);
      settings_videoFilter->addAction(action);
      settings_videoFilter_list.append(action);
    }
  }

  settings->addAction(settings_smoothVideo = new CheckAction("&Smooth Video Output", 0));

  settings->addSeparator();

  settings->addAction(settings_muteAudio = new CheckAction("&Mute Audio Output", 0));

  settings->addSeparator();

  settings_emulationSpeed = settings->addMenu("Emulation &Speed");

  settings_emulationSpeed->addAction(settings_emulationSpeed_slowest = new RadioAction("Slowest", 0));

  settings_emulationSpeed->addAction(settings_emulationSpeed_slow = new RadioAction("Slow", 0));

  settings_emulationSpeed->addAction(settings_emulationSpeed_normal = new RadioAction("Normal", 0));

  settings_emulationSpeed->addAction(settings_emulationSpeed_fast = new RadioAction("Fast", 0));

  settings_emulationSpeed->addAction(settings_emulationSpeed_fastest = new RadioAction("Fastest", 0));

  settings_emulationSpeed->addSeparator();

  settings_emulationSpeed->addAction(settings_emulationSpeed_syncVideo = new CheckAction("Sync &Video", 0));

  settings_emulationSpeed->addAction(settings_emulationSpeed_syncAudio = new CheckAction("Sync &Audio", 0));

  settings_configuration = settings->addAction("&Configuration ...");
  settings_configuration->setMenuRole(QAction::PreferencesRole);

  tools = menuBar->addMenu("&Tools");

  tools_movies = tools->addMenu("&Movies");

  tools_movies_play = tools_movies->addAction("Play Movie ...");

  tools_movies_stop = tools_movies->addAction("Stop");

  tools_movies_recordFromPowerOn = tools_movies->addAction("Record Movie (and restart system)");

  tools_movies_recordFromHere = tools_movies->addAction("Record Movie (starting from here)");

  tools_captureScreenshot = tools->addAction("&Capture Screenshot");
  
  tools_captureSPC = tools->addAction("Capture &SPC Dump");

  tools->addSeparator();

  tools_loadState = tools->addMenu("&Load Quick State");
  for(unsigned i = 0; i < 10; i++) {
    QAction *loadAction = new QAction(string("Slot ", i + 1), 0);
    loadAction->setData(i);
    connect(loadAction, SIGNAL(triggered()), this, SLOT(loadState()));
    tools_loadState->addAction(loadAction);
  }

  tools_saveState = tools->addMenu("&Save Quick State");
  for(unsigned i = 0; i < 10; i++) {
    QAction *saveAction = new QAction(string("Slot ", i + 1), 0);
    saveAction->setData(i);
    connect(saveAction, SIGNAL(triggered()), this, SLOT(saveState()));
    tools_saveState->addAction(saveAction);
  }

  tools->addSeparator();

  tools_cheatEditor = tools->addAction("Cheat &Editor ...");

  tools_cheatFinder = tools->addAction("Cheat &Finder ...");

  tools_stateManager = tools->addAction("&State Manager ...");

  tools_effectToggle = tools->addAction("Effect &Toggle ...");
  if(!SNES::PPU::SupportsLayerEnable && !SNES::DSP::SupportsChannelEnable)
    tools_effectToggle->setVisible(false);
  
  tools_manifestViewer = tools->addAction("&Manifest Viewer ...");
  
  tools_soundViewer = tools->addAction("Sound &Viewer ...");

  tools_debugger = tools->addAction("&Debugger ...");
  #if !defined(DEBUGGER)
  tools_debugger->setVisible(false);
  #endif

  help = menuBar->addMenu("&Help");

  help_documentation = help->addAction("&Documentation ...");

  help_license = help->addAction("&License ...");

  #if !defined(PLATFORM_OSX)
  help->addSeparator();
  #endif

  help_about = help->addAction("&About ...");
  help_about->setMenuRole(QAction::AboutRole);

  //canvas
  canvasContainer = new CanvasObject;
  canvasContainer->setAcceptDrops(true); {
    canvasContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    canvasContainer->setObjectName("backdrop");

    canvasLayout = new QVBoxLayout; {
      canvasLayout->setMargin(0);
      canvasLayout->setAlignment(Qt::AlignCenter);

      canvas = new CanvasWidget;
      canvas->setAcceptDrops(true);
      canvas->setFocusPolicy(Qt::StrongFocus);
      canvas->setAttribute(Qt::WA_PaintOnScreen, true);  //disable Qt painting on focus / resize
      canvas->setAttribute(Qt::WA_NoSystemBackground, true);
    }
    canvasLayout->addWidget(canvas);
  }
  canvasContainer->setLayout(canvasLayout);

  //status bar
  statusBar = new QStatusBar;
  statusBar->setSizeGripEnabled(false);
  statusBar->showMessage("");
  systemState = new QLabel;
  statusBar->addPermanentWidget(systemState);

  //layout
  layout = new QVBoxLayout;
  layout->setMargin(0);
  layout->setSpacing(0);
  #if !defined(PLATFORM_OSX)
  layout->addWidget(menuBar);
  #endif
  layout->addWidget(canvasContainer);
  layout->addWidget(statusBar);
  setLayout(layout);

  //cursor hide timer
  cursorTimer = new QTimer(this);
  cursorTimer->setSingleShot(true);
  cursorTimer->setInterval(5*1000);

  //slots
  connect(system_load, SIGNAL(triggered()), this, SLOT(loadCartridge()));
  connect(system_reload, SIGNAL(triggered()), this, SLOT(reloadCartridge()));
  connect(system_loadSpecial_bsxSlotted, SIGNAL(triggered()), this, SLOT(loadBsxSlottedCartridge()));
  connect(system_loadSpecial_bsx, SIGNAL(triggered()), this, SLOT(loadBsxCartridge()));
  connect(system_loadSpecial_sufamiTurbo, SIGNAL(triggered()), this, SLOT(loadSufamiTurboCartridge()));
  connect(system_loadSpecial_superGameBoy, SIGNAL(triggered()), this, SLOT(loadSuperGameBoyCartridge()));
  connect(system_saveMemoryPack, SIGNAL(triggered()), this, SLOT(saveMemoryPack()));
  connect(system_power, SIGNAL(triggered()), this, SLOT(power()));
  connect(system_reset, SIGNAL(triggered()), this, SLOT(reset()));
  connect(system_port1_none, SIGNAL(triggered()), this, SLOT(setPort1None()));
  connect(system_port1_gamepad, SIGNAL(triggered()), this, SLOT(setPort1Gamepad()));
  connect(system_port1_asciipad, SIGNAL(triggered()), this, SLOT(setPort1Asciipad()));
  connect(system_port1_multitap, SIGNAL(triggered()), this, SLOT(setPort1Multitap()));
  connect(system_port1_mouse, SIGNAL(triggered()), this, SLOT(setPort1Mouse()));
  connect(system_port1_nttdatakeypad, SIGNAL(triggered()), this, SLOT(setPort1NTTDataKeypad()));
  connect(system_port2_none, SIGNAL(triggered()), this, SLOT(setPort2None()));
  connect(system_port2_gamepad, SIGNAL(triggered()), this, SLOT(setPort2Gamepad()));
  connect(system_port2_asciipad, SIGNAL(triggered()), this, SLOT(setPort2Asciipad()));
  connect(system_port2_multitap, SIGNAL(triggered()), this, SLOT(setPort2Multitap()));
  connect(system_port2_mouse, SIGNAL(triggered()), this, SLOT(setPort2Mouse()));
  connect(system_port2_superscope, SIGNAL(triggered()), this, SLOT(setPort2SuperScope()));
  connect(system_port2_justifier, SIGNAL(triggered()), this, SLOT(setPort2Justifier()));
  connect(system_port2_justifiers, SIGNAL(triggered()), this, SLOT(setPort2Justifiers()));
  connect(system_exit, SIGNAL(triggered()), this, SLOT(quit()));
  connect(settings_videoMode_1x, SIGNAL(triggered()), this, SLOT(setVideoMode1x()));
  connect(settings_videoMode_2x, SIGNAL(triggered()), this, SLOT(setVideoMode2x()));
  connect(settings_videoMode_3x, SIGNAL(triggered()), this, SLOT(setVideoMode3x()));
  connect(settings_videoMode_4x, SIGNAL(triggered()), this, SLOT(setVideoMode4x()));
  connect(settings_videoMode_5x, SIGNAL(triggered()), this, SLOT(setVideoMode5x()));
  connect(settings_videoMode_max_normal, SIGNAL(triggered()), this, SLOT(setVideoModeMaxNormal()));
  connect(settings_videoMode_max_wide, SIGNAL(triggered()), this, SLOT(setVideoModeMaxWide()));
  connect(settings_videoMode_max_wideZoom, SIGNAL(triggered()), this, SLOT(setVideoModeMaxWideZoom()));
  connect(settings_videoMode_correctAspectRatio, SIGNAL(triggered()), this, SLOT(toggleAspectCorrection()));
  connect(settings_videoMode_ntsc, SIGNAL(triggered()), this, SLOT(setVideoNtsc()));
  connect(settings_videoMode_pal, SIGNAL(triggered()), this, SLOT(setVideoPal()));
  if(filter.opened()) {
    connect(settings_videoFilter_configure, SIGNAL(triggered()), this, SLOT(configureFilter()));
    for(unsigned i = 0; i < settings_videoFilter_list.size(); i++) {
      connect(settings_videoFilter_list[i], SIGNAL(triggered()), this, SLOT(setFilter()));
    }
  }
  connect(settings_smoothVideo, SIGNAL(triggered()), this, SLOT(toggleSmoothVideo()));
  connect(settings_muteAudio, SIGNAL(triggered()), this, SLOT(muteAudio()));
  connect(settings_emulationSpeed_slowest, SIGNAL(triggered()), this, SLOT(setSpeedSlowest()));
  connect(settings_emulationSpeed_slow, SIGNAL(triggered()), this, SLOT(setSpeedSlow()));
  connect(settings_emulationSpeed_normal, SIGNAL(triggered()), this, SLOT(setSpeedNormal()));
  connect(settings_emulationSpeed_fast, SIGNAL(triggered()), this, SLOT(setSpeedFast()));
  connect(settings_emulationSpeed_fastest, SIGNAL(triggered()), this, SLOT(setSpeedFastest()));
  connect(settings_emulationSpeed_syncVideo, SIGNAL(triggered()), this, SLOT(syncVideo()));
  connect(settings_emulationSpeed_syncAudio, SIGNAL(triggered()), this, SLOT(syncAudio()));
  connect(settings_configuration, SIGNAL(triggered()), this, SLOT(showConfigWindow()));
  connect(tools_movies_play, SIGNAL(triggered()), this, SLOT(playMovie()));
  connect(tools_movies_stop, SIGNAL(triggered()), this, SLOT(stopMovie()));
  connect(tools_movies_recordFromPowerOn, SIGNAL(triggered()), this, SLOT(recordMovieFromPowerOn()));
  connect(tools_movies_recordFromHere, SIGNAL(triggered()), this, SLOT(recordMovieFromHere()));
  connect(tools_captureScreenshot, SIGNAL(triggered()), this, SLOT(saveScreenshot()));
  connect(tools_captureSPC, SIGNAL(triggered()), this, SLOT(saveSPC()));
  connect(tools_cheatEditor, SIGNAL(triggered()), this, SLOT(showCheatEditor()));
  connect(tools_cheatFinder, SIGNAL(triggered()), this, SLOT(showCheatFinder()));
  connect(tools_stateManager, SIGNAL(triggered()), this, SLOT(showStateManager()));
  connect(tools_effectToggle, SIGNAL(triggered()), this, SLOT(showEffectToggle()));
  connect(tools_manifestViewer, SIGNAL(triggered()), this, SLOT(showManifestViewer()));
  connect(tools_soundViewer, SIGNAL(triggered()), this, SLOT(showSoundViewer()));
  connect(tools_debugger, SIGNAL(triggered()), this, SLOT(showDebugger()));
  connect(help_documentation, SIGNAL(triggered()), this, SLOT(showDocumentation()));
  connect(help_license, SIGNAL(triggered()), this, SLOT(showLicense()));
  connect(help_about, SIGNAL(triggered()), this, SLOT(showAbout()));

  syncUi();
}
コード例 #2
0
ファイル: main.cpp プロジェクト: ben401/OpenEmu
MainWindow::MainWindow() : QbWindow(config.geometry.mainWindow) {
  setObjectName("main-window");
  setWindowTitle(utf8() << bsnesTitle << " v" << bsnesVersion);

  //menu bar
  #if defined(PLATFORM_OSX)
  menuBar = new QMenuBar(0);
  #else
  menuBar = new QMenuBar;
  #endif

  system = menuBar->addMenu("System");
    system_load = system->addAction("Load Cartridge ...");
    system_load->setIcon(QIcon(":/16x16/document-open.png"));
    system_loadSpecial = system->addMenu("Load Special");
    system_loadSpecial->setIcon(QIcon(":/16x16/document-open.png"));
      system_loadSpecial_bsxSlotted = system_loadSpecial->addAction("Load BS-X Slotted Cartridge ...");
      system_loadSpecial_bsxSlotted->setIcon(QIcon(":/16x16/document-open.png"));
      system_loadSpecial_bsx = system_loadSpecial->addAction("Load BS-X Cartridge ...");
      system_loadSpecial_bsx->setIcon(QIcon(":/16x16/document-open.png"));
      system_loadSpecial_sufamiTurbo = system_loadSpecial->addAction("Load Sufami Turbo Cartridge ...");
      system_loadSpecial_sufamiTurbo->setIcon(QIcon(":/16x16/document-open.png"));
      system_loadSpecial_superGameBoy = system_loadSpecial->addAction("Load Super Game Boy Cartridge ...");
      system_loadSpecial_superGameBoy->setIcon(QIcon(":/16x16/document-open.png"));
    system->addSeparator();
    system->addAction(system_power = new QbCheckAction("Power", 0));
    system_reset = system->addAction("Reset");
    system_reset->setIcon(QIcon(":/16x16/view-refresh.png"));
    system->addSeparator();
    system_port1 = system->addMenu("Controller Port 1");
    system_port1->setIcon(QIcon(":/16x16/input-gaming.png"));
      system_port1->addAction(system_port1_none = new QbRadioAction("None", 0));
      system_port1->addAction(system_port1_joypad = new QbRadioAction("Joypad", 0));
      system_port1->addAction(system_port1_multitap = new QbRadioAction("Multitap", 0));
      system_port1->addAction(system_port1_mouse = new QbRadioAction("Mouse", 0));
    system_port2 = system->addMenu("Controller Port 2");
    system_port2->setIcon(QIcon(":/16x16/input-gaming.png"));
      system_port2->addAction(system_port2_none = new QbRadioAction("None", 0));
      system_port2->addAction(system_port2_joypad = new QbRadioAction("Joypad", 0));
      system_port2->addAction(system_port2_multitap = new QbRadioAction("Multitap", 0));
      system_port2->addAction(system_port2_mouse = new QbRadioAction("Mouse", 0));
      system_port2->addAction(system_port2_superscope = new QbRadioAction("Super Scope", 0));
      system_port2->addAction(system_port2_justifier = new QbRadioAction("Justifier", 0));
      system_port2->addAction(system_port2_justifiers = new QbRadioAction("Two Justifiers", 0));
    #if !defined(PLATFORM_OSX)
    system->addSeparator();
    #endif
    system_exit = system->addAction("Exit");
    system_exit->setIcon(QIcon(":/16x16/process-stop.png"));
    system_exit->setMenuRole(QAction::QuitRole);

  settings = menuBar->addMenu("Settings");
    settings_videoMode = settings->addMenu("Video Mode");
    settings_videoMode->setIcon(QIcon(":/16x16/video-display.png"));
      settings_videoMode->addAction(settings_videoMode_1x = new QbRadioAction("Scale 1x", 0));
      settings_videoMode->addAction(settings_videoMode_2x = new QbRadioAction("Scale 2x", 0));
      settings_videoMode->addAction(settings_videoMode_3x = new QbRadioAction("Scale 3x", 0));
      settings_videoMode->addAction(settings_videoMode_4x = new QbRadioAction("Scale 4x", 0));
      settings_videoMode->addAction(settings_videoMode_max = new QbRadioAction("Scale Max", 0));
      settings_videoMode->addSeparator();
      settings_videoMode->addAction(settings_videoMode_correctAspectRatio = new QbCheckAction("Correct Aspect Ratio", 0));
      settings_videoMode->addAction(settings_videoMode_fullscreen = new QbCheckAction("Fullscreen", 0));
      settings_videoMode->addSeparator();
      settings_videoMode->addAction(settings_videoMode_ntsc = new QbRadioAction("NTSC", 0));
      settings_videoMode->addAction(settings_videoMode_pal = new QbRadioAction("PAL", 0));

    if(filter.opened()) {
      settings_videoFilter = settings->addMenu("Video Filter");
      settings_videoFilter->setIcon(QIcon(":/16x16/image-x-generic.png"));

      settings_videoFilter_configure = settings_videoFilter->addAction("Configure Active Filter ...");
      settings_videoFilter_configure->setIcon(QIcon(":/16x16/preferences-desktop.png"));
      settings_videoFilter->addSeparator();

      settings_videoFilter->addAction(settings_videoFilter_none = new QbRadioAction("None", 0));
      settings_videoFilter_list.add(settings_videoFilter_none);

      lstring filterlist;
      filterlist.split(";", filter.dl_supported());
      for(unsigned i = 0; i < filterlist.size(); i++) {
        QbRadioAction *action = new QbRadioAction(utf8() << filterlist[i], 0);
        settings_videoFilter->addAction(action);
        settings_videoFilter_list.add(action);
      }
    }

    settings->addAction(settings_smoothVideo = new QbCheckAction("Smooth Video Output", 0));
    settings->addSeparator();
    settings->addAction(settings_muteAudio = new QbCheckAction("Mute Audio Output", 0));
    settings->addSeparator();
    settings_emulationSpeed = settings->addMenu("Emulation Speed");
    settings_emulationSpeed->setIcon(QIcon(":/16x16/appointment-new.png"));
      settings_emulationSpeed->addAction(settings_emulationSpeed_slowest = new QbRadioAction("50%", 0));
      settings_emulationSpeed->addAction(settings_emulationSpeed_slow = new QbRadioAction("75%", 0));
      settings_emulationSpeed->addAction(settings_emulationSpeed_normal = new QbRadioAction("100%", 0));
      settings_emulationSpeed->addAction(settings_emulationSpeed_fast = new QbRadioAction("150%", 0));
      settings_emulationSpeed->addAction(settings_emulationSpeed_fastest = new QbRadioAction("200%", 0));
      settings_emulationSpeed->addSeparator();
      settings_emulationSpeed->addAction(settings_emulationSpeed_syncVideo = new QbCheckAction("Sync Video", 0));
      settings_emulationSpeed->addAction(settings_emulationSpeed_syncAudio = new QbCheckAction("Sync Audio", 0));
    settings_configuration = settings->addAction("Configuration ...");
    settings_configuration->setIcon(QIcon(":/16x16/preferences-desktop.png"));
    settings_configuration->setMenuRole(QAction::PreferencesRole);

  tools = menuBar->addMenu("Tools");
    tools_cheatEditor = tools->addAction("Cheat Editor ...");
    tools_cheatEditor->setIcon(QIcon(":/16x16/accessories-text-editor.png"));
    tools_cheatFinder = tools->addAction("Cheat Finder ...");
    tools_cheatFinder->setIcon(QIcon(":/16x16/system-search.png"));
    tools_stateManager = tools->addAction("State Manager ...");
    tools_stateManager->setIcon(QIcon(":/16x16/system-file-manager.png"));
    tools->addSeparator();
    tools_captureScreenshot = tools->addAction("Capture Screenshot");
    tools_captureScreenshot->setIcon(QIcon(":/16x16/image-x-generic.png"));
    tools_debugger = tools->addAction("Debugger ...");
    tools_debugger->setIcon(QIcon(":/16x16/utilities-terminal.png"));
    #if !defined(DEBUGGER)
    tools_debugger->setVisible(false);
    #endif

  help = menuBar->addMenu("Help");
    help_documentation = help->addAction("Documentation ...");
    help_documentation->setIcon(QIcon(":/16x16/text-x-generic.png"));
    help_license = help->addAction("License ...");
    help_license->setIcon(QIcon(":/16x16/text-x-generic.png"));
    #if !defined(PLATFORM_OSX)
    help->addSeparator();
    #endif
    help_about = help->addAction("About ...");
    help_about->setIcon(QIcon(":/16x16/help-browser.png"));
    help_about->setMenuRole(QAction::AboutRole);

  //canvas
  canvasContainer = new CanvasObject;
  canvasContainer->setAcceptDrops(true); {
    canvasContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    canvasContainer->setObjectName("backdrop");

    canvasLayout = new QVBoxLayout; {
      canvasLayout->setMargin(0);
      canvasLayout->setAlignment(Qt::AlignCenter);

      canvas = new CanvasWidget;
      canvas->setAcceptDrops(true);
      canvas->setFocusPolicy(Qt::StrongFocus);
      canvas->setAttribute(Qt::WA_PaintOnScreen, true);  //disable Qt painting on focus / resize

      QPalette palette;
      palette.setColor(QPalette::Window, QColor(0, 0, 0));
      canvas->setPalette(palette);
      canvas->setAutoFillBackground(true);
    }
    canvasLayout->addWidget(canvas);
  }
  canvasContainer->setLayout(canvasLayout);

  //status bar
  statusBar = new QStatusBar;
  statusBar->showMessage("");
  systemState = new QLabel;
  statusBar->addPermanentWidget(systemState);

  //layout
  layout = new QVBoxLayout;
  layout->setMargin(0);
  layout->setSpacing(0);
  #if !defined(PLATFORM_OSX)
  layout->addWidget(menuBar);
  #endif
  layout->addWidget(canvasContainer);
  layout->addWidget(statusBar);
  setLayout(layout);

  //slots
  connect(system_load, SIGNAL(triggered()), this, SLOT(loadCartridge()));
  connect(system_loadSpecial_bsxSlotted, SIGNAL(triggered()), this, SLOT(loadBsxSlottedCartridge()));
  connect(system_loadSpecial_bsx, SIGNAL(triggered()), this, SLOT(loadBsxCartridge()));
  connect(system_loadSpecial_sufamiTurbo, SIGNAL(triggered()), this, SLOT(loadSufamiTurboCartridge()));
  connect(system_loadSpecial_superGameBoy, SIGNAL(triggered()), this, SLOT(loadSuperGameBoyCartridge()));
  connect(system_power, SIGNAL(triggered()), this, SLOT(power()));
  connect(system_reset, SIGNAL(triggered()), this, SLOT(reset()));
  connect(system_port1_none, SIGNAL(triggered()), this, SLOT(setPort1None()));
  connect(system_port1_joypad, SIGNAL(triggered()), this, SLOT(setPort1Joypad()));
  connect(system_port1_multitap, SIGNAL(triggered()), this, SLOT(setPort1Multitap()));
  connect(system_port1_mouse, SIGNAL(triggered()), this, SLOT(setPort1Mouse()));
  connect(system_port2_none, SIGNAL(triggered()), this, SLOT(setPort2None()));
  connect(system_port2_joypad, SIGNAL(triggered()), this, SLOT(setPort2Joypad()));
  connect(system_port2_multitap, SIGNAL(triggered()), this, SLOT(setPort2Multitap()));
  connect(system_port2_mouse, SIGNAL(triggered()), this, SLOT(setPort2Mouse()));
  connect(system_port2_superscope, SIGNAL(triggered()), this, SLOT(setPort2SuperScope()));
  connect(system_port2_justifier, SIGNAL(triggered()), this, SLOT(setPort2Justifier()));
  connect(system_port2_justifiers, SIGNAL(triggered()), this, SLOT(setPort2Justifiers()));
  connect(system_exit, SIGNAL(triggered()), this, SLOT(quit()));
  connect(settings_videoMode_1x, SIGNAL(triggered()), this, SLOT(setVideoMode1x()));
  connect(settings_videoMode_2x, SIGNAL(triggered()), this, SLOT(setVideoMode2x()));
  connect(settings_videoMode_3x, SIGNAL(triggered()), this, SLOT(setVideoMode3x()));
  connect(settings_videoMode_4x, SIGNAL(triggered()), this, SLOT(setVideoMode4x()));
  connect(settings_videoMode_max, SIGNAL(triggered()), this, SLOT(setVideoModeMax()));
  connect(settings_videoMode_correctAspectRatio, SIGNAL(triggered()), this, SLOT(toggleAspectCorrection()));
  connect(settings_videoMode_fullscreen, SIGNAL(triggered()), this, SLOT(toggleFullscreen()));
  connect(settings_videoMode_ntsc, SIGNAL(triggered()), this, SLOT(setVideoNtsc()));
  connect(settings_videoMode_pal, SIGNAL(triggered()), this, SLOT(setVideoPal()));
  if(filter.opened()) {
    connect(settings_videoFilter_configure, SIGNAL(triggered()), this, SLOT(configureFilter()));
    for(unsigned i = 0; i < settings_videoFilter_list.size(); i++) {
      connect(settings_videoFilter_list[i], SIGNAL(triggered()), this, SLOT(setFilter()));
    }
  }
  connect(settings_smoothVideo, SIGNAL(triggered()), this, SLOT(toggleSmoothVideo()));
  connect(settings_muteAudio, SIGNAL(triggered()), this, SLOT(muteAudio()));
  connect(settings_emulationSpeed_slowest, SIGNAL(triggered()), this, SLOT(setSpeedSlowest()));
  connect(settings_emulationSpeed_slow, SIGNAL(triggered()), this, SLOT(setSpeedSlow()));
  connect(settings_emulationSpeed_normal, SIGNAL(triggered()), this, SLOT(setSpeedNormal()));
  connect(settings_emulationSpeed_fast, SIGNAL(triggered()), this, SLOT(setSpeedFast()));
  connect(settings_emulationSpeed_fastest, SIGNAL(triggered()), this, SLOT(setSpeedFastest()));
  connect(settings_emulationSpeed_syncVideo, SIGNAL(triggered()), this, SLOT(syncVideo()));
  connect(settings_emulationSpeed_syncAudio, SIGNAL(triggered()), this, SLOT(syncAudio()));
  connect(settings_configuration, SIGNAL(triggered()), this, SLOT(showConfigWindow()));
  connect(tools_cheatEditor, SIGNAL(triggered()), this, SLOT(showCheatEditor()));
  connect(tools_cheatFinder, SIGNAL(triggered()), this, SLOT(showCheatFinder()));
  connect(tools_stateManager, SIGNAL(triggered()), this, SLOT(showStateManager()));
  connect(tools_captureScreenshot, SIGNAL(triggered()), this, SLOT(saveScreenshot()));
  connect(tools_debugger, SIGNAL(triggered()), this, SLOT(showDebugger()));
  connect(help_documentation, SIGNAL(triggered()), this, SLOT(showDocumentation()));
  connect(help_license, SIGNAL(triggered()), this, SLOT(showLicense()));
  connect(help_about, SIGNAL(triggered()), this, SLOT(showAbout()));

  syncUi();
}
コード例 #3
0
ファイル: main.cpp プロジェクト: CatalystG/mednafen-libretro
MainWindow::MainWindow() : QbWindow(config().geometry.mainWindow) {
  setObjectName("main-window");
  setWindowTitle(string() << bsnesTitle << " v" << bsnesVersion);
  setCloseOnEscape(false);

  //menu bar
  #if defined(PLATFORM_OSX)
  menuBar = new QMenuBar(0);
  #else
  menuBar = new QMenuBar;
  #endif

  system = menuBar->addMenu("&System");

  system_load = system->addAction("Load &Cartridge ...");
  system_load->setIcon(QIcon(":/16x16/document-open.png"));

  system_loadSpecial = system->addMenu("Load &Special");
  system_loadSpecial->setIcon(QIcon(":/16x16/document-open.png"));

  system_loadSpecial_bsxSlotted = system_loadSpecial->addAction("Load BS-X &Slotted Cartridge ...");
  system_loadSpecial_bsxSlotted->setIcon(QIcon(":/16x16/document-open.png"));

  system_loadSpecial_bsx = system_loadSpecial->addAction("Load &BS-X Cartridge ...");
  system_loadSpecial_bsx->setIcon(QIcon(":/16x16/document-open.png"));

  system_loadSpecial_sufamiTurbo = system_loadSpecial->addAction("Load Sufami &Turbo Cartridge ...");
  system_loadSpecial_sufamiTurbo->setIcon(QIcon(":/16x16/document-open.png"));

  system_loadSpecial_superGameBoy = system_loadSpecial->addAction("Load Super &Game Boy Cartridge ...");
  system_loadSpecial_superGameBoy->setIcon(QIcon(":/16x16/document-open.png"));

  system->addSeparator();

  system->addAction(system_power = new QbCheckAction("&Power", 0));

  system_reset = system->addAction("&Reset");
  system_reset->setIcon(QIcon(":/16x16/view-refresh.png"));

  system->addSeparator();

  system_port1 = system->addMenu("Controller Port &1");
  system_port1->setIcon(QIcon(":/16x16/input-gaming.png"));
  system_port1->addAction(system_port1_none = new QbRadioAction("&None", 0));
  system_port1->addAction(system_port1_gamepad = new QbRadioAction("&Gamepad", 0));
  system_port1->addAction(system_port1_asciipad = new QbRadioAction("&asciiPad", 0));
  system_port1->addAction(system_port1_multitap = new QbRadioAction("&Multitap", 0));
  system_port1->addAction(system_port1_mouse = new QbRadioAction("&Mouse", 0));

  system_port2 = system->addMenu("Controller Port &2");
  system_port2->setIcon(QIcon(":/16x16/input-gaming.png"));
  system_port2->addAction(system_port2_none = new QbRadioAction("&None", 0));
  system_port2->addAction(system_port2_gamepad = new QbRadioAction("&Gamepad", 0));
  system_port2->addAction(system_port2_asciipad = new QbRadioAction("&asciiPad", 0));
  system_port2->addAction(system_port2_multitap = new QbRadioAction("&Multitap", 0));
  system_port2->addAction(system_port2_mouse = new QbRadioAction("&Mouse", 0));
  system_port2->addAction(system_port2_superscope = new QbRadioAction("&Super Scope", 0));
  system_port2->addAction(system_port2_justifier = new QbRadioAction("&Justifier", 0));
  system_port2->addAction(system_port2_justifiers = new QbRadioAction("Two &Justifiers", 0));

  #if !defined(PLATFORM_OSX)
  system->addSeparator();
  #endif

  system_exit = system->addAction("E&xit");
  system_exit->setIcon(QIcon(":/16x16/process-stop.png"));
  system_exit->setMenuRole(QAction::QuitRole);

  settings = menuBar->addMenu("S&ettings");

  settings_videoMode = settings->addMenu("Video &Mode");
  settings_videoMode->setIcon(QIcon(":/16x16/video-display.png"));

  settings_videoMode->addAction(settings_videoMode_1x = new QbRadioAction("Scale &1x", 0));

  settings_videoMode->addAction(settings_videoMode_2x = new QbRadioAction("Scale &2x", 0));

  settings_videoMode->addAction(settings_videoMode_3x = new QbRadioAction("Scale &3x", 0));

  settings_videoMode->addAction(settings_videoMode_4x = new QbRadioAction("Scale &4x", 0));

  settings_videoMode->addAction(settings_videoMode_5x = new QbRadioAction("Scale &5x", 0));

  settings_videoMode->addSeparator();

  settings_videoMode->addAction(settings_videoMode_correctAspectRatio = new QbCheckAction("Correct &Aspect Ratio", 0));

  settings_videoMode->addSeparator();

  settings_videoMode->addAction(settings_videoMode_ntsc = new QbRadioAction("&NTSC", 0));
  settings_videoMode->addAction(settings_videoMode_pal = new QbRadioAction("&PAL", 0));

  if(filter.opened()) {
    settings_videoFilter = settings->addMenu("Video &Filter");
    settings_videoFilter->setIcon(QIcon(":/16x16/image-x-generic.png"));

    settings_videoFilter_configure = settings_videoFilter->addAction("&Configure Active Filter ...");
    settings_videoFilter_configure->setIcon(QIcon(":/16x16/preferences-desktop.png"));
    settings_videoFilter->addSeparator();

    settings_videoFilter->addAction(settings_videoFilter_none = new QbRadioAction("&None", 0));
    settings_videoFilter_list.add(settings_videoFilter_none);

    lstring filterlist;
    filterlist.split(";", filter.dl_supported());
    for(unsigned i = 0; i < filterlist.size(); i++) {
      QbRadioAction *action = new QbRadioAction(filterlist[i], 0);
      settings_videoFilter->addAction(action);
      settings_videoFilter_list.add(action);
    }
  }

  settings->addAction(settings_smoothVideo = new QbCheckAction("&Smooth Video Output", 0));

  settings->addSeparator();

  settings->addAction(settings_muteAudio = new QbCheckAction("&Mute Audio Output", 0));

  settings->addSeparator();

  settings_emulationSpeed = settings->addMenu("Emulation &Speed");
  settings_emulationSpeed->setIcon(QIcon(":/16x16/appointment-new.png"));

  settings_emulationSpeed->addAction(settings_emulationSpeed_slowest = new QbRadioAction("Slowest", 0));

  settings_emulationSpeed->addAction(settings_emulationSpeed_slow = new QbRadioAction("Slow", 0));

  settings_emulationSpeed->addAction(settings_emulationSpeed_normal = new QbRadioAction("Normal", 0));

  settings_emulationSpeed->addAction(settings_emulationSpeed_fast = new QbRadioAction("Fast", 0));

  settings_emulationSpeed->addAction(settings_emulationSpeed_fastest = new QbRadioAction("Fastest", 0));

  settings_emulationSpeed->addSeparator();

  settings_emulationSpeed->addAction(settings_emulationSpeed_syncVideo = new QbCheckAction("Sync &Video", 0));

  settings_emulationSpeed->addAction(settings_emulationSpeed_syncAudio = new QbCheckAction("Sync &Audio", 0));

  settings_configuration = settings->addAction("&Configuration ...");
  settings_configuration->setIcon(QIcon(":/16x16/preferences-desktop.png"));
  settings_configuration->setMenuRole(QAction::PreferencesRole);

  tools = menuBar->addMenu("&Tools");

  tools_movies = tools->addMenu("&Movies");
  tools_movies->setIcon(QIcon(":/16x16/applications-multimedia.png"));

  tools_movies_play = tools_movies->addAction("Play Movie ...");
  tools_movies_play->setIcon(QIcon(":/16x16/media-playback-start.png"));

  tools_movies_stop = tools_movies->addAction("Stop");
  tools_movies_stop->setIcon(QIcon(":/16x16/media-playback-stop.png"));

  tools_movies_recordFromPowerOn = tools_movies->addAction("Record Movie (and restart system)");
  tools_movies_recordFromPowerOn->setIcon(QIcon(":/16x16/media-record.png"));

  tools_movies_recordFromHere = tools_movies->addAction("Record Movie (starting from here)");
  tools_movies_recordFromHere->setIcon(QIcon(":/16x16/media-record.png"));

  tools_captureScreenshot = tools->addAction("&Capture Screenshot");
  tools_captureScreenshot->setIcon(QIcon(":/16x16/image-x-generic.png"));

  tools->addSeparator();

  tools_dialog = tools->addAction("&Tools Dialog ...");
  tools_dialog->setIcon(QIcon(":/16x16/preferences-desktop.png"));

  tools_debugger = tools->addAction("&Debugger ...");
  tools_debugger->setIcon(QIcon(":/16x16/utilities-terminal.png"));
  #if !defined(DEBUGGER)
  tools_debugger->setVisible(false);
  #endif

  help = menuBar->addMenu("&Help");

  help_documentation = help->addAction("&Documentation ...");
  help_documentation->setIcon(QIcon(":/16x16/text-x-generic.png"));

  help_license = help->addAction("&License ...");
  help_license->setIcon(QIcon(":/16x16/text-x-generic.png"));

  #if !defined(PLATFORM_OSX)
  help->addSeparator();
  #endif

  help_about = help->addAction("&About ...");
  help_about->setIcon(QIcon(":/16x16/help-browser.png"));
  help_about->setMenuRole(QAction::AboutRole);

  //canvas
  canvasContainer = new CanvasObject;
  canvasContainer->setAcceptDrops(true); {
    canvasContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    canvasContainer->setObjectName("backdrop");

    canvasLayout = new QVBoxLayout; {
      canvasLayout->setMargin(0);
      canvasLayout->setAlignment(Qt::AlignCenter);

      canvas = new CanvasWidget;
      canvas->setAcceptDrops(true);
      canvas->setFocusPolicy(Qt::StrongFocus);
      canvas->setAttribute(Qt::WA_PaintOnScreen, true);  //disable Qt painting on focus / resize

      QPalette palette;
      palette.setColor(QPalette::Window, QColor(0, 0, 0));
      canvas->setPalette(palette);
      canvas->setAutoFillBackground(true);
    }
    canvasLayout->addWidget(canvas);
  }
  canvasContainer->setLayout(canvasLayout);

  //status bar
  statusBar = new QStatusBar;
  statusBar->showMessage("");
  systemState = new QLabel;
  statusBar->addPermanentWidget(systemState);

  //layout
  layout = new QVBoxLayout;
  layout->setMargin(0);
  layout->setSpacing(0);
  #if !defined(PLATFORM_OSX)
  layout->addWidget(menuBar);
  #endif
  layout->addWidget(canvasContainer);
  layout->addWidget(statusBar);
  setLayout(layout);

  //slots
  connect(system_load, SIGNAL(triggered()), this, SLOT(loadCartridge()));
  connect(system_loadSpecial_bsxSlotted, SIGNAL(triggered()), this, SLOT(loadBsxSlottedCartridge()));
  connect(system_loadSpecial_bsx, SIGNAL(triggered()), this, SLOT(loadBsxCartridge()));
  connect(system_loadSpecial_sufamiTurbo, SIGNAL(triggered()), this, SLOT(loadSufamiTurboCartridge()));
  connect(system_loadSpecial_superGameBoy, SIGNAL(triggered()), this, SLOT(loadSuperGameBoyCartridge()));
  connect(system_power, SIGNAL(triggered()), this, SLOT(power()));
  connect(system_reset, SIGNAL(triggered()), this, SLOT(reset()));
  connect(system_port1_none, SIGNAL(triggered()), this, SLOT(setPort1None()));
  connect(system_port1_gamepad, SIGNAL(triggered()), this, SLOT(setPort1Gamepad()));
  connect(system_port1_asciipad, SIGNAL(triggered()), this, SLOT(setPort1Asciipad()));
  connect(system_port1_multitap, SIGNAL(triggered()), this, SLOT(setPort1Multitap()));
  connect(system_port1_mouse, SIGNAL(triggered()), this, SLOT(setPort1Mouse()));
  connect(system_port2_none, SIGNAL(triggered()), this, SLOT(setPort2None()));
  connect(system_port2_gamepad, SIGNAL(triggered()), this, SLOT(setPort2Gamepad()));
  connect(system_port2_asciipad, SIGNAL(triggered()), this, SLOT(setPort2Asciipad()));
  connect(system_port2_multitap, SIGNAL(triggered()), this, SLOT(setPort2Multitap()));
  connect(system_port2_mouse, SIGNAL(triggered()), this, SLOT(setPort2Mouse()));
  connect(system_port2_superscope, SIGNAL(triggered()), this, SLOT(setPort2SuperScope()));
  connect(system_port2_justifier, SIGNAL(triggered()), this, SLOT(setPort2Justifier()));
  connect(system_port2_justifiers, SIGNAL(triggered()), this, SLOT(setPort2Justifiers()));
  connect(system_exit, SIGNAL(triggered()), this, SLOT(quit()));
  connect(settings_videoMode_1x, SIGNAL(triggered()), this, SLOT(setVideoMode1x()));
  connect(settings_videoMode_2x, SIGNAL(triggered()), this, SLOT(setVideoMode2x()));
  connect(settings_videoMode_3x, SIGNAL(triggered()), this, SLOT(setVideoMode3x()));
  connect(settings_videoMode_4x, SIGNAL(triggered()), this, SLOT(setVideoMode4x()));
  connect(settings_videoMode_5x, SIGNAL(triggered()), this, SLOT(setVideoMode5x()));
  connect(settings_videoMode_correctAspectRatio, SIGNAL(triggered()), this, SLOT(toggleAspectCorrection()));
  connect(settings_videoMode_ntsc, SIGNAL(triggered()), this, SLOT(setVideoNtsc()));
  connect(settings_videoMode_pal, SIGNAL(triggered()), this, SLOT(setVideoPal()));
  if(filter.opened()) {
    connect(settings_videoFilter_configure, SIGNAL(triggered()), this, SLOT(configureFilter()));
    for(unsigned i = 0; i < settings_videoFilter_list.size(); i++) {
      connect(settings_videoFilter_list[i], SIGNAL(triggered()), this, SLOT(setFilter()));
    }
  }
  connect(settings_smoothVideo, SIGNAL(triggered()), this, SLOT(toggleSmoothVideo()));
  connect(settings_muteAudio, SIGNAL(triggered()), this, SLOT(muteAudio()));
  connect(settings_emulationSpeed_slowest, SIGNAL(triggered()), this, SLOT(setSpeedSlowest()));
  connect(settings_emulationSpeed_slow, SIGNAL(triggered()), this, SLOT(setSpeedSlow()));
  connect(settings_emulationSpeed_normal, SIGNAL(triggered()), this, SLOT(setSpeedNormal()));
  connect(settings_emulationSpeed_fast, SIGNAL(triggered()), this, SLOT(setSpeedFast()));
  connect(settings_emulationSpeed_fastest, SIGNAL(triggered()), this, SLOT(setSpeedFastest()));
  connect(settings_emulationSpeed_syncVideo, SIGNAL(triggered()), this, SLOT(syncVideo()));
  connect(settings_emulationSpeed_syncAudio, SIGNAL(triggered()), this, SLOT(syncAudio()));
  connect(settings_configuration, SIGNAL(triggered()), this, SLOT(showConfigWindow()));
  connect(tools_movies_play, SIGNAL(triggered()), this, SLOT(playMovie()));
  connect(tools_movies_stop, SIGNAL(triggered()), this, SLOT(stopMovie()));
  connect(tools_movies_recordFromPowerOn, SIGNAL(triggered()), this, SLOT(recordMovieFromPowerOn()));
  connect(tools_movies_recordFromHere, SIGNAL(triggered()), this, SLOT(recordMovieFromHere()));
  connect(tools_captureScreenshot, SIGNAL(triggered()), this, SLOT(saveScreenshot()));
  connect(tools_debugger, SIGNAL(triggered()), this, SLOT(showDebugger()));
  connect(tools_dialog, SIGNAL(triggered()), this, SLOT(showToolsDialog()));
  connect(help_documentation, SIGNAL(triggered()), this, SLOT(showDocumentation()));
  connect(help_license, SIGNAL(triggered()), this, SLOT(showLicense()));
  connect(help_about, SIGNAL(triggered()), this, SLOT(showAbout()));

  syncUi();
}