void MainWindow::installSWGEmu() { InstallFromSWG installation(this); int result = installation.installFiles(); if (result == 0) { QSettings settingsVals; settingsVals.setValue("swg_folder", installation.getEmuFolder()); settings->restoreFolder(); startFullScan(true); } }
void SqlCollection::init() { QTimer::singleShot( 0, this, SLOT( initXesam() ) ); if( !m_updater ) { debug() << "Could not load updater!"; return; } if( m_updater->needsUpdate() ) m_updater->update(); QStringList result = query( "SELECT count(*) FROM tracks" ); // If database version is updated, the collection needs to be rescanned. // Works also if the collection is empty for some other reason // (e.g. deleted collection.db) if( !result.isEmpty() && result.first().toInt() == 0 ) { QTimer::singleShot( 0, m_scanManager, SLOT( startFullScan() ) ); } //perform a quick check of the database m_updater->cleanupDatabase(); }
CollectionSetup::CollectionSetup( QWidget *parent ) : QWidget( parent ) , m_rescanDirAction( new QAction( this ) ) { m_ui.setupUi(this); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); setObjectName( "CollectionSetup" ); s_instance = this; if( KGlobalSettings::graphicEffectsLevel() != KGlobalSettings::NoEffects ) m_ui.view->setAnimated( true ); connect( m_ui.view, SIGNAL(clicked(QModelIndex)), this, SIGNAL(changed()) ); connect( m_ui.view, SIGNAL(pressed(QModelIndex)), this, SLOT(slotPressed(QModelIndex)) ); connect( m_rescanDirAction, SIGNAL(triggered()), this, SLOT(slotRescanDirTriggered()) ); KPushButton *rescan = new KPushButton( KIcon( "collection-rescan-amarok" ), i18n( "Full rescan" ), m_ui.buttonContainer ); rescan->setToolTip( i18n( "Rescan your entire collection. This will <i>not</i> delete any statistics." ) ); connect( rescan, SIGNAL(clicked()), CollectionManager::instance(), SLOT(startFullScan()) ); KPushButton *import = new KPushButton( KIcon( "tools-wizard" ), i18n( "Import" ), m_ui.buttonContainer ); import->setToolTip( i18n( "Import collection and/or statistics from older Amarok versions, the batch scanner or media players." ) ); connect( import, SIGNAL(clicked()), this, SLOT(importCollection()) ); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addWidget( rescan ); buttonLayout->addWidget( import ); m_ui.buttonContainer->setLayout( buttonLayout ); m_recursive = new QCheckBox( i18n("&Scan folders recursively (requires full rescan if newly checked)"), m_ui.checkboxContainer ); m_monitor = new QCheckBox( i18n("&Watch folders for changes"), m_ui.checkboxContainer ); connect( m_recursive, SIGNAL(toggled(bool)), this, SIGNAL(changed()) ); connect( m_monitor , SIGNAL(toggled(bool)), this, SIGNAL(changed()) ); QVBoxLayout *checkboxLayout = new QVBoxLayout(); checkboxLayout->addWidget( m_recursive ); checkboxLayout->addWidget( m_monitor ); m_ui.checkboxContainer->setLayout( checkboxLayout ); m_recursive->setToolTip( i18n( "If selected, Amarok will read all subfolders." ) ); m_monitor->setToolTip( i18n( "If selected, the collection folders will be watched " "for changes.\nThe watcher will not notice changes behind symbolic links." ) ); m_recursive->setChecked( AmarokConfig::scanRecursively() ); m_monitor->setChecked( AmarokConfig::monitorChanges() ); // set the model _after_ constructing the checkboxes m_model = new CollectionFolder::Model( this ); m_ui.view->setModel( m_model ); #ifndef Q_OS_WIN m_ui.view->setRootIndex( m_model->setRootPath( QDir::rootPath() ) ); #else m_ui.view->setRootIndex( m_model->setRootPath( m_model->myComputer().toString() ) ); #endif Collections::Collection *primaryCollection = CollectionManager::instance()->primaryCollection(); QStringList dirs = primaryCollection ? primaryCollection->property( "collectionFolders" ).toStringList() : QStringList(); m_model->setDirectories( dirs ); // make sure that the tree is expanded to show all selected items foreach( const QString &dir, dirs ) { QModelIndex index = m_model->index( dir ); m_ui.view->scrollTo( index, QAbstractItemView::EnsureVisible ); }
CollectionSetup::CollectionSetup( QWidget *parent ) : KVBox( parent ) { DEBUG_BLOCK setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); setObjectName( "CollectionSetup" ); s_instance = this; (new QLabel( i18n( "These folders will be scanned for " "media to make up your collection:"), this ))->setAlignment( Qt::AlignJustify ); m_view = new QTreeView( this ); m_view->setHeaderHidden( true ); m_view->setRootIsDecorated( true ); m_view->setAnimated( true ); m_view->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); connect( m_view, SIGNAL( clicked( const QModelIndex & ) ), this, SIGNAL( changed() ) ); KHBox* buttonBox = new KHBox( this ); KPushButton *rescan = new KPushButton( KIcon( "collection-rescan-amarok" ), i18n( "Rescan Collection" ), buttonBox ); connect( rescan, SIGNAL( clicked() ), CollectionManager::instance(), SLOT( startFullScan() ) ); KPushButton *import = new KPushButton( KIcon( "tools-wizard" ), i18n( "Import Collection" ), buttonBox ); connect( import, SIGNAL( clicked() ), this, SLOT( importCollection() ) ); m_recursive = new QCheckBox( i18n("&Scan folders recursively"), this ); m_monitor = new QCheckBox( i18n("&Watch folders for changes"), this ); connect( m_recursive, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) ); connect( m_monitor , SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) ); m_recursive->setToolTip( i18n( "If selected, Amarok will read all subfolders." ) ); m_monitor->setToolTip( i18n( "If selected, folders will automatically get rescanned when the content is modified, e.g. when a new file was added." ) ); m_recursive->setChecked( AmarokConfig::scanRecursively() ); m_monitor->setChecked( AmarokConfig::monitorChanges() ); // set the model _after_ constructing the checkboxes m_model = new CollectionFolder::Model(); m_view->setModel( m_model ); #ifndef Q_OS_WIN m_view->setRootIndex( m_model->setRootPath( QDir::rootPath() ) ); #else m_view->setRootIndex( m_model->setRootPath( m_model->myComputer().toString() ) ); #endif // Read config values //we have to detect if this is the actual first run and not get the collectionFolders in that case //there won't be any anyway and accessing them creates a Sqlite database, even if the user wants to //use another database //bug 131719 131724 //if( !Amarok::config().readEntry( "First Run", true ) ) QStringList dirs = MountPointManager::instance()->collectionFolders(); m_model->setDirectories( dirs ); // make sure that the tree is expanded to show all selected items foreach( const QString &dir, dirs ) { QModelIndex index = m_model->index( dir ); m_view->scrollTo( index, QAbstractItemView::EnsureVisible ); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), networkAccessManager(this), clientFilesNetworkAccessManager(this), novaNetworkAccessManager(this), requiredFilesNetworkManager(this), patchesNetworkManager(this), fullScanWorkingThreads(0) { ui->setupUi(this); QCoreApplication::setOrganizationName("SWGEmu"); QCoreApplication::setOrganizationDomain("swg.openkod.com"); QCoreApplication::setApplicationName("Launchpad"); requiredFilesCount = 0; nextFileToDownload = 0; updateTimeCounter = 5; gameProcessesCount = 0; runningFullScan = false; fileScanner = new FileScanner(this); settings = new Settings(this); loginServers = new LoginServers(this); systemTrayIcon = new QSystemTrayIcon(this); systemTrayIcon->setIcon(QIcon(":/img/swgemu.svg")); systemTrayMenu = new QMenu(); closeAction = new QAction("Close", NULL); systemTrayMenu->addAction(closeAction); systemTrayIcon->setContextMenu(systemTrayMenu); QToolButton* newsButton = new QToolButton(ui->mainToolBar); newsButton->setIcon(QIcon(":/img/globe.svg")); newsButton->setText("News"); newsButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); newsButton->setCheckable(true); ui->mainToolBar->addWidget(newsButton); connect(newsButton, SIGNAL(clicked()), this, SLOT(triggerNews())); toolButtons.append(newsButton); QToolButton* updateStatusButton = new QToolButton(ui->mainToolBar); updateStatusButton->setIcon(QIcon(":/img/update_status.svg")); updateStatusButton->setText("Update status"); updateStatusButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui->mainToolBar->addWidget(updateStatusButton); connect(updateStatusButton, SIGNAL(clicked()), this, SLOT(updateServerStatus())); toolButtons.append(updateStatusButton); QToolButton* gameSettingsButton = new QToolButton(ui->mainToolBar); gameSettingsButton->setIcon(QIcon(":/img/game_settings.svg")); gameSettingsButton->setText("Game settings"); gameSettingsButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui->mainToolBar->addWidget(gameSettingsButton); connect(gameSettingsButton, SIGNAL(clicked()), this, SLOT(startSWGSetup())); toolButtons.append(gameSettingsButton); QToolButton* gameModsButton = new QToolButton(ui->mainToolBar); gameModsButton->setIcon(QIcon(":/img/magic.svg")); gameModsButton->setText("Game mods"); gameModsButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui->mainToolBar->addWidget(gameModsButton); connect(gameModsButton, SIGNAL(clicked()), this, SLOT(showGameModsOptions())); toolButtons.append(gameModsButton); #ifdef ENABLE_MACRO_EDITOR QToolButton* macroEditorButton = new QToolButton(ui->mainToolBar); macroEditorButton->setIcon(QIcon(":/img/book.svg")); macroEditorButton->setText("Macro Editor"); macroEditorButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui->mainToolBar->addWidget(macroEditorButton); connect(macroEditorButton, SIGNAL(clicked()), this, SLOT(showMacroEditor())); toolButtons.append(macroEditorButton); #endif QToolButton* profCalculatorButton = new QToolButton(ui->mainToolBar); profCalculatorButton->setIcon(QIcon(":/img/design.svg")); profCalculatorButton->setText("Profession Calculator"); profCalculatorButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui->mainToolBar->addWidget(profCalculatorButton); connect(profCalculatorButton, SIGNAL(clicked()), this, SLOT(startKodanCalculator())); toolButtons.append(profCalculatorButton); QToolButton* deleteProfilesButton = new QToolButton(ui->mainToolBar); deleteProfilesButton->setIcon(QIcon(":/img/bin.svg")); deleteProfilesButton->setText("Delete game profiles"); deleteProfilesButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui->mainToolBar->addWidget(deleteProfilesButton); connect(deleteProfilesButton, SIGNAL(clicked()), this, SLOT(deleteProfiles())); toolButtons.append(deleteProfilesButton); QToolButton* updateButton = new QToolButton(ui->mainToolBar); updateButton->setIcon(QIcon(":/img/cloud_down.svg")); updateButton->setText("Check for updates"); updateButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui->mainToolBar->addWidget(updateButton); connect(updateButton, SIGNAL(clicked()), this, SLOT(checkForUpdates())); toolButtons.append(updateButton); cancelWorkingThreads = false; connect(ui->mainToolBar, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(toolBarOrientationChanged(Qt::Orientation))); connect(systemTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayActivated(QSystemTrayIcon::ActivationReason))); connect(closeAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(ui->actionFolders, SIGNAL(triggered()), this, SLOT(showSettings())); connect(&networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(statusXmlIsReady(QNetworkReply*)) ); connect(&novaNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(statusXmlIsReady(QNetworkReply*)) ); connect(&clientFilesNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFileFinished(QNetworkReply*))); connect(&requiredFilesNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(requiredFileDownloadFileFinished(QNetworkReply*))); connect(&patchesNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(patchesDownloadFileFinished(QNetworkReply*))); connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(webPageLoadFinished(bool))); connect(ui->pushButton_Start, SIGNAL(clicked()), this, SLOT(startSWG())); connect(fileScanner, SIGNAL(requiredFileExists(QString)), this, SLOT(updateBasicLoadProgress(QString))); connect(fileScanner, SIGNAL(fullScannedFile(QString, bool)), this, SLOT(updateFullScanProgress(QString, bool))); connect(this, SIGNAL(startDownload()), this, SLOT(startFileDownload())); connect(ui->actionLogin_Servers, SIGNAL(triggered()), loginServers, SLOT(show())); connect(ui->actionShow_news, SIGNAL(triggered()), this, SLOT(triggerNews())); connect(ui->checkBox_instances, SIGNAL(toggled(bool)), this, SLOT(triggerMultipleInstances(bool))); connect(ui->actionUpdate_Status, SIGNAL(triggered()), this, SLOT(updateServerStatus())); connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(ui->actionCheck_for_updates, SIGNAL(triggered()), this, SLOT(checkForUpdates())); connect(ui->actionGame_Settings, SIGNAL(triggered()), this, SLOT(startSWGSetup())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutDialog())); connect(ui->actionDelete_Profiles, SIGNAL(triggered()), this, SLOT(deleteProfiles())); connect(fileScanner, SIGNAL(addFileToDownload(QString)), this, SLOT(addFileToDownloadSlot(QString))); connect(ui->actionInstall_from_SWG, SIGNAL(triggered()), this, SLOT(installSWGEmu())); ui->groupBox_browser->hide(); QTabBar* tabBar = ui->tabWidget->tabBar(); tabBar->setTabButton(0, QTabBar::RightSide, 0); tabBar->setTabButton(0, QTabBar::LeftSide, 0); QSettings settingsOptions; QString swgFolder = settingsOptions.value("swg_folder").toString(); bool multipleInstances = settingsOptions.value("multiple_instances").toBool(); ui->checkBox_instances->setChecked(multipleInstances); ui->textBrowser->viewport()->setAutoFillBackground(false); ui->textBrowser->setAutoFillBackground(false); updateServerStatus(); connect(&loadWatcher, SIGNAL(finished()), this, SLOT(loadFinished())); //connect(&fullScanWatcher, SIGNAL(finished()), this, SLOT(fullScanFinished())); connect(ui->pushButton_FullScan, SIGNAL(clicked()), this, SLOT(startFullScan())); loginServers->reloadServers(); updateLoginServerList(); silentSelfUpdater = new SelfUpdater(true, this); if (!swgFolder.isEmpty()) startLoadBasicCheck(); else { #ifdef Q_OS_WIN32 QDir dir("C:/SWGEmu"); if (dir.exists() && FileScanner::checkSwgFolder("C:/SWGEmu")) { settingsOptions.setValue("swg_folder", "C:/SWGEmu"); startLoadBasicCheck(); } else #endif QMessageBox::warning(this, "Error", "Please set the swgemu folder in Settings->Options or install using Settings->Select install folder option"); } restoreGeometry(settingsOptions.value("mainWindowGeometry").toByteArray()); restoreState(settingsOptions.value("mainWindowState").toByteArray()); QString savedLogin = settingsOptions.value("selected_login_server", "").toString(); if (!savedLogin.isEmpty()) { int idx = ui->comboBox_login->findText(savedLogin); if (idx >= 0) { ui->comboBox_login->setCurrentIndex(idx); } } requiredFilesNetworkManager.get(QNetworkRequest(QUrl(patchUrl + "required2.txt"))); //patchesNetworkManager.get(QNetworkRequest(QUrl(patchUrl + "patches.txt"))); silentSelfUpdater->silentCheck(); //ui->webView->setUrl(newsUrl); //gameMods = new GameMods(this); }