MainWindow::MainWindow(QWidget *parent) : QWebView(parent) { //! The object we will expose to JavaScript engine: m_magicbox = new CMagicBox(this); // Signal is emitted before frame loads any web content: QObject::connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJSObject())); // QWebInspector QWebInspector *inspector = new QWebInspector; inspector->setPage(page()); QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); // context menu this->setContextMenuPolicy(Qt::NoContextMenu); //No context menu is allowed if you don't need it // Try to handle cicks by self page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);//Handle link clicks by yourself QObject::connect(page(), SIGNAL( linkClicked( QUrl ) ), this, SLOT( linkClickedSlot( QUrl ) ) ); // qrc:// URLs refer to resources. See views.qrc QUrl startURL = QUrl("qrc:/index.html"); // Load web content now! this->setUrl(startURL); }
UserManual::UserManual(QWidget *parent) : QMainWindow(parent), ui(new Ui::UserManual) { ui->setupUi(this); QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); connect(closeKey, SIGNAL(activated()), this, SLOT(close())); QShortcut *quitKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); connect(quitKey, SIGNAL(activated()), parent, SLOT(close())); QAction *actionShowSearch = new QAction(this); actionShowSearch->setShortcut(Qt::CTRL + Qt::Key_F); actionShowSearch->setShortcutContext(Qt::WindowShortcut); addAction(actionShowSearch); QAction *actionHideSearch = new QAction(this); actionHideSearch->setShortcut(Qt::Key_Escape); actionHideSearch->setShortcutContext(Qt::WindowShortcut); addAction(actionHideSearch); setWindowTitle(tr("User Manual")); ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); QString searchPath = getSubsurfaceDataPath("Documentation"); if (searchPath.size()) { // look for localized versions of the manual first QString lang = uiLanguage(NULL); QString prefix = searchPath.append("/user-manual"); QFile manual(prefix + "_" + lang + ".html"); if (!manual.exists()) manual.setFileName(prefix + "_" + lang.left(2) + ".html"); if (!manual.exists()) manual.setFileName(prefix + ".html"); if (!manual.exists()) { ui->webView->setHtml(tr("Cannot find the Subsurface manual")); } else { QString urlString = QString("file:///") + manual.fileName(); QUrl url(urlString, QUrl::TolerantMode); ui->webView->setUrl(url); } } else { ui->webView->setHtml(tr("Cannot find the Subsurface manual")); } ui->searchPanel->setParent(this); ui->searchPanel->hide(); connect(actionShowSearch, SIGNAL(triggered(bool)), this, SLOT(showSearchPanel())); connect(actionHideSearch, SIGNAL(triggered(bool)), this, SLOT(hideSearchPanel())); connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl))); connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString))); connect(ui->findNext, SIGNAL(clicked()), this, SLOT(searchNext())); connect(ui->findPrev, SIGNAL(clicked()), this, SLOT(searchPrev())); }
UserManual::UserManual(QWidget *parent) : QMainWindow(parent), ui(new Ui::UserManual) { ui->setupUi(this); QAction *actionShowSearch = new QAction(this); actionShowSearch->setShortcut(Qt::CTRL + Qt::Key_F); actionShowSearch->setShortcutContext(Qt::WindowShortcut); addAction(actionShowSearch); QAction *actionHideSearch = new QAction(this); actionHideSearch->setShortcut(Qt::Key_Escape); actionHideSearch->setShortcutContext(Qt::WindowShortcut); addAction(actionHideSearch); setWindowTitle(tr("User Manual")); ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); QString searchPath = getSubsurfaceDataPath("Documentation"); if (searchPath != "") { QUrl url(searchPath.append("/user-manual.html")); ui->webView->setUrl(url); } else { ui->webView->setHtml(tr("Cannot find the Subsurface manual")); } ui->searchPanel->setParent(this); ui->searchPanel->hide(); connect(actionShowSearch, SIGNAL(triggered(bool)), this, SLOT(showSearchPanel())); connect(actionHideSearch, SIGNAL(triggered(bool)), this, SLOT(hideSearchPanel())); connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl))); connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString))); connect(ui->findNext, SIGNAL(clicked()), this, SLOT(searchNext())); connect(ui->findPrev, SIGNAL(clicked()), this, SLOT(searchPrev())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); torrent = NULL; // Center the widget this->setGeometry(QStyle::alignedRect( Qt::LeftToRight, Qt::AlignCenter, this->size(), qApp->desktop()->availableGeometry() )); // Create the tray icon setupTray(); // Translator translator = new QTranslator(); // Set the current launcher version settings.setSetting("launcherVersion", QCoreApplication::applicationVersion()); // Get path and split it to remove /launcher QString tmpPath = QApplication::applicationDirPath().replace('\\','/'); QStringList realPathList = tmpPath.split("/"); tmpPath = ""; #ifdef Q_OS_LINUX for(int i = 0; i < realPathList.size() - 2; i++) { tmpPath += realPathList.at(i) + "/"; } if(!tmpPath.endsWith("/")) { tmpPath += "/"; } #else for(int i = 0; i < realPathList.size() - 1; i++) { tmpPath += realPathList.at(i) + "/"; } if(!tmpPath.endsWith("/")) { tmpPath += "/"; } #endif settings.setSetting("installLocation", tmpPath); //Create all dirs, maybe one is missing QStringList dirs; dirs << tmpPath + "game" << tmpPath + "game/bin" << tmpPath + "game/data" << tmpPath + "game/lib" << tmpPath + "game/data/logs" << tmpPath + "game/data/relics_of_annorath" << tmpPath + "game/data/relics_of_annorath/configuration" << tmpPath + "game/data/relics_of_annorath/configuration/gui" << tmpPath + "game/data/relics_of_annorath/terrains" << tmpPath + "game/data/relics_of_annorath/terrains/merasurien" << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/1_14_westzones" << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/1_14_westzones/1_14_westzones" << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/1_14_westzones/Layers" << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/3_14_Nordzone1" << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/3_14_Nordzone1/3_14_nordzone1" << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/3_14_Nordzone1/Terrain_Masken" << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/4_14_Nordzone2" << tmpPath + "game/data/relics_of_annorath/terrains/merasurien/4_14_Nordzone2/4_14_nordzone2"; for(int i = 0; i < dirs.size(); i++) { QDir dir(dirs.at(i)); if(!dir.exists()) QDir().mkpath(dirs.at(i)); } // Remove window borders setWindowFlags(Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground, true); // Set window state as not moving moving = false; setMouseTracking(false); //@FIXME: What does this? //this->ui->webView->setDisabled(true); // Set not muted and torrent not paused muted = false; pause = false; // Torrent is not done yet torrentDone = 0; // Hide the game start button //this->ui->buttonPlay->hide(); this->ui->buttonPlay->setText(tr("Wait...")); this->ui->buttonPlay->setEnabled(0); // Style progressbar this->ui->progressBar->setStyleSheet("QProgressBar {" " color: rgb(0, 0, 0);" " border: 0px solid;" " background-color: rgba(255, 255, 127, 40);" "}" "QProgressBar::chunk {" " color: rgb(0, 0, 0);" "background-color: rgba(42, 85, 0, 90);" " width: 20px;" "}"); // Add values to the boxes for language seleciton ui->boxLanguage->addItem( "English", "english" ); ui->boxLanguage->addItem( "Español", "spanish" ); ui->boxLanguage->addItem( "Deutsch", "german" ); ui->boxLanguage->addItem( "Français", "french" ); ui->boxLanguage->addItem( "Italiano", "italian" ); ui->boxLanguage->addItem( "Polski", "polish" ); ui->boxLanguage->addItem( "Português", "portuguese" ); ui->boxLanguage->addItem( "Svenska", "swedish" ); ui->boxLanguage->addItem( "ελληνικά", "greek" ); // Add rendering options ui->boxRendering->addItem("OpenGL", "opengl"); #ifdef Q_OS_WIN // Set rendering options ui->boxRendering->addItem("DirectX 9", "direct3d9"); ui->boxRendering->addItem("DirectX 11", "direct3d11"); #endif // Get configured values for the language ui->boxLanguage->setCurrentIndex(ui->boxLanguage->findData(settings.getSetting(QString("language")))); // Get renderer ui->boxRendering->setCurrentIndex(ui->boxRendering->findData(settings.getSetting(QString("rendering")))); // Connect event connect(ui->boxLanguage, SIGNAL(currentIndexChanged(int)),SLOT(slot_boxLanguage_currentIndexChanged(int))); connect(ui->boxRendering, SIGNAL(currentIndexChanged(int)),SLOT(slot_boxRendering_currentIndexChanged(int))); // Get torrent values ui->lineTCP->setText(settings.getSetting(QString("torPort"))); ui->lineMaxDL->setText(settings.getSetting(QString("torDLMax"))); ui->lineMaxUL->setText(settings.getSetting(QString("torULMax"))); // Set http status if(settings.getSetting("useHTTP") == "true") { ui->checkHTTP->setChecked(true); } else { ui->checkHTTP->setChecked(false); } ui->webView_2->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); ui->webView_2->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff ); // Set link handling ui->webView_2->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); connect(ui->webView_2, SIGNAL(linkClicked( QUrl )), this, SLOT( linkClickedSlot( QUrl ) )); // Check configuration refreshConfiguration(); // Retranslate to the new language retranslate(); // Create about page about = new AboutLauncher(); // Start configurePath(); }