aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2019-05-21 11:26:25 +0200
committerThomas Hartmann <thomas.hartmann@qt.io>2019-05-21 12:30:32 +0000
commita345fbb5b136fd91d6a58bffcdb314179613a819 (patch)
treeca8702942df62e931fe5bc3b4c351cf87ca86df6
parentbd2aa8ada387184b6ab1f995a54582ae60093c7d (diff)
QmlDesigner: Improve readability of names in the easingcurve editor
- Increased item size - Decreased font size - Changed text background color - Added tooltips - Elide text in the middle Task-number: QDS-394 Change-Id: Ia796bfb0fbf25bee3ad8d2dd7c697163607426a4 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r--src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.cpp28
-rw-r--r--src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.h4
2 files changed, 26 insertions, 6 deletions
diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.cpp b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.cpp
index 203da8bacd..4e6f9c9f17 100644
--- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.cpp
+++ b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.cpp
@@ -32,7 +32,6 @@
#include <QAbstractButton>
#include <QApplication>
#include <QContextMenuEvent>
-#include <QDebug>
#include <QMenu>
#include <QMessageBox>
#include <QPainter>
@@ -42,11 +41,12 @@
#include <QString>
#include <coreplugin/icore.h>
+#include <theme.h>
namespace QmlDesigner {
-constexpr int iconWidth = 64;
-constexpr int iconHeight = 64;
+constexpr int iconWidth = 86;
+constexpr int iconHeight = 86;
constexpr int itemFrame = 3;
constexpr int itemWidth = iconWidth + 2 * itemFrame;
constexpr int unsavedMarkSize = 18;
@@ -77,15 +77,15 @@ void PresetItemDelegate::paint(QPainter *painter,
auto textRect = QRect(option.rect.topLeft(), textSize);
textRect.moveBottom(option.rect.bottom());
- QFontMetrics fm(option.font);
- option.text = fm.elidedText(option.text, Qt::ElideRight, textRect.width());
+ option.font.setPixelSize(Theme::instance()->smallFontPixelSize());
+ painter->save();
painter->fillRect(option.rect, canvasBackground);
if (option.text.isEmpty())
painter->fillRect(textRect, canvasBackground);
else
- painter->fillRect(textRect, labelBackground);
+ painter->fillRect(textRect, Theme::instance()->qmlDesignerButtonColor());
style->drawControl(QStyle::CE_ItemViewItem, &option, painter, option.widget);
@@ -108,6 +108,7 @@ void PresetItemDelegate::paint(QPainter *painter,
painter->drawText(asteriskRect, Qt::AlignTop | Qt::AlignRight, "*");
}
}
+ painter->restore();
}
QSize PresetItemDelegate::sizeHint(const QStyleOptionViewItem &opt, const QModelIndex &index) const
@@ -185,6 +186,8 @@ PresetList::PresetList(QSettings::Scope scope, QWidget *parent)
setWrapping(true);
+ setTextElideMode(Qt::ElideMiddle);
+
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
}
@@ -278,6 +281,7 @@ void PresetList::readPresets()
auto *item = new QStandardItem(paintPreview(curves[i].curve()), curves[i].name());
item->setData(curveData, ItemRole_Data);
item->setEditable(m_scope == QSettings::UserScope);
+ item->setToolTip(curves[i].name());
simodel->setItem(i, item);
}
@@ -318,6 +322,7 @@ void PresetList::revert(const QModelIndex &index)
item->setData(false, ItemRole_Dirty);
item->setData(paintPreview(curve.curve()), Qt::DecorationRole);
item->setData(QVariant::fromValue(curve.curve()), ItemRole_Data);
+ item->setToolTip(name);
return;
}
}
@@ -357,6 +362,16 @@ void PresetList::contextMenuEvent(QContextMenuEvent *event)
menu.exec(event->globalPos());
}
+void PresetList::dataChanged(const QModelIndex &topLeft,
+ const QModelIndex &bottomRight,
+ const QVector<int> &roles)
+{
+ if (topLeft == bottomRight && roles.contains(0)) {
+ const QVariant name = model()->data(topLeft, 0);
+ model()->setData(topLeft, name, Qt::ToolTipRole);
+ }
+}
+
void PresetList::createItem()
{
EasingCurve curve;
@@ -368,6 +383,7 @@ void PresetList::createItem(const QString &name, const EasingCurve &curve)
{
auto *item = new QStandardItem(paintPreview(curve), name);
item->setData(QVariant::fromValue(curve), ItemRole_Data);
+ item->setToolTip(name);
int row = model()->rowCount();
qobject_cast<QStandardItemModel *>(model())->setItem(row, item);
diff --git a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.h b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.h
index e1907af99c..6fab3e7adb 100644
--- a/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.h
+++ b/src/plugins/qmldesigner/qmldesignerextension/timelineeditor/preseteditor.h
@@ -99,6 +99,10 @@ public:
protected:
void contextMenuEvent(QContextMenuEvent *event) override;
+ void dataChanged(const QModelIndex &topLeft,
+ const QModelIndex &bottomRight,
+ const QVector<int> &roles = QVector<int>()) override;
+
private:
QStringList allNames() const;