aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2023-01-13 17:27:53 +0100
committerThomas Hartmann <thomas.hartmann@qt.io>2023-01-16 16:38:42 +0000
commit17cec4609c2687fc3af75fc8e6722785539db4bc (patch)
tree1dc10658b1cac3ebce5518ffa542bd00be49eccc
parente74dd74ee8a0acf63350c5fcc5d5bc34c287ef2d (diff)
Call the feedback dialog from the QmlDesigner
This makes maintenance of the UI simpler. Removing the QML UI from usagestatistics. Change-Id: Ic623b83bbabf1e0bbf2f2eceb92a2c2466475666 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r--src/datasources/qmldesignerusageeventsource.cpp69
-rw-r--r--src/datasources/qmldesignerusageeventsource.h3
-rw-r--r--src/images/star_empty.pngbin876 -> 0 bytes
-rw-r--r--src/images/star_empty@2x.pngbin1688 -> 0 bytes
-rw-r--r--src/images/star_filled.pngbin669 -> 0 bytes
-rw-r--r--src/images/star_filled@2x.pngbin1246 -> 0 bytes
-rw-r--r--src/ui/FeedbackPopup.qml158
-rw-r--r--src/usagestatistic.qrc5
8 files changed, 25 insertions, 210 deletions
diff --git a/src/datasources/qmldesignerusageeventsource.cpp b/src/datasources/qmldesignerusageeventsource.cpp
index 06fc090..e411111 100644
--- a/src/datasources/qmldesignerusageeventsource.cpp
+++ b/src/datasources/qmldesignerusageeventsource.cpp
@@ -66,10 +66,21 @@ QmlDesignerUsageEventSource::QmlDesignerUsageEventSource()
SIGNAL(usageStatisticsNotifier(QString)),
this,
SLOT(handleUsageStatisticsNotifier(QString)));
+
+ connect(qmlDesignerPlugin,
+ SIGNAL(usageStatisticsUsageTimer(QString, int)),
+ this,
+ SLOT(handleUsageStatisticsUsageTimer(QString, int)));
+
connect(qmlDesignerPlugin,
- SIGNAL(usageStatisticsUsageTimer(QString,int)),
+ SIGNAL(usageStatisticsInsertFeedback(QString, QString, int)),
this,
- SLOT(handleUsageStatisticsUsageTimer(QString,int)));
+ SLOT(insertFeedback(QString, QString, int)));
+
+ connect(this,
+ SIGNAL(launchPopup(QString)),
+ qmlDesignerPlugin,
+ SLOT(lauchFeedbackPopup(QString)));
}
}
@@ -88,36 +99,14 @@ void QmlDesignerUsageEventSource::closeFeedbackPopup()
m_feedbackWidget->deleteLater();
}
-void QmlDesignerUsageEventSource::insertFeedback(const QString &feedback, int rating)
+void QmlDesignerUsageEventSource::insertFeedback(const QString &identifier,
+ const QString &feedback,
+ int rating)
{
if (!feedback.isEmpty())
- m_feedbackTextData.insert(currentIdentifier, feedback);
+ m_feedbackTextData.insert(identifier, feedback);
- m_feedbackRatingData.insert(currentIdentifier, rating);
-}
-
-void QmlDesignerUsageEventSource::launchPopup(const QString &identifier)
-{
- currentIdentifier = identifier;
-
- if (!m_feedbackWidget) {
- m_feedbackWidget = new QQuickWidget(Core::ICore::dialogParent());
- m_feedbackWidget->setSource(QUrl("qrc:/usagestatistic/ui/FeedbackPopup.qml"));
- m_feedbackWidget->setWindowModality(Qt::ApplicationModal);
- m_feedbackWidget->setWindowFlags(Qt::SplashScreen);
- m_feedbackWidget->setAttribute(Qt::WA_DeleteOnClose);
-
- QQuickItem *root = m_feedbackWidget->rootObject();
- QObject *title = root->findChild<QObject *>("title");
- QString name = tr("Enjoying %1?").arg(identifier);
- title->setProperty("text", name);
-
- QObject::connect(root, SIGNAL(submitFeedback(QString,int)),
- this, SLOT(insertFeedback(QString,int)));
- QObject::connect(root, SIGNAL(closeClicked()), this, SLOT(closeFeedbackPopup()));
- }
-
- m_feedbackWidget->show();
+ m_feedbackRatingData.insert(identifier, rating);
}
void QmlDesignerUsageEventSource::handleUsageStatisticsNotifier(const QString &identifier)
@@ -132,28 +121,16 @@ void QmlDesignerUsageEventSource::handleUsageStatisticsNotifier(const QString &i
void QmlDesignerUsageEventSource::handleUsageStatisticsUsageTimer(const QString &identifier, int elapsed)
{
+
auto it = m_timeData.find(identifier);
if (it != m_timeData.end()) {
it.value() = it.value().toInt() + elapsed;
- // Show the user feedback prompt after time limit is passed
- static const QSet<QString> supportedViews{"formEditor",
- "3DEditor",
- "statesEditor,",
- "timeline",
- "itemLibrary",
- "assetsLibrary",
- "transitionEditor",
- "curveEditor",
- "propertyEditor",
- "textEditor",
- "materialBrowser",
- "navigatorView"};
- static const int timeLimit = 864'000'00; // 1 day
- if (supportedViews.contains(identifier) && !m_feedbackPoppedData[identifier].toBool()
- && m_timeData.value(identifier).toInt() >= timeLimit) {
- launchPopup(identifier);
+ static const int timeLimit = 14400000; // 4 hours
+ if (!m_feedbackPoppedData[identifier].toBool()
+ && m_timeData.value(identifier).toInt() >= timeLimit) {
+ emit launchPopup(identifier);
m_feedbackPoppedData[identifier] = QVariant(true);
}
} else {
diff --git a/src/datasources/qmldesignerusageeventsource.h b/src/datasources/qmldesignerusageeventsource.h
index 9843555..5003175 100644
--- a/src/datasources/qmldesignerusageeventsource.h
+++ b/src/datasources/qmldesignerusageeventsource.h
@@ -51,12 +51,13 @@ public:
void storeImpl(QSettings *settings) override;
void resetImpl(QSettings *settings) override;
+signals:
void launchPopup(const QString &identifier); // launch user feedback popup
public slots:
void handleUsageStatisticsNotifier(const QString &identifier);
void handleUsageStatisticsUsageTimer(const QString &identifier, int elapsed);
- void insertFeedback(const QString &feedback, int rating);
+ void insertFeedback(const QString &identifier, const QString &feedback, int rating);
void closeFeedbackPopup();
private:
diff --git a/src/images/star_empty.png b/src/images/star_empty.png
deleted file mode 100644
index 3ea5966..0000000
--- a/src/images/star_empty.png
+++ /dev/null
Binary files differ
diff --git a/src/images/star_empty@2x.png b/src/images/star_empty@2x.png
deleted file mode 100644
index a06ef89..0000000
--- a/src/images/star_empty@2x.png
+++ /dev/null
Binary files differ
diff --git a/src/images/star_filled.png b/src/images/star_filled.png
deleted file mode 100644
index 0180fde..0000000
--- a/src/images/star_filled.png
+++ /dev/null
Binary files differ
diff --git a/src/images/star_filled@2x.png b/src/images/star_filled@2x.png
deleted file mode 100644
index 2d8be01..0000000
--- a/src/images/star_filled@2x.png
+++ /dev/null
Binary files differ
diff --git a/src/ui/FeedbackPopup.qml b/src/ui/FeedbackPopup.qml
deleted file mode 100644
index a8b5455..0000000
--- a/src/ui/FeedbackPopup.qml
+++ /dev/null
@@ -1,158 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of UsageStatistic plugin for Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-import QtQuick 2.15
-import QtQuick.Controls 2.15
-import QtQuick.Window 2.15
-
-Rectangle {
- id: root_rectangle
-
- property int rating: 0
-
- signal submitFeedback(string feedback, int rating)
- signal closeClicked()
-
- width: 740
- height: 382
- border { color: "#0094ce"; width: 1 }
-
- Text {
- id: h1
- objectName: "title"
- color: "#333333"
- text: "Enjoying Qt Design Studio?"
- font { family: "Titillium"; capitalization: Font.AllUppercase; pixelSize: 21 }
- anchors { horizontalCenter: parent.horizontalCenter; top: parent.top; topMargin: 50 }
- }
-
- Text {
- id: h2
- color: "#333333"
- text: "Tap a star to rate the usefulness of the feature"
- font { family: "Titillium"; pixelSize: 21 }
- anchors { horizontalCenter: parent.horizontalCenter; top: h1.bottom; topMargin: 12 }
- }
-
- Row {
- id: starRow
- width: 246; height: 42; spacing: 6.5
- anchors { horizontalCenter: parent.horizontalCenter; top: h2.bottom; topMargin: 32 }
-
- Repeater { // create the stars
- id: rep
- model: 5
- Image {
- source: "../images/star_empty.png"
- fillMode: Image.PreserveAspectFit
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- for (var i = 0; i < 5; ++i) {
- rep.itemAt(i).source = i <= index ? "../images/star_filled.png"
- : "../images/star_empty.png"
- }
- rating = index + 1
- }
- }
- }
- }
- }
-
- ScrollView {
- id: scroll_textarea
- width: 436
- height: 96
- anchors { horizontalCenter: parent.horizontalCenter; top: starRow.bottom; topMargin: 28 }
-
- TextArea {
- id: textarea
- width: 426
- height: 90
- color: "#333333";
- placeholderText: "We highly appreciate additional feedback.\nBouquets or Brickbats, suggestions, all welcome!"
- font { pixelSize: 14; family: "Titillium" }
- wrapMode: Text.Wrap
- }
-
- background: Rectangle {
- border { color: "#e6e6e6"; width: 1 }
- }
- }
-
- Row {
- id: buttonRow
- anchors { horizontalCenter: parent.horizontalCenter; top: scroll_textarea.bottom; topMargin: 28 }
- spacing: 10
-
- Button {
- id: buttonSkip
- width: 80
- height: 28
-
- contentItem: Text {
- text: "Skip"
- color: parent.hovered ? Qt.darker("#999999", 1.9) : Qt.darker("#999999", 1.2)
- font { family: "Titillium"; pixelSize: 14 }
- horizontalAlignment: Text.AlignHCenter
- }
-
- background: Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- border { color: "#999999"; width: 1 }
- }
-
- onClicked: root_rectangle.closeClicked()
- }
-
- Button {
- id: buttonSubmit
-
- width: 80
- height: 28
- enabled: rating > 0
-
- contentItem: Text {
- text: "Submit";
- color: enabled ? "white" : Qt.lighter("#999999", 1.3)
- font { family: "Titillium"; pixelSize: 14 }
- horizontalAlignment: Text.AlignHCenter
- }
-
- background: Rectangle {
- anchors.fill: parent
- color: enabled ? parent.hovered ? Qt.lighter("#0094ce", 1.2) : "#0094ce" : "white"
- border { color: enabled ? "#999999" : Qt.lighter("#999999", 1.3); width: 1 }
- }
-
- onClicked: {
- root_rectangle.submitFeedback(textarea.text, rating);
- root_rectangle.closeClicked();
- }
- }
- }
-}
diff --git a/src/usagestatistic.qrc b/src/usagestatistic.qrc
index f0b34f8..8ab02df 100644
--- a/src/usagestatistic.qrc
+++ b/src/usagestatistic.qrc
@@ -2,10 +2,5 @@
<qresource prefix="/usagestatistic">
<file>images/settingscategory_usagestatistic.png</file>
<file>images/settingscategory_usagestatistic@2x.png</file>
- <file>images/star_empty.png</file>
- <file>images/star_empty@2x.png</file>
- <file>images/star_filled.png</file>
- <file>images/star_filled@2x.png</file>
- <file>ui/FeedbackPopup.qml</file>
</qresource>
</RCC>