void MainWindow::createDockWindows() { // Engine debug QDockWidget* engineDebugDock = new QDockWidget(tr("Engine Debug"), this); m_engineDebugLog = new PlainTextLog(engineDebugDock); connect(m_engineDebugLog, SIGNAL(saveLogToFileRequest()), this, SLOT(saveLogToFile())); engineDebugDock->setWidget(m_engineDebugLog); addDockWidget(Qt::BottomDockWidgetArea, engineDebugDock); // Move list QDockWidget* moveListDock = new QDockWidget(tr("Moves"), this); moveListDock->setWidget(m_moveList); addDockWidget(Qt::RightDockWidgetArea, moveListDock); // Tags QDockWidget* tagsDock = new QDockWidget(tr("Tags"), this); QTreeView* tagsView = new QTreeView(tagsDock); tagsView->setModel(m_tagsModel); tagsView->setAlternatingRowColors(true); tagsView->setRootIsDecorated(false); tagsDock->setWidget(tagsView); addDockWidget(Qt::RightDockWidgetArea, tagsDock); tabifyDockWidget(moveListDock, tagsDock); moveListDock->raise(); // Add toggle view actions to the View menu m_viewMenu->addAction(moveListDock->toggleViewAction()); m_viewMenu->addAction(tagsDock->toggleViewAction()); m_viewMenu->addAction(engineDebugDock->toggleViewAction()); }
void FancyMainWindow::onDockActionTriggered() { QDockWidget *dw = qobject_cast<QDockWidget *>(sender()->parent()); if (dw) { if (dw->isVisible()) dw->raise(); } }
void ControlSingleton::showDialog(Gui::TaskView::TaskDialog *dlg) { // only one dialog at a time assert(!ActiveDialog || ActiveDialog==dlg); Gui::DockWnd::CombiView* pcCombiView = qobject_cast<Gui::DockWnd::CombiView*> (Gui::DockWindowManager::instance()->getDockWindow("Combo View")); // should return the pointer to combo view if (pcCombiView) { pcCombiView->showDialog(dlg); // make sure that the combo view is shown QDockWidget* dw = qobject_cast<QDockWidget*>(pcCombiView->parentWidget()); if (dw) { dw->setVisible(true); dw->toggleViewAction()->setVisible(true); dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); } if (ActiveDialog == dlg) return; // dialog is already defined ActiveDialog = dlg; connect(dlg, SIGNAL(destroyed()), this, SLOT(closedDialog())); } // not all workbenches have the combo view enabled else if (!_taskPanel) { QDockWidget* dw = new QDockWidget(); dw->setWindowTitle(tr("Task panel")); dw->setFeatures(QDockWidget::DockWidgetMovable); _taskPanel = new Gui::TaskView::TaskView(dw); dw->setWidget(_taskPanel); _taskPanel->showDialog(dlg); getMainWindow()->addDockWidget(Qt::LeftDockWidgetArea, dw); connect(dlg, SIGNAL(destroyed()), dw, SLOT(deleteLater())); // if we have the normal tree view available then just tabify with it QWidget* treeView = Gui::DockWindowManager::instance()->getDockWindow("Tree view"); QDockWidget* par = treeView ? qobject_cast<QDockWidget*>(treeView->parent()) : 0; if (par && par->isVisible()) { getMainWindow()->tabifyDockWidget(par, dw); qApp->processEvents(); // make sure that the task panel is tabified now dw->show(); dw->raise(); } } }
QT_BEGIN_NAMESPACE MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) : QMainWindow(parent) , m_bookmarkWidget(0) , m_filterCombo(0) , m_toolBarMenu(0) , m_cmdLine(cmdLine) , m_progressWidget(0) , m_qtDocInstaller(0) , m_connectedInitSignals(false) { TRACE_OBJ setToolButtonStyle(Qt::ToolButtonFollowStyle); setDockOptions(dockOptions() | AllowNestedDocks); QString collectionFile; if (usesDefaultCollection()) { MainWindow::collectionFileDirectory(true); collectionFile = MainWindow::defaultHelpCollectionFileName(); } else { collectionFile = cmdLine->collectionFile(); } HelpEngineWrapper &helpEngineWrapper = HelpEngineWrapper::instance(collectionFile); BookmarkManager *bookMarkManager = BookmarkManager::instance(); if (!initHelpDB(!cmdLine->collectionFileGiven())) { qDebug("Fatal error: Help engine initialization failed. " "Error message was: %s\nAssistant will now exit.", qPrintable(HelpEngineWrapper::instance().error())); std::exit(1); } m_centralWidget = new CentralWidget(this); setCentralWidget(m_centralWidget); m_indexWindow = new IndexWindow(this); QDockWidget *indexDock = new QDockWidget(tr("Index"), this); indexDock->setObjectName(QLatin1String("IndexWindow")); indexDock->setWidget(m_indexWindow); addDockWidget(Qt::LeftDockWidgetArea, indexDock); m_contentWindow = new ContentWindow; QDockWidget *contentDock = new QDockWidget(tr("Contents"), this); contentDock->setObjectName(QLatin1String("ContentWindow")); contentDock->setWidget(m_contentWindow); addDockWidget(Qt::LeftDockWidgetArea, contentDock); m_searchWindow = new SearchWidget(helpEngineWrapper.searchEngine()); m_searchWindow->setFont(!helpEngineWrapper.usesBrowserFont() ? qApp->font() : helpEngineWrapper.browserFont()); QDockWidget *searchDock = new QDockWidget(tr("Search"), this); searchDock->setObjectName(QLatin1String("SearchWindow")); searchDock->setWidget(m_searchWindow); addDockWidget(Qt::LeftDockWidgetArea, searchDock); QDockWidget *bookmarkDock = new QDockWidget(tr("Bookmarks"), this); bookmarkDock->setObjectName(QLatin1String("BookmarkWindow")); bookmarkDock->setWidget(m_bookmarkWidget = bookMarkManager->bookmarkDockWidget()); addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock); QDockWidget *openPagesDock = new QDockWidget(tr("Open Pages"), this); openPagesDock->setObjectName(QLatin1String("Open Pages")); OpenPagesManager *openPagesManager = OpenPagesManager::createInstance(this, usesDefaultCollection(), m_cmdLine->url()); openPagesDock->setWidget(openPagesManager->openPagesWidget()); addDockWidget(Qt::LeftDockWidgetArea, openPagesDock); connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)), bookMarkManager, SLOT(addBookmark(QString, QString))); connect(bookMarkManager, SIGNAL(escapePressed()), this, SLOT(activateCurrentCentralWidgetTab())); connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget, SLOT(setSource(QUrl))); connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)), openPagesManager, SLOT(createPage(QUrl))); QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine(); connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted())); connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); QString defWindowTitle = tr("Qt Assistant"); setWindowTitle(defWindowTitle); setupActions(); statusBar()->show(); m_centralWidget->connectTabBar(); setupFilterToolbar(); setupAddressToolbar(); const QString windowTitle = helpEngineWrapper.windowTitle(); setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle); QByteArray iconArray = helpEngineWrapper.applicationIcon(); if (iconArray.size() > 0) { QPixmap pix; pix.loadFromData(iconArray); QIcon appIcon(pix); qApp->setWindowIcon(appIcon); } else { QIcon appIcon(QLatin1String(":/trolltech/assistant/images/assistant-128.png")); qApp->setWindowIcon(appIcon); } QToolBar *toolBar = addToolBar(tr("Bookmark Toolbar")); toolBar->setObjectName(QLatin1String("Bookmark Toolbar")); bookMarkManager->setBookmarksToolbar(toolBar); // Show the widget here, otherwise the restore geometry and state won't work // on x11. show(); toolBar->hide(); toolBarMenu()->addAction(toolBar->toggleViewAction()); QByteArray ba(helpEngineWrapper.mainWindow()); if (!ba.isEmpty()) restoreState(ba); ba = helpEngineWrapper.mainWindowGeometry(); if (!ba.isEmpty()) { restoreGeometry(ba); } else { tabifyDockWidget(contentDock, indexDock); tabifyDockWidget(indexDock, bookmarkDock); tabifyDockWidget(bookmarkDock, searchDock); contentDock->raise(); const QRect screen = QApplication::desktop()->screenGeometry(); resize(4*screen.width()/5, 4*screen.height()/5); } if (!helpEngineWrapper.hasFontSettings()) { helpEngineWrapper.setUseAppFont(false); helpEngineWrapper.setUseBrowserFont(false); helpEngineWrapper.setAppFont(qApp->font()); helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin); helpEngineWrapper.setBrowserFont(qApp->font()); helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin); } else { updateApplicationFont(); } updateAboutMenuText(); QTimer::singleShot(0, this, SLOT(insertLastPages())); if (m_cmdLine->enableRemoteControl()) (void)new RemoteControl(this); if (m_cmdLine->contents() == CmdLineParser::Show) showContents(); else if (m_cmdLine->contents() == CmdLineParser::Hide) hideContents(); if (m_cmdLine->index() == CmdLineParser::Show) showIndex(); else if (m_cmdLine->index() == CmdLineParser::Hide) hideIndex(); if (m_cmdLine->bookmarks() == CmdLineParser::Show) showBookmarksDockWidget(); else if (m_cmdLine->bookmarks() == CmdLineParser::Hide) hideBookmarksDockWidget(); if (m_cmdLine->search() == CmdLineParser::Show) showSearch(); else if (m_cmdLine->search() == CmdLineParser::Hide) hideSearch(); if (m_cmdLine->contents() == CmdLineParser::Activate) showContents(); else if (m_cmdLine->index() == CmdLineParser::Activate) showIndex(); else if (m_cmdLine->bookmarks() == CmdLineParser::Activate) showBookmarksDockWidget(); if (!m_cmdLine->currentFilter().isEmpty()) { const QString &curFilter = m_cmdLine->currentFilter(); if (helpEngineWrapper.customFilters().contains(curFilter)) helpEngineWrapper.setCurrentFilter(curFilter); } if (usesDefaultCollection()) QTimer::singleShot(0, this, SLOT(lookForNewQtDocumentation())); else checkInitState(); connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)), this, SLOT(documentationRemoved(QString))); connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)), this, SLOT(documentationUpdated(QString))); setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); GlobalActions::instance()->updateActions(); if (helpEngineWrapper.addressBarEnabled()) showNewAddress(); }
PDFViewer::PDFViewer(const QString & pdf_doc, QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags) { QtPDF::PDFDocumentWidget *docWidget = new QtPDF::PDFDocumentWidget(this); connect(this, SIGNAL(switchInterfaceLocale(QLocale)), docWidget, SLOT(switchInterfaceLocale(QLocale))); #ifdef USE_MUPDF docWidget->setDefaultBackend(QString::fromLatin1("mupdf")); #elif USE_POPPLERQT docWidget->setDefaultBackend(QString::fromLatin1("poppler-qt")); #else #error At least one backend is required #endif if (!pdf_doc.isEmpty() && docWidget) docWidget->load(pdf_doc); docWidget->goFirst(); _counter = new PageCounter(this->statusBar()); _zoomWdgt = new ZoomTracker(this); _search = new SearchLineEdit(this); _toolBar = new QToolBar(this); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/document-open.png")), tr("Open..."), this, SLOT(open())); _toolBar->addSeparator(); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/zoomin.png")), tr("Zoom In"), docWidget, SLOT(zoomIn())); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/zoomout.png")), tr("Zoom Out"), docWidget, SLOT(zoomOut())); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/zoom-fitwidth.png")), tr("Fit to Width"), docWidget, SLOT(zoomFitWidth())); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/zoom-fitwindow.png")), tr("Fit to Window"), docWidget, SLOT(zoomFitWindow())); _toolBar->addSeparator(); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/pagemode-single.png")), tr("Single Page Mode"), docWidget, SLOT(setSinglePageMode())); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/pagemode-continuous.png")), tr("One Column Continuous Page Mode"), docWidget, SLOT(setOneColContPageMode())); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/pagemode-twocols.png")), tr("Two Columns Continuous Page Mode"), docWidget, SLOT(setTwoColContPageMode())); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/pagemode-present.png")), tr("Presentation Mode"), docWidget, SLOT(setPresentationMode())); // TODO: fullscreen mode for presentations _toolBar->addSeparator(); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/zoom.png")), tr("Magnify"), docWidget, SLOT(setMouseModeMagnifyingGlass())); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/hand.png")), tr("Pan"), docWidget, SLOT(setMouseModeMove())); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/zoom-select.png")), tr("Marquee Zoom"), docWidget, SLOT(setMouseModeMarqueeZoom())); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/measure.png")), tr("Measure"), docWidget, SLOT(setMouseModeMeasure())); _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/select-text.png")), tr("Select"), docWidget, SLOT(setMouseModeSelect())); _counter->setLastPage(docWidget->lastPage()); connect(docWidget, SIGNAL(changedPage(int)), _counter, SLOT(setCurrentPage(int))); connect(docWidget, SIGNAL(changedZoom(qreal)), _zoomWdgt, SLOT(setZoom(qreal))); connect(docWidget, SIGNAL(requestOpenUrl(const QUrl)), this, SLOT(openUrl(const QUrl))); connect(docWidget, SIGNAL(requestOpenPdf(QString, QtPDF::PDFDestination, bool)), this, SLOT(openPdf(QString, QtPDF::PDFDestination, bool))); connect(docWidget, SIGNAL(contextClick(const int, const QPointF)), this, SLOT(syncFromPdf(const int, const QPointF))); connect(docWidget, SIGNAL(searchProgressChanged(int, int)), this, SLOT(searchProgressChanged(int, int))); connect(docWidget, SIGNAL(changedDocument(const QWeakPointer<QtPDF::Backend::Document>)), this, SLOT(documentChanged(const QWeakPointer<QtPDF::Backend::Document>))); _toolBar->addSeparator(); #ifdef DEBUG // FIXME: Remove this _toolBar->addAction(QString::fromUtf8("en"), this, SLOT(setEnglishLocale())); _toolBar->addAction(QString::fromUtf8("de"), this, SLOT(setGermanLocale())); _toolBar->addSeparator(); #endif _toolBar->addWidget(_search); connect(_search, SIGNAL(searchRequested(QString)), docWidget, SLOT(search(QString))); connect(_search, SIGNAL(gotoNextResult()), docWidget, SLOT(nextSearchResult())); connect(_search, SIGNAL(gotoPreviousResult()), docWidget, SLOT(previousSearchResult())); connect(_search, SIGNAL(searchCleared()), docWidget, SLOT(clearSearchResults())); statusBar()->addPermanentWidget(_counter); statusBar()->addWidget(_zoomWdgt); addToolBar(_toolBar); setCentralWidget(docWidget); QDockWidget * toc = docWidget->dockWidget(QtPDF::PDFDocumentView::Dock_TableOfContents, this); addDockWidget(Qt::LeftDockWidgetArea, toc); tabifyDockWidget(toc, docWidget->dockWidget(QtPDF::PDFDocumentView::Dock_MetaData, this)); tabifyDockWidget(toc, docWidget->dockWidget(QtPDF::PDFDocumentView::Dock_Fonts, this)); tabifyDockWidget(toc, docWidget->dockWidget(QtPDF::PDFDocumentView::Dock_Permissions, this)); tabifyDockWidget(toc, docWidget->dockWidget(QtPDF::PDFDocumentView::Dock_Annotations, this)); toc->raise(); QShortcut * goPrevViewRect = new QShortcut(QKeySequence(tr("Alt+Left")), this); connect(goPrevViewRect, SIGNAL(activated()), docWidget, SLOT(goPrevViewRect())); }
void SearchResultWidget::setupUi(QMainWindow *qmw, const QString &iconThemePath) { QDockWidget *searchResultWidget = 0; QString dockTitle = sectionName+":"+phrase; dockTitle.replace("==", tr("Radifs that contain: ")); dockTitle.replace("=", tr("Rhymed by: ")); searchResultWidget = new QDockWidget(dockTitle, qmw); searchResultWidget->setObjectName(QString::fromUtf8("searchResultWidget_new"));//object name for created instance, it renames to 'searchResultWidget_old' //searchResultWidget->setLayoutDirection(Qt::RightToLeft); searchResultWidget->setFeatures(QDockWidget::AllDockWidgetFeatures); searchResultWidget->setAttribute(Qt::WA_DeleteOnClose, true); QGridLayout *searchGridLayout = new QGridLayout(searchResultContents); searchGridLayout->setSpacing(6); searchGridLayout->setContentsMargins(11, 11, 11, 11); searchGridLayout->setObjectName(QString::fromUtf8("searchGridLayout")); QHBoxLayout *horizontalLayout = new QHBoxLayout(); horizontalLayout->setSpacing(6); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); QGridLayout *searchTableGridLayout = new QGridLayout(); searchTableGridLayout->setSpacing(6); searchTableGridLayout->setObjectName(QString::fromUtf8("gridLayout_3")); //create filter lable and lineEdit and layout QHBoxLayout *filterHorizontalLayout = new QHBoxLayout(); filterHorizontalLayout->setSpacing(6); filterHorizontalLayout->setObjectName(QString::fromUtf8("filterHorizontalLayout")); QLabel *filterLabel = new QLabel(searchResultContents); filterLabel->setObjectName(QString::fromUtf8("filterLabel")); filterLabel->setText(tr("Filter:")); filterHorizontalLayout->addWidget(filterLabel, 0, Qt::AlignRight|Qt::AlignCenter); QString clearIconPath = iconThemePath+"/clear-left.png"; if (searchResultContents->layoutDirection() == Qt::RightToLeft) clearIconPath = iconThemePath+"/clear-right.png"; filterLineEdit = new QSearchLineEdit(searchResultContents, clearIconPath, iconThemePath+"/filter.png"); filterLineEdit->setObjectName(QString::fromUtf8("filterLineEdit")); #if QT_VERSION > 0x040700 filterLineEdit->setPlaceholderText(tr("Filter")); #endif connect(filterLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterResults(const QString &))); filterHorizontalLayout->addWidget(filterLineEdit); QSpacerItem *filterHorizSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); filterHorizontalLayout->addItem(filterHorizSpacer); pageLabel = new QLabel(searchResultContents); pageLabel->setObjectName(QString::fromUtf8("pageLabel")); // filterHorizontalLayout->addWidget(pageLabel, 0, Qt::AlignRight|Qt::AlignCenter); //searchTableGridLayout->addLayout(filterHorizontalLayout, 1, 0, 1, 1); //create QTableWidget searchTable = new QTableWidget(searchResultContents); searchTable->setObjectName(QString::fromUtf8("searchTable")); searchTable->setColumnCount(3); searchTable->setLayoutDirection(Qt::RightToLeft); searchTable->setAlternatingRowColors(true); searchTable->setSelectionMode(QAbstractItemView::NoSelection); searchTable->setSelectionBehavior(QAbstractItemView::SelectRows); searchTable->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); searchTable->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); searchTable->verticalHeader()->setVisible(false); //searchTable->horizontalHeader()->setVisible(false); searchTable->horizontalHeader()->setHighlightSections(false); searchTable->horizontalHeader()->setStretchLastSection(true); //install delagate on third column SaagharItemDelegate *searchDelegate = new SaagharItemDelegate(searchTable, searchTable->style(), phrase); searchTable->setItemDelegateForColumn(2, searchDelegate); connect(this, SIGNAL(searchFiltered(const QString &)), searchDelegate, SLOT(keywordChanged(const QString &)) ); //searchTable->setItemDelegateForColumn(2, new SaagharItemDelegate(searchTable, searchTable->style(), phrase)); searchTableGridLayout->addWidget(searchTable, 0, 0, 1, 1); // QVBoxLayout *searchNavVerticalLayout = new QVBoxLayout(); // searchNavVerticalLayout->setSpacing(6); // searchNavVerticalLayout->setObjectName(QString::fromUtf8("searchNavVerticalLayout")); searchNextPage = new QToolButton(searchResultContents); searchNextPage->setObjectName(QString::fromUtf8("searchNextPage")); searchNextPage->setStyleSheet("QToolButton { border: none; padding: 0px; }"); actSearchNextPage = new QAction(searchResultContents); searchNextPage->setDefaultAction(actSearchNextPage); connect(searchNextPage, SIGNAL(triggered(QAction *)), this, SLOT(searchPageNavigationClicked(QAction *))); searchNextPage->setEnabled(false); searchNextPage->hide(); //searchNavVerticalLayout->addWidget(searchNextPage); searchPreviousPage = new QToolButton(searchResultContents); searchPreviousPage->setObjectName(QString::fromUtf8("searchPreviousPage")); searchPreviousPage->setStyleSheet("QToolButton { border: none; padding: 0px; }"); actSearchPreviousPage = new QAction(searchResultContents); searchPreviousPage->setDefaultAction(actSearchPreviousPage); if (qmw->layoutDirection() == Qt::LeftToRight) { actSearchPreviousPage->setIcon(QIcon(iconThemePath+"/previous.png")); actSearchNextPage->setIcon(QIcon(iconThemePath+"/next.png")); } else { actSearchPreviousPage->setIcon(QIcon(iconThemePath+"/next.png")); actSearchNextPage->setIcon(QIcon(iconThemePath+"/previous.png")); } connect(searchPreviousPage, SIGNAL(triggered(QAction *)), this, SLOT(searchPageNavigationClicked(QAction *))); searchPreviousPage->setEnabled(false); searchPreviousPage->hide(); // searchNavVerticalLayout->addWidget(searchPreviousPage); //QSpacerItem *searchNavVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); //searchNavVerticalLayout->addItem(searchNavVerticalSpacer); // if (moreThanOnePage) // horizontalLayout->addLayout(searchNavVerticalLayout); filterHorizontalLayout->addWidget(searchPreviousPage); filterHorizontalLayout->addWidget(searchNextPage); filterHorizontalLayout->addWidget(pageLabel, 0, Qt::AlignRight|Qt::AlignCenter); searchTableGridLayout->addLayout(filterHorizontalLayout, 1, 0, 1, 1); horizontalLayout->addLayout(searchTableGridLayout); searchGridLayout->addLayout(horizontalLayout, 0, 0, 1, 1); /****************************/ QDockWidget *tmpDockWidget = 0; QObjectList mainWindowChildren = qmw->children(); for (int i=0; i < mainWindowChildren.size(); ++i) { tmpDockWidget = qobject_cast<QDockWidget *>(mainWindowChildren.at(i)); if (tmpDockWidget) { if (mainWindowChildren.at(i)->objectName() == "searchResultWidget_old") break; } } /****************************************/ searchResultWidget->setWidget(searchResultContents); qmw->addDockWidget(Qt::LeftDockWidgetArea, searchResultWidget); if (tmpDockWidget && tmpDockWidget->objectName() == "searchResultWidget_old") //there is another search results dock-widget present qmw->tabifyDockWidget(tmpDockWidget, searchResultWidget); searchResultWidget->setObjectName("searchResultWidget_old"); searchResultWidget->show(); searchResultWidget->raise(); }
void tst_QDockWidget::visibilityChanged() { QMainWindow mw; QDockWidget dw; QSignalSpy spy(&dw, SIGNAL(visibilityChanged(bool))); mw.addDockWidget(Qt::LeftDockWidgetArea, &dw); mw.show(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); spy.clear(); dw.hide(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), false); spy.clear(); dw.hide(); QCOMPARE(spy.count(), 0); dw.show(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); spy.clear(); dw.show(); QCOMPARE(spy.count(), 0); QDockWidget dw2; mw.tabifyDockWidget(&dw, &dw2); dw2.show(); dw2.raise(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), false); spy.clear(); dw2.hide(); qApp->processEvents(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); spy.clear(); dw2.show(); dw2.raise(); qApp->processEvents(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), false); spy.clear(); dw.raise(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); spy.clear(); dw.raise(); QCOMPARE(spy.count(), 0); dw2.raise(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), false); spy.clear(); dw2.raise(); QCOMPARE(spy.count(), 0); mw.addDockWidget(Qt::RightDockWidgetArea, &dw2); QTest::qWait(200); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); }
void VolumeViewer::initUserInterfaceWidgets() { // Create a toolbar at the top of the window. QToolBar *toolbar = addToolBar("toolbar"); // Add preferences widget and callback. PreferencesDialog *preferencesDialog = new PreferencesDialog(this, boundingBox); QAction *showPreferencesAction = new QAction("Preferences", this); connect(showPreferencesAction, SIGNAL(triggered()), preferencesDialog, SLOT(show())); toolbar->addAction(showPreferencesAction); // Add the "auto rotate" widget and callback. autoRotateAction = new QAction("Auto rotate", this); autoRotateAction->setCheckable(true); connect(autoRotateAction, SIGNAL(toggled(bool)), this, SLOT(autoRotate(bool))); toolbar->addAction(autoRotateAction); // Add the "next timestep" widget and callback. QAction *nextTimeStepAction = new QAction("Next timestep", this); connect(nextTimeStepAction, SIGNAL(triggered()), this, SLOT(nextTimeStep())); toolbar->addAction(nextTimeStepAction); // Add the "play timesteps" widget and callback. QAction *playTimeStepsAction = new QAction("Play timesteps", this); playTimeStepsAction->setCheckable(true); connect(playTimeStepsAction, SIGNAL(toggled(bool)), this, SLOT(playTimeSteps(bool))); toolbar->addAction(playTimeStepsAction); // Connect the "play timesteps" timer. connect(&playTimeStepsTimer, SIGNAL(timeout()), this, SLOT(nextTimeStep())); // Add the "add geometry" widget and callback. QAction *addGeometryAction = new QAction("Add geometry", this); connect(addGeometryAction, SIGNAL(triggered()), this, SLOT(addGeometry())); toolbar->addAction(addGeometryAction); // Add the "screenshot" widget and callback. QAction *screenshotAction = new QAction("Screenshot", this); connect(screenshotAction, SIGNAL(triggered()), this, SLOT(screenshot())); toolbar->addAction(screenshotAction); // Create the transfer function editor dock widget, this widget modifies the transfer function directly. QDockWidget *transferFunctionEditorDockWidget = new QDockWidget("Transfer Function", this); transferFunctionEditor = new TransferFunctionEditor(transferFunction); transferFunctionEditorDockWidget->setWidget(transferFunctionEditor); connect(transferFunctionEditor, SIGNAL(committed()), this, SLOT(commitVolumes())); connect(transferFunctionEditor, SIGNAL(committed()), this, SLOT(render())); addDockWidget(Qt::LeftDockWidgetArea, transferFunctionEditorDockWidget); // Set the transfer function editor widget to its minimum allowed height, to leave room for other dock widgets. transferFunctionEditor->setMaximumHeight(transferFunctionEditor->minimumSize().height()); // Create slice editor dock widget. QDockWidget *sliceEditorDockWidget = new QDockWidget("Slices", this); sliceEditor = new SliceEditor(boundingBox); sliceEditorDockWidget->setWidget(sliceEditor); connect(sliceEditor, SIGNAL(slicesChanged(std::vector<SliceParameters>)), this, SLOT(setSlices(std::vector<SliceParameters>))); addDockWidget(Qt::LeftDockWidgetArea, sliceEditorDockWidget); // Create isosurface editor dock widget. QDockWidget *isosurfaceEditorDockWidget = new QDockWidget("Isosurfaces", this); isosurfaceEditor = new IsosurfaceEditor(); isosurfaceEditorDockWidget->setWidget(isosurfaceEditor); connect(isosurfaceEditor, SIGNAL(isovaluesChanged(std::vector<float>)), this, SLOT(setIsovalues(std::vector<float>))); addDockWidget(Qt::LeftDockWidgetArea, isosurfaceEditorDockWidget); // Create the light editor dock widget, this widget modifies the light directly. QDockWidget *lightEditorDockWidget = new QDockWidget("Lights", this); LightEditor *lightEditor = new LightEditor(ambientLight, directionalLight); lightEditorDockWidget->setWidget(lightEditor); connect(lightEditor, SIGNAL(lightsChanged()), this, SLOT(render())); addDockWidget(Qt::LeftDockWidgetArea, lightEditorDockWidget); // Create the probe dock widget. QDockWidget *probeDockWidget = new QDockWidget("Probe", this); probeWidget = new ProbeWidget(this); probeDockWidget->setWidget(probeWidget); addDockWidget(Qt::LeftDockWidgetArea, probeDockWidget); // Tabify dock widgets. tabifyDockWidget(transferFunctionEditorDockWidget, sliceEditorDockWidget); tabifyDockWidget(transferFunctionEditorDockWidget, isosurfaceEditorDockWidget); tabifyDockWidget(transferFunctionEditorDockWidget, lightEditorDockWidget); tabifyDockWidget(transferFunctionEditorDockWidget, probeDockWidget); // Tabs on top. setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::North); // Default to showing transfer function tab widget. transferFunctionEditorDockWidget->raise(); // Add the current OSPRay object file label to the bottom status bar. statusBar()->addWidget(¤tFilenameInfoLabel); }
PointViewerMainWindow::PointViewerMainWindow(const QGLFormat& format) : m_progressBar(0), m_pointView(0), m_shaderEditor(0), m_helpDialog(0), m_logTextView(0), m_maxPointCount(200*1000*1000), // 200 million m_geometries(0), m_ipcServer(0), m_hookManager(0) { #ifndef _WIN32 setWindowIcon(QIcon(":resource/icons/hicolor/256x256/apps/displaz.png")); #else // On windows, application icon is set via windows resource file #endif setWindowTitle("Displaz"); setAcceptDrops(true); m_helpDialog = new HelpDialog(this); m_geometries = new GeometryCollection(this); connect(m_geometries, SIGNAL(layoutChanged()), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(updateTitle())); //-------------------------------------------------- // Set up file loader in a separate thread // // Some subtleties regarding qt thread usage are discussed here: // http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation // // Main point: each QObject has a thread affinity which determines which // thread its slots will execute on, when called via a connected signal. QThread* loaderThread = new QThread(); m_fileLoader = new FileLoader(m_maxPointCount); m_fileLoader->moveToThread(loaderThread); connect(loaderThread, SIGNAL(finished()), m_fileLoader, SLOT(deleteLater())); connect(loaderThread, SIGNAL(finished()), loaderThread, SLOT(deleteLater())); //connect(m_fileLoader, SIGNAL(finished()), this, SIGNAL(fileLoadFinished())); connect(m_fileLoader, SIGNAL(geometryLoaded(std::shared_ptr<Geometry>, bool, bool)), m_geometries, SLOT(addGeometry(std::shared_ptr<Geometry>, bool, bool))); connect(m_fileLoader, SIGNAL(geometryMutatorLoaded(std::shared_ptr<GeometryMutator>)), m_geometries, SLOT(mutateGeometry(std::shared_ptr<GeometryMutator>))); loaderThread->start(); //-------------------------------------------------- // Menus menuBar()->setNativeMenuBar(false); // OS X doesn't activate the native menu bar under Qt5 // File menu QMenu* fileMenu = menuBar()->addMenu(tr("&File")); QAction* openAct = fileMenu->addAction(tr("&Open")); openAct->setToolTip(tr("Open a data set")); openAct->setShortcuts(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(openFiles())); QAction* addAct = fileMenu->addAction(tr("&Add")); addAct->setToolTip(tr("Add a data set")); connect(addAct, SIGNAL(triggered()), this, SLOT(addFiles())); QAction* reloadAct = fileMenu->addAction(tr("&Reload")); reloadAct->setStatusTip(tr("Reload point files from disk")); reloadAct->setShortcut(Qt::Key_F5); connect(reloadAct, SIGNAL(triggered()), this, SLOT(reloadFiles())); fileMenu->addSeparator(); QAction* screenShotAct = fileMenu->addAction(tr("Scree&nshot")); screenShotAct->setStatusTip(tr("Save screen shot of 3D window")); screenShotAct->setShortcut(Qt::Key_F9); connect(screenShotAct, SIGNAL(triggered()), this, SLOT(screenShot())); fileMenu->addSeparator(); QAction* quitAct = fileMenu->addAction(tr("&Quit")); quitAct->setStatusTip(tr("Exit the application")); quitAct->setShortcuts(QKeySequence::Quit); connect(quitAct, SIGNAL(triggered()), this, SLOT(close())); // View menu QMenu* viewMenu = menuBar()->addMenu(tr("&View")); QAction* trackballMode = viewMenu->addAction(tr("Use &Trackball camera")); trackballMode->setCheckable(true); trackballMode->setChecked(false); // Background sub-menu QMenu* backMenu = viewMenu->addMenu(tr("Set &Background")); QSignalMapper* mapper = new QSignalMapper(this); // Selectable backgrounds (svg_names from SVG standard - see QColor docs) const char* backgroundNames[] = {/* "Display Name", "svg_name", */ "Default", "#3C3232", "Black", "black", "Dark Grey", "dimgrey", "Slate Grey", "#858C93", "Light Grey", "lightgrey", "White", "white" }; for(size_t i = 0; i < sizeof(backgroundNames)/sizeof(const char*); i+=2) { QAction* backgroundAct = backMenu->addAction(tr(backgroundNames[i])); QPixmap pixmap(50,50); QString colName = backgroundNames[i+1]; pixmap.fill(QColor(colName)); QIcon icon(pixmap); backgroundAct->setIcon(icon); mapper->setMapping(backgroundAct, colName); connect(backgroundAct, SIGNAL(triggered()), mapper, SLOT(map())); } connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setBackground(QString))); backMenu->addSeparator(); QAction* backgroundCustom = backMenu->addAction(tr("&Custom")); connect(backgroundCustom, SIGNAL(triggered()), this, SLOT(chooseBackground())); // Check boxes for drawing various scene elements by category viewMenu->addSeparator(); QAction* drawBoundingBoxes = viewMenu->addAction(tr("Draw Bounding bo&xes")); drawBoundingBoxes->setCheckable(true); drawBoundingBoxes->setChecked(false); QAction* drawCursor = viewMenu->addAction(tr("Draw 3D &Cursor")); drawCursor->setCheckable(true); drawCursor->setChecked(true); QAction* drawAxes = viewMenu->addAction(tr("Draw &Axes")); drawAxes->setCheckable(true); drawAxes->setChecked(true); QAction* drawGrid = viewMenu->addAction(tr("Draw &Grid")); drawGrid->setCheckable(true); drawGrid->setChecked(false); QAction* drawAnnotations = viewMenu->addAction(tr("Draw A&nnotations")); drawAnnotations->setCheckable(true); drawAnnotations->setChecked(true); // Shader menu QMenu* shaderMenu = menuBar()->addMenu(tr("&Shader")); QAction* openShaderAct = shaderMenu->addAction(tr("&Open")); openShaderAct->setToolTip(tr("Open a shader file")); connect(openShaderAct, SIGNAL(triggered()), this, SLOT(openShaderFile())); QAction* editShaderAct = shaderMenu->addAction(tr("&Edit")); editShaderAct->setToolTip(tr("Open shader editor window")); QAction* saveShaderAct = shaderMenu->addAction(tr("&Save")); saveShaderAct->setToolTip(tr("Save current shader file")); connect(saveShaderAct, SIGNAL(triggered()), this, SLOT(saveShaderFile())); shaderMenu->addSeparator(); // Help menu QMenu* helpMenu = menuBar()->addMenu(tr("&Help")); QAction* helpAct = helpMenu->addAction(tr("User &Guide")); connect(helpAct, SIGNAL(triggered()), this, SLOT(helpDialog())); helpMenu->addSeparator(); QAction* aboutAct = helpMenu->addAction(tr("&About")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(aboutDialog())); //-------------------------------------------------- // Point viewer m_pointView = new View3D(m_geometries, format, this); setCentralWidget(m_pointView); connect(drawBoundingBoxes, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawBoundingBoxes())); connect(drawCursor, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawCursor())); connect(drawAxes, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawAxes())); connect(drawGrid, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawGrid())); connect(drawAnnotations, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawAnnotations())); connect(trackballMode, SIGNAL(triggered()), m_pointView, SLOT(toggleCameraMode())); connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(geometryRowsInserted(QModelIndex,int,int))); //-------------------------------------------------- // Docked widgets // Shader parameters UI QDockWidget* shaderParamsDock = new QDockWidget(tr("Shader Parameters"), this); shaderParamsDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable); QWidget* shaderParamsUI = new QWidget(shaderParamsDock); shaderParamsDock->setWidget(shaderParamsUI); m_pointView->setShaderParamsUIWidget(shaderParamsUI); // Shader editor UI QDockWidget* shaderEditorDock = new QDockWidget(tr("Shader Editor"), this); shaderEditorDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); QWidget* shaderEditorUI = new QWidget(shaderEditorDock); m_shaderEditor = new ShaderEditor(shaderEditorUI); QGridLayout* shaderEditorLayout = new QGridLayout(shaderEditorUI); shaderEditorLayout->setContentsMargins(2,2,2,2); shaderEditorLayout->addWidget(m_shaderEditor, 0, 0, 1, 1); connect(editShaderAct, SIGNAL(triggered()), shaderEditorDock, SLOT(show())); shaderEditorDock->setWidget(shaderEditorUI); shaderMenu->addAction(m_shaderEditor->compileAction()); connect(m_shaderEditor->compileAction(), SIGNAL(triggered()), this, SLOT(compileShaderFile())); // TODO: check if this is needed - test shader update functionality //connect(m_shaderEditor, SIGNAL(sendShader(QString)), // &m_pointView->shaderProgram(), SLOT(setShader(QString))); // Log viewer UI QDockWidget* logDock = new QDockWidget(tr("Log"), this); logDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable); QWidget* logUI = new QWidget(logDock); m_logTextView = new LogViewer(logUI); m_logTextView->setReadOnly(true); m_logTextView->setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse); m_logTextView->connectLogger(&g_logger); // connect to global logger m_progressBar = new QProgressBar(logUI); m_progressBar->setRange(0,100); m_progressBar->setValue(0); m_progressBar->hide(); connect(m_fileLoader, SIGNAL(loadStepStarted(QString)), this, SLOT(setProgressBarText(QString))); connect(m_fileLoader, SIGNAL(loadProgress(int)), m_progressBar, SLOT(setValue(int))); connect(m_fileLoader, SIGNAL(resetProgress()), m_progressBar, SLOT(hide())); QVBoxLayout* logUILayout = new QVBoxLayout(logUI); //logUILayout->setContentsMargins(2,2,2,2); logUILayout->addWidget(m_logTextView); logUILayout->addWidget(m_progressBar); //m_logTextView->setLineWrapMode(QPlainTextEdit::NoWrap); logDock->setWidget(logUI); // Data set list UI QDockWidget* dataSetDock = new QDockWidget(tr("Data Sets"), this); dataSetDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); DataSetUI* dataSetUI = new DataSetUI(this); dataSetDock->setWidget(dataSetUI); QAbstractItemView* dataSetOverview = dataSetUI->view(); dataSetOverview->setModel(m_geometries); connect(dataSetOverview, SIGNAL(doubleClicked(const QModelIndex&)), m_pointView, SLOT(centerOnGeometry(const QModelIndex&))); m_pointView->setSelectionModel(dataSetOverview->selectionModel()); // Set up docked widgets addDockWidget(Qt::RightDockWidgetArea, shaderParamsDock); addDockWidget(Qt::LeftDockWidgetArea, shaderEditorDock); addDockWidget(Qt::RightDockWidgetArea, logDock); addDockWidget(Qt::RightDockWidgetArea, dataSetDock); tabifyDockWidget(logDock, dataSetDock); logDock->raise(); shaderEditorDock->setVisible(false); // Add dock widget toggles to view menu viewMenu->addSeparator(); viewMenu->addAction(shaderParamsDock->toggleViewAction()); viewMenu->addAction(logDock->toggleViewAction()); viewMenu->addAction(dataSetDock->toggleViewAction()); // Create custom hook events from CLI at runtime m_hookManager = new HookManager(this); }
static void* ui_companion_qt_init(void) { ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle)); MainWindow *mainwindow = NULL; QHBoxLayout *browserButtonsHBoxLayout = NULL; QVBoxLayout *layout = NULL; QVBoxLayout *launchWithWidgetLayout = NULL; QHBoxLayout *coreComboBoxLayout = NULL; QMenuBar *menu = NULL; QDesktopWidget *desktop = NULL; QMenu *fileMenu = NULL; QMenu *editMenu = NULL; QMenu *viewMenu = NULL; QMenu *viewClosedDocksMenu = NULL; QRect desktopRect; QDockWidget *thumbnailDock = NULL; QDockWidget *thumbnail2Dock = NULL; QDockWidget *thumbnail3Dock = NULL; QDockWidget *browserAndPlaylistTabDock = NULL; QDockWidget *coreSelectionDock = NULL; QTabWidget *browserAndPlaylistTabWidget = NULL; QWidget *widget = NULL; QWidget *browserWidget = NULL; QWidget *playlistWidget = NULL; QWidget *coreSelectionWidget = NULL; QWidget *launchWithWidget = NULL; ThumbnailWidget *thumbnailWidget = NULL; ThumbnailWidget *thumbnail2Widget = NULL; ThumbnailWidget *thumbnail3Widget = NULL; QPushButton *browserDownloadsButton = NULL; QPushButton *browserUpButton = NULL; QPushButton *browserStartButton = NULL; ThumbnailLabel *thumbnail = NULL; ThumbnailLabel *thumbnail2 = NULL; ThumbnailLabel *thumbnail3 = NULL; QAction *editSearchAction = NULL; QAction *loadCoreAction = NULL; QAction *unloadCoreAction = NULL; QAction *exitAction = NULL; QComboBox *launchWithComboBox = NULL; QSettings *qsettings = NULL; if (!handle) return NULL; handle->app = static_cast<ui_application_qt_t*>(ui_application_qt.initialize()); handle->window = static_cast<ui_window_qt_t*>(ui_window_qt.init()); desktop = qApp->desktop(); desktopRect = desktop->availableGeometry(); mainwindow = handle->window->qtWindow; qsettings = mainwindow->settings(); mainwindow->resize(qMin(desktopRect.width(), INITIAL_WIDTH), qMin(desktopRect.height(), INITIAL_HEIGHT)); mainwindow->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, mainwindow->size(), desktopRect)); mainwindow->setWindowTitle("RetroArch"); mainwindow->setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | GROUPED_DRAGGING); widget = new QWidget(mainwindow); widget->setObjectName("tableWidget"); layout = new QVBoxLayout(); layout->addWidget(mainwindow->contentTableWidget()); widget->setLayout(layout); mainwindow->setCentralWidget(widget); menu = mainwindow->menuBar(); fileMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE)); loadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_LOAD_CORE), mainwindow, SLOT(onLoadCoreClicked())); loadCoreAction->setShortcut(QKeySequence("Ctrl+L")); unloadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_UNLOAD_CORE), mainwindow, SLOT(onUnloadCoreMenuAction())); unloadCoreAction->setObjectName("unloadCoreAction"); unloadCoreAction->setEnabled(false); unloadCoreAction->setShortcut(QKeySequence("Ctrl+U")); exitAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_EXIT), mainwindow, SLOT(close())); exitAction->setShortcut(QKeySequence::Quit); editMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT)); editSearchAction = editMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT_SEARCH), mainwindow->searchLineEdit(), SLOT(setFocus())); editSearchAction->setShortcut(QKeySequence::Find); viewMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW)); viewClosedDocksMenu = viewMenu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_CLOSED_DOCKS)); viewClosedDocksMenu->setObjectName("viewClosedDocksMenu"); QObject::connect(viewClosedDocksMenu, SIGNAL(aboutToShow()), mainwindow, SLOT(onViewClosedDocksAboutToShow())); viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS), mainwindow->viewOptionsDialog(), SLOT(showDialog())); playlistWidget = new QWidget(); playlistWidget->setLayout(new QVBoxLayout()); playlistWidget->setObjectName("playlistWidget"); playlistWidget->layout()->addWidget(mainwindow->playlistListWidget()); browserWidget = new QWidget(); browserWidget->setLayout(new QVBoxLayout()); browserWidget->setObjectName("browserWidget"); browserDownloadsButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_ASSETS_DIRECTORY)); browserUpButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER_UP)); browserStartButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES)); QObject::connect(browserDownloadsButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserDownloadsClicked())); QObject::connect(browserUpButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserUpClicked())); QObject::connect(browserStartButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserStartClicked())); browserButtonsHBoxLayout = new QHBoxLayout(); browserButtonsHBoxLayout->addWidget(browserUpButton); browserButtonsHBoxLayout->addWidget(browserStartButton); browserButtonsHBoxLayout->addWidget(browserDownloadsButton); qobject_cast<QVBoxLayout*>(browserWidget->layout())->addLayout(browserButtonsHBoxLayout); browserWidget->layout()->addWidget(mainwindow->dirTreeView()); browserAndPlaylistTabWidget = mainwindow->browserAndPlaylistTabWidget(); browserAndPlaylistTabWidget->setObjectName("browserAndPlaylistTabWidget"); /* Several functions depend on the same tab title strings here, so if you change these, make sure to change those too * setCoreActions() * onTabWidgetIndexChanged() * onCurrentListItemChanged() */ browserAndPlaylistTabWidget->addTab(playlistWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS)); browserAndPlaylistTabWidget->addTab(browserWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER)); browserAndPlaylistTabDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER), mainwindow); browserAndPlaylistTabDock->setObjectName("browserAndPlaylistTabDock"); browserAndPlaylistTabDock->setProperty("default_area", Qt::LeftDockWidgetArea); browserAndPlaylistTabDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER)); browserAndPlaylistTabDock->setWidget(browserAndPlaylistTabWidget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(browserAndPlaylistTabDock->property("default_area").toInt()), browserAndPlaylistTabDock); browserButtonsHBoxLayout->addItem(new QSpacerItem(browserAndPlaylistTabWidget->tabBar()->width(), 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); thumbnailWidget = new ThumbnailWidget(); thumbnail2Widget = new ThumbnailWidget(); thumbnail3Widget = new ThumbnailWidget(); thumbnailWidget->setLayout(new QVBoxLayout()); thumbnail2Widget->setLayout(new QVBoxLayout()); thumbnail3Widget->setLayout(new QVBoxLayout()); thumbnailWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail2Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail3Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail = new ThumbnailLabel(); thumbnail->setObjectName("thumbnail"); thumbnail2 = new ThumbnailLabel(); thumbnail2->setObjectName("thumbnail2"); thumbnail3 = new ThumbnailLabel(); thumbnail3->setObjectName("thumbnail3"); thumbnail->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail3->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); QObject::connect(mainwindow, SIGNAL(thumbnailChanged(const QPixmap&)), thumbnail, SLOT(setPixmap(const QPixmap&))); QObject::connect(mainwindow, SIGNAL(thumbnail2Changed(const QPixmap&)), thumbnail2, SLOT(setPixmap(const QPixmap&))); QObject::connect(mainwindow, SIGNAL(thumbnail3Changed(const QPixmap&)), thumbnail3, SLOT(setPixmap(const QPixmap&))); thumbnailWidget->layout()->addWidget(thumbnail); thumbnail2Widget->layout()->addWidget(thumbnail2); thumbnail3Widget->layout()->addWidget(thumbnail3); thumbnailDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART), mainwindow); thumbnailDock->setObjectName("thumbnailDock"); thumbnailDock->setProperty("default_area", Qt::RightDockWidgetArea); thumbnailDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART)); thumbnailDock->setWidget(thumbnailWidget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnailDock->property("default_area").toInt()), thumbnailDock); thumbnail2Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN), mainwindow); thumbnail2Dock->setObjectName("thumbnail2Dock"); thumbnail2Dock->setProperty("default_area", Qt::RightDockWidgetArea); thumbnail2Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN)); thumbnail2Dock->setWidget(thumbnail2Widget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail2Dock->property("default_area").toInt()), thumbnail2Dock); thumbnail3Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT), mainwindow); thumbnail3Dock->setObjectName("thumbnail3Dock"); thumbnail3Dock->setProperty("default_area", Qt::RightDockWidgetArea); thumbnail3Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT)); thumbnail3Dock->setWidget(thumbnail3Widget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail3Dock->property("default_area").toInt()), thumbnail3Dock); mainwindow->tabifyDockWidget(thumbnailDock, thumbnail2Dock); mainwindow->tabifyDockWidget(thumbnailDock, thumbnail3Dock); /* when tabifying the dock widgets, the last tab added is selected by default, so we need to re-select the first tab */ thumbnailDock->raise(); coreSelectionWidget = new QWidget(); coreSelectionWidget->setLayout(new QVBoxLayout()); launchWithComboBox = mainwindow->launchWithComboBox(); launchWithWidgetLayout = new QVBoxLayout(); launchWithWidget = new QWidget(); launchWithWidget->setLayout(launchWithWidgetLayout); coreComboBoxLayout = new QHBoxLayout(); mainwindow->runPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); mainwindow->stopPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); mainwindow->startCorePushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); coreComboBoxLayout->addWidget(launchWithComboBox); coreComboBoxLayout->addWidget(mainwindow->startCorePushButton()); coreComboBoxLayout->addWidget(mainwindow->coreInfoPushButton()); coreComboBoxLayout->addWidget(mainwindow->runPushButton()); coreComboBoxLayout->addWidget(mainwindow->stopPushButton()); mainwindow->stopPushButton()->hide(); coreComboBoxLayout->setStretchFactor(launchWithComboBox, 1); launchWithWidgetLayout->addLayout(coreComboBoxLayout); coreSelectionWidget->layout()->addWidget(launchWithWidget); coreSelectionWidget->layout()->addItem(new QSpacerItem(20, browserAndPlaylistTabWidget->height(), QSizePolicy::Minimum, QSizePolicy::Expanding)); coreSelectionDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE), mainwindow); coreSelectionDock->setObjectName("coreSelectionDock"); coreSelectionDock->setProperty("default_area", Qt::LeftDockWidgetArea); coreSelectionDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE)); coreSelectionDock->setWidget(coreSelectionWidget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(coreSelectionDock->property("default_area").toInt()), coreSelectionDock); mainwindow->splitDockWidget(browserAndPlaylistTabDock, coreSelectionDock, Qt::Vertical); #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) mainwindow->resizeDocks(QList<QDockWidget*>() << coreSelectionDock, QList<int>() << 1, Qt::Vertical); #endif /* this should come last */ mainwindow->resizeThumbnails(true, true, true); if (qsettings->contains("geometry")) if (qsettings->contains("save_geometry")) mainwindow->restoreGeometry(qsettings->value("geometry").toByteArray()); if (qsettings->contains("save_dock_positions")) if (qsettings->contains("dock_positions")) mainwindow->restoreState(qsettings->value("dock_positions").toByteArray()); if (qsettings->contains("save_last_tab")) { if (qsettings->contains("last_tab")) { int lastTabIndex = qsettings->value("last_tab", 0).toInt(); if (lastTabIndex >= 0 && browserAndPlaylistTabWidget->count() > lastTabIndex) browserAndPlaylistTabWidget->setCurrentIndex(lastTabIndex); } } if (qsettings->contains("theme")) { QString themeStr = qsettings->value("theme").toString(); MainWindow::Theme theme = mainwindow->getThemeFromString(themeStr); if (qsettings->contains("custom_theme") && theme == MainWindow::THEME_CUSTOM) { QString customThemeFilePath = qsettings->value("custom_theme").toString(); mainwindow->setCustomThemeFile(customThemeFilePath); } mainwindow->setTheme(theme); } else mainwindow->setTheme(); return handle; }
static void* ui_companion_qt_init(void) { ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle)); MainWindow *mainwindow = NULL; QHBoxLayout *browserButtonsHBoxLayout = NULL; QVBoxLayout *layout = NULL; QVBoxLayout *launchWithWidgetLayout = NULL; QHBoxLayout *coreComboBoxLayout = NULL; QMenuBar *menu = NULL; QDesktopWidget *desktop = NULL; QMenu *fileMenu = NULL; QMenu *editMenu = NULL; QMenu *viewMenu = NULL; QMenu *viewClosedDocksMenu = NULL; QMenu *toolsMenu = NULL; QMenu *updaterMenu = NULL; QMenu *helpMenu = NULL; QRect desktopRect; QDockWidget *thumbnailDock = NULL; QDockWidget *thumbnail2Dock = NULL; QDockWidget *thumbnail3Dock = NULL; QDockWidget *browserAndPlaylistTabDock = NULL; QDockWidget *coreSelectionDock = NULL; QTabWidget *browserAndPlaylistTabWidget = NULL; QWidget *widget = NULL; QWidget *browserWidget = NULL; QWidget *playlistWidget = NULL; QWidget *coreSelectionWidget = NULL; QWidget *launchWithWidget = NULL; ThumbnailWidget *thumbnailWidget = NULL; ThumbnailWidget *thumbnail2Widget = NULL; ThumbnailWidget *thumbnail3Widget = NULL; QPushButton *browserDownloadsButton = NULL; QPushButton *browserUpButton = NULL; QPushButton *browserStartButton = NULL; ThumbnailLabel *thumbnail = NULL; ThumbnailLabel *thumbnail2 = NULL; ThumbnailLabel *thumbnail3 = NULL; QAction *editSearchAction = NULL; QAction *loadCoreAction = NULL; QAction *unloadCoreAction = NULL; QAction *exitAction = NULL; QComboBox *launchWithComboBox = NULL; QSettings *qsettings = NULL; QListWidget *listWidget = NULL; int i = 0; if (!handle) return NULL; handle->app = static_cast<ui_application_qt_t*>(ui_application_qt.initialize()); handle->window = static_cast<ui_window_qt_t*>(ui_window_qt.init()); desktop = qApp->desktop(); desktopRect = desktop->availableGeometry(); mainwindow = handle->window->qtWindow; qsettings = mainwindow->settings(); mainwindow->resize(qMin(desktopRect.width(), INITIAL_WIDTH), qMin(desktopRect.height(), INITIAL_HEIGHT)); mainwindow->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, mainwindow->size(), desktopRect)); mainwindow->setWindowTitle("RetroArch"); mainwindow->setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | GROUPED_DRAGGING); listWidget = mainwindow->playlistListWidget(); widget = new FileDropWidget(mainwindow); widget->setObjectName("tableWidget"); widget->setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(widget, SIGNAL(filesDropped(QStringList)), mainwindow, SLOT(onPlaylistFilesDropped(QStringList))); QObject::connect(widget, SIGNAL(deletePressed()), mainwindow, SLOT(deleteCurrentPlaylistItem())); QObject::connect(widget, SIGNAL(customContextMenuRequested(const QPoint&)), mainwindow, SLOT(onFileDropWidgetContextMenuRequested(const QPoint&))); layout = new QVBoxLayout(); layout->addWidget(mainwindow->contentTableWidget()); layout->addWidget(mainwindow->contentGridWidget()); widget->setLayout(layout); mainwindow->setCentralWidget(widget); menu = mainwindow->menuBar(); fileMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE)); loadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_LOAD_CORE), mainwindow, SLOT(onLoadCoreClicked())); loadCoreAction->setShortcut(QKeySequence("Ctrl+L")); unloadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_UNLOAD_CORE), mainwindow, SLOT(onUnloadCoreMenuAction())); unloadCoreAction->setObjectName("unloadCoreAction"); unloadCoreAction->setEnabled(false); unloadCoreAction->setShortcut(QKeySequence("Ctrl+U")); exitAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_EXIT), mainwindow, SLOT(close())); exitAction->setShortcut(QKeySequence::Quit); editMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT)); editSearchAction = editMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT_SEARCH), mainwindow->searchLineEdit(), SLOT(setFocus())); editSearchAction->setShortcut(QKeySequence::Find); viewMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW)); viewClosedDocksMenu = viewMenu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_CLOSED_DOCKS)); viewClosedDocksMenu->setObjectName("viewClosedDocksMenu"); QObject::connect(viewClosedDocksMenu, SIGNAL(aboutToShow()), mainwindow, SLOT(onViewClosedDocksAboutToShow())); viewMenu->addSeparator(); viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS), mainwindow, SLOT(onIconViewClicked())); viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST), mainwindow, SLOT(onListViewClicked())); viewMenu->addSeparator(); viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS), mainwindow->viewOptionsDialog(), SLOT(showDialog())); toolsMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_TOOLS)); updaterMenu = toolsMenu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ONLINE_UPDATER)); #ifdef Q_OS_WIN updaterMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_UPDATE_RETROARCH_NIGHTLY), mainwindow, SLOT(updateRetroArchNightly())); #endif helpMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP)); helpMenu->addAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP_DOCUMENTATION)), mainwindow, SLOT(showDocs())); helpMenu->addAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP_ABOUT)) + "...", mainwindow, SLOT(showAbout())); helpMenu->addAction("About Qt...", qApp, SLOT(aboutQt())); playlistWidget = new QWidget(); playlistWidget->setLayout(new QVBoxLayout()); playlistWidget->setObjectName("playlistWidget"); playlistWidget->layout()->addWidget(mainwindow->playlistListWidget()); browserWidget = new QWidget(); browserWidget->setLayout(new QVBoxLayout()); browserWidget->setObjectName("browserWidget"); browserDownloadsButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_ASSETS_DIRECTORY)); browserUpButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER_UP)); browserStartButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES)); QObject::connect(browserDownloadsButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserDownloadsClicked())); QObject::connect(browserUpButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserUpClicked())); QObject::connect(browserStartButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserStartClicked())); browserButtonsHBoxLayout = new QHBoxLayout(); browserButtonsHBoxLayout->addWidget(browserUpButton); browserButtonsHBoxLayout->addWidget(browserStartButton); browserButtonsHBoxLayout->addWidget(browserDownloadsButton); qobject_cast<QVBoxLayout*>(browserWidget->layout())->addLayout(browserButtonsHBoxLayout); browserWidget->layout()->addWidget(mainwindow->dirTreeView()); browserAndPlaylistTabWidget = mainwindow->browserAndPlaylistTabWidget(); browserAndPlaylistTabWidget->setObjectName("browserAndPlaylistTabWidget"); /* Several functions depend on the same tab title strings here, so if you change these, make sure to change those too * setCoreActions() * onTabWidgetIndexChanged() * onCurrentListItemChanged() */ browserAndPlaylistTabWidget->addTab(playlistWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS)); browserAndPlaylistTabWidget->addTab(browserWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER)); browserAndPlaylistTabDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER), mainwindow); browserAndPlaylistTabDock->setObjectName("browserAndPlaylistTabDock"); browserAndPlaylistTabDock->setProperty("default_area", Qt::LeftDockWidgetArea); browserAndPlaylistTabDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER)); browserAndPlaylistTabDock->setWidget(browserAndPlaylistTabWidget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(browserAndPlaylistTabDock->property("default_area").toInt()), browserAndPlaylistTabDock); browserButtonsHBoxLayout->addItem(new QSpacerItem(browserAndPlaylistTabWidget->tabBar()->width(), 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); thumbnailWidget = new ThumbnailWidget(); thumbnail2Widget = new ThumbnailWidget(); thumbnail3Widget = new ThumbnailWidget(); thumbnailWidget->setLayout(new QVBoxLayout()); thumbnail2Widget->setLayout(new QVBoxLayout()); thumbnail3Widget->setLayout(new QVBoxLayout()); thumbnailWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail2Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail3Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail = new ThumbnailLabel(); thumbnail->setObjectName("thumbnail"); thumbnail2 = new ThumbnailLabel(); thumbnail2->setObjectName("thumbnail2"); thumbnail3 = new ThumbnailLabel(); thumbnail3->setObjectName("thumbnail3"); thumbnail->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); thumbnail3->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); QObject::connect(mainwindow, SIGNAL(thumbnailChanged(const QPixmap&)), thumbnail, SLOT(setPixmap(const QPixmap&))); QObject::connect(mainwindow, SIGNAL(thumbnail2Changed(const QPixmap&)), thumbnail2, SLOT(setPixmap(const QPixmap&))); QObject::connect(mainwindow, SIGNAL(thumbnail3Changed(const QPixmap&)), thumbnail3, SLOT(setPixmap(const QPixmap&))); thumbnailWidget->layout()->addWidget(thumbnail); thumbnail2Widget->layout()->addWidget(thumbnail2); thumbnail3Widget->layout()->addWidget(thumbnail3); thumbnailDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART), mainwindow); thumbnailDock->setObjectName("thumbnailDock"); thumbnailDock->setProperty("default_area", Qt::RightDockWidgetArea); thumbnailDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART)); thumbnailDock->setWidget(thumbnailWidget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnailDock->property("default_area").toInt()), thumbnailDock); thumbnail2Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN), mainwindow); thumbnail2Dock->setObjectName("thumbnail2Dock"); thumbnail2Dock->setProperty("default_area", Qt::RightDockWidgetArea); thumbnail2Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN)); thumbnail2Dock->setWidget(thumbnail2Widget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail2Dock->property("default_area").toInt()), thumbnail2Dock); thumbnail3Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT), mainwindow); thumbnail3Dock->setObjectName("thumbnail3Dock"); thumbnail3Dock->setProperty("default_area", Qt::RightDockWidgetArea); thumbnail3Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT)); thumbnail3Dock->setWidget(thumbnail3Widget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail3Dock->property("default_area").toInt()), thumbnail3Dock); mainwindow->tabifyDockWidget(thumbnailDock, thumbnail2Dock); mainwindow->tabifyDockWidget(thumbnailDock, thumbnail3Dock); /* when tabifying the dock widgets, the last tab added is selected by default, so we need to re-select the first tab */ thumbnailDock->raise(); coreSelectionWidget = new QWidget(); coreSelectionWidget->setLayout(new QVBoxLayout()); launchWithComboBox = mainwindow->launchWithComboBox(); launchWithWidgetLayout = new QVBoxLayout(); launchWithWidget = new QWidget(); launchWithWidget->setLayout(launchWithWidgetLayout); coreComboBoxLayout = new QHBoxLayout(); mainwindow->runPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); mainwindow->stopPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); mainwindow->startCorePushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); coreComboBoxLayout->addWidget(launchWithComboBox); coreComboBoxLayout->addWidget(mainwindow->startCorePushButton()); coreComboBoxLayout->addWidget(mainwindow->coreInfoPushButton()); coreComboBoxLayout->addWidget(mainwindow->runPushButton()); coreComboBoxLayout->addWidget(mainwindow->stopPushButton()); mainwindow->stopPushButton()->hide(); coreComboBoxLayout->setStretchFactor(launchWithComboBox, 1); launchWithWidgetLayout->addLayout(coreComboBoxLayout); coreSelectionWidget->layout()->addWidget(launchWithWidget); coreSelectionWidget->layout()->addItem(new QSpacerItem(20, browserAndPlaylistTabWidget->height(), QSizePolicy::Minimum, QSizePolicy::Expanding)); coreSelectionDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE), mainwindow); coreSelectionDock->setObjectName("coreSelectionDock"); coreSelectionDock->setProperty("default_area", Qt::LeftDockWidgetArea); coreSelectionDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE)); coreSelectionDock->setWidget(coreSelectionWidget); mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(coreSelectionDock->property("default_area").toInt()), coreSelectionDock); mainwindow->splitDockWidget(browserAndPlaylistTabDock, coreSelectionDock, Qt::Vertical); #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) mainwindow->resizeDocks(QList<QDockWidget*>() << coreSelectionDock, QList<int>() << 1, Qt::Vertical); #endif /* this should come last */ mainwindow->resizeThumbnails(true, true, true); if (qsettings->contains("all_playlists_list_max_count")) mainwindow->setAllPlaylistsListMaxCount(qsettings->value("all_playlists_list_max_count", 0).toInt()); if (qsettings->contains("all_playlists_grid_max_count")) mainwindow->setAllPlaylistsGridMaxCount(qsettings->value("all_playlists_grid_max_count", 5000).toInt()); if (qsettings->contains("geometry")) if (qsettings->contains("save_geometry")) mainwindow->restoreGeometry(qsettings->value("geometry").toByteArray()); if (qsettings->contains("save_dock_positions")) if (qsettings->contains("dock_positions")) mainwindow->restoreState(qsettings->value("dock_positions").toByteArray()); if (qsettings->contains("theme")) { QString themeStr = qsettings->value("theme").toString(); MainWindow::Theme theme = mainwindow->getThemeFromString(themeStr); if (qsettings->contains("custom_theme") && theme == MainWindow::THEME_CUSTOM) { QString customThemeFilePath = qsettings->value("custom_theme").toString(); mainwindow->setCustomThemeFile(customThemeFilePath); } mainwindow->setTheme(theme); } else mainwindow->setTheme(); if (qsettings->contains("view_type")) { QString viewType = qsettings->value("view_type", "list").toString(); if (viewType == "list") mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST); else if (viewType == "icons") mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_ICONS); else mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST); /* we set it to the same thing a second time so that m_lastViewType is also equal to the startup view type */ mainwindow->setCurrentViewType(mainwindow->getCurrentViewType()); } else mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST); /* We make sure to hook up the tab widget callback only after the tabs themselves have been added, * but before changing to a specific one, to avoid the callback firing before the view type is set. */ QObject::connect(browserAndPlaylistTabWidget, SIGNAL(currentChanged(int)), mainwindow, SLOT(onTabWidgetIndexChanged(int))); /* setting the last tab must come after setting the view type */ if (qsettings->contains("save_last_tab")) { int lastTabIndex = qsettings->value("last_tab", 0).toInt(); if (lastTabIndex >= 0 && browserAndPlaylistTabWidget->count() > lastTabIndex) { browserAndPlaylistTabWidget->setCurrentIndex(lastTabIndex); mainwindow->onTabWidgetIndexChanged(lastTabIndex); } } else { browserAndPlaylistTabWidget->setCurrentIndex(0); mainwindow->onTabWidgetIndexChanged(0); } for (i = 0; i < listWidget->count() && listWidget->count() > 0; i++) { /* select the first non-hidden row */ if (!listWidget->isRowHidden(i)) { listWidget->setCurrentRow(i); break; } } return handle; }