summaryrefslogtreecommitdiffstats
path: root/tools/designer/src/lib/shared
diff options
context:
space:
mode:
Diffstat (limited to 'tools/designer/src/lib/shared')
-rw-r--r--tools/designer/src/lib/shared/actionrepository.cpp6
-rw-r--r--tools/designer/src/lib/shared/filterwidget.cpp167
-rw-r--r--tools/designer/src/lib/shared/filterwidget_p.h53
-rw-r--r--tools/designer/src/lib/shared/formwindowbase.cpp13
-rw-r--r--tools/designer/src/lib/shared/plugindialog.cpp4
-rw-r--r--tools/designer/src/lib/shared/previewconfigurationwidget.cpp2
-rw-r--r--tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp6
-rw-r--r--tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h4
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menu.cpp8
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertycommand.cpp54
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertycommand_p.h28
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertyeditor.cpp16
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h8
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertysheet.cpp38
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertysheet_p.h3
-rw-r--r--tools/designer/src/lib/shared/qdesigner_toolbar.cpp1
-rw-r--r--tools/designer/src/lib/shared/qtresourcemodel.cpp6
-rw-r--r--tools/designer/src/lib/shared/qtresourceview.cpp7
-rw-r--r--tools/designer/src/lib/shared/shared.pri10
-rw-r--r--tools/designer/src/lib/shared/stylesheeteditor.cpp1
20 files changed, 272 insertions, 163 deletions
diff --git a/tools/designer/src/lib/shared/actionrepository.cpp b/tools/designer/src/lib/shared/actionrepository.cpp
index 1076ff4..a54c1e7 100644
--- a/tools/designer/src/lib/shared/actionrepository.cpp
+++ b/tools/designer/src/lib/shared/actionrepository.cpp
@@ -397,9 +397,10 @@ void ActionTreeView::contextMenuEvent(QContextMenuEvent *event)
emit contextMenuRequested(event, m_model->actionAt(indexAt(event->pos())));
}
-void ActionTreeView::currentChanged(const QModelIndex &current, const QModelIndex &/*previous*/)
+void ActionTreeView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
{
emit currentChanged(m_model->actionAt(current));
+ QTreeView::currentChanged(current, previous);
}
void ActionTreeView::slotActivated(const QModelIndex &index)
@@ -478,9 +479,10 @@ void ActionListView::contextMenuEvent(QContextMenuEvent *event)
emit contextMenuRequested(event, m_model->actionAt(indexAt(event->pos())));
}
-void ActionListView::currentChanged(const QModelIndex &current, const QModelIndex & /*previous*/)
+void ActionListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
{
emit currentChanged(m_model->actionAt(current));
+ QListView::currentChanged(current, previous);
}
void ActionListView::slotActivated(const QModelIndex &index)
diff --git a/tools/designer/src/lib/shared/filterwidget.cpp b/tools/designer/src/lib/shared/filterwidget.cpp
index 6c73a08..a501c02 100644
--- a/tools/designer/src/lib/shared/filterwidget.cpp
+++ b/tools/designer/src/lib/shared/filterwidget.cpp
@@ -44,13 +44,17 @@
#include <QtGui/QVBoxLayout>
#include <QtGui/QHBoxLayout>
-#include <QtGui/QPushButton>
#include <QtGui/QLineEdit>
#include <QtGui/QFocusEvent>
#include <QtGui/QPalette>
#include <QtGui/QCursor>
+#include <QtGui/QToolButton>
+#include <QtGui/QPainter>
+#include <QtGui/QStyle>
+#include <QtGui/QStyleOption>
#include <QtCore/QDebug>
+#include <QtCore/QPropertyAnimation>
enum { debugFilter = 0 };
@@ -61,12 +65,47 @@ namespace qdesigner_internal {
HintLineEdit::HintLineEdit(QWidget *parent) :
QLineEdit(parent),
m_defaultFocusPolicy(focusPolicy()),
- m_hintColor(QColor(0xbbbbbb)),
- m_refuseFocus(false),
- m_showingHintText(false)
+ m_refuseFocus(false)
{
}
+IconButton::IconButton(QWidget *parent)
+ : QToolButton(parent)
+{
+ setCursor(Qt::ArrowCursor);
+}
+
+void IconButton::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ // Note isDown should really use the active state but in most styles
+ // this has no proper feedback
+ QIcon::Mode state = QIcon::Disabled;
+ if (isEnabled())
+ state = isDown() ? QIcon::Selected : QIcon::Normal;
+ QPixmap iconpixmap = icon().pixmap(QSize(ICONBUTTON_SIZE, ICONBUTTON_SIZE),
+ state, QIcon::Off);
+ QRect pixmapRect = QRect(0, 0, iconpixmap.width(), iconpixmap.height());
+ pixmapRect.moveCenter(rect().center());
+ painter.setOpacity(m_fader);
+ painter.drawPixmap(pixmapRect, iconpixmap);
+}
+
+void IconButton::animateShow(bool visible)
+{
+ if (visible) {
+ QPropertyAnimation *animation = new QPropertyAnimation(this, "fader");
+ animation->setDuration(160);
+ animation->setEndValue(1.0);
+ animation->start(QAbstractAnimation::DeleteWhenStopped);
+ } else {
+ QPropertyAnimation *animation = new QPropertyAnimation(this, "fader");
+ animation->setDuration(160);
+ animation->setEndValue(0.0);
+ animation->start(QAbstractAnimation::DeleteWhenStopped);
+ }
+}
+
bool HintLineEdit::refuseFocus() const
{
return m_refuseFocus;
@@ -111,92 +150,53 @@ void HintLineEdit::focusInEvent(QFocusEvent *e)
}
}
- hideHintText();
QLineEdit::focusInEvent(e);
}
-void HintLineEdit::focusOutEvent(QFocusEvent *e)
-{
- if (debugFilter)
- qDebug() << Q_FUNC_INFO;
- // Focus out: Switch to displaying the hint text unless there is user input
- showHintText();
- QLineEdit::focusOutEvent(e);
-}
-
-QString HintLineEdit::hintText() const
+// ------------------- FilterWidget
+FilterWidget::FilterWidget(QWidget *parent, LayoutMode lm) :
+ QWidget(parent),
+ m_editor(new HintLineEdit(this)),
+ m_button(new IconButton(m_editor)),
+ m_buttonwidth(0)
{
- return m_hintText;
-}
+ m_editor->setPlaceholderText(tr("Filter"));
-void HintLineEdit::setHintText(const QString &ht)
-{
- if (ht == m_hintText)
- return;
- hideHintText();
- m_hintText = ht;
- if (!hasFocus() && !ht.isEmpty())
- showHintText();
-}
+ // Let the style determine minimum height for our widget
+ QSize size(ICONBUTTON_SIZE + 6, ICONBUTTON_SIZE + 2);
-void HintLineEdit::showHintText(bool force)
-{
- if (m_showingHintText || m_hintText.isEmpty())
- return;
- if (force || text().isEmpty()) {
- m_showingHintText = true;
- setText(m_hintText);
- setTextColor(m_hintColor, &m_textColor);
- }
-}
-void HintLineEdit::hideHintText()
-{
- if (m_showingHintText && !m_hintText.isEmpty()) {
- m_showingHintText = false;
- setText(QString());
- setTextColor(m_textColor);
+ // Note KDE does not reserve space for the highlight color
+ if (style()->inherits("OxygenStyle")) {
+ size = size.expandedTo(QSize(24, 0));
}
-}
-bool HintLineEdit::isShowingHintText() const
-{
- return m_showingHintText;
-}
-
-QString HintLineEdit::typedText() const
-{
- return m_showingHintText ? QString() : text();
-}
+ // Make room for clear icon
+ QMargins margins = m_editor->textMargins();
+ if (layoutDirection() == Qt::LeftToRight)
+ margins.setRight(size.width());
+ else
+ margins.setLeft(size.width());
-void HintLineEdit::setTextColor(const QColor &newColor, QColor *oldColor)
-{
- QPalette pal = palette();
- if (oldColor)
- *oldColor = pal.color(QPalette::Text);
- pal.setColor(QPalette::Text, newColor);
- setPalette(pal);}
+ m_editor->setTextMargins(margins);
-// ------------------- 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);
+ // 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)));
@@ -204,25 +204,40 @@ FilterWidget::FilterWidget(QWidget *parent, LayoutMode lm) :
QString FilterWidget::text() const
{
- return m_editor->typedText();
+ return m_editor->text();
}
-void FilterWidget::checkButton(const QString &)
+void FilterWidget::checkButton(const QString &text)
{
- m_button->setEnabled(!text().isEmpty());
+ if (m_oldText.isEmpty() || text.isEmpty())
+ m_button->animateShow(!m_editor->text().isEmpty());
+ m_oldText = text;
}
void FilterWidget::reset()
{
if (debugFilter)
qDebug() << Q_FUNC_INFO;
- if (!text().isEmpty()) {
+
+ if (!m_editor->text().isEmpty()) {
// Editor has lost focus once this is pressed
- m_editor->showHintText(true);
+ m_editor->clear();
emit filterChanged(QString());
}
}
+void FilterWidget::resizeEvent(QResizeEvent *)
+{
+ QRect contentRect = m_editor->rect();
+ if (layoutDirection() == Qt::LeftToRight) {
+ const int iconoffset = m_editor->textMargins().right() + 4;
+ m_button->setGeometry(contentRect.adjusted(m_editor->width() - iconoffset, 0, 0, 0));
+ } else {
+ const int iconoffset = m_editor->textMargins().left() + 4;
+ m_button->setGeometry(contentRect.adjusted(0, 0, -m_editor->width() + iconoffset, 0));
+ }
+}
+
bool FilterWidget::refuseFocus() const
{
return m_editor->refuseFocus();
diff --git a/tools/designer/src/lib/shared/filterwidget_p.h b/tools/designer/src/lib/shared/filterwidget_p.h
index 025d708..8ca2073 100644
--- a/tools/designer/src/lib/shared/filterwidget_p.h
+++ b/tools/designer/src/lib/shared/filterwidget_p.h
@@ -58,58 +58,55 @@
#include <QtGui/QWidget>
#include <QtGui/QLineEdit>
#include <QtGui/QColor>
+#include <QtGui/QToolButton>
QT_BEGIN_NAMESPACE
-class QPushButton;
+class QToolButton;
namespace qdesigner_internal {
-/* A line edit that displays a grayed hintText (like "Type Here to Filter")
- * when not focused and empty. When connecting to the changed signals and
- * querying text, one has to be aware that the text is set to that hint
- * text if isShowingHintText() returns true (that is, does not contain
- * valid user input). This widget should never have initial focus
+/* This widget should never have initial focus
* (ie, be the first widget of a dialog, else, the hint cannot be displayed.
* For situations, where it is the only focusable control (widget box),
* there is a special "refuseFocus()" mode, in which it clears the focus
* policy and focusses explicitly on click (note that setting Qt::ClickFocus
* is not sufficient for that as an ActivationFocus will occur). */
+#define ICONBUTTON_SIZE 16
+
class QDESIGNER_SHARED_EXPORT HintLineEdit : public QLineEdit {
Q_OBJECT
public:
explicit HintLineEdit(QWidget *parent = 0);
- QString hintText() const;
-
- bool isShowingHintText() const;
-
- // Convenience for accessing the text that returns "" in case of isShowingHintText().
- QString typedText() const;
-
bool refuseFocus() const;
void setRefuseFocus(bool v);
-public slots:
- void setHintText(const QString &ht);
- void showHintText(bool force = false);
- void hideHintText();
-
protected:
virtual void mousePressEvent(QMouseEvent *event);
virtual void focusInEvent(QFocusEvent *e);
- virtual void focusOutEvent(QFocusEvent *e);
private:
- void setTextColor(const QColor &newColor, QColor *oldColor = 0);
-
const Qt::FocusPolicy m_defaultFocusPolicy;
- const QColor m_hintColor;
- QColor m_textColor;
bool m_refuseFocus;
- QString m_hintText;
- bool m_showingHintText;
+};
+
+// IconButton: This is a simple helper class that represents clickable icons
+
+class IconButton: public QToolButton
+{
+ Q_OBJECT
+ Q_PROPERTY(float fader READ fader WRITE setFader)
+public:
+ IconButton(QWidget *parent);
+ void paintEvent(QPaintEvent *event);
+ float fader() { return m_fader; }
+ void setFader(float value) { m_fader = value; update(); }
+ void animateShow(bool visible);
+
+private:
+ float m_fader;
};
// FilterWidget: For filtering item views, with reset button Uses HintLineEdit.
@@ -128,7 +125,7 @@ public:
explicit FilterWidget(QWidget *parent = 0, LayoutMode lm = LayoutAlignRight);
QString text() const;
-
+ void resizeEvent(QResizeEvent *);
bool refuseFocus() const; // see HintLineEdit
void setRefuseFocus(bool v);
@@ -142,8 +139,10 @@ private slots:
void checkButton(const QString &text);
private:
- QPushButton *m_button;
HintLineEdit *m_editor;
+ IconButton *m_button;
+ int m_buttonwidth;
+ QString m_oldText;
};
} // namespace qdesigner_internal
diff --git a/tools/designer/src/lib/shared/formwindowbase.cpp b/tools/designer/src/lib/shared/formwindowbase.cpp
index 2c5efbf..5292f5f 100644
--- a/tools/designer/src/lib/shared/formwindowbase.cpp
+++ b/tools/designer/src/lib/shared/formwindowbase.cpp
@@ -72,6 +72,7 @@
#include <QtGui/QStatusBar>
#include <QtGui/QMenu>
#include <QtGui/QAction>
+#include <QtGui/QLabel>
QT_BEGIN_NAMESPACE
@@ -181,7 +182,17 @@ void FormWindowBase::reloadProperties()
QMapIterator<int, bool> itIndex(itSheet.value());
while (itIndex.hasNext()) {
const int index = itIndex.next().key();
- sheet->setProperty(index, sheet->property(index));
+ const QVariant newValue = sheet->property(index);
+ if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == QLatin1String("text")) {
+ const PropertySheetStringValue newString = qVariantValue<PropertySheetStringValue>(newValue);
+ // optimize a bit, reset only if the text value might contain a reference to qt resources
+ // (however reloading of icons other than taken from resources might not work here)
+ if (newString.value().contains(QLatin1String(":/"))) {
+ const QVariant resetValue = qVariantFromValue(PropertySheetStringValue());
+ sheet->setProperty(index, resetValue);
+ }
+ }
+ sheet->setProperty(index, newValue);
}
if (QTabWidget *tabWidget = qobject_cast<QTabWidget *>(sheet->object())) {
const int count = tabWidget->count();
diff --git a/tools/designer/src/lib/shared/plugindialog.cpp b/tools/designer/src/lib/shared/plugindialog.cpp
index 3e88043..63ba81c 100644
--- a/tools/designer/src/lib/shared/plugindialog.cpp
+++ b/tools/designer/src/lib/shared/plugindialog.cpp
@@ -102,7 +102,7 @@ void PluginDialog::populateTreeWidget()
const QStringList fileNames = pluginManager->registeredPlugins();
if (!fileNames.isEmpty()) {
- QTreeWidgetItem *topLevelItem = setTopLevelItem(QLatin1String("Loaded Plugins"));
+ QTreeWidgetItem *topLevelItem = setTopLevelItem(tr("Loaded Plugins"));
QFont boldFont = topLevelItem->font(0);
foreach (const QString &fileName, fileNames) {
@@ -125,7 +125,7 @@ void PluginDialog::populateTreeWidget()
const QStringList notLoadedPlugins = pluginManager->failedPlugins();
if (!notLoadedPlugins.isEmpty()) {
- QTreeWidgetItem *topLevelItem = setTopLevelItem(QLatin1String("Failed Plugins"));
+ QTreeWidgetItem *topLevelItem = setTopLevelItem(tr("Failed Plugins"));
const QFont boldFont = topLevelItem->font(0);
foreach (const QString &plugin, notLoadedPlugins) {
const QString failureReason = pluginManager->failureReason(plugin);
diff --git a/tools/designer/src/lib/shared/previewconfigurationwidget.cpp b/tools/designer/src/lib/shared/previewconfigurationwidget.cpp
index e07d155..d116d58 100644
--- a/tools/designer/src/lib/shared/previewconfigurationwidget.cpp
+++ b/tools/designer/src/lib/shared/previewconfigurationwidget.cpp
@@ -41,7 +41,7 @@
/* It is possible to link the skins as resources into Designer by specifying:
* QVFB_ROOT=$$QT_SOURCE_TREE/tools/qvfb
- * RESOURCES += $$QVFB_ROOT/ClamshellPhone.qrc $$QVFB_ROOT/PDAPhone.qrc ...
+ * RESOURCES += $$QVFB_ROOT/ClamshellPhone.qrc $$QVFB_ROOT/TouchScreenPhone.qrc ...
* in lib/shared/shared.pri. However, this exceeds a limit of Visual Studio 6. */
#include "previewconfigurationwidget_p.h"
diff --git a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp
index 8c55d26..490373e 100644
--- a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp
@@ -62,8 +62,10 @@ QT_BEGIN_NAMESPACE
namespace qdesigner_internal {
// ---- QDesignerFormWindowCommand ----
-QDesignerFormWindowCommand::QDesignerFormWindowCommand(const QString &description, QDesignerFormWindowInterface *formWindow)
- : QUndoCommand(description),
+QDesignerFormWindowCommand::QDesignerFormWindowCommand(const QString &description,
+ QDesignerFormWindowInterface *formWindow,
+ QUndoCommand *parent)
+ : QUndoCommand(description, parent),
m_formWindow(formWindow)
{
}
diff --git a/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h b/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h
index d8cd018..d73d70c 100644
--- a/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h
@@ -70,7 +70,9 @@ class QDESIGNER_SHARED_EXPORT QDesignerFormWindowCommand: public QUndoCommand
{
public:
- QDesignerFormWindowCommand(const QString &description, QDesignerFormWindowInterface *formWindow);
+ QDesignerFormWindowCommand(const QString &description,
+ QDesignerFormWindowInterface *formWindow,
+ QUndoCommand *parent = 0);
virtual void undo();
virtual void redo();
diff --git a/tools/designer/src/lib/shared/qdesigner_menu.cpp b/tools/designer/src/lib/shared/qdesigner_menu.cpp
index ba512e4..31a226a 100644
--- a/tools/designer/src/lib/shared/qdesigner_menu.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_menu.cpp
@@ -77,6 +77,7 @@ using namespace qdesigner_internal;
static inline void extendClickableArea(QRect *subMenuRect, Qt::LayoutDirection dir)
{
switch (dir) {
+ case Qt::LayoutDirectionAuto: // Should never happen
case Qt::LeftToRight:
subMenuRect->setLeft(subMenuRect->left() - 20);
break;
@@ -931,8 +932,8 @@ void QDesignerMenu::moveUp(bool ctrl)
if (ctrl)
(void) swap(m_currentIndex, m_currentIndex - 1);
-
- m_currentIndex = qMax(0, --m_currentIndex);
+ --m_currentIndex;
+ m_currentIndex = qMax(0, m_currentIndex);
// Always re-select, swapping destroys order
update();
selectCurrentAction();
@@ -947,7 +948,8 @@ void QDesignerMenu::moveDown(bool ctrl)
if (ctrl)
(void) swap(m_currentIndex + 1, m_currentIndex);
- m_currentIndex = qMin(actions().count() - 1, ++m_currentIndex);
+ ++m_currentIndex;
+ m_currentIndex = qMin(actions().count() - 1, m_currentIndex);
update();
if (!ctrl)
selectCurrentAction();
diff --git a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp
index 822c14b..6cc054c 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp
@@ -926,8 +926,9 @@ bool PropertyListCommand::PropertyDescription::equals(const PropertyDescription
// ---- PropertyListCommand
-PropertyListCommand::PropertyListCommand(QDesignerFormWindowInterface *formWindow) :
- QDesignerFormWindowCommand(QString(), formWindow)
+PropertyListCommand::PropertyListCommand(QDesignerFormWindowInterface *formWindow,
+ QUndoCommand *parent) :
+ QDesignerFormWindowCommand(QString(), formWindow, parent)
{
}
@@ -966,10 +967,17 @@ bool PropertyListCommand::add(QObject *object, const QString &propertyName)
if (!match || m_propertyDescription.m_specialProperty == SP_ObjectName)
return false;
}
- m_propertyHelperList.push_back(PropertyHelper(object, m_propertyDescription.m_specialProperty, sheet, index));
+
+ const PropertyHelperPtr ph(createPropertyHelper(object, m_propertyDescription.m_specialProperty, sheet, index));
+ m_propertyHelperList.push_back(ph);
return true;
}
+PropertyHelper *PropertyListCommand::createPropertyHelper(QObject *object, SpecialProperty sp,
+ QDesignerPropertySheetExtension *sheet, int sheetIndex) const
+{
+ return new PropertyHelper(object, sp, sheet, sheetIndex);
+}
// Init from a list and make sure referenceObject is added first to obtain the right property group
bool PropertyListCommand::initList(const ObjectList &list, const QString &apropertyName, QObject *referenceObject)
@@ -993,19 +1001,19 @@ bool PropertyListCommand::initList(const ObjectList &list, const QString &aprope
QObject* PropertyListCommand::object(int index) const
{
Q_ASSERT(index < m_propertyHelperList.size());
- return m_propertyHelperList[index].object();
+ return m_propertyHelperList.at(index)->object();
}
QVariant PropertyListCommand::oldValue(int index) const
{
Q_ASSERT(index < m_propertyHelperList.size());
- return m_propertyHelperList[index].oldValue();
+ return m_propertyHelperList.at(index)->oldValue();
}
void PropertyListCommand::setOldValue(const QVariant &oldValue, int index)
{
Q_ASSERT(index < m_propertyHelperList.size());
- m_propertyHelperList[index].setOldValue(oldValue);
+ m_propertyHelperList.at(index)->setOldValue(oldValue);
}
// ----- SetValueFunction: Set a new value when applied to a PropertyHelper.
class SetValueFunction {
@@ -1065,9 +1073,10 @@ template <class PropertyListIterator, class Function>
bool updatedPropertyEditor = false;
for (PropertyListIterator it = begin; it != end; ++it) {
- if (QObject* object = it->object()) { // Might have been deleted in the meantime
- const PropertyHelper::Value newValue = function(*it);
- updateMask |= it->updateMask();
+ PropertyHelper *ph = it->data();
+ if (QObject* object = ph->object()) { // Might have been deleted in the meantime
+ const PropertyHelper::Value newValue = function( *ph );
+ updateMask |= ph->updateMask();
// Update property editor if it is the current object
if (!updatedPropertyEditor && propertyEditor && object == propertyEditor->object()) {
propertyEditor->setPropertyValue(propertyName, newValue.first, newValue.second);
@@ -1084,9 +1093,11 @@ template <class PropertyListIterator, class Function>
unsigned PropertyListCommand::setValue(QVariant value, bool changed, unsigned subPropertyMask)
{
if(debugPropertyCommands)
- qDebug() << "PropertyListCommand::setValue(" << value << changed << subPropertyMask << ')';
+ qDebug() << "PropertyListCommand::setValue(" << value
+ << changed << subPropertyMask << ')';
return changePropertyList(formWindow()->core(),
- m_propertyDescription.m_propertyName, m_propertyHelperList.begin(), m_propertyHelperList.end(),
+ m_propertyDescription.m_propertyName,
+ m_propertyHelperList.begin(), m_propertyHelperList.end(),
SetValueFunction(formWindow(), PropertyHelper::Value(value, changed), subPropertyMask));
}
@@ -1146,15 +1157,16 @@ bool PropertyListCommand::canMergeLists(const PropertyHelperList& other) const
if (m_propertyHelperList.size() != other.size())
return false;
for (int i = 0; i < m_propertyHelperList.size(); i++) {
- if (!m_propertyHelperList[i].canMerge(other[i]))
+ if (!m_propertyHelperList.at(i)->canMerge(*other.at(i)))
return false;
}
return true;
}
// ---- SetPropertyCommand ----
-SetPropertyCommand::SetPropertyCommand(QDesignerFormWindowInterface *formWindow)
- : PropertyListCommand(formWindow),
+SetPropertyCommand::SetPropertyCommand(QDesignerFormWindowInterface *formWindow,
+ QUndoCommand *parent)
+ : PropertyListCommand(formWindow, parent),
m_subPropertyMask(SubPropertyAll)
{
}
@@ -1210,7 +1222,7 @@ unsigned SetPropertyCommand::subPropertyMask(const QVariant &newValue, QObject *
void SetPropertyCommand::setDescription()
{
if (propertyHelperList().size() == 1) {
- setText(QApplication::translate("Command", "Changed '%1' of '%2'").arg(propertyName()).arg(propertyHelperList()[0].object()->objectName()));
+ setText(QApplication::translate("Command", "Changed '%1' of '%2'").arg(propertyName()).arg(propertyHelperList().at(0)->object()->objectName()));
} else {
int count = propertyHelperList().size();
setText(QApplication::translate("Command", "Changed '%1' of %n objects", "", QCoreApplication::UnicodeUTF8, count).arg(propertyName()));
@@ -1231,6 +1243,11 @@ int SetPropertyCommand::id() const
return 1976;
}
+QVariant SetPropertyCommand::mergeValue(const QVariant &newValue)
+{
+ return newValue;
+}
+
bool SetPropertyCommand::mergeWith(const QUndoCommand *other)
{
if (id() != other->id() || !formWindow()->isDirty())
@@ -1248,7 +1265,10 @@ bool SetPropertyCommand::mergeWith(const QUndoCommand *other)
!canMergeLists(cmd->propertyHelperList()))
return false;
- m_newValue = cmd->newValue();
+ const QVariant newValue = mergeValue(cmd->newValue());
+ if (!newValue.isValid())
+ return false;
+ m_newValue = newValue;
m_subPropertyMask |= cmd->m_subPropertyMask;
if(debugPropertyCommands)
qDebug() << "SetPropertyCommand::mergeWith() succeeded " << propertyName();
@@ -1289,7 +1309,7 @@ bool ResetPropertyCommand::init(const ObjectList &list, const QString &aproperty
void ResetPropertyCommand::setDescription()
{
if (propertyHelperList().size() == 1) {
- setText(QApplication::translate("Command", "Reset '%1' of '%2'").arg(propertyName()).arg(propertyHelperList()[0].object()->objectName()));
+ setText(QApplication::translate("Command", "Reset '%1' of '%2'").arg(propertyName()).arg(propertyHelperList().at(0)->object()->objectName()));
} else {
int count = propertyHelperList().size();
setText(QApplication::translate("Command", "Reset '%1' of %n objects", "", QCoreApplication::UnicodeUTF8, count).arg(propertyName()));
diff --git a/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h b/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h
index f6b7262..75b23ca 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h
@@ -58,6 +58,7 @@
#include <QtCore/QVariant>
#include <QtCore/QList>
#include <QtCore/QPair>
+#include <QtCore/QSharedPointer>
QT_BEGIN_NAMESPACE
@@ -77,11 +78,12 @@ enum SpecialProperty {
//Determine special property
enum SpecialProperty getSpecialProperty(const QString& propertyName);
-
// A helper class for applying properties to objects.
// Can be used for Set commands (setValue(), restoreOldValue()) or
// Reset Commands restoreDefaultValue(), restoreOldValue()).
-class PropertyHelper {
+//
+class QDESIGNER_SHARED_EXPORT PropertyHelper {
+ Q_DISABLE_COPY(PropertyHelper)
public:
// A pair of Value and changed flag
typedef QPair<QVariant, bool> Value;
@@ -92,11 +94,13 @@ public:
SpecialProperty specialProperty,
QDesignerPropertySheetExtension *sheet,
int index);
+ virtual ~PropertyHelper() {}
QObject *object() const { return m_object; }
SpecialProperty specialProperty() const { return m_specialProperty; }
- // set a new value
- Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask);
+ // set a new value. Can be overwritten to perform a transformation (see
+ // handling of Arrow key move in FormWindow class).
+ virtual Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask);
// restore old value
Value restoreOldValue(QDesignerFormWindowInterface *fw);
@@ -147,7 +151,7 @@ class QDESIGNER_SHARED_EXPORT PropertyListCommand : public QDesignerFormWindowCo
public:
typedef QList<QObject *> ObjectList;
- explicit PropertyListCommand(QDesignerFormWindowInterface *formWindow);
+ explicit PropertyListCommand(QDesignerFormWindowInterface *formWindow, QUndoCommand *parent = 0);
QObject* object(int index = 0) const;
@@ -159,8 +163,8 @@ public:
virtual void undo();
protected:
- typedef QList<PropertyHelper> PropertyHelperList;
-
+ typedef QSharedPointer<PropertyHelper> PropertyHelperPtr;
+ typedef QList<PropertyHelperPtr> PropertyHelperList;
// add an object
bool add(QObject *object, const QString &propertyName);
@@ -204,6 +208,10 @@ protected:
};
const PropertyDescription &propertyDescription() const { return m_propertyDescription; }
+protected:
+ virtual PropertyHelper *createPropertyHelper(QObject *o, SpecialProperty sp,
+ QDesignerPropertySheetExtension *sheet, int sheetIndex) const;
+
private:
PropertyDescription m_propertyDescription;
PropertyHelperList m_propertyHelperList;
@@ -215,7 +223,7 @@ class QDESIGNER_SHARED_EXPORT SetPropertyCommand: public PropertyListCommand
public:
typedef QList<QObject *> ObjectList;
- explicit SetPropertyCommand(QDesignerFormWindowInterface *formWindow);
+ explicit SetPropertyCommand(QDesignerFormWindowInterface *formWindow, QUndoCommand *parent = 0);
bool init(QObject *object, const QString &propertyName, const QVariant &newValue);
bool init(const ObjectList &list, const QString &propertyName, const QVariant &newValue,
@@ -232,6 +240,10 @@ public:
bool mergeWith(const QUndoCommand *other);
virtual void redo();
+
+protected:
+ virtual QVariant mergeValue(const QVariant &newValue);
+
private:
unsigned subPropertyMask(const QVariant &newValue, QObject *referenceObject);
void setDescription();
diff --git a/tools/designer/src/lib/shared/qdesigner_propertyeditor.cpp b/tools/designer/src/lib/shared/qdesigner_propertyeditor.cpp
index e89c47c..9a1739e 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertyeditor.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_propertyeditor.cpp
@@ -92,7 +92,8 @@ static const PropertyNameTypeMap &stringPropertyTypes()
}
QDesignerPropertyEditor::QDesignerPropertyEditor(QWidget *parent, Qt::WindowFlags flags) :
- QDesignerPropertyEditorInterface(parent, flags)
+ QDesignerPropertyEditorInterface(parent, flags),
+ m_propertyChangedForwardingBlocked(false)
{
// Make old signal work for compatibility
connect(this, SIGNAL(propertyChanged(QString,QVariant)), this, SLOT(slotPropertyChanged(QString,QVariant)));
@@ -147,9 +148,20 @@ QDesignerPropertyEditor::StringPropertyParameters QDesignerPropertyEditor::textP
return StringPropertyParameters(ValidationSingleLine, true);
}
+void QDesignerPropertyEditor::emitPropertyValueChanged(const QString &name, const QVariant &value, bool enableSubPropertyHandling)
+{
+ // Avoid duplicate signal emission - see below
+ m_propertyChangedForwardingBlocked = true;
+ emit propertyValueChanged(name, value, enableSubPropertyHandling);
+ emit propertyChanged(name, value);
+ m_propertyChangedForwardingBlocked = false;
+}
+
void QDesignerPropertyEditor::slotPropertyChanged(const QString &name, const QVariant &value)
{
- emit propertyValueChanged(name, value, true);
+ // Forward signal from Integration using the old interfaces.
+ if (!m_propertyChangedForwardingBlocked)
+ emit propertyValueChanged(name, value, true);
}
}
diff --git a/tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h b/tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h
index cdd53f0..27078f2 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h
@@ -79,7 +79,6 @@ public:
static StringPropertyParameters textPropertyValidationMode(QDesignerFormEditorInterface *core,
const QObject *object, const QString &propertyName, bool isMainContainer);
-
Q_SIGNALS:
void propertyValueChanged(const QString &name, const QVariant &value, bool enableSubPropertyHandling);
void resetProperty(const QString &name);
@@ -97,6 +96,13 @@ public Q_SLOTS:
private Q_SLOTS:
void slotPropertyChanged(const QString &name, const QVariant &value);
+
+protected:
+ void emitPropertyValueChanged(const QString &name, const QVariant &value, bool enableSubPropertyHandling);
+
+private:
+ bool m_propertyChangedForwardingBlocked;
+
};
} // namespace qdesigner_internal
diff --git a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
index b4b962c..086f46d 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp
@@ -271,6 +271,7 @@ bool QDesignerPropertySheetPrivate::isReloadableProperty(int index) const
{
return isResourceProperty(index)
|| propertyType(index) == QDesignerPropertySheet::PropertyStyleSheet
+ || propertyType(index) == QDesignerPropertySheet::PropertyText
|| q->property(index).type() == QVariant::Url;
}
@@ -549,6 +550,7 @@ QDesignerPropertySheet::PropertyType QDesignerPropertySheet::propertyTypeFromNam
propertyTypeHash.insert(QLatin1String("windowModality"), PropertyWindowModality);
propertyTypeHash.insert(QLatin1String("windowModified"), PropertyWindowModified);
propertyTypeHash.insert(QLatin1String("styleSheet"), PropertyStyleSheet);
+ propertyTypeHash.insert(QLatin1String("text"), PropertyText);
}
return propertyTypeHash.value(name, PropertyNone);
}
@@ -610,8 +612,9 @@ QDesignerPropertySheet::QDesignerPropertySheet(QObject *object, QObject *parent)
createFakeProperty(QLatin1String("whatsThis"));
createFakeProperty(QLatin1String("acceptDrops"));
createFakeProperty(QLatin1String("dragEnabled"));
- // windowModality is visible only for the main container, in which case the form windows enables it on loading
+ // windowModality/Opacity is visible only for the main container, in which case the form windows enables it on loading
setVisible(createFakeProperty(QLatin1String("windowModality")), false);
+ setVisible(createFakeProperty(QLatin1String("windowOpacity"), double(1.0)), false);
if (qobject_cast<const QToolBar *>(d->m_object)) { // prevent toolbars from being dragged off
createFakeProperty(QLatin1String("floatable"), QVariant(true));
} else {
@@ -690,6 +693,10 @@ bool QDesignerPropertySheet::dynamicPropertiesAllowed() const
bool QDesignerPropertySheet::canAddDynamicProperty(const QString &propName) const
{
+ // used internally
+ if (propName == QLatin1String("database") ||
+ propName == QLatin1String("buttonGroupId"))
+ return false;
const int index = d->m_meta->indexOfProperty(propName);
if (index != -1)
return false; // property already exists and is not a dynamic one
@@ -719,10 +726,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<QKeySequence>(value);
+ v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence));
+ }
if (d->m_addIndex.contains(propName)) {
const int idx = d->m_addIndex.value(propName);
@@ -1127,7 +1135,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))
@@ -1197,10 +1205,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<QKeySequence>(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()) {
@@ -1451,8 +1466,13 @@ bool QDesignerPropertySheet::isVisible(int index) const
}
if (isFakeProperty(index)) {
- if (type == PropertyWindowModality) // Hidden for child widgets
+ switch (type) {
+ case PropertyWindowModality: // Hidden for child widgets
+ case PropertyWindowOpacity:
return d->m_info.value(index).visible;
+ default:
+ break;
+ }
return true;
}
diff --git a/tools/designer/src/lib/shared/qdesigner_propertysheet_p.h b/tools/designer/src/lib/shared/qdesigner_propertysheet_p.h
index 9db7367..0105eac 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertysheet_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_propertysheet_p.h
@@ -176,7 +176,8 @@ public:
PropertyWindowIconText,
PropertyWindowModality,
PropertyWindowModified,
- PropertyStyleSheet
+ PropertyStyleSheet,
+ PropertyText
};
enum ObjectType { ObjectNone, ObjectLabel, ObjectLayout, ObjectLayoutWidget, ObjectQ3GroupBox };
diff --git a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
index 02a2f6d..e3bc64c 100644
--- a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
@@ -467,6 +467,7 @@ QRect ToolBarEventFilter::freeArea(const QToolBar *tb)
switch (tb->orientation()) {
case Qt::Horizontal:
switch (tb->layoutDirection()) {
+ case Qt::LayoutDirectionAuto: // Should never happen
case Qt::LeftToRight:
rc.setX(exclusionRectangle.right() + 1);
break;
diff --git a/tools/designer/src/lib/shared/qtresourcemodel.cpp b/tools/designer/src/lib/shared/qtresourcemodel.cpp
index 709f389..e3fc805 100644
--- a/tools/designer/src/lib/shared/qtresourcemodel.cpp
+++ b/tools/designer/src/lib/shared/qtresourcemodel.cpp
@@ -428,10 +428,10 @@ void QtResourceModelPrivate::removeOldPaths(QtResourceSet *resourceSet, const QS
void QtResourceModelPrivate::setWatcherEnabled(const QString &path, bool enable)
{
- m_fileWatcher->removePath(path);
-
- if (!enable)
+ if (!enable) {
+ m_fileWatcher->removePath(path);
return;
+ }
QFileInfo fi(path);
if (fi.exists())
diff --git a/tools/designer/src/lib/shared/qtresourceview.cpp b/tools/designer/src/lib/shared/qtresourceview.cpp
index c15942f..18fd07b 100644
--- a/tools/designer/src/lib/shared/qtresourceview.cpp
+++ b/tools/designer/src/lib/shared/qtresourceview.cpp
@@ -377,7 +377,8 @@ void QtResourceViewPrivate::createPaths()
if (!m_resourceModel)
return;
- const QString root(QLatin1Char(':'));
+ // Resource root up until 4.6 was ':', changed to ":/" as of 4.7
+ const QString root(QLatin1String(":/"));
QMap<QString, QString> contents = m_resourceModel->contents();
QMapIterator<QString, QString> itContents(contents);
@@ -420,7 +421,7 @@ void QtResourceViewPrivate::filterOutResources()
// 3) we hide these items which has pathToVisible value false.
const bool matchAll = m_filterPattern.isEmpty();
- const QString root(QLatin1Char(':'));
+ const QString root(QLatin1String(":/"));
QQueue<QString> pathQueue;
pathQueue.enqueue(root);
@@ -664,6 +665,8 @@ QString QtResourceView::selectedResource() const
void QtResourceView::selectResource(const QString &resource)
{
+ if (resource.isEmpty())
+ return;
QFileInfo fi(resource);
QDir dir = fi.absoluteDir();
if (fi.isDir())
diff --git a/tools/designer/src/lib/shared/shared.pri b/tools/designer/src/lib/shared/shared.pri
index 570b208..8286360 100644
--- a/tools/designer/src/lib/shared/shared.pri
+++ b/tools/designer/src/lib/shared/shared.pri
@@ -2,11 +2,11 @@
INCLUDEPATH += $$PWD
contains(QT_CONFIG, script): QT += script
-include($$QT_SOURCE_TREE/tools/shared/qtpropertybrowser/qtpropertybrowser.pri)
-include($$QT_SOURCE_TREE/tools/shared/deviceskin/deviceskin.pri)
-include($$QT_SOURCE_TREE/src/tools/rcc/rcc.pri)
-include($$QT_SOURCE_TREE/tools/shared/findwidget/findwidget.pri)
-include($$QT_SOURCE_TREE/tools/shared/qtgradienteditor/qtgradienteditor.pri)
+include(../../../../shared/qtpropertybrowser/qtpropertybrowser.pri)
+include(../../../../shared/deviceskin/deviceskin.pri)
+include(../../../../../src/tools/rcc/rcc.pri)
+include(../../../../shared/findwidget/findwidget.pri)
+include(../../../../shared/qtgradienteditor/qtgradienteditor.pri)
# Input
FORMS += $$PWD/addlinkdialog.ui \
diff --git a/tools/designer/src/lib/shared/stylesheeteditor.cpp b/tools/designer/src/lib/shared/stylesheeteditor.cpp
index b76d700..e809447 100644
--- a/tools/designer/src/lib/shared/stylesheeteditor.cpp
+++ b/tools/designer/src/lib/shared/stylesheeteditor.cpp
@@ -79,6 +79,7 @@ StyleSheetEditor::StyleSheetEditor(QWidget *parent)
: QTextEdit(parent)
{
setTabStopWidth(fontMetrics().width(QLatin1Char(' '))*4);
+ setAcceptRichText(false);
new CssHighlighter(document());
}