// ----------------- CodeDialog CodeDialog::CodeDialog(QWidget *parent) : QDialog(parent), m_impl(new CodeDialogPrivate) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); QVBoxLayout *vBoxLayout = new QVBoxLayout; // Edit tool bar QToolBar *toolBar = new QToolBar; const QIcon saveIcon = createIconSet(QLatin1String("filesave.png")); QAction *saveAction = toolBar->addAction(saveIcon, tr("Save...")); connect(saveAction, SIGNAL(triggered()), this, SLOT(slotSaveAs())); const QIcon copyIcon = createIconSet(QLatin1String("editcopy.png")); QAction *copyAction = toolBar->addAction(copyIcon, tr("Copy All")); connect(copyAction, SIGNAL(triggered()), this, SLOT(copyAll())); QAction *findAction = toolBar->addAction( TextEditFindWidget::findIconSet(), tr("&Find in Text..."), m_impl->m_findWidget, SLOT(activate())); findAction->setShortcut(QKeySequence::Find); vBoxLayout->addWidget(toolBar); // Edit m_impl->m_textEdit->setReadOnly(true); m_impl->m_textEdit->setMinimumSize(QSize( m_impl->m_findWidget->minimumSize().width(), 500)); vBoxLayout->addWidget(m_impl->m_textEdit); // Find m_impl->m_findWidget->setTextEdit(m_impl->m_textEdit); vBoxLayout->addWidget(m_impl->m_findWidget); // Button box QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); // Disable auto default QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close); closeButton->setAutoDefault(false); vBoxLayout->addWidget(buttonBox); setLayout(vBoxLayout); }
// -------------------- NewActionDialog NewActionDialog::NewActionDialog(ActionEditor *parent) : QDialog(parent, Qt::Sheet), m_ui(new Ui::NewActionDialog), m_actionEditor(parent) { m_ui->setupUi(this); m_ui->tooltipEditor->setTextPropertyValidationMode(ValidationRichText); connect(m_ui->toolTipToolButton, SIGNAL(clicked()), this, SLOT(slotEditToolTip())); m_ui->keysequenceResetToolButton->setIcon(createIconSet(QStringLiteral("resetproperty.png"))); connect(m_ui->keysequenceResetToolButton, SIGNAL(clicked()), this, SLOT(slotResetKeySequence())); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); m_ui->editActionText->setFocus(); m_auto_update_object_name = true; updateButtons(); QDesignerFormWindowInterface *form = parent->formWindow(); m_ui->iconSelector->setFormEditor(form->core()); FormWindowBase *formBase = qobject_cast<FormWindowBase *>(form); if (formBase) { m_ui->iconSelector->setPixmapCache(formBase->pixmapCache()); m_ui->iconSelector->setIconCache(formBase->iconCache()); } }
TreeWidgetEditor::TreeWidgetEditor(QDesignerFormWindowInterface *form, QWidget *parent) : AbstractItemEditor(form, parent), m_updatingBrowser(false) { m_columnEditor = new ItemListEditor(form, this); m_columnEditor->setObjectName(QLatin1String("columnEditor")); m_columnEditor->setNewItemText(tr("New Column")); ui.setupUi(this); injectPropertyBrowser(ui.itemsTab, ui.widget); connect(ui.showPropertiesButton, SIGNAL(clicked()), this, SLOT(togglePropertyBrowser())); togglePropertyBrowser(); ui.tabWidget->insertTab(0, m_columnEditor, tr("&Columns")); ui.tabWidget->setCurrentIndex(0); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); ui.newItemButton->setIcon(createIconSet(QString::fromUtf8("plus.png"))); ui.newSubItemButton->setIcon(createIconSet(QString::fromUtf8("downplus.png"))); ui.deleteItemButton->setIcon(createIconSet(QString::fromUtf8("minus.png"))); ui.moveItemUpButton->setIcon(createIconSet(QString::fromUtf8("up.png"))); ui.moveItemDownButton->setIcon(createIconSet(QString::fromUtf8("down.png"))); ui.moveItemRightButton->setIcon(createIconSet(QString::fromUtf8("leveldown.png"))); ui.moveItemLeftButton->setIcon(createIconSet(QString::fromUtf8("levelup.png"))); ui.treeWidget->header()->setMovable(false); connect(iconCache(), SIGNAL(reloaded()), this, SLOT(cacheReloaded())); }
OrderDialog::OrderDialog(QWidget *parent) : QDialog(parent), m_ui(new Ui::OrderDialog), m_format(PageOrderFormat) { m_ui->setupUi(this); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); m_ui->upButton->setIcon(createIconSet(QString::fromUtf8("up.png"))); m_ui->downButton->setIcon(createIconSet(QString::fromUtf8("down.png"))); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), this, SLOT(slotReset())); // Catch the remove operation of a DnD operation in QAbstractItemView::InternalMove mode to enable buttons // Selection mode is 'contiguous' to enable DnD of groups connect(m_ui->pageList->model(), SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(slotEnableButtonsAfterDnD())); m_ui->upButton->setEnabled(false); m_ui->downButton->setEnabled(false); }
QIcon WidgetBoxTreeWidget::iconForWidget(QString iconName) const { if (iconName.isEmpty()) iconName = QLatin1String(qtLogoC); if (iconName.startsWith(QLatin1String(iconPrefixC))) { const IconCache::const_iterator it = m_pluginIcons.constFind(iconName); if (it != m_pluginIcons.constEnd()) return it.value(); } return createIconSet(iconName); }
TreeWidgetEditor::TreeWidgetEditor(QDesignerFormWindowInterface *form, QDialog *dialog) : AbstractItemEditor(form, 0), m_updatingBrowser(false) { m_columnEditor = new ItemListEditor(form, this); m_columnEditor->setObjectName(QStringLiteral("columnEditor")); m_columnEditor->setNewItemText(tr("New Column")); ui.setupUi(dialog); injectPropertyBrowser(ui.itemsTab, ui.widget); connect(ui.showPropertiesButton, SIGNAL(clicked()), this, SLOT(togglePropertyBrowser())); setPropertyBrowserVisible(false); ui.tabWidget->insertTab(0, m_columnEditor, tr("&Columns")); ui.tabWidget->setCurrentIndex(0); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); ui.newItemButton->setIcon(createIconSet(QString::fromUtf8("plus.png"))); ui.newSubItemButton->setIcon(createIconSet(QString::fromUtf8("downplus.png"))); ui.deleteItemButton->setIcon(createIconSet(QString::fromUtf8("minus.png"))); ui.moveItemUpButton->setIcon(createIconSet(QString::fromUtf8("up.png"))); ui.moveItemDownButton->setIcon(createIconSet(QString::fromUtf8("down.png"))); ui.moveItemRightButton->setIcon(createIconSet(QString::fromUtf8("leveldown.png"))); ui.moveItemLeftButton->setIcon(createIconSet(QString::fromUtf8("levelup.png"))); ui.treeWidget->header()->setSectionsMovable(false); connect(ui.newItemButton, SIGNAL(clicked()), this, SLOT(on_newItemButton_clicked())); connect(ui.newSubItemButton, SIGNAL(clicked()), this, SLOT(on_newSubItemButton_clicked())); connect(ui.moveItemUpButton, SIGNAL(clicked()), this, SLOT(on_moveItemUpButton_clicked())); connect(ui.moveItemDownButton, SIGNAL(clicked()), this, SLOT(on_moveItemDownButton_clicked())); connect(ui.moveItemRightButton, SIGNAL(clicked()), this, SLOT(on_moveItemRightButton_clicked())); connect(ui.moveItemLeftButton, SIGNAL(clicked()), this, SLOT(on_moveItemLeftButton_clicked())); connect(ui.deleteItemButton, SIGNAL(clicked()), this, SLOT(on_deleteItemButton_clicked())); connect(ui.treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(on_treeWidget_currentItemChanged())); connect(ui.treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(on_treeWidget_itemChanged(QTreeWidgetItem*,int))); connect(m_columnEditor, SIGNAL(indexChanged(int)), this, SLOT(on_columnEditor_indexChanged(int))); connect(m_columnEditor, SIGNAL(itemChanged(int,int,QVariant)), this, SLOT(on_columnEditor_itemChanged(int,int,QVariant))); connect(m_columnEditor, SIGNAL(itemInserted(int)), this, SLOT(on_columnEditor_itemInserted(int))); connect(m_columnEditor, SIGNAL(itemDeleted(int)), this, SLOT(on_columnEditor_itemDeleted(int))); connect(m_columnEditor, SIGNAL(itemMovedUp(int)), this, SLOT(on_columnEditor_itemMovedUp(int))); connect(m_columnEditor, SIGNAL(itemMovedDown(int)), this, SLOT(on_columnEditor_itemMovedDown(int))); connect(iconCache(), SIGNAL(reloaded()), this, SLOT(cacheReloaded())); }
void Help::setupGoActions() { QPopupMenu* menu = new QPopupMenu( this ); menuBar()->insertItem( tr( "&Go" ), menu ); QAction *a; a = new QAction( tr( "Home" ), createIconSet( "home.xpm" ), ( "&Home" ), ALT + Key_Home, this ); a->addTo( menu ); a->addTo( toolbar ); connect( a, SIGNAL( activated() ), this, SLOT( goHome() ) ); a = new QAction( tr( "Qt Reference Documentation" ), createIconSet( "customwidget.xpm" ), ( "&Qt Reference Documentation" ), ALT + SHIFT + Key_Home, this ); a->addTo( menu ); a->addTo( toolbar ); connect( a, SIGNAL( activated() ), this, SLOT( goQt() ) ); menu->insertSeparator(); a = new QAction( tr( "Backward" ), createIconSet( "left.xpm" ), ( "&Backward" ), ALT + Key_Left, this ); a->addTo( menu ); a->addTo( toolbar ); connect( a, SIGNAL( activated() ), browser, SLOT( backward() ) ); connect( browser, SIGNAL( backwardAvailable( bool ) ), a, SLOT( setEnabled( bool ) ) ); a = new QAction( tr( "Forward" ), createIconSet( "right.xpm" ), tr( "&Forward" ), ALT + Key_Right, this ); a->addTo( menu ); a->addTo( toolbar ); connect( a, SIGNAL( activated() ), browser, SLOT( forward() ) ); connect( browser, SIGNAL( forwardAvailable( bool ) ), a, SLOT( setEnabled( bool ) ) ); menu->insertSeparator(); a = new QAction( tr( "Topics/Index" ), createIconSet( "help.xpm" ), tr( "&Topics/Index..." ), CTRL + Key_T, this ); a->addTo( menu ); a->addTo( toolbar ); connect( a, SIGNAL( activated() ), this, SLOT( goTopics() ) ); }
void Help::setupFileActions() { QPopupMenu* menu = new QPopupMenu( this ); menuBar()->insertItem( tr( "&File" ), menu ); QAction *a; a = new QAction( tr( "Print" ), createIconSet( "print.xpm" ), tr( "&Print" ), CTRL + Key_P, this ); a->addTo( menu ); a->addTo( toolbar ); connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) ); a = new QAction( tr( "Close" ), tr( "&Close" ), 0, this ); a->addTo( menu ); connect( a, SIGNAL( activated() ), this, SLOT( close() ) ); }
// ------------------- FilterWidget FilterWidget::FilterWidget(QWidget *parent, LayoutMode lm) : QWidget(parent), m_editor(new HintLineEdit(this)), m_button(new IconButton(m_editor)), m_buttonwidth(0) { m_editor->setPlaceholderText(tr("Filter")); // Let the style determine minimum height for our widget QSize size(ICONBUTTON_SIZE + 6, ICONBUTTON_SIZE + 2); // Note KDE does not reserve space for the highlight color if (style()->inherits("OxygenStyle")) { size = size.expandedTo(QSize(24, 0)); } // Make room for clear icon QMargins margins = m_editor->textMargins(); if (layoutDirection() == Qt::LeftToRight) margins.setRight(size.width()); else margins.setLeft(size.width()); m_editor->setTextMargins(margins); QHBoxLayout *l = new QHBoxLayout(this); l->setMargin(0); l->setSpacing(0); if (lm == LayoutAlignRight) l->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum)); l->addWidget(m_editor); // KDE has custom icons for this. Notice that icon namings are counter intuitive // If these icons are not avaiable we use the freedesktop standard name before // falling back to a bundled resource QIcon icon = QIcon::fromTheme(layoutDirection() == Qt::LeftToRight ? QLatin1String("edit-clear-locationbar-rtl") : QLatin1String("edit-clear-locationbar-ltr"), QIcon::fromTheme("edit-clear", createIconSet(QLatin1String("cleartext.png")))); m_button->setIcon(icon); m_button->setToolTip(tr("Clear text")); connect(m_button, SIGNAL(clicked()), this, SLOT(reset())); connect(m_editor, SIGNAL(textChanged(QString)), this, SLOT(checkButton(QString))); connect(m_editor, SIGNAL(textEdited(QString)), this, SIGNAL(filterChanged(QString))); }
IconSetPtr IconManager::getIconSet(const std::string& IconSetName) { IconSetMap::const_iterator SearchItor(_IconSetMap.find(IconSetName)); if(SearchItor == _IconSetMap.end()) { //Attempt to create it IconSetPtr NewSet = createIconSet(IconSetName); if(NewSet != NULL) { _IconSetMap[IconSetName] = NewSet; } return NewSet; } else { return SearchItor->second; } }
RoleEditor::RoleEditor(QWidget *parent) : QWidget(parent), m_label(new QLabel(this)), m_edited(false) { QHBoxLayout *layout = new QHBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); layout->addWidget(m_label); m_label->setAutoFillBackground(true); m_label->setIndent(3); // ### hardcode it should have the same value of textMargin in QItemDelegate setFocusProxy(m_label); QToolButton *button = new QToolButton(this); button->setToolButtonStyle(Qt::ToolButtonIconOnly); button->setIcon(createIconSet(QLatin1String("resetproperty.png"))); button->setIconSize(QSize(8,8)); button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding)); layout->addWidget(button); connect(button, SIGNAL(clicked()), this, SLOT(emitResetProperty())); }
// ------------------- FilterWidget FilterWidget::FilterWidget(QWidget *parent, LayoutMode lm) : QWidget(parent), m_button(new QPushButton), m_editor(new HintLineEdit) { m_editor->setHintText(tr("<Filter>")); QHBoxLayout *l = new QHBoxLayout(this); l->setMargin(0); l->setSpacing(0); if (lm == LayoutAlignRight) l->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum)); l->addWidget(m_editor); m_button->setIcon(createIconSet(QLatin1String("resetproperty.png"))); m_button->setIconSize(QSize(8, 8)); m_button->setFlat(true); l->addWidget(m_button); connect(m_button, SIGNAL(clicked()), this, SLOT(reset())); connect(m_editor, SIGNAL(textChanged(QString)), this, SLOT(checkButton(QString))); connect(m_editor, SIGNAL(textEdited(QString)), this, SIGNAL(filterChanged(QString))); }
TreeWidgetEditor::TreeWidgetEditor(QDesignerFormWindowInterface *form, QWidget *parent) : QDialog(parent), m_updating(false) { ui.setupUi(this); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); m_form = qobject_cast<FormWindowBase *>(form); ui.itemIconSelector->setFormEditor(form->core()); ui.itemIconSelector->setEnabled(false); ui.itemIconSelector->setPixmapCache(m_form->pixmapCache()); ui.itemIconSelector->setIconCache(m_form->iconCache()); ui.columnIconSelector->setFormEditor(form->core()); ui.columnIconSelector->setEnabled(false); ui.columnIconSelector->setPixmapCache(m_form->pixmapCache()); ui.columnIconSelector->setIconCache(m_form->iconCache()); QIcon upIcon = createIconSet(QString::fromUtf8("up.png")); QIcon downIcon = createIconSet(QString::fromUtf8("down.png")); QIcon backIcon = createIconSet(QString::fromUtf8("back.png")); QIcon forwardIcon = createIconSet(QString::fromUtf8("forward.png")); QIcon minusIcon = createIconSet(QString::fromUtf8("minus.png")); QIcon plusIcon = createIconSet(QString::fromUtf8("plus.png")); ui.newColumnButton->setIcon(plusIcon); ui.deleteColumnButton->setIcon(minusIcon); ui.moveColumnUpButton->setIcon(upIcon); ui.moveColumnDownButton->setIcon(downIcon); ui.newItemButton->setIcon(plusIcon); ui.deleteItemButton->setIcon(minusIcon); ui.moveItemUpButton->setIcon(upIcon); ui.moveItemDownButton->setIcon(downIcon); ui.moveItemRightButton->setIcon(forwardIcon); ui.moveItemLeftButton->setIcon(backIcon); ui.treeWidget->header()->setMovable(false); connect(m_form->iconCache(), SIGNAL(reloaded()), this, SLOT(cacheReloaded())); }
void FormWindowManager::setupActions() { #ifndef QT_NO_CLIPBOARD m_actionCut = new QAction(createIconSet(QStringLiteral("editcut.png")), tr("Cu&t"), this); m_actionCut->setObjectName(QStringLiteral("__qt_cut_action")); m_actionCut->setShortcut(QKeySequence::Cut); m_actionCut->setStatusTip(tr("Cuts the selected widgets and puts them on the clipboard")); m_actionCut->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Cut"))); connect(m_actionCut, SIGNAL(triggered()), this, SLOT(slotActionCutActivated())); m_actionCut->setEnabled(false); m_actionCopy = new QAction(createIconSet(QStringLiteral("editcopy.png")), tr("&Copy"), this); m_actionCopy->setObjectName(QStringLiteral("__qt_copy_action")); m_actionCopy->setShortcut(QKeySequence::Copy); m_actionCopy->setStatusTip(tr("Copies the selected widgets to the clipboard")); m_actionCopy->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Copy"))); connect(m_actionCopy, SIGNAL(triggered()), this, SLOT(slotActionCopyActivated())); m_actionCopy->setEnabled(false); m_actionPaste = new QAction(createIconSet(QStringLiteral("editpaste.png")), tr("&Paste"), this); m_actionPaste->setObjectName(QStringLiteral("__qt_paste_action")); m_actionPaste->setShortcut(QKeySequence::Paste); m_actionPaste->setStatusTip(tr("Pastes the clipboard's contents")); m_actionPaste->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Paste"))); connect(m_actionPaste, SIGNAL(triggered()), this, SLOT(slotActionPasteActivated())); m_actionPaste->setEnabled(false); #endif m_actionDelete = new QAction(tr("&Delete"), this); m_actionDelete->setObjectName(QStringLiteral("__qt_delete_action")); m_actionDelete->setStatusTip(tr("Deletes the selected widgets")); m_actionDelete->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Delete"))); connect(m_actionDelete, SIGNAL(triggered()), this, SLOT(slotActionDeleteActivated())); m_actionDelete->setEnabled(false); m_actionSelectAll = new QAction(tr("Select &All"), this); m_actionSelectAll->setObjectName(QStringLiteral("__qt_select_all_action")); m_actionSelectAll->setShortcut(QKeySequence::SelectAll); m_actionSelectAll->setStatusTip(tr("Selects all widgets")); m_actionSelectAll->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Select All"))); connect(m_actionSelectAll, SIGNAL(triggered()), this, SLOT(slotActionSelectAllActivated())); m_actionSelectAll->setEnabled(false); m_actionRaise = new QAction(createIconSet(QStringLiteral("editraise.png")), tr("Bring to &Front"), this); m_actionRaise->setObjectName(QStringLiteral("__qt_raise_action")); m_actionRaise->setShortcut(Qt::CTRL + Qt::Key_L); m_actionRaise->setStatusTip(tr("Raises the selected widgets")); m_actionRaise->setWhatsThis(tr("Raises the selected widgets")); connect(m_actionRaise, SIGNAL(triggered()), this, SLOT(slotActionRaiseActivated())); m_actionRaise->setEnabled(false); m_actionLower = new QAction(createIconSet(QStringLiteral("editlower.png")), tr("Send to &Back"), this); m_actionLower->setObjectName(QStringLiteral("__qt_lower_action")); m_actionLower->setShortcut(Qt::CTRL + Qt::Key_K); m_actionLower->setStatusTip(tr("Lowers the selected widgets")); m_actionLower->setWhatsThis(tr("Lowers the selected widgets")); connect(m_actionLower, SIGNAL(triggered()), this, SLOT(slotActionLowerActivated())); m_actionLower->setEnabled(false); m_actionAdjustSize = new QAction(createIconSet(QStringLiteral("adjustsize.png")), tr("Adjust &Size"), this); m_actionAdjustSize->setObjectName(QStringLiteral("__qt_adjust_size_action")); m_actionAdjustSize->setShortcut(Qt::CTRL + Qt::Key_J); m_actionAdjustSize->setStatusTip(tr("Adjusts the size of the selected widget")); m_actionAdjustSize->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Adjust Size"))); connect(m_actionAdjustSize, SIGNAL(triggered()), this, SLOT(slotActionAdjustSizeActivated())); m_actionAdjustSize->setEnabled(false); m_actionHorizontalLayout = new QAction(createIconSet(QStringLiteral("edithlayout.png")), tr("Lay Out &Horizontally"), this); m_actionHorizontalLayout->setObjectName(QStringLiteral("__qt_horizontal_layout_action")); m_actionHorizontalLayout->setShortcut(Qt::CTRL + Qt::Key_1); m_actionHorizontalLayout->setStatusTip(tr("Lays out the selected widgets horizontally")); m_actionHorizontalLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Horizontally"))); m_actionHorizontalLayout->setData(LayoutInfo::HBox); m_actionHorizontalLayout->setEnabled(false); connect(m_actionHorizontalLayout, SIGNAL(triggered()), this, SLOT(createLayout())); m_actionVerticalLayout = new QAction(createIconSet(QStringLiteral("editvlayout.png")), tr("Lay Out &Vertically"), this); m_actionVerticalLayout->setObjectName(QStringLiteral("__qt_vertical_layout_action")); m_actionVerticalLayout->setShortcut(Qt::CTRL + Qt::Key_2); m_actionVerticalLayout->setStatusTip(tr("Lays out the selected widgets vertically")); m_actionVerticalLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Vertically"))); m_actionVerticalLayout->setData(LayoutInfo::VBox); m_actionVerticalLayout->setEnabled(false); connect(m_actionVerticalLayout, SIGNAL(triggered()), this, SLOT(createLayout())); QIcon formIcon = QIcon::fromTheme(QStringLiteral("designer-form-layout"), createIconSet(QStringLiteral("editform.png"))); m_actionFormLayout = new QAction(formIcon, tr("Lay Out in a &Form Layout"), this); m_actionFormLayout->setObjectName(QStringLiteral("__qt_form_layout_action")); m_actionFormLayout->setShortcut(Qt::CTRL + Qt::Key_6); m_actionFormLayout->setStatusTip(tr("Lays out the selected widgets in a form layout")); m_actionFormLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out in a Form"))); m_actionFormLayout->setData(LayoutInfo::Form); m_actionFormLayout->setEnabled(false); connect(m_actionFormLayout, SIGNAL(triggered()), this, SLOT(createLayout())); m_actionGridLayout = new QAction(createIconSet(QStringLiteral("editgrid.png")), tr("Lay Out in a &Grid"), this); m_actionGridLayout->setObjectName(QStringLiteral("__qt_grid_layout_action")); m_actionGridLayout->setShortcut(Qt::CTRL + Qt::Key_5); m_actionGridLayout->setStatusTip(tr("Lays out the selected widgets in a grid")); m_actionGridLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out in a Grid"))); m_actionGridLayout->setData(LayoutInfo::Grid); m_actionGridLayout->setEnabled(false); connect(m_actionGridLayout, SIGNAL(triggered()), this, SLOT(createLayout())); m_actionSplitHorizontal = new QAction(createIconSet(QStringLiteral("edithlayoutsplit.png")), tr("Lay Out Horizontally in S&plitter"), this); m_actionSplitHorizontal->setObjectName(QStringLiteral("__qt_split_horizontal_action")); m_actionSplitHorizontal->setShortcut(Qt::CTRL + Qt::Key_3); m_actionSplitHorizontal->setStatusTip(tr("Lays out the selected widgets horizontally in a splitter")); m_actionSplitHorizontal->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Horizontally in Splitter"))); m_actionSplitHorizontal->setData(LayoutInfo::HSplitter); m_actionSplitHorizontal->setEnabled(false); connect(m_actionSplitHorizontal, SIGNAL(triggered()), this, SLOT(createLayout())); m_actionSplitVertical = new QAction(createIconSet(QStringLiteral("editvlayoutsplit.png")), tr("Lay Out Vertically in Sp&litter"), this); m_actionSplitVertical->setObjectName(QStringLiteral("__qt_split_vertical_action")); m_actionSplitVertical->setShortcut(Qt::CTRL + Qt::Key_4); m_actionSplitVertical->setStatusTip(tr("Lays out the selected widgets vertically in a splitter")); m_actionSplitVertical->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Vertically in Splitter"))); connect(m_actionSplitVertical, SIGNAL(triggered()), this, SLOT(createLayout())); m_actionSplitVertical->setData(LayoutInfo::VSplitter); m_actionSplitVertical->setEnabled(false); m_actionBreakLayout = new QAction(createIconSet(QStringLiteral("editbreaklayout.png")), tr("&Break Layout"), this); m_actionBreakLayout->setObjectName(QStringLiteral("__qt_break_layout_action")); m_actionBreakLayout->setShortcut(Qt::CTRL + Qt::Key_0); m_actionBreakLayout->setStatusTip(tr("Breaks the selected layout")); m_actionBreakLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Break Layout"))); connect(m_actionBreakLayout, SIGNAL(triggered()), this, SLOT(slotActionBreakLayoutActivated())); m_actionBreakLayout->setEnabled(false); m_actionSimplifyLayout = new QAction(tr("Si&mplify Grid Layout"), this); m_actionSimplifyLayout->setObjectName(QStringLiteral("__qt_simplify_layout_action")); m_actionSimplifyLayout->setStatusTip(tr("Removes empty columns and rows")); m_actionSimplifyLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Simplify Layout"))); connect(m_actionSimplifyLayout, SIGNAL(triggered()), this, SLOT(slotActionSimplifyLayoutActivated())); m_actionSimplifyLayout->setEnabled(false); m_actionDefaultPreview = new QAction(tr("&Preview..."), this); m_actionDefaultPreview->setObjectName(QStringLiteral("__qt_default_preview_action")); m_actionDefaultPreview->setStatusTip(tr("Preview current form")); m_actionDefaultPreview->setWhatsThis(whatsThisFrom(QStringLiteral("Form|Preview"))); connect(m_actionDefaultPreview, SIGNAL(triggered()), this, SLOT(showPreview())); m_undoGroup = new QUndoGroup(this); m_actionUndo = m_undoGroup->createUndoAction(this); m_actionUndo->setEnabled(false); m_actionUndo->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo"), createIconSet(QStringLiteral("undo.png")))); m_actionRedo = m_undoGroup->createRedoAction(this); m_actionRedo->setEnabled(false); m_actionRedo->setIcon(QIcon::fromTheme(QStringLiteral("edit-redo"), createIconSet(QStringLiteral("redo.png")))); m_actionShowFormWindowSettingsDialog = new QAction(tr("Form &Settings..."), this); m_actionShowFormWindowSettingsDialog->setObjectName(QStringLiteral("__qt_form_settings_action")); connect(m_actionShowFormWindowSettingsDialog, SIGNAL(triggered()), this, SLOT(slotActionShowFormWindowSettingsDialog())); m_actionShowFormWindowSettingsDialog->setEnabled(false); #if defined (Q_OS_UNIX) && !defined(Q_OS_MAC) #ifndef QT_NO_CLIPBOARD m_actionCopy->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"), m_actionCopy->icon())); m_actionCut->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut"), m_actionCut->icon())); m_actionPaste->setIcon(QIcon::fromTheme(QStringLiteral("edit-paste"), m_actionPaste->icon())); #endif m_actionDelete->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete"), m_actionDelete->icon())); // These do not currently exist, but will allow theme authors to fill in the gaps m_actionBreakLayout->setIcon(QIcon::fromTheme(QStringLiteral("designer-break-layout"), m_actionBreakLayout->icon())); m_actionGridLayout->setIcon(QIcon::fromTheme(QStringLiteral("designer-grid-layout"), m_actionGridLayout->icon())); m_actionHorizontalLayout->setIcon(QIcon::fromTheme(QStringLiteral("designer-horizontal-layout"), m_actionHorizontalLayout->icon())); m_actionVerticalLayout->setIcon(QIcon::fromTheme(QStringLiteral("designer-vertical-layout"), m_actionVerticalLayout->icon())); m_actionSplitHorizontal->setIcon(QIcon::fromTheme(QStringLiteral("designer-split-horizontal"), m_actionSplitHorizontal->icon())); m_actionSplitVertical->setIcon(QIcon::fromTheme(QStringLiteral("designer-split-vertical"), m_actionSplitVertical->icon())); m_actionAdjustSize->setIcon(QIcon::fromTheme(QStringLiteral("designer-adjust-size"), m_actionAdjustSize->icon())); #endif }
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(); }
// --------------- QDesignerPromotionDialog QDesignerPromotionDialog::QDesignerPromotionDialog(QDesignerFormEditorInterface *core, QWidget *parent, const QString &promotableWidgetClassName, QString *promoteTo) : QDialog(parent), m_mode(promotableWidgetClassName.isEmpty() || promoteTo == 0 ? ModeEdit : ModeEditChooseClass), m_promotableWidgetClassName(promotableWidgetClassName), m_core(core), m_promoteTo(promoteTo), m_promotion(core->promotion()), m_model(new PromotionModel(core)), m_treeView(new QTreeView), m_buttonBox(0), m_removeButton(new QPushButton(createIconSet(QString::fromUtf8("minus.png")), QString())) { m_buttonBox = createButtonBox(); setModal(true); setWindowTitle(tr("Promoted Widgets")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); QVBoxLayout *vboxLayout = new QVBoxLayout(this); // tree view group QGroupBox *treeViewGroup = new QGroupBox(); treeViewGroup->setTitle(tr("Promoted Classes")); QVBoxLayout *treeViewVBoxLayout = new QVBoxLayout(treeViewGroup); // tree view m_treeView->setModel (m_model); m_treeView->setMinimumWidth(450); m_treeView->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(slotSelectionChanged(QItemSelection, QItemSelection))); connect(m_treeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotTreeViewContextMenu(QPoint))); QHeaderView *headerView = m_treeView->header(); headerView->setResizeMode(QHeaderView::ResizeToContents); treeViewVBoxLayout->addWidget(m_treeView); // remove button QHBoxLayout *hboxLayout = new QHBoxLayout(); hboxLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored)); m_removeButton->setAutoDefault(false); connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemove())); m_removeButton->setEnabled(false); hboxLayout->addWidget(m_removeButton); treeViewVBoxLayout->addLayout(hboxLayout); vboxLayout->addWidget(treeViewGroup); // Create new panel: Try to be smart and preselect a base class. Default to QFrame const QStringList &baseClassNameList = baseClassNames(m_promotion); int preselectedBaseClass = -1; if (m_mode == ModeEditChooseClass) { preselectedBaseClass = baseClassNameList.indexOf(m_promotableWidgetClassName); } if (preselectedBaseClass == -1) preselectedBaseClass = baseClassNameList.indexOf(QLatin1String("QFrame")); NewPromotedClassPanel *newPromotedClassPanel = new NewPromotedClassPanel(baseClassNameList, preselectedBaseClass); connect(newPromotedClassPanel, SIGNAL(newPromotedClass(PromotionParameters, bool *)), this, SLOT(slotNewPromotedClass(PromotionParameters, bool *))); connect(this, SIGNAL(selectedBaseClassChanged(QString)), newPromotedClassPanel, SLOT(chooseBaseClass(QString))); vboxLayout->addWidget(newPromotedClassPanel); // button box vboxLayout->addWidget(m_buttonBox); // connect model connect(m_model, SIGNAL(includeFileChanged(QDesignerWidgetDataBaseItemInterface*, QString)), this, SLOT(slotIncludeFileChanged(QDesignerWidgetDataBaseItemInterface*, QString))); connect(m_model, SIGNAL(classNameChanged(QDesignerWidgetDataBaseItemInterface*, QString)), this, SLOT(slotClassNameChanged(QDesignerWidgetDataBaseItemInterface*, QString))); // focus if (m_mode == ModeEditChooseClass) newPromotedClassPanel->grabFocus(); slotUpdateFromWidgetDatabase(); }