From 24eec1960e0dc3594bd8ff77a8f329207a669056 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 13 Apr 2010 15:15:49 +0200 Subject: Use unifiedToolBarOnMac, by default don't show some tool action. Some tool actions are hidden by default (undo/redo, cut.copy.paste), the user can bring them back by using View|Toolbars|Configure Toolbars dialog. Reviewed-by: Jens Bache-Wiig Reviewed-by: Friedemann Kleint Reviewed-by: Daniel Molkentin --- tools/designer/src/designer/mainwindow.cpp | 20 +++++++++++++++++++- tools/designer/src/designer/qdesigner_actions.cpp | 19 +++++++++++++++++++ tools/designer/src/designer/qdesigner_actions.h | 4 ++++ tools/designer/src/designer/qdesigner_workbench.cpp | 1 + 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/tools/designer/src/designer/mainwindow.cpp b/tools/designer/src/designer/mainwindow.cpp index c27e2b4..86bc47e 100644 --- a/tools/designer/src/designer/mainwindow.cpp +++ b/tools/designer/src/designer/mainwindow.cpp @@ -75,7 +75,7 @@ static void addActionsToToolBar(const ActionList &actions, QToolBar *t) const ActionList::const_iterator cend = actions.constEnd(); for (ActionList::const_iterator it = actions.constBegin(); it != cend; ++it) { QAction *action = *it; - if (!action->icon().isNull()) + if (action->property(QDesignerActions::defaultToolbarPropertyName).toBool()) t->addAction(action); } } @@ -113,6 +113,8 @@ void MainWindowBase::closeEvent(QCloseEvent *e) QList MainWindowBase::createToolBars(const QDesignerActions *actions, bool singleToolBar) { + // Note that whenever you want to add a new tool bar here, you also have to update the default + // action groups added to the toolbar manager in the mainwindow constructor QList rc; if (singleToolBar) { //: Not currently used (main tool bar) @@ -252,6 +254,22 @@ ToolBarManager::ToolBarManager(QMainWindow *configureableMainWindow, m_manager->addAction(action, dockTitle); } + QString category(tr("File")); + foreach(QAction *action, actions->fileActions()->actions()) + m_manager->addAction(action, category); + + category = tr("Edit"); + foreach(QAction *action, actions->editActions()->actions()) + m_manager->addAction(action, category); + + category = tr("Tools"); + foreach(QAction *action, actions->toolActions()->actions()) + m_manager->addAction(action, category); + + category = tr("Form"); + foreach(QAction *action, actions->formActions()->actions()) + m_manager->addAction(action, category); + m_manager->addAction(m_configureAction, tr("Toolbars")); updateToolBarMenu(); } diff --git a/tools/designer/src/designer/qdesigner_actions.cpp b/tools/designer/src/designer/qdesigner_actions.cpp index 6776351..a593a76 100644 --- a/tools/designer/src/designer/qdesigner_actions.cpp +++ b/tools/designer/src/designer/qdesigner_actions.cpp @@ -107,6 +107,8 @@ QT_BEGIN_NAMESPACE using namespace qdesigner_internal; +const char *QDesignerActions::defaultToolbarPropertyName = "__qt_defaultToolBarAction"; + //#ifdef Q_WS_MAC # define NONMODAL_PREVIEW //#endif @@ -236,6 +238,10 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) m_helpActions = createHelpActions(); + m_newFormAction->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + m_openFormAction->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + m_saveFormAction->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + QDesignerFormWindowManagerInterface *formWindowManager = m_core->formWindowManager(); Q_ASSERT(formWindowManager != 0); @@ -322,6 +328,9 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) m_editActions->addAction(formWindowManager->actionLower()); m_editActions->addAction(formWindowManager->actionRaise()); + formWindowManager->actionLower()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->actionRaise()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + // // edit mode actions // @@ -349,6 +358,7 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) if (QDesignerFormEditorPluginInterface *formEditorPlugin = qobject_cast(plugin)) { if (QAction *action = formEditorPlugin->action()) { m_toolActions->addAction(action); + action->setProperty(QDesignerActions::defaultToolbarPropertyName, true); action->setCheckable(true); } } @@ -376,6 +386,15 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) m_formActions->addAction(formWindowManager->actionSimplifyLayout()); m_formActions->addAction(createSeparator(this)); + formWindowManager->actionHorizontalLayout()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->actionVerticalLayout()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->actionSplitHorizontal()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->actionSplitVertical()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->actionGridLayout()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->actionFormLayout()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->actionBreakLayout()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->actionAdjustSize()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + m_previewFormAction->setShortcut(tr("CTRL+R")); m_formActions->addAction(m_previewFormAction); connect(m_previewManager, SIGNAL(firstPreviewOpened()), this, SLOT(updateCloseAction())); diff --git a/tools/designer/src/designer/qdesigner_actions.h b/tools/designer/src/designer/qdesigner_actions.h index 9dfcef1..d8f9e42 100644 --- a/tools/designer/src/designer/qdesigner_actions.h +++ b/tools/designer/src/designer/qdesigner_actions.h @@ -113,6 +113,10 @@ public: QString uiExtension() const; + // Boolean dynamic property set on actions to + // show them in the default toolbar layout + static const char *defaultToolbarPropertyName; + public slots: void activeFormWindowChanged(QDesignerFormWindowInterface *formWindow); void createForm(); diff --git a/tools/designer/src/designer/qdesigner_workbench.cpp b/tools/designer/src/designer/qdesigner_workbench.cpp index b65ce7e..168c468 100644 --- a/tools/designer/src/designer/qdesigner_workbench.cpp +++ b/tools/designer/src/designer/qdesigner_workbench.cpp @@ -419,6 +419,7 @@ void QDesignerWorkbench::switchToDockedMode() m_mode = DockedMode; const QDesignerSettings settings(m_core); m_dockedMainWindow = new DockedMainWindow(this, m_toolbarMenu, m_toolWindows); + m_dockedMainWindow->setUnifiedTitleAndToolBarOnMac(true); m_dockedMainWindow->setCloseEventPolicy(MainWindowBase::EmitCloseEventSignal); connect(m_dockedMainWindow, SIGNAL(closeEventReceived(QCloseEvent*)), this, SLOT(handleCloseEvent(QCloseEvent*))); connect(m_dockedMainWindow, SIGNAL(fileDropped(QString)), this, SLOT(slotFileDropped(QString))); -- cgit v0.12 From 2ff6df50fac75af2d1b9d49101d9b1d8af28535d Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 13 Apr 2010 15:25:16 +0200 Subject: Fix dealing with the default dynamic properties of string type. Fixed showing, changing and resetting of default dynamic properties of string and keysequence type. Reviewed-by: Friedemann Kleint Task-number: QTBUG-9603 --- .../src/lib/shared/qdesigner_propertysheet.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp index 77ab2a6..08fedd2 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp +++ b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp @@ -722,10 +722,11 @@ int QDesignerPropertySheet::addDynamicProperty(const QString &propName, const QV else if (value.type() == QVariant::Pixmap) v = qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue()); else if (value.type() == QVariant::String) - v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); - else if (value.type() == QVariant::KeySequence) - v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue()); - + v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(value.toString())); + else if (value.type() == QVariant::KeySequence) { + const QKeySequence keySequence = qVariantValue(value); + v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence)); + } if (d->m_addIndex.contains(propName)) { const int idx = d->m_addIndex.value(propName); @@ -1130,7 +1131,7 @@ void QDesignerPropertySheet::setProperty(int index, const QVariant &value) } } - if (isDynamicProperty(index)) { + if (isDynamicProperty(index) || isDefaultDynamicProperty(index)) { if (d->isResourceProperty(index)) d->setResourceProperty(index, value); if (d->isStringProperty(index)) @@ -1200,10 +1201,17 @@ bool QDesignerPropertySheet::reset(int index) } else if (isDynamic(index)) { const QString propName = propertyName(index); const QVariant oldValue = d->m_addProperties.value(index); - const QVariant newValue = d->m_info.value(index).defaultValue; + const QVariant defaultValue = d->m_info.value(index).defaultValue; + QVariant newValue = defaultValue; + if (d->isStringProperty(index)) { + newValue = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(newValue.toString())); + } else if (d->isKeySequenceProperty(index)) { + const QKeySequence keySequence = qVariantValue(newValue); + newValue = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence)); + } if (oldValue == newValue) return true; - d->m_object->setProperty(propName.toUtf8(), newValue); + d->m_object->setProperty(propName.toUtf8(), defaultValue); d->m_addProperties[index] = newValue; return true; } else if (!d->m_info.value(index).defaultValue.isNull()) { -- cgit v0.12 From 6f8364ac0c128eb8afe897b5d8f3f4e26b9105f5 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 13 Apr 2010 15:44:13 +0200 Subject: Fix writing duplicate headers' properties in designer. Designer has written verticalHeaderVisible property in ui file twice: once done implicitly while saving the fake properties and once done explicitly inside QDesignerResource by calling saveWidget(QTableView/QTreeView). The latter is removed as it is redundant now. Reviewed-by: Friedemann Kleint Task-number: QTBUG-9351 --- .../components/formeditor/qdesigner_resource.cpp | 61 ---------------------- .../src/components/formeditor/qdesigner_resource.h | 4 -- 2 files changed, 65 deletions(-) diff --git a/tools/designer/src/components/formeditor/qdesigner_resource.cpp b/tools/designer/src/components/formeditor/qdesigner_resource.cpp index b659179..1d78695 100644 --- a/tools/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/tools/designer/src/components/formeditor/qdesigner_resource.cpp @@ -53,7 +53,6 @@ #include "qtresourcemodel_p.h" #include "qmdiarea_container.h" #include "qwizard_container.h" -#include "itemview_propertysheet.h" #include "layout_propertysheet.h" #include @@ -106,8 +105,6 @@ #include #include #include -#include -#include #include #include @@ -1275,10 +1272,6 @@ DomWidget *QDesignerResource::createDom(QWidget *widget, DomWidget *ui_parentWid w = saveWidget(dockWidget, ui_parentWidget); else if (QDesignerContainerExtension *container = qt_extension(core()->extensionManager(), widget)) w = saveWidget(widget, container, ui_parentWidget); - else if (QTreeView *treeView = qobject_cast(widget)) - w = saveWidget(treeView, ui_parentWidget); - else if (QTableView *tableView = qobject_cast(widget)) - w = saveWidget(tableView, ui_parentWidget); else if (QWizardPage *wizardPage = qobject_cast(widget)) w = saveWidget(wizardPage, ui_parentWidget); else @@ -1553,60 +1546,6 @@ DomWidget *QDesignerResource::saveWidget(QDesignerDockWidget *dockWidget, DomWid return ui_widget; } -DomWidget *QDesignerResource::saveWidget(QTreeView *treeView, DomWidget *ui_parentWidget) -{ - DomWidget *ui_widget = QAbstractFormBuilder::createDom(treeView, ui_parentWidget, true); - - QDesignerPropertySheetExtension *sheet - = qt_extension(core()->extensionManager(), treeView); - ItemViewPropertySheet *itemViewSheet = static_cast(sheet); - - if (itemViewSheet) { - QHash nameMap = itemViewSheet->propertyNameMap(); - foreach (const QString &fakeName, nameMap.keys()) { - int index = itemViewSheet->indexOf(fakeName); - if (sheet->isChanged(index)) { - DomProperty *domAttr = createProperty(treeView->header(), nameMap.value(fakeName), - itemViewSheet->property(index)); - domAttr->setAttributeName(fakeName); - ui_widget->setElementAttribute(ui_widget->elementAttribute() << domAttr); - } - } - } - - return ui_widget; -} - -DomWidget *QDesignerResource::saveWidget(QTableView *tableView, DomWidget *ui_parentWidget) -{ - DomWidget *ui_widget = QAbstractFormBuilder::createDom(tableView, ui_parentWidget, true); - - QDesignerPropertySheetExtension *sheet - = qt_extension(core()->extensionManager(), tableView); - ItemViewPropertySheet *itemViewSheet = static_cast(sheet); - - if (itemViewSheet) { - QHash nameMap = itemViewSheet->propertyNameMap(); - foreach (const QString &fakeName, nameMap.keys()) { - int index = itemViewSheet->indexOf(fakeName); - if (sheet->isChanged(index)) { - DomProperty *domAttr; - if (fakeName.startsWith(QLatin1String("horizontal"))) { - domAttr = createProperty(tableView->horizontalHeader(), nameMap.value(fakeName), - itemViewSheet->property(index)); - } else { - domAttr = createProperty(tableView->verticalHeader(), nameMap.value(fakeName), - itemViewSheet->property(index)); - } - domAttr->setAttributeName(fakeName); - ui_widget->setElementAttribute(ui_widget->elementAttribute() << domAttr); - } - } - } - - return ui_widget; -} - static void saveStringProperty(DomProperty *property, const PropertySheetStringValue &value) { DomString *str = new DomString(); diff --git a/tools/designer/src/components/formeditor/qdesigner_resource.h b/tools/designer/src/components/formeditor/qdesigner_resource.h index 33b5b88..47dd263 100644 --- a/tools/designer/src/components/formeditor/qdesigner_resource.h +++ b/tools/designer/src/components/formeditor/qdesigner_resource.h @@ -64,8 +64,6 @@ class QTabWidget; class QStackedWidget; class QToolBox; class QToolBar; -class QTreeView; -class QTableView; class QDesignerDockWidget; class QLayoutWidget; class QWizardPage; @@ -138,8 +136,6 @@ protected: DomWidget *saveWidget(QWidget *widget, QDesignerContainerExtension *container, DomWidget *ui_parentWidget); DomWidget *saveWidget(QToolBar *toolBar, DomWidget *ui_parentWidget); DomWidget *saveWidget(QDesignerDockWidget *dockWidget, DomWidget *ui_parentWidget); - DomWidget *saveWidget(QTreeView *treeView, DomWidget *ui_parentWidget); - DomWidget *saveWidget(QTableView *tableView, DomWidget *ui_parentWidget); DomWidget *saveWidget(QWizardPage *wizardPage, DomWidget *ui_parentWidget); virtual DomCustomWidgets *saveCustomWidgets(); -- cgit v0.12