void QDesignerSettings::setUiMode(UIMode mode) { QDesignerSettingsInterface *s = settings(); s->beginGroup(QLatin1String("UI")); s->setValue(QLatin1String("currentMode"), mode); s->endGroup(); }
PlainTextEditorDialog::PlainTextEditorDialog(QDesignerFormEditorInterface *core, QWidget *parent) : QDialog(parent), m_editor(new QPlainTextEdit), m_core(core) { setWindowTitle(tr("Edit text")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); QVBoxLayout *vlayout = new QVBoxLayout(this); vlayout->addWidget(m_editor); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal); QPushButton *ok_button = buttonBox->button(QDialogButtonBox::Ok); ok_button->setDefault(true); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); vlayout->addWidget(buttonBox); QDesignerSettingsInterface *settings = core->settingsManager(); settings->beginGroup(QLatin1String(PlainTextDialogC)); if (settings->contains(QLatin1String(Geometry))) restoreGeometry(settings->value(QLatin1String(Geometry)).toByteArray()); settings->endGroup(); }
StyleSheetEditorDialog::~StyleSheetEditorDialog() { QDesignerSettingsInterface *settings = m_core->settingsManager(); settings->beginGroup(QLatin1String(StyleSheetDialogC)); settings->setValue(QLatin1String(Geometry), saveGeometry()); settings->endGroup(); }
void QDesignerSettings::setToolWindowFont(const ToolWindowFontSettings &fontSettings) { QDesignerSettingsInterface *s = settings(); s->beginGroup(QLatin1String("UI")); s->setValue(QLatin1String("font"), fontSettings.m_font); s->setValue(QLatin1String("useFont"), fontSettings.m_useFont); s->setValue(QLatin1String("writingSystem"), fontSettings.m_writingSystem); s->endGroup(); }
void QtResourceViewPrivate::saveSettings() { if (m_settingsKey.isEmpty()) return; QDesignerSettingsInterface *settings = m_core->settingsManager(); settings->beginGroup(m_settingsKey); settings->setValue(QLatin1String(SplitterPosition), m_splitter->saveState()); settings->endGroup(); }
void QDesignerSettings::saveGeometryFor(const QWidget *w) { Q_ASSERT(w && !w->objectName().isEmpty()); QDesignerSettingsInterface *s = settings(); const bool visible = w->isVisible(); if (debugSettings) qDebug() << Q_FUNC_INFO << w << "visible=" << visible; s->beginGroup(w->objectName()); s->setValue(QLatin1String("visible"), visible); s->setValue(QLatin1String("geometry"), w->saveGeometry()); s->endGroup(); }
void WidgetBoxTreeWidget::saveExpandedState() const { QStringList closedCategories; if (const int numCategories = categoryCount()) { for (int i = 0; i < numCategories; ++i) { const QTreeWidgetItem *cat_item = topLevelItem(i); if (!isItemExpanded(cat_item)) closedCategories.append(cat_item->text(0)); } } QDesignerSettingsInterface *settings = m_core->settingsManager(); settings->beginGroup(QLatin1String(widgetBoxRootElementC)); settings->setValue(QLatin1String("Closed categories"), closedCategories); settings->setValue(QLatin1String("View mode"), m_iconMode); settings->endGroup(); }
void PropertyEditor::saveSettings() const { QDesignerSettingsInterface *settings = m_core->settingsManager(); settings->beginGroup(QLatin1String(SettingsGroupC)); #if QT_VERSION >= 0x040500 settings->setValue(QLatin1String(ViewKeyC), QVariant(m_treeAction->isChecked() ? TreeView : ButtonView)); #endif settings->setValue(QLatin1String(ColorKeyC), QVariant(m_coloring)); settings->setValue(QLatin1String(SortedKeyC), QVariant(m_sorting)); // Save last expansionState as QVariant map QVariantMap expansionState; if (!m_expansionState.empty()) { const QMap<QString, bool>::const_iterator cend = m_expansionState.constEnd(); for (QMap<QString, bool>::const_iterator it = m_expansionState.constBegin(); it != cend; ++it) expansionState.insert(it.key(), QVariant(it.value())); } settings->setValue(QLatin1String(ExpansionKeyC), expansionState); settings->endGroup(); }
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(); }
// --- StyleSheetEditorDialog StyleSheetEditorDialog::StyleSheetEditorDialog(QDesignerFormEditorInterface *core, QWidget *parent, Mode mode): QDialog(parent), m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Help)), m_editor(new StyleSheetEditor), m_validityLabel(new QLabel(tr("Valid Style Sheet"))), m_core(core), m_addResourceAction(new QAction(tr("Add Resource..."), this)), m_addGradientAction(new QAction(tr("Add Gradient..."), this)), m_addColorAction(new QAction(tr("Add Color..."), this)), m_addFontAction(new QAction(tr("Add Font..."), this)) { setWindowTitle(tr("Edit Style Sheet")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(m_buttonBox, SIGNAL(helpRequested()), this, SLOT(slotRequestHelp())); m_buttonBox->button(QDialogButtonBox::Help)->setShortcut(QKeySequence::HelpContents); connect(m_editor, SIGNAL(textChanged()), this, SLOT(validateStyleSheet())); QToolBar *toolBar = new QToolBar; QGridLayout *layout = new QGridLayout; layout->addWidget(toolBar, 0, 0, 1, 2); layout->addWidget(m_editor, 1, 0, 1, 2); layout->addWidget(m_validityLabel, 2, 0, 1, 1); layout->addWidget(m_buttonBox, 2, 1, 1, 1); setLayout(layout); m_editor->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_editor, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenuRequested(QPoint))); QSignalMapper *resourceActionMapper = new QSignalMapper(this); QSignalMapper *gradientActionMapper = new QSignalMapper(this); QSignalMapper *colorActionMapper = new QSignalMapper(this); resourceActionMapper->setMapping(m_addResourceAction, QString()); gradientActionMapper->setMapping(m_addGradientAction, QString()); colorActionMapper->setMapping(m_addColorAction, QString()); connect(m_addResourceAction, SIGNAL(triggered()), resourceActionMapper, SLOT(map())); connect(m_addGradientAction, SIGNAL(triggered()), gradientActionMapper, SLOT(map())); connect(m_addColorAction, SIGNAL(triggered()), colorActionMapper, SLOT(map())); connect(m_addFontAction, SIGNAL(triggered()), this, SLOT(slotAddFont())); m_addResourceAction->setEnabled(mode == ModePerForm); const char * const resourceProperties[] = { "background-image", "border-image", "image", 0 }; const char * const colorProperties[] = { "color", "background-color", "alternate-background-color", "border-color", "border-top-color", "border-right-color", "border-bottom-color", "border-left-color", "gridline-color", "selection-color", "selection-background-color", 0 }; QMenu *resourceActionMenu = new QMenu(this); QMenu *gradientActionMenu = new QMenu(this); QMenu *colorActionMenu = new QMenu(this); for (int resourceProperty = 0; resourceProperties[resourceProperty]; ++resourceProperty) { QAction *action = resourceActionMenu->addAction(QLatin1String(resourceProperties[resourceProperty])); connect(action, SIGNAL(triggered()), resourceActionMapper, SLOT(map())); resourceActionMapper->setMapping(action, QLatin1String(resourceProperties[resourceProperty])); } for (int colorProperty = 0; colorProperties[colorProperty]; ++colorProperty) { QAction *gradientAction = gradientActionMenu->addAction(QLatin1String(colorProperties[colorProperty])); QAction *colorAction = colorActionMenu->addAction(QLatin1String(colorProperties[colorProperty])); connect(gradientAction, SIGNAL(triggered()), gradientActionMapper, SLOT(map())); connect(colorAction, SIGNAL(triggered()), colorActionMapper, SLOT(map())); gradientActionMapper->setMapping(gradientAction, QLatin1String(colorProperties[colorProperty])); colorActionMapper->setMapping(colorAction, QLatin1String(colorProperties[colorProperty])); } connect(resourceActionMapper, SIGNAL(mapped(QString)), this, SLOT(slotAddResource(QString))); connect(gradientActionMapper, SIGNAL(mapped(QString)), this, SLOT(slotAddGradient(QString))); connect(colorActionMapper, SIGNAL(mapped(QString)), this, SLOT(slotAddColor(QString))); m_addResourceAction->setMenu(resourceActionMenu); m_addGradientAction->setMenu(gradientActionMenu); m_addColorAction->setMenu(colorActionMenu); toolBar->addAction(m_addResourceAction); toolBar->addAction(m_addGradientAction); toolBar->addAction(m_addColorAction); toolBar->addAction(m_addFontAction); m_editor->setFocus(); QDesignerSettingsInterface *settings = core->settingsManager(); settings->beginGroup(QLatin1String(StyleSheetDialogC)); if (settings->contains(QLatin1String(Geometry))) restoreGeometry(settings->value(QLatin1String(Geometry)).toByteArray()); settings->endGroup(); }