QWidget* ProjectWindow::setupParametersWidget() { ParametersWidget* parameters = new ParametersWidget(projectData.projectParameterData(), projectData.projectParameterData()->getLookupTable().keys(), 1); QGridLayout* mainLayout = new QGridLayout(); QHBoxLayout* headerLayout = new QHBoxLayout; headerLayout->addStretch(0); QLabel* searchLabel = new QLabel("Search Parameters:"); QLineEdit* searchEditBox = new QLineEdit(); searchEditBox->setFrame(false); searchLabel->setBuddy(searchEditBox); searchEditBox->setPlaceholderText("Search Parameters"); searchEditBox->setFixedWidth(200); connect(searchEditBox, &QLineEdit::editingFinished, [=]() { parameters->searchParams(searchEditBox->text()); }); headerLayout->addWidget(searchLabel, 0); headerLayout->addWidget(searchEditBox, 0); headerLayout->addStretch(1); QListWidget* imagesBox = new QListWidget(); imagesBox->setSelectionMode(QAbstractItemView::SingleSelection); imagesBox->addItem("Project Parameters"); imagesBox->setCurrentRow(0); for (ProjectImage* image : projectData.projectImageList()) { imagesList_.append(image); imagesBox->addItem(image->toString()); } connect(&projectData, &ProjectData::imageAdded, [ = ](ProjectImage * image){ imagesList_.append(image); imagesBox->addItem(image->toString()); }); connect(&projectData, &ProjectData::imageMoved, [ = ](ProjectImage* image) { int idx = imagesList_.indexOf(image) + 1; if(idx > 0) { imagesBox->item(idx)->setText(image->toString()); } }); connect(imagesBox, &QListWidget::currentRowChanged, [ = ](int id) { if(id == 0) parameters->resetConf(projectData.projectParameterData()); else parameters->resetConf(imagesList_[id -1]->parameters()); }); BlockContainer* imagesBoxContainer = new BlockContainer("Select the scope of parameters", imagesBox); imagesBoxContainer->setMaximumWidth(300); mainLayout->addLayout(headerLayout, 0, 0, 1, 1); mainLayout->addWidget(parameters, 1, 0, 1, 1); mainLayout->addWidget(imagesBoxContainer, 0, 1, 2, 1); QWidget* mainWid = new QWidget; mainWid->setLayout(mainLayout); return mainWid; }
void Configurator::initUiFromSettings() { // load section from the file if( false == loadSettingsFile() ) return; // focus the right section int sectionIndex = 0; if( false == _startSectionName.isEmpty() ) { for( ; sectionIndex < _sections->count(); sectionIndex++ ) { QString sectionName = _sections->widget(sectionIndex)->objectName(); if( _startSectionName == sectionName ) break; } } _sections->setCurrentIndex( sectionIndex ); // focus the right sectionItem QListWidget* listWidget = qobject_cast<QListWidget*>( _sections->currentWidget() ); if( 0 != listWidget ) { int sectionItemIndex = 0; for( ; sectionItemIndex < listWidget->count(); sectionItemIndex++ ) { QString itemName = listWidget->item( sectionItemIndex )->data( Qt::UserRole ).toString(); if( _startSectionItemName == itemName ) break; } sectionItemIndex = (sectionItemIndex >= listWidget->count()) ? 0 : sectionItemIndex; listWidget->setCurrentRow( sectionItemIndex ); } }
void MainWindow::fillLists(DisplayData *display) { QListWidget* list; unsigned char rowsCount = display->getRowCount(); if(font != nullptr) for(int i=1;i<=4;i++) { switch(i) { case 1:list = listOfRows1;break; case 2:list = listOfRows2;break; case 3:list = listOfRows3;break; case 4:list = listOfRows4;break; } if(rowsCount>=i) { list->clear(); for(int j=0;j<display->getCountOfLinesInRow(i-1);j++) { QString text = QString::number(j) + ")" + display->getLine(i-1,j)->getAsString(font); list->addItem(text); } } quint16 num = lcd->getCurrentLineNumber(i-1); if(num<list->count()) list->setCurrentRow(num,QItemSelectionModel::SelectCurrent); } }
void MainWindow::ProcessAdded(Process* _process) { QListWidget* list = this->ui.procListWidget; list->addItem(QString::number(_process->id, 10)); QListWidgetItem* item = this->GetProcessItem(_process); if(item != NULL) { int row = list->row(item); list->setCurrentRow(row); } }
void ItemOrderList::onPushButtonUpClicked() { QListWidget *list = ui->listWidgetItems; const int row = list->currentRow(); if (row < 1) return; list->blockSignals(true); list->insertItem(row - 1, list->takeItem(row)); list->setCurrentRow(row - 1); list->blockSignals(false); }
void ItemOrderList::on_pushButtonDown_clicked() { QListWidget *list = ui->listWidgetItems; const int row = list->currentRow(); if (row < 0 || row == list->count() - 1) return; list->blockSignals(true); list->insertItem(row + 1, list->takeItem(row)); list->setCurrentRow(row + 1); list->blockSignals(false); }
void MainWindow::ProcessRemoved(Process* _process) { QListWidgetItem* item = this->GetProcessItem(_process); QListWidget* list = this->ui.procListWidget; if(item != NULL) delete list->takeItem(list->row(item)); if (list->count() == 0x00) this->ResetUI(); else list->setCurrentRow(0x00); }
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- // handlers for controls // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- void Configurator::currentChanged( int index ) { // saving data for the previous section if( _configOptions->children().count() && _currentWigetItem ) { saveItem( _currentWigetItem ); _currentWigetItem->listWidget()->setCurrentRow( -1 ); } // find the new section and set current item to first QListWidget* listWidget = qobject_cast<QListWidget*>( _sections->widget(index) ); if( 0 == listWidget ) return; listWidget->setCurrentRow( 0 ); }
void GuiSpellchecker::updateSuggestions(docstring_list & words) { QString const suggestion = toqstr(d->word_.word()); d->ui.wordED->setText(suggestion); QListWidget * lw = d->ui.suggestionsLW; lw->clear(); if (words.empty()) { on_suggestionsLW_itemClicked(new QListWidgetItem(suggestion)); return; } for (size_t i = 0; i != words.size(); ++i) lw->addItem(toqstr(words[i])); on_suggestionsLW_itemClicked(lw->item(0)); lw->setCurrentRow(0); }
QString QtopiaInputDialog::getItem(QWidget *parent, const QString &title, const QString &label, const QStringList &list, int current, bool *ok) { QListWidget *listWidget = new QListWidget; listWidget->addItems(list); listWidget->setCurrentRow(current); listWidget->setFrameShadow(QFrame::Plain); QtopiaInputDialog dlg(parent, title, label, listWidget); bool accepted = (QtopiaApplication::execDialog(&dlg) == QDialog::Accepted); if (ok) *ok = accepted; if (listWidget->currentItem()) return listWidget->currentItem()->text(); else return QString(); }
bool ThemeManager::selectItem(const QString& id, bool is_default) { QListWidget* view = m_themes; QListWidget* other_view = m_default_themes; if (is_default) { std::swap(view, other_view); } QAbstractItemModel* model = view->model(); QModelIndexList items = model->match(model->index(0, 0, QModelIndex()), Qt::UserRole, id, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive); if (!items.isEmpty()) { view->setCurrentRow(items.first().row()); other_view->setCurrentIndex(other_view->rootIndex()); m_tabs->setCurrentIndex(!is_default); return true; } else { return false; } }
void ItemOrderList::insertItem(const QString &label, bool checked, bool highlight, const QIcon &icon, const ItemPtr &item, int targetRow) { QListWidget *list = ui->listWidgetItems; QListWidgetItem *listItem = new QListWidgetItem(icon, label); const int row = targetRow >= 0 ? qMin(list->count(), targetRow) : list->count(); list->insertItem(row, listItem); listItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked); setItemHighlight(listItem, highlight); m_items[listItem] = ItemWidgetPair(item); // Resize list to minimal size. const int w = list->sizeHintForColumn(0) + list->verticalScrollBar()->sizeHint().width() + 4; list->setMaximumWidth(w); if ( list->currentItem() == NULL ) list->setCurrentRow(row); }
void ItemOrderList::insertItem(const QString &label, bool checked, const QIcon &icon, const ItemPtr &item, int targetRow) { QListWidget *list = ui->listWidgetItems; auto listItem = new QListWidgetItem(icon, label); listItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked); m_items[listItem] = ItemWidgetPair(item, checked); const int row = targetRow >= 0 ? qMin(list->count(), targetRow) : list->count(); list->insertItem(row, listItem); // Resize list to minimal size. if ( !isVisible() ) { const int w = list->sizeHintForColumn(0) + list->verticalScrollBar()->sizeHint().width() + 4; list->resize( w, list->height() ); } if ( list->currentItem() == nullptr ) list->setCurrentRow(row); }
// **** keyboard selection dialog ********************************************* int KNHelper::selectDialog(QWidget *parent, const QString &caption, const QStringList &options, int initialValue) { KDialog *dlg = new KDialog( parent ); dlg->setCaption( caption ); dlg->setButtons( KDialog::Ok|KDialog::Cancel ); dlg->setDefaultButton( KDialog::Ok ); QFrame *page = new QFrame( dlg ); dlg->setMainWidget( page ); QHBoxLayout *pageL = new QHBoxLayout(page); pageL->setSpacing(5); pageL->setMargin(8); QListWidget *list = new QListWidget( page ); pageL->addWidget(list); QString s; for ( QStringList::ConstIterator it = options.begin(); it != options.end(); ++it ) { s = (*it); // remove accelerators s.replace( QRegExp( "&" ), "" ); // krazy:exclude=doublequote_chars list->addItem( s ); } list->setCurrentRow( initialValue ); list->setFocus(); QObject::connect( list, SIGNAL( itemActivated( QListWidgetItem* ) ), dlg, SLOT( accept() ) ); restoreWindowSize("selectBox", dlg, QSize(247,174)); int ret; if (dlg->exec()) ret = list->currentRow(); else ret = -1; saveWindowSize("selectBox", dlg->size()); delete dlg; return ret; }
AboutPlugins::AboutPlugins( Config *_config, QWidget* parent, Qt::WFlags f ) : KDialog( parent, f ), config( _config ), currentPlugin( 0 ) { setCaption( i18n("About plugins") ); setWindowIcon( KIcon("preferences-plugin") ); setButtons( KDialog::Close ); setButtonFocus( KDialog::Close ); QWidget *widget = new QWidget( this ); setMainWidget( widget ); QHBoxLayout *box = new QHBoxLayout( widget ); QVBoxLayout *pluginListBox = new QVBoxLayout( widget ); box->addLayout( pluginListBox ); QLabel *installedPlugins = new QLabel( i18n("Installed plugins:"), this ); pluginListBox->addWidget( installedPlugins ); QListWidget *pluginsList = new QListWidget( this ); pluginListBox->addWidget( pluginsList ); connect( pluginsList, SIGNAL(currentTextChanged(const QString&)), this, SLOT(currentPluginChanged(const QString&)) ); QStringList pluginNames; QList<CodecPlugin*> codecPlugins = config->pluginLoader()->getAllCodecPlugins(); for( int i=0; i<codecPlugins.count(); i++ ) { pluginNames += codecPlugins.at(i)->name(); } pluginNames.sort(); pluginsList->addItems( pluginNames ); pluginNames.clear(); QList<FilterPlugin*> filterPlugins = config->pluginLoader()->getAllFilterPlugins(); for( int i=0; i<filterPlugins.count(); i++ ) { pluginNames += filterPlugins.at(i)->name(); } pluginNames.sort(); pluginsList->addItems( pluginNames ); pluginNames.clear(); QList<ReplayGainPlugin*> replaygainPlugins = config->pluginLoader()->getAllReplayGainPlugins(); for( int i=0; i<replaygainPlugins.count(); i++ ) { pluginNames += replaygainPlugins.at(i)->name(); } pluginNames.sort(); pluginsList->addItems( pluginNames ); pluginNames.clear(); QList<RipperPlugin*> ripperPlugins = config->pluginLoader()->getAllRipperPlugins(); for( int i=0; i<ripperPlugins.count(); i++ ) { pluginNames += ripperPlugins.at(i)->name(); } pluginNames.sort(); pluginsList->addItems( pluginNames ); pluginsList->setFixedWidth( 180 ); box->addSpacing( 10 ); QVBoxLayout *pluginInfoBox = new QVBoxLayout( widget ); box->addLayout( pluginInfoBox ); aboutPluginLabel = new QLabel( this ); aboutPluginLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); aboutPluginLabel->setWordWrap( true ); aboutPluginLabel->setTextFormat( Qt::RichText ); pluginInfoBox->addWidget( aboutPluginLabel ); connect( aboutPluginLabel, SIGNAL(linkActivated(const QString&)), this, SLOT(showProblemInfo(const QString&)) ); pluginInfoBox->addStretch(); QHBoxLayout *configurePluginBox = new QHBoxLayout( widget ); pluginInfoBox->addLayout( configurePluginBox ); configurePlugin = new KPushButton( KIcon("configure"), "", widget ); configurePlugin->hide(); configurePluginBox->addWidget( configurePlugin ); configurePluginBox->addStretch(); connect( configurePlugin, SIGNAL(clicked()), this, SLOT(configurePluginClicked()) ); pluginsList->setCurrentRow(0); QListWidgetItem *currentItem = pluginsList->currentItem(); if( currentItem ) { currentPluginChanged( currentItem->text() ); } setInitialSize( QSize(500,300) ); KSharedConfig::Ptr conf = KGlobal::config(); KConfigGroup group = conf->group( "AboutPlugins" ); restoreDialogSize( group ); }
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; }
lv2Description::lv2Description( QWidget * _parent, lv2PluginType _type ) : QWidget( _parent ) { lv2Manager * manager = static_lv2_manager; /* switch( _type ) { case SOURCE: plugins = manager->getInstruments(); break; case TRANSFER: plugins = manager->getValidEffects(); break; case VALID: plugins = manager->getValidEffects(); break; case INVALID: plugins = manager->getInvalidEffects(); break; case SINK: plugins = manager->getAnalysisTools(); break; case OTHER: plugins = manager->getOthers(); break; default: break; } */ // Simpler : Get all the plugins, and select based on the type... l_sortable_plugin_t plugins = manager->getSortedPlugins(); QList<QString> pluginNames; for( l_sortable_plugin_t::iterator it = plugins.begin(); it != plugins.end(); it++ ) { lv2ManagerDescription * description=manager->getDescription( ( *it ).second ); if( description->type == _type && ( _type != VALID || description->inputChannels <= engine::mixer()->audioOutputContext()->audioBackend()->channels() ) ) { pluginNames.push_back( ( *it ).first ); m_pluginKeys.push_back( ( *it ).second ); } } QGroupBox * pluginsBox = new QGroupBox( tr( "Plugins" ), this ); QListWidget * pluginList = new QListWidget( pluginsBox ); pluginList->addItems( pluginNames ); connect( pluginList, SIGNAL( currentRowChanged( int ) ), SLOT( rowChanged( int ) ) ); connect( pluginList, SIGNAL( itemDoubleClicked( QListWidgetItem * ) ), SLOT( onDoubleClicked( QListWidgetItem * ) ) ); ( new QVBoxLayout( pluginsBox ) )->addWidget( pluginList ); QGroupBox * descriptionBox = new QGroupBox( tr( "Description" ), this ); QVBoxLayout * descriptionLayout = new QVBoxLayout( descriptionBox ); descriptionLayout->setSpacing( 0 ); descriptionLayout->setMargin( 0 ); m_scrollArea = new QScrollArea( descriptionBox ); descriptionLayout->addWidget( m_scrollArea ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( pluginsBox ); layout->addWidget( descriptionBox ); if( pluginList->count() > 0 ) { pluginList->setCurrentRow( 0 ); m_currentSelection = m_pluginKeys[0]; update( m_currentSelection ); } }
QWidget *ConfigDialog::centerWidget() { /* m_pagesTabWidget = new QTabWidget; for (int i = 0; i < m_pageWidgets.size(); ++i) m_pagesTabWidget->addTab(m_pageWidgets.at(i), m_pageTitles.at(i)); return m_pagesTabWidget; */ // create list QListWidget *pagesListWidget = new QListWidget; pagesListWidget->setViewMode(QListView::IconMode); pagesListWidget->setMovement(QListView::Static); pagesListWidget->setFlow(QListView::TopToBottom); pagesListWidget->setWordWrap(true); pagesListWidget->setUniformItemSizes(true); pagesListWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); // add items to list QFontMetrics fm(qApp->font()); int iconWidth = 0; for (int i = 0; i < m_pagesListWidgetItems.size(); ++i) iconWidth = qMax(iconWidth, fm.boundingRect(0, 0, 0, 0, Qt::AlignCenter, m_pagesListWidgetItems.at(i)->text()).width()); iconWidth += 20; const int iconHeight = fm.height() + 42; for (int i = 0; i < m_pagesListWidgetItems.size(); ++i) { m_pagesListWidgetItems.at(i)->setSizeHint(QSize(iconWidth, iconHeight)); pagesListWidget->addItem(m_pagesListWidgetItems.at(i)); } pagesListWidget->setFixedWidth(m_pagesListWidgetItems.at(0)->sizeHint().width() + 6); // create title QFrame *titleFrame = new QFrame(this); // titleFrame->setAutoFillBackground(true); // titleFrame->setFrameShape(QFrame::StyledPanel); titleFrame->setFrameShape(QFrame::Box); // titleFrame->setFrameShadow(QFrame::Plain); // titleFrame->setBackgroundRole(QPalette::Base); m_pagesTitleLabel = new QLabel(titleFrame); m_pagesTitleLabel->setStyleSheet("QLabel { font-weight: bold; }"); QGridLayout *titleLayout = new QGridLayout(titleFrame); titleLayout->setColumnStretch(0, 1); titleLayout->setMargin(6); titleLayout->addWidget(m_pagesTitleLabel); // add pages QStackedWidget *pagesStackedWidget = new QStackedWidget; for (int i = 0; i < m_pageWidgets.size(); ++i) pagesStackedWidget->addWidget(m_pageWidgets.at(i)); connect(pagesListWidget, SIGNAL(currentRowChanged(int)), pagesStackedWidget, SLOT(setCurrentIndex(int))); connect(pagesListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setCurrentPage(int))); pagesListWidget->setCurrentRow(0); QWidget *mainWidget = new QWidget; QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(pagesListWidget, 0, 0, 2, 1); mainLayout->addWidget(titleFrame, 0, 1); mainLayout->addWidget(pagesStackedWidget, 1, 1); mainWidget->setLayout(mainLayout); return mainWidget; }
static mpdm_t kde4_drv_form(mpdm_t a, mpdm_t ctxt) { int n; mpdm_t widget_list; QWidget *qlist[100]; mpdm_t r; KDialog *dialog = new KDialog(window); dialog->setModal(true); dialog->setButtons(KDialog::Ok | KDialog::Cancel); widget_list = mpdm_aget(a, 0); KVBox *vb = new KVBox(dialog); dialog->setMainWidget(vb); for (n = 0; n < mpdm_size(widget_list); n++) { mpdm_t w = mpdm_aget(widget_list, n); wchar_t *type; mpdm_t t; KHBox *hb = new KHBox(vb); type = mpdm_string(mpdm_hget_s(w, L"type")); if ((t = mpdm_hget_s(w, L"label")) != NULL) { QLabel *ql = new QLabel(hb); ql->setText(str_to_qstring(mpdm_gettext(t))); } t = mpdm_hget_s(w, L"value"); if (wcscmp(type, L"text") == 0) { mpdm_t h; QComboBox *ql = new QComboBox(hb); ql->setEditable(true); ql->setMinimumContentsLength(30); ql->setMaxVisibleItems(8); if (t != NULL) ql->setEditText(str_to_qstring(t)); qlist[n] = ql; if ((h = mpdm_hget_s(w, L"history")) != NULL) { int i; /* has history; fill it */ h = mp_get_history(h); for (i = mpdm_size(h) - 1; i >= 0; i--) ql->addItem(str_to_qstring(mpdm_aget(h, i))); } } else if (wcscmp(type, L"password") == 0) { QLineEdit *ql = new QLineEdit(hb); ql->setEchoMode(QLineEdit::Password); qlist[n] = ql; } else if (wcscmp(type, L"checkbox") == 0) { QCheckBox *qc = new QCheckBox(hb); if (mpdm_ival(t)) qc->setCheckState(Qt::Checked); qlist[n] = qc; } else if (wcscmp(type, L"list") == 0) { int i; QListWidget *ql = new QListWidget(hb); ql->setMinimumWidth(480); /* use a monospaced font */ ql->setFont(QFont(QString("Mono"))); mpdm_t l = mpdm_hget_s(w, L"list"); for (i = 0; i < mpdm_size(l); i++) ql->addItem(str_to_qstring(mpdm_aget(l, i))); ql->setCurrentRow(mpdm_ival(t)); qlist[n] = ql; } if (n == 0) qlist[n]->setFocus(Qt::OtherFocusReason); } n = dialog->exec(); if (!n) return NULL; r = MPDM_A(mpdm_size(widget_list)); /* fill the return values */ for (n = 0; n < mpdm_size(widget_list); n++) { mpdm_t w = mpdm_aget(widget_list, n); mpdm_t v = NULL; wchar_t *type; type = mpdm_string(mpdm_hget_s(w, L"type")); if (wcscmp(type, L"text") == 0) { mpdm_t h; QComboBox *ql = (QComboBox *) qlist[n]; v = qstring_to_str(ql->currentText()); /* if it has history, add to it */ if ((h = mpdm_hget_s(w, L"history")) != NULL && v != NULL && mpdm_cmp_s(v, L"") != 0) { h = mp_get_history(h); if (mpdm_cmp(v, mpdm_aget(h, -1)) != 0) mpdm_push(h, v); } } else if (wcscmp(type, L"password") == 0) { QLineEdit *ql = (QLineEdit *) qlist[n]; v = qstring_to_str(ql->text()); } else if (wcscmp(type, L"checkbox") == 0) { QCheckBox *qb = (QCheckBox *) qlist[n]; v = MPDM_I(qb->checkState() == Qt::Checked); } else if (wcscmp(type, L"list") == 0) { QListWidget *ql = (QListWidget *) qlist[n]; v = MPDM_I(ql->currentRow()); } mpdm_aset(r, v, n); } return r; }
NewFileDialog::NewFileDialog(QWidget *parent):QDialog(parent) { this->setupUi(this); this->createButton->setDisabled(true); connect(this->browse,SIGNAL(clicked()),SLOT(browseFile())); connect(this->filepath,SIGNAL(textChanged(QString)),SLOT(setButtonStatus())); this->filetypes->addItem(QString("Client-Side Files")); this->filetypes->addItem(QString("Server-Side Files")); this->filetypes->setCurrentRow(0); //the client side widgets); this->clientside = new QWidget(this); QHBoxLayout *clientsidelayout = new QHBoxLayout(this->clientside); this->clientside->setLayout(clientsidelayout); clientsidelayout->setMargin(0); this->clientSideFileTypes = new QListWidget(this); this->clientSideFileTypes->addItem(tr("HTML File")); this->clientSideFileTypes->addItem(tr("CSS File")); this->clientSideFileTypes->addItem(tr("Javascript File")); this->clientSideFileTypes->addItem(tr("Adobe Flex MXML File")); this->clientSideFileTypes->setCurrentRow(0); this->clientsidedetail = new QWidget(this); QStackedLayout *clientsidedetaillayout = new QStackedLayout(this->clientsidedetail); this->clientsidedetail->setLayout(clientsidedetaillayout); clientsidedetaillayout->setMargin(0); QListWidget *htmlTemplates = new QListWidget(this); htmlTemplates->addItem(tr("Plain HTML File")); htmlTemplates->setCurrentRow(0); QListWidget *cssTemplates = new QListWidget(this); cssTemplates->addItem(tr("Plain CSS File")); cssTemplates->setCurrentRow(0); QListWidget *jsTemplates = new QListWidget(this); jsTemplates->addItem(tr("Plain JS File")); jsTemplates->setCurrentRow(0); QListWidget *mxmlTemplates = new QListWidget(this); mxmlTemplates->addItem(tr("Plain MXML File")); mxmlTemplates->setCurrentRow(0); clientsidedetaillayout->addWidget(htmlTemplates); clientsidedetaillayout->addWidget(cssTemplates); clientsidedetaillayout->addWidget(jsTemplates); clientsidedetaillayout->addWidget(mxmlTemplates); connect(this->clientSideFileTypes,SIGNAL(currentRowChanged(int)),clientsidedetaillayout,SLOT(setCurrentIndex(int))); clientsidelayout->addWidget(this->clientSideFileTypes); clientsidelayout->addWidget(this->clientsidedetail); this->serverSideFileTypes = new QListWidget(this); this->serverSideFileTypes->addItem(tr("PHP File")); this->serverSideFileTypes->setCurrentRow(0); //this->serverSideFileTypes->addItem(tr("Python File")); this->detailLayout = new QStackedLayout(); detailLayout->setMargin(0); this->detail->setLayout(this->detailLayout); detailLayout->addWidget(this->clientside); detailLayout->addWidget(this->serverSideFileTypes); connect(this->filetypes,SIGNAL(currentRowChanged(int)),this->detailLayout,SLOT(setCurrentIndex(int))); }