void powerfulTabWidget::setNoCloseButton(int iIndex, const QSize &sizeItem) { QTabBar* pTabBar = tabBar(); if (NULL != pTabBar) { QWidget *pWidget = new QWidget; pWidget->resize(sizeItem); pTabBar->setTabButton(iIndex, QTabBar::RightSide, pWidget); } }
// QTabBar::setTabButton(index, closeSide, closeButton); void tst_QTabBar::tabButton() { QFETCH(QTabBar::ButtonPosition, position); QTabBar::ButtonPosition otherSide = (position == QTabBar::LeftSide ? QTabBar::RightSide : QTabBar::LeftSide); QTabBar tabbar; tabbar.resize(500, 200); tabbar.show(); QTRY_VERIFY(tabbar.isVisible()); tabbar.setTabButton(-1, position, 0); QVERIFY(tabbar.tabButton(-1, position) == 0); QVERIFY(tabbar.tabButton(0, position) == 0); tabbar.addTab("foo"); QCOMPARE(tabbar.count(), 1); tabbar.setTabButton(0, position, 0); QVERIFY(tabbar.tabButton(0, position) == 0); QPushButton *button = new QPushButton; button->show(); button->setText("hi"); button->resize(10, 10); QTRY_VERIFY(button->isVisible()); QTRY_VERIFY(button->isVisible()); tabbar.setTabButton(0, position, button); QCOMPARE(tabbar.tabButton(0, position), static_cast<QWidget *>(button)); QTRY_VERIFY(!button->isHidden()); QVERIFY(tabbar.tabButton(0, otherSide) == 0); QCOMPARE(button->parent(), static_cast<QObject *>(&tabbar)); QVERIFY(button->pos() != QPoint(0, 0)); QPushButton *button2 = new QPushButton; tabbar.setTabButton(0, position, button2); QVERIFY(button->isHidden()); }
void powerfulTabWidget::feed2Full() { QTabBar* pTabBar = tabBar(); if (NULL != pTabBar) { for (int iIndex = 0; iIndex < count(); ++iIndex) { QWidget *pWidget = new QWidget; pWidget->setMaximumSize(pTabBar->width() / count() / 2, pTabBar->height()); pWidget->setMinimumSize(pTabBar->width() / count() / 2, pTabBar->height()); pTabBar->setTabButton(iIndex, QTabBar::LeftSide, pWidget); } } }
CFileListWidget::CFileListWidget(UINT Mode, QWidget *parent) :QWidget(parent) { m_Mode = Mode; m_Ops = Mode2Str(Mode); m_CurID = 0; m_pGrabbingsSyncJob = NULL; m_OldPending = 0; m_pMainLayout = new QVBoxLayout(); m_pMainLayout->setMargin(1); m_pSplitter = new QSplitter(); m_pSplitter->setOrientation(Qt::Vertical); m_pFileList = new CFileListView(Mode); connect(m_pFileList, SIGNAL(FileItemClicked(uint64, bool)), this, SLOT(OnFileItemClicked(uint64, bool))); connect(m_pFileList, SIGNAL(StreamFile(uint64, const QString&, bool)), this, SIGNAL(StreamFile(uint64, const QString&, bool))); connect(m_pFileList, SIGNAL(TogleDetails()), this, SIGNAL(TogleDetails())); m_pSubWidget = new QWidget(); m_pSubLayout = new QVBoxLayout(); m_pSubLayout->setMargin(0); m_pSubLayout->addWidget(m_pFileList); // m_pFinder = new CFinder(); m_pSubLayout->addWidget(m_pFinder); QObject::connect(m_pFinder, SIGNAL(SetFilter(const QRegExp&)), m_pFileList, SLOT(SetFilter(const QRegExp&))); QAction* pFinder = new QAction(tr("&Find ..."), this); pFinder->setShortcut(QKeySequence::Find); pFinder->setShortcutContext(Qt::WidgetWithChildrenShortcut); this->addAction(pFinder); QObject::connect(pFinder, SIGNAL(triggered()), m_pFinder, SLOT(Open())); // m_pSubWidget->setLayout(m_pSubLayout); m_pSplitter->addWidget(m_pSubWidget); m_pFileTabs = new QTabWidget(); m_pSummary = new CFileSummary(Mode); m_pFileTabs->addTab(m_pSummary, tr("Summary")); m_pDetails = new CDetailsView(Mode); m_pFileTabs->addTab(m_pDetails, tr("Details")); //QMultiMap<int, SField> Settings; //SetupFile(Settings); //m_pSettings = new CFileSettingsView(Settings); //m_pFileTabs->addTab(m_pSettings, tr("Settings")); if(theGUI->Cfg()->GetInt("Gui/AdvancedControls")) { m_pTransfers = new CTransfersView(CTransfersView::eTransfers); m_pFileTabs->addTab(m_pTransfers, tr("Transfers")); connect(m_pTransfers, SIGNAL(OpenTransfer(uint64, uint64)), this, SLOT(OpenLog(uint64, uint64))); } else m_pTransfers = NULL; m_pSubFiles = new CFileListView(CFileListView::eSubFiles); m_pFileTabs->addTab(m_pSubFiles, tr("Sub Files")); m_pHosting = new CHostingView(); m_pFileTabs->addTab(m_pHosting, tr("Hosting")); if(theGUI->Cfg()->GetInt("Gui/AdvancedControls")) { m_pTracker = new CTrackerView(); m_pFileTabs->addTab(m_pTracker, tr("Tracker")); } else m_pTracker = NULL; m_pRating = new CRatingView(); connect(m_pRating, SIGNAL(FindRating()), m_pFileList, SLOT(OnFindRating())); connect(m_pRating, SIGNAL(ClearRating()), m_pFileList, SLOT(OnClearRating())); m_pFileTabs->addTab(m_pRating, tr("Rating")); if(theGUI->Cfg()->GetInt("Gui/AdvancedControls") == 1) { m_pProperties = new CPropertiesView(true); m_pFileTabs->addTab(m_pProperties, tr("Properties")); } else m_pProperties = NULL; if(theGUI->Cfg()->GetBool("Gui/ShowLog")) { m_pLogView = new CLogView(); m_pFileTabs->addTab(m_pLogView, tr("Log")); } else m_pLogView = NULL; // Make all additionaly added tabs closable - client log tab m_pFileTabs->setTabsClosable(true); QTabBar* pTabBar = m_pFileTabs->tabBar(); m_TabOffset = m_pFileTabs->count(); for(int i=0; i < m_TabOffset; i++) pTabBar->setTabButton(i,static_cast<QTabBar::ButtonPosition>(pTabBar->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, pTabBar)),0); connect(pTabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(CloseLog(int))); m_pSplitter->addWidget(m_pFileTabs); m_pMainLayout->addWidget(m_pSplitter); m_pProgress = new QProgressBar(); m_pProgress->setVisible(false); m_pProgress->setMinimum(0); m_pProgress->setMaximum(100); m_pMainLayout->addWidget(m_pProgress); setLayout(m_pMainLayout); connect(m_pFileTabs, SIGNAL(currentChanged(int)), this, SLOT(OnTab(int))); m_pSplitter->restoreState(theGUI->Cfg()->GetBlob("Gui/Widget_" + m_Ops + "_Spliter")); m_pFileTabs->setCurrentIndex(theGUI->Cfg()->GetSetting("Gui/Widget_" + m_Ops + "_Detail").toInt()); m_TimerId = startTimer(1000); }
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); }