Ejemplo n.º 1
0
MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
  ui->setupUi(this); //load the designer file
  mousegrabbed = false;
  XCB = new LXCB();
  IMG = new ImageEditor(this);
  ui->scrollArea->setWidget(IMG);
  ui->tabWidget->setCurrentWidget(ui->tab_view);
  ppath = QDir::homePath();

  setupIcons();
  ui->spin_monitor->setMaximum(QApplication::desktop()->screenCount());
  if(ui->spin_monitor->maximum()<2){
    ui->spin_monitor->setEnabled(false);
    ui->radio_monitor->setEnabled(false);
  }	  

  //Setup the connections
  connect(ui->tool_save, SIGNAL(clicked()), this, SLOT(saveScreenshot()) );
  connect(ui->actionSave_As, SIGNAL(triggered()), this, SLOT(saveScreenshot()) );
  connect(ui->tool_quicksave, SIGNAL(clicked()), this, SLOT(quicksave()) );
  connect(ui->actionQuick_Save, SIGNAL(triggered()), this, SLOT(quicksave()) );
  connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(closeApplication()) );
  connect(ui->push_snap, SIGNAL(clicked()), this, SLOT(startScreenshot()) );
  connect(ui->actionTake_Screenshot, SIGNAL(triggered()), this, SLOT(startScreenshot()) );
  connect(ui->tool_crop, SIGNAL(clicked()), IMG, SLOT(cropImage()) );
  connect(IMG, SIGNAL(selectionChanged(bool)), this, SLOT(imgselchanged(bool)) );

  settings = new QSettings("lumina-desktop", "lumina-screenshot",this);
  if(settings->value("screenshot-target", "window").toString() == "window") {
	ui->radio_window->setChecked(true);
  }else{
	ui->radio_all->setChecked(true);
  }
  ui->spin_delay->setValue(settings->value("screenshot-delay", 0).toInt());

  ui->tool_resize->setVisible(false); //not implemented yet
  this->show();
  IMG->setDefaultSize(ui->scrollArea->maximumViewportSize());
  IMG->LoadImage( QApplication::screens().at(0)->grabWindow(QApplication::desktop()->winId()).toImage() ); //initial screenshot
  //ui->label_screenshot->setPixmap( cpic.scaled(ui->label_screenshot->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation) );
}
Ejemplo n.º 2
0
FastQSPWindow::FastQSPWindow(QWidget *parent)
    : QMainWindow(parent), gameWidth(800), gameHeight(600),
      aspectRatio(qreal(gameWidth) / qreal(gameHeight)), scaleFactor(1),
      gameIsOpen(false), netManager(),
      settings (QSettings::IniFormat, QSettings::UserScope, "FastQSP", "config")
{
// Init audio
#if QT_VERSION < 0x050000
  media = new Phonon::MediaObject(this);
  audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
  Phonon::createPath(media, audioOutput);
#else
  player = new QMediaPlayer();
#endif

  // Start timer
  timer.start();

  // Init view
  scene = new QGraphicsScene(this);
  graphicsView = new QGraphicsView(scene, this);
  graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  graphicsView->setUpdatesEnabled(true);
  graphicsView->setFrameStyle(QFrame::NoFrame);

  webView = new QGraphicsWebView();
  webView->page()->setNetworkAccessManager(&netManager);
  webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
  webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
  webView->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
  scene->addItem(webView);
  scene->setBackgroundBrush(QBrush(QColor(0, 0, 0)));
  webView->setRenderHints(
      QPainter::Antialiasing | QPainter::HighQualityAntialiasing |
      QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform |
      QPainter::NonCosmeticDefaultPen);
  webView->settings()->setAttribute(QWebSettings::AutoLoadImages, true);
  webView->setAutoFillBackground(false);

  videoPlayer = new QMediaPlayer();
  videoItem = new QGraphicsVideoItem();
  videoItem->setSize(QSize(gameWidth + 4, gameHeight + 4));
  videoItem->setAspectRatioMode(Qt::KeepAspectRatioByExpanding);
  videoPlayer->setVideoOutput(videoItem);
  videoPlayer->setMuted(true);
  videoPlayer->setNotifyInterval(500);
  scene->addItem(videoItem);
  videoItem->hide();

  savestatus = new QGraphicsTextItem;
  savestatus->setDefaultTextColor(Qt::yellow);
  QFont f;
  f.setBold(true);
  f.setPixelSize(20);
  savestatus->setFont(f);
  savestatus->setVisible(false);
  scene->addItem(savestatus);

  connect(videoPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(replayVideo(qint64)));

  // Filter context menu event
  graphicsView->viewport()->installEventFilter(this);

  // Creating menu
  //-File menu--------------------------------------------------------
  QMenu *fileMenu = new QMenu("File");
  fileMenu->addAction("Open file\tCtrl+O", this, SLOT(openFileDialog()));
  QShortcut *openFile = new QShortcut(QKeySequence("Ctrl+O"), this);
  connect(openFile, SIGNAL(activated()), SLOT(openFileDialog()));

//  fileMenu->addAction("Reload QSP file\tc", this, SLOT(openFileDialog())); //for powerairmax
//  QShortcut *reloadFile = new QShortcut(QKeySequence("c"), this); //for powerairmax
  fileMenu->addAction("Reload QSP file\tF3", this, SLOT(reloadQSP()));
  QShortcut *reloadFile = new QShortcut(QKeySequence("F3"), this);
  connect(reloadFile, SIGNAL(activated()), SLOT(reloadQSP()));

  fileMenu->addAction("Exit\tCtrl+Q", this, SLOT(close()));
  QShortcut *exit = new QShortcut(QKeySequence("Ctrl+Q"), this);
  connect(exit, SIGNAL(activated()), SLOT(close()));

  menuBar()->addMenu(fileMenu);

  //-Game menu--------------------------------------------------------
  gameMenu = new QMenu("Game");
  gameMenu->addAction("Save\tCtrl+S", this, SLOT(saveGameDialog()));
  QShortcut *save = new QShortcut(QKeySequence("Ctrl+S"), this);
  connect(save, SIGNAL(activated()), SLOT(saveGameDialog()));

  gameMenu->addAction("Load\tCtrl+L", this, SLOT(loadGameDialog()));
  QShortcut *load = new QShortcut(QKeySequence("Ctrl+L"), this);
  connect(load, SIGNAL(activated()), SLOT(loadGameDialog()));

//  gameMenu->addAction("Quicksave\tz", this, SLOT(saveGameDialog())); //for powerairmax
//  QShortcut *quicksave = new QShortcut(QKeySequence("z"), this); //for powerairmax
  gameMenu->addAction("Quicksave\tF5", this, SLOT(quicksave()));
  QShortcut *quicksave = new QShortcut(QKeySequence("F5"), this);
  connect(quicksave, SIGNAL(activated()), SLOT(quicksave()));

//  gameMenu->addAction("Quickload\tx", this, SLOT(loadGameDialog())); //for powerairmax
//  QShortcut *quickload = new QShortcut(QKeySequence("x"), this); //for powerairmax
  gameMenu->addAction("Quickload\tF2", this, SLOT(quickload()));
  QShortcut *quickload = new QShortcut(QKeySequence("F2"), this);
  connect(quickload, SIGNAL(activated()), SLOT(quickload()));

  gameMenu->addAction("Restart\tCtrl+R", this, SLOT(restartGame()));
  QShortcut *restart = new QShortcut(QKeySequence("Ctrl+R"), this);
  connect(restart, SIGNAL(activated()), SLOT(restartGame()));

  //Game shortcuts
  QShortcut *next = new QShortcut(QKeySequence("space"), this);
  connect(next, SIGNAL(activated()), SLOT(nextScreen()));

  QShortcut *prev= new QShortcut(QKeySequence("backspace"), this);
  connect(prev, SIGNAL(activated()), SLOT(prevScreen()));

  QShortcut *main_screen= new QShortcut(QKeySequence("escape"), this);
  connect(main_screen, SIGNAL(activated()), SLOT(gotoMainScreen()));

  ignoreCRCAction = new QAction("Ignore version check when loading", this);
  ignoreCRCAction->setCheckable(true);
  ignoreCRCAction->setChecked(settings.value("ignoreCRC", false).toBool());
  connect(ignoreCRCAction, SIGNAL(toggled(bool)), this, SLOT(saveIgnoreCRCState()));
  gameMenu->addAction(ignoreCRCAction);

  // TODO: slows the game, move saving to diffrent thread
  autosaveAction = new QAction("Autosave", this);
  autosaveAction->setCheckable(true);
  autosaveAction->setChecked(false);
  // gameMenu->addAction(autosave);

  menuBar()->addMenu(gameMenu);
  gameMenu->setDisabled(true);

  //-Other menu-------------------------------------------------------
  QMenu *otherMenu = new QMenu("Other");
  otherMenu->addAction("Fullscreen\tAlt+Enter", this, SLOT(toggleFullscreen()));
  QShortcut *fullscreen =
      new QShortcut(QKeySequence(Qt::Key_Return + Qt::AltModifier), this);
  otherMenu->addAction("Show html", this, SLOT(showHtml()));
  connect(fullscreen, SIGNAL(activated()), SLOT(toggleFullscreen()));

  muteAction = new QAction("Mute sound", this);
  muteAction ->setCheckable(true);
  muteAction ->setChecked(settings.value("mutedState", false).toBool());
  connect(muteAction, SIGNAL(toggled(bool)), this, SLOT(saveMutedState()));
  otherMenu->addAction(muteAction);

  menuBar()->addMenu(otherMenu);

  //-Help menu--------------------------------------------------------
  QMenu *helpMenu = new QMenu("Help");
  helpMenu->addAction("About", this, SLOT(about()));
  menuBar()->addMenu(helpMenu);
  //------------------------------------------------------------------

  connect(webView, SIGNAL(linkClicked(const QUrl &)),
          SLOT(linkClicked(const QUrl &)), Qt::DirectConnection);
  connect(webView, SIGNAL(loadFinished(bool)), SLOT(toggleUpdate()),
          Qt::DirectConnection);
  connect(webView, SIGNAL(loadStarted()), SLOT(toggleUpdate()),
          Qt::DirectConnection);

  setCentralWidget(graphicsView);

  // Initializing QSP
  QSPInit();
  QSPCallback::QSPCallback();

//  qDebug() << "QSP init finished";
}