LayoutsConfigWidget::LayoutsConfigWidget (QWidget *parent) : QWidget (parent) , AvailableModel_ (new QStandardItemModel (this)) , EnabledModel_ (new QStandardItemModel (this)) { QStringList availHeaders { tr ("Code"), tr ("Description") }; AvailableModel_->setHorizontalHeaderLabels (availHeaders); EnabledModel_->setHorizontalHeaderLabels (availHeaders << tr ("Variant")); FillModels (); Ui_.setupUi (this); Ui_.AvailableView_->setModel (AvailableModel_); Ui_.EnabledView_->setModel (EnabledModel_); Ui_.EnabledView_->setItemDelegate (new EnabledItemDelegate (Ui_.EnabledView_)); connect (Ui_.AvailableView_->selectionModel (), SIGNAL (currentRowChanged (QModelIndex, QModelIndex)), this, SLOT (updateActionsState ())); connect (Ui_.EnabledView_->selectionModel (), SIGNAL (currentRowChanged (QModelIndex, QModelIndex)), this, SLOT (updateActionsState ())); updateActionsState (); }
void SCgView::setScene(SCgScene* scene) { QGraphicsView::setScene(scene); connect(scene, SIGNAL(sceneRectChanged(const QRectF&)), this, SLOT(updateSceneRect(const QRectF&)) ); connect(scene, SIGNAL(selectionChanged()), this, SLOT(updateActionsState()) ); connect(scene, SIGNAL(editModeChanged(int)), this, SLOT(editModeChanged(int))); updateActionsState(); }
void PlaylistComponent::cancelChanges(const bool noChanges) { treeWidget_.setEditMode(false, ! noChanges); temporaryTree_.reset(); updateActionsState(); emit editModeChanged(); }
void PlaylistComponent::enterEditMode() { temporaryTree_.reset(new ItemTree::Tree(itemTree_)); treeWidget_.setEditMode(true, false); updateActionsState(); emit editModeChanged(); }
void MainWindow::newTraceFile(const QString &fileName) { qDebug()<< "Loading : " <<fileName; m_progressBar->setValue(0); m_trace->setFileName(fileName); if (fileName.isEmpty()) { updateActionsState(false); setWindowTitle(tr("QApiTrace")); } else { updateActionsState(true); QFileInfo info(fileName); setWindowTitle( tr("QApiTrace - %1").arg(info.fileName())); } }
void MainWindow::onActivated ( const QModelIndex & proxyIndex ) { QModelIndex index = mapIndex(proxyIndex); QString name = _objectModel->data(index).toString(); if (_objectModel->enter(index.row())) _history.push_back(qMakePair(name, _objectModel->parentObjectId())); updateActionsState(); }
void MainWindow::down() { QModelIndex index = mapIndex(_ui->listView->currentIndex()); QString name = _objectModel->data(index).toString(); if (_objectModel->enter(index.row())) _history.push_back(qMakePair(name, _objectModel->parentObjectId())); updateActionsState(); }
void MainWindow::onStorageChanged(int idx) { if (!_storageModel) return; mtp::StorageId storageId = _storageModel->getStorageId(idx); qDebug() << "switching to storage id " << storageId.Id; _objectModel->setStorageId(storageId); _history.clear(); updateActionsState(); }
void MainWindow::replayError(const QString &message) { updateActionsState(true); m_stateEvent = 0; m_nonDefaultsLookupEvent = 0; m_progressBar->hide(); statusBar()->showMessage( tr("Replaying unsuccessful."), 2000); QMessageBox::warning( this, tr("Replay Failed"), message); }
void MainWindow::replayFinished(const QString &message) { updateActionsState(true); m_progressBar->hide(); statusBar()->showMessage(message, 2000); m_stateEvent = 0; m_ui.actionShowErrorsDock->setEnabled(m_trace->hasErrors()); m_ui.errorsDock->setVisible(m_trace->hasErrors()); if (!m_trace->hasErrors()) { m_ui.errorsTreeWidget->clear(); } }
MainWindow::MainWindow() : QMainWindow(), m_api(trace::API_GL), m_initalCallNum(-1), m_selectedEvent(0), m_stateEvent(0), m_nonDefaultsLookupEvent(0) { m_ui.setupUi(this); updateActionsState(false); initObjects(); initConnections(); }
void MainWindow::back() { if (_history.empty()) return; mtp::ObjectId oldParent = _objectModel->parentObjectId(); _history.pop_back(); mtp::ObjectId oid = _history.empty()? mtp::Session::Root: _history.back().second; _objectModel->setParent(oid); QModelIndex prevIndex = _objectModel->findObject(oldParent); if (prevIndex.isValid()) _ui->listView->setCurrentIndex(_proxyModel->mapFromSource(prevIndex)); updateActionsState(); }
void PropertyEditor::slotSorting(bool sort) { if (sort == m_sorting) return; storeExpansionState(); m_sorting = sort; collapseAll(); { UpdateBlocker ub(this); clearView(); m_treeBrowser->setRootIsDecorated(sort); fillView(); applyExpansionState(); applyFilter(); } updateActionsState(); }
void PropertyEditor::slotViewTriggered(QAction *action) { storeExpansionState(); collapseAll(); { UpdateBlocker ub(this); clearView(); int idx = 0; if (action == m_treeAction) { m_currentBrowser = m_treeBrowser; idx = m_treeIndex; } else if (action == m_buttonAction) { m_currentBrowser = m_buttonBrowser; idx = m_buttonIndex; } fillView(); m_stackedWidget->setCurrentIndex(idx); applyExpansionState(); applyFilter(); } updateActionsState(); }
void MainWindow::replayStop() { m_retracer->quit(); updateActionsState(true, true); }
PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *parent, Qt::WindowFlags flags) : QDesignerPropertyEditor(parent, flags), m_core(core), m_propertySheet(0), m_currentBrowser(0), m_treeBrowser(0), m_propertyManager(new DesignerPropertyManager(m_core, this)), m_dynamicGroup(0), m_updatingBrowser(false), m_stackedWidget(new QStackedWidget), m_filterWidget(new FilterWidget(0, FilterWidget::LayoutAlignNone)), m_buttonIndex(-1), m_treeIndex(-1), m_addDynamicAction(new QAction(createIconSet(QLatin1String("plus.png")), tr("Add Dynamic Property..."), this)), m_removeDynamicAction(new QAction(createIconSet(QLatin1String("minus.png")), tr("Remove Dynamic Property"), this)), m_sortingAction(new QAction(createIconSet(QLatin1String("sort.png")), tr("Sorting"), this)), m_coloringAction(new QAction(createIconSet(QLatin1String("color.png")), tr("Color Groups"), this)), m_treeAction(new QAction(tr("Tree View"), this)), m_buttonAction(new QAction(tr("Drop Down Button View"), this)), m_classLabel(new QLabel), m_sorting(false), m_coloring(false), m_brightness(false) { QVector<QColor> colors; colors.reserve(6); colors.push_back(QColor(255, 230, 191)); colors.push_back(QColor(255, 255, 191)); colors.push_back(QColor(191, 255, 191)); colors.push_back(QColor(199, 255, 255)); colors.push_back(QColor(234, 191, 255)); colors.push_back(QColor(255, 191, 239)); m_colors.reserve(colors.count()); for (int i = 0; i < colors.count(); i++) { QColor c = colors.at(i); m_colors.push_back(qMakePair(c, c.darker(150))); } QColor dynamicColor(191, 207, 255); QColor layoutColor(255, 191, 191); m_dynamicColor = qMakePair(dynamicColor, dynamicColor.darker(150)); m_layoutColor = qMakePair(layoutColor, layoutColor.darker(150)); updateForegroundBrightness(); QActionGroup *actionGroup = new QActionGroup(this); m_treeAction->setCheckable(true); m_treeAction->setIcon(createIconSet(QLatin1String("widgets/listview.png"))); m_buttonAction->setCheckable(true); m_buttonAction->setIcon(createIconSet(QLatin1String("dropdownbutton.png"))); actionGroup->addAction(m_treeAction); actionGroup->addAction(m_buttonAction); connect(actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotViewTriggered(QAction*))); QWidget *classWidget = new QWidget; QHBoxLayout *l = new QHBoxLayout(classWidget); l->setContentsMargins(5, 0, 5, 0); l->addWidget(m_classLabel); // Add actions QActionGroup *addDynamicActionGroup = new QActionGroup(this); connect(addDynamicActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotAddDynamicProperty(QAction*))); QMenu *addDynamicActionMenu = new QMenu(this); m_addDynamicAction->setMenu(addDynamicActionMenu); m_addDynamicAction->setEnabled(false); QAction *addDynamicAction = addDynamicActionGroup->addAction(tr("String...")); addDynamicAction->setData(static_cast<int>(QVariant::String)); addDynamicActionMenu->addAction(addDynamicAction); addDynamicAction = addDynamicActionGroup->addAction(tr("Bool...")); addDynamicAction->setData(static_cast<int>(QVariant::Bool)); addDynamicActionMenu->addAction(addDynamicAction); addDynamicActionMenu->addSeparator(); addDynamicAction = addDynamicActionGroup->addAction(tr("Other...")); addDynamicAction->setData(static_cast<int>(QVariant::Invalid)); addDynamicActionMenu->addAction(addDynamicAction); // remove m_removeDynamicAction->setEnabled(false); connect(m_removeDynamicAction, SIGNAL(triggered()), this, SLOT(slotRemoveDynamicProperty())); // Configure QAction *configureAction = new QAction(tr("Configure Property Editor"), this); configureAction->setIcon(createIconSet(QLatin1String("configure.png"))); QMenu *configureMenu = new QMenu(this); configureAction->setMenu(configureMenu); m_sortingAction->setCheckable(true); connect(m_sortingAction, SIGNAL(toggled(bool)), this, SLOT(slotSorting(bool))); m_coloringAction->setCheckable(true); connect(m_coloringAction, SIGNAL(toggled(bool)), this, SLOT(slotColoring(bool))); configureMenu->addAction(m_sortingAction); configureMenu->addAction(m_coloringAction); #if QT_VERSION >= 0x040600 configureMenu->addSeparator(); configureMenu->addAction(m_treeAction); configureMenu->addAction(m_buttonAction); #endif // Assemble toolbar QToolBar *toolBar = new QToolBar; toolBar->addWidget(classWidget); toolBar->addWidget(m_filterWidget); toolBar->addWidget(createDropDownButton(m_addDynamicAction)); toolBar->addAction(m_removeDynamicAction); toolBar->addWidget(createDropDownButton(configureAction)); // Views QScrollArea *buttonScroll = new QScrollArea(m_stackedWidget); m_buttonBrowser = new QtButtonPropertyBrowser(buttonScroll); buttonScroll->setWidgetResizable(true); buttonScroll->setWidget(m_buttonBrowser); m_buttonIndex = m_stackedWidget->addWidget(buttonScroll); connect(m_buttonBrowser, SIGNAL(currentItemChanged(QtBrowserItem*)), this, SLOT(slotCurrentItemChanged(QtBrowserItem*))); m_treeBrowser = new QtTreePropertyBrowser(m_stackedWidget); m_treeBrowser->setRootIsDecorated(false); m_treeBrowser->setPropertiesWithoutValueMarked(true); m_treeBrowser->setResizeMode(QtTreePropertyBrowser::Interactive); m_treeIndex = m_stackedWidget->addWidget(m_treeBrowser); connect(m_treeBrowser, SIGNAL(currentItemChanged(QtBrowserItem*)), this, SLOT(slotCurrentItemChanged(QtBrowserItem*))); connect(m_filterWidget, SIGNAL(filterChanged(QString)), this, SLOT(setFilter(QString))); QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(toolBar); layout->addWidget(m_stackedWidget); layout->setMargin(0); layout->setSpacing(0); m_treeFactory = new DesignerEditorFactory(m_core, this); m_treeFactory->setSpacing(0); m_groupFactory = new DesignerEditorFactory(m_core, this); QtVariantPropertyManager *variantManager = m_propertyManager; m_buttonBrowser->setFactoryForManager(variantManager, m_groupFactory); m_treeBrowser->setFactoryForManager(variantManager, m_treeFactory); m_stackedWidget->setCurrentIndex(m_treeIndex); m_currentBrowser = m_treeBrowser; m_treeAction->setChecked(true); connect(m_groupFactory, SIGNAL(resetProperty(QtProperty*)), this, SLOT(slotResetProperty(QtProperty*))); connect(m_treeFactory, SIGNAL(resetProperty(QtProperty*)), this, SLOT(slotResetProperty(QtProperty*))); connect(variantManager, SIGNAL(valueChanged(QtProperty*,QVariant,bool)), this, SLOT(slotValueChanged(QtProperty*,QVariant,bool))); // retrieve initial settings QDesignerSettingsInterface *settings = m_core->settingsManager(); settings->beginGroup(QLatin1String(SettingsGroupC)); #if QT_VERSION >= 0x040500 const SettingsView view = settings->value(QLatin1String(ViewKeyC), TreeView).toInt() == TreeView ? TreeView : ButtonView; #endif // Coloring not available unless treeview and not sorted m_sorting = settings->value(QLatin1String(SortedKeyC), false).toBool(); m_coloring = settings->value(QLatin1String(ColorKeyC), true).toBool(); const QVariantMap expansionState = settings->value(QLatin1String(ExpansionKeyC), QVariantMap()).toMap(); settings->endGroup(); // Apply settings m_sortingAction->setChecked(m_sorting); m_coloringAction->setChecked(m_coloring); #if QT_VERSION >= 0x040500 switch (view) { case TreeView: m_currentBrowser = m_treeBrowser; m_stackedWidget->setCurrentIndex(m_treeIndex); m_treeAction->setChecked(true); break; case ButtonView: m_currentBrowser = m_buttonBrowser; m_stackedWidget->setCurrentIndex(m_buttonIndex); m_buttonAction->setChecked(true); break; } #endif // Restore expansionState from QVariant map if (!expansionState.empty()) { const QVariantMap::const_iterator cend = expansionState.constEnd(); for (QVariantMap::const_iterator it = expansionState.constBegin(); it != cend; ++it) m_expansionState.insert(it.key(), it.value().toBool()); } updateActionsState(); }
PlaylistComponent::PlaylistComponent( QMainWindow & mainWindow, const Actions & actions, QtUtilities::Widgets::InputController & inputController, const Preferences & preferences, CommonTypes::PlayItems playItems, const std::string & preferencesDir, bool & cancelled) : actions_(actions), inputController_(inputController), addingPatterns_(preferences.addingPatterns), addingPolicy_(preferences.addingPolicy), playItems_(std::move(playItems)), itemsFilename_(preferencesDir + "items"), qItemsFilename_(QtUtilities::toQString(itemsFilename_)), qBackupItemsFilename_(qItemsFilename_ + ".backup"), treeAutoCleanup_(preferences.treeAutoCleanup), treeWidget_(itemTree_, temporaryTree_, preferences.customActions, playItems_) { # ifdef DEBUG_VENTUROUS_PLAYLIST_COMPONENT std::cout << "itemsFilename_ = " << itemsFilename_ << std::endl; # endif treeWidget_.setAutoUnfoldedLevels(preferences.treeAutoUnfoldedLevels); if (QFileInfo(qItemsFilename_).isFile()) { if (QtUtilities::Widgets::HandleErrors { [&] { const std::string errorMessage = itemTree_.load(itemsFilename_); return errorMessage.empty() ? QString() : loadingErrorFullMessage(QtUtilities::toQString(errorMessage)); } } .blocking(inputController_, loadingFailed(), & cancelled)) { itemTree_.nodesChanged(); treeWidget_.updateTree(); } else if (cancelled) return; else { itemTree_.topLevelNodes().clear(); itemTree_.nodesChanged(); } } else cancelled = false; mainWindow.setCentralWidget(& treeWidget_); connect(actions.playback.nextRandom, SIGNAL(triggered(bool)), SLOT(playbackNextRandom())); connect(actions.playback.playAll, SIGNAL(triggered(bool)), SLOT(playbackPlayAll())); { const Actions::Playlist & p = actions.playlist; connect(p.editMode, SIGNAL(triggered(bool)), SLOT(onEditModeStateChanged())); connect(p.applyChanges, SIGNAL(triggered(bool)), SLOT(applyChanges())); connect(p.cancelChanges, SIGNAL(triggered(bool)), SLOT(cancelChanges())); connect(p.addFiles, SIGNAL(triggered(bool)), SLOT(onAddFiles())); connect(p.addDirectory, SIGNAL(triggered(bool)), SLOT(onAddDirectory())); connect(p.cleanUp, SIGNAL(triggered(bool)), SLOT(onCleanUp())); connect(p.clear, SIGNAL(triggered(bool)), SLOT(onClear())); connect(p.restorePrevious, SIGNAL(triggered(bool)), SLOT(onRestorePrevious())); connect(p.load, SIGNAL(triggered(bool)), SLOT(onLoad())); connect(p.saveAs, SIGNAL(triggered(bool)), SLOT(onSaveAs())); } updateActionsState(); }