diff options
author | Eike Ziller <eike.ziller@qt.io> | 2019-12-06 08:52:58 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2019-12-06 08:52:58 +0100 |
commit | 9b2d1a8c7440d60226d9bef1c2b05b23f172256f (patch) | |
tree | d9a2e2c671f2351d754d74614537b7ba68379982 | |
parent | ce2efcf29baf75d81da16a720066d2ec00529329 (diff) | |
parent | 3abd2d15c1130fedf3e57abbcf7120d831140908 (diff) |
Merge remote-tracking branch 'origin/4.11'
Change-Id: If40f5b353999e0c3910c9c6b5ccc3dccd79404ec
-rw-r--r-- | .gitmodules | 3 | ||||
m--------- | 3rdparty/extra-cmake-modules | 0 | ||||
-rw-r--r-- | CMakeLists.txt | 63 | ||||
-rw-r--r-- | src/CMakeLists.txt | 37 | ||||
-rw-r--r-- | src/datasources/qmldesignerusagetimesource.cpp | 2 | ||||
-rw-r--r-- | src/src.pro | 4 | ||||
-rw-r--r-- | src/ui/encouragementwidget.cpp | 101 | ||||
-rw-r--r-- | src/ui/encouragementwidget.h | 69 | ||||
-rw-r--r-- | src/ui/outputpane.cpp | 121 | ||||
-rw-r--r-- | src/ui/outputpane.h | 95 | ||||
-rw-r--r-- | src/usagestatisticconstants.h | 2 | ||||
-rw-r--r-- | src/usagestatisticplugin.cpp | 85 | ||||
-rw-r--r-- | src/usagestatisticplugin.h | 6 |
13 files changed, 173 insertions, 415 deletions
diff --git a/.gitmodules b/.gitmodules index 0a464e5..8a90637 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "3rdparty/kuserfeedback"] path = 3rdparty/kuserfeedback url = https://git.qt.io/aportale/kuserfeedback.git +[submodule "3rdparty/extra-cmake-modules"] + path = 3rdparty/extra-cmake-modules + url = https://github.com/KDE/extra-cmake-modules.git diff --git a/3rdparty/extra-cmake-modules b/3rdparty/extra-cmake-modules new file mode 160000 +Subproject fd6e98ba6de89a7f08364bb2ec096a5310c1cde diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..895425d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 3.9) + +project(plugin-telemetry) + +include(ExternalProject) + +# Set common CMAKE_PREFIX_PATH/ CMAKE_PREFIX_PATH_ALT_SEP +# that can be forwarded to external projects +list(APPEND CMAKE_PREFIX_PATH + ${CMAKE_CURRENT_BINARY_DIR}/extra-cmake-modules + ${CMAKE_CURRENT_BINARY_DIR}/kuserfeedback) +string(REPLACE ";" "|" CMAKE_PREFIX_PATH_ALT_SEP "${CMAKE_PREFIX_PATH}") + +ExternalProject_Add(extra-cmake-modules + PREFIX extra-cmake-modules + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/extra-cmake-modules" + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/extra-cmake-modules +) + +set(KUSERFEEDBACK_COMPONENTS + -DBUILD_SHARED_LIBS=OFF + -DENABLE_SURVEY_TARGET_EXPRESSIONS=OFF + -DENABLE_PHP=OFF + -DENABLE_PHP_UNIT=OFF + -DENABLE_TESTING=OFF + -DENABLE_DOCS=OFF + -DENABLE_CONSOLE=OFF + -DENABLE_CLI=OFF + -DBUILD_SHARED_LIBS=OFF +) + +ExternalProject_Add(kuserfeedback + PREFIX kuserfeedback + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/kuserfeedback" + LIST_SEPARATOR | + CMAKE_ARGS + ${KUSERFEEDBACK_DEFINES} + ${KUSERFEEDBACK_COMPONENTS} + -DKDE_INSTALL_LIBDIR=lib + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP} + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/kuserfeedback + DEPENDS extra-cmake-modules +) + +if(NOT DEFINED USP_SERVER_URL OR NOT DEFINED USP_AUTH_KEY) + message(WARNING "Collected data won't be sent +Define both USP_SERVER_URL and USP_AUTH_KEY to enable data submission") +endif() + +ExternalProject_Add(plugin + PREFIX plugin + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src" + LIST_SEPARATOR | + CMAKE_ARGS + -DUSP_AUTH_KEY=${USP_AUTH_KEY} + -DUSP_SERVER_URL=${USP_SERVER_URL} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP} + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + DEPENDS kuserfeedback +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..533dc4e --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.9) + +project(UsageStatistic) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_CXX_STANDARD 14) + +find_package(QtCreator COMPONENTS Core TextEditor ProjectExplorer VcsBase REQUIRED) +find_package(Qt5 COMPONENTS Widgets REQUIRED) +find_package(KUserFeedback REQUIRED) + +add_qtc_plugin(UsageStatistic + PLUGIN_DEPENDS + QtCreator::Core QtCreator::Debugger QtCreator::ProjectExplorer QtCreator::QtSupport + DEPENDS Qt5::Widgets QtCreator::ExtensionSystem QtCreator::Utils KUserFeedbackCore KUserFeedbackWidgets + SOURCES + usagestatisticplugin.cpp + datasources/qtclicensesource.cpp + datasources/buildcountsource.cpp + common/scopedsettingsgroupsetter.cpp + datasources/buildsystemsource.cpp + datasources/timeusagesourcebase.cpp + datasources/modeusagetimesource.cpp + datasources/examplesdatasource.cpp + datasources/kitsource.cpp + datasources/qmldesignerusagetimesource.cpp + datasources/servicesource.cpp + ui/usagestatisticpage.cpp + ui/usagestatisticwidget.cpp + services/datasubmitter.cpp + usagestatistic.qrc + DEFINES + USP_AUTH_KEY="${USP_AUTH_KEY}" + USP_SERVER_URL="${USP_SERVER_URL}" +) diff --git a/src/datasources/qmldesignerusagetimesource.cpp b/src/datasources/qmldesignerusagetimesource.cpp index 5859345..fdc1b91 100644 --- a/src/datasources/qmldesignerusagetimesource.cpp +++ b/src/datasources/qmldesignerusagetimesource.cpp @@ -76,7 +76,7 @@ static bool isDesignMode(const QString &modeName) static bool editingQmlFile() { - static const QSet<QString> validExtentions = {"qml", "qml.ui"}; + static const QList<QString> validExtentions = {"qml", "ui.qml"}; static const QString validMimeType = "qml"; if (auto document = Core::EditorManager::currentDocument()) { diff --git a/src/src.pro b/src/src.pro index 897f53c..6e8f16c 100644 --- a/src/src.pro +++ b/src/src.pro @@ -24,8 +24,6 @@ SOURCES += \ datasources/qmldesignerusagetimesource.cpp \ ui/usagestatisticpage.cpp \ ui/usagestatisticwidget.cpp \ - ui/outputpane.cpp \ - ui/encouragementwidget.cpp \ services/datasubmitter.cpp HEADERS += \ @@ -44,8 +42,6 @@ HEADERS += \ datasources/qmldesignerusagetimesource.h \ ui/usagestatisticpage.h \ ui/usagestatisticwidget.h \ - ui/outputpane.h \ - ui/encouragementwidget.h \ services/datasubmitter.h \ common/utils.h diff --git a/src/ui/encouragementwidget.cpp b/src/ui/encouragementwidget.cpp deleted file mode 100644 index 457422e..0000000 --- a/src/ui/encouragementwidget.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company -** 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. -** -****************************************************************************/ -#include "encouragementwidget.h" -#include "ui_encouragementwidget.h" - -#include "coreplugin/icore.h" - -#include <KUserFeedback/FeedbackConfigUiController> - -#include "usagestatisticconstants.h" - -namespace UsageStatistic { -namespace Internal { - -using namespace KUserFeedback; - -EncouragementWidget::EncouragementWidget(QWidget *parent) - : QWidget(parent) - , ui(new Ui::EncouragementWidget) - , m_controller(std::make_unique<FeedbackConfigUiController>()) -{ - ui->setupUi(this); - - connect(this, &EncouragementWidget::providerChanged, - this, &EncouragementWidget::onProviderChanged); - connect(ui->pbOptions, &QPushButton::clicked, - this, &EncouragementWidget::showSettingsDialog); -} - -std::shared_ptr<Provider> EncouragementWidget::provider() const -{ - return m_provider; -} - -void EncouragementWidget::setProvider(std::shared_ptr<Provider> provider) -{ - m_provider = std::move(provider); - - Q_EMIT providerChanged(m_provider); -} - -void EncouragementWidget::showEvent(QShowEvent *event) -{ - updateMessage(); - QWidget::showEvent(event); -} - -void EncouragementWidget::showSettingsDialog() -{ - Core::ICore::showOptionsDialog(Constants::USAGE_STATISTIC_PAGE_ID, this); -} - -void EncouragementWidget::updateMessage() -{ - if (m_provider) { - auto modeIndex = m_controller->telemetryModeToIndex(m_provider->telemetryMode()); - - auto description = m_controller->telemetryModeDescription(modeIndex); - - auto modeName = m_controller->telemetryModeName(modeIndex); - description.prepend(tr("Telemetry mode: %1.\n").arg(modeName)); - - ui->lblMsg->setText(description); - } -} - -void EncouragementWidget::onProviderChanged(const std::shared_ptr<Provider> &p) -{ - m_controller->setFeedbackProvider(p.get()); - - connect(m_provider.get(), &Provider::telemetryModeChanged, - this, &EncouragementWidget::updateMessage); - updateMessage(); -} - -EncouragementWidget::~EncouragementWidget() = default; - -} // namespace Internal -} // namespace UsageStatistic diff --git a/src/ui/encouragementwidget.h b/src/ui/encouragementwidget.h deleted file mode 100644 index 6386a54..0000000 --- a/src/ui/encouragementwidget.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company -** 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. -** -****************************************************************************/ -#include <memory> - -#include <QWidget> - -namespace KUserFeedback { -class Provider; -class FeedbackConfigUiController; -} - -namespace UsageStatistic { -namespace Internal { - -namespace Ui { class EncouragementWidget; } - -//! Widget for displaying current telemetry level at the output pane -class EncouragementWidget : public QWidget -{ - Q_OBJECT - -public: - explicit EncouragementWidget(QWidget *parent = nullptr); - ~EncouragementWidget() override; - - std::shared_ptr<KUserFeedback::Provider> provider() const; - void setProvider(std::shared_ptr<KUserFeedback::Provider> provider); - -protected: // QWidget interface - void showEvent(QShowEvent *event) override; - -Q_SIGNALS: - void providerChanged(const std::shared_ptr<KUserFeedback::Provider> &); - -private Q_SLOTS: - void showSettingsDialog(); - void updateMessage(); - void onProviderChanged(const std::shared_ptr<KUserFeedback::Provider> &p); - -private: - QScopedPointer<Ui::EncouragementWidget> ui; - std::shared_ptr<KUserFeedback::Provider> m_provider; - std::unique_ptr<KUserFeedback::FeedbackConfigUiController> m_controller; -}; - -} // namespace Internal -} // namespace UsageStatistic diff --git a/src/ui/outputpane.cpp b/src/ui/outputpane.cpp deleted file mode 100644 index 3529ca3..0000000 --- a/src/ui/outputpane.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company -** 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. -** -****************************************************************************/ -#include "outputpane.h" - -#include <QtWidgets/QPushButton> -#include <QtWidgets/QHBoxLayout> -#include <QtCore/QDebug> - -#include "encouragementwidget.h" - -namespace UsageStatistic { -namespace Internal { - -OutputPane::OutputPane() = default; - -OutputPane::~OutputPane() = default; - -QWidget *OutputPane::outputWidget(QWidget *parent) -{ - if (!m_outputPaneWidget) { - createEncouragementWidget(parent); - } - - return m_outputPaneWidget; -} - -QList<QWidget *> OutputPane::toolBarWidgets() const -{ - return {}; -} - -QString OutputPane::displayName() const -{ - return tr("Feedback"); -} - -int OutputPane::priorityInStatusBar() const -{ - return 1; -} - -void OutputPane::clearContents() {} - -void OutputPane::visibilityChanged(bool /*visible*/) -{ -} - -void OutputPane::setFocus() {} - -bool OutputPane::hasFocus() const -{ - return false; -} - -bool OutputPane::canFocus() const -{ - return true; -} - -bool OutputPane::canNavigate() const -{ - return false; -} - -bool OutputPane::canNext() const -{ - return false; -} - -bool OutputPane::canPrevious() const -{ - return false; -} - -void OutputPane::goToNext() {} - -void OutputPane::goToPrev() {} - -void OutputPane::createEncouragementWidget(QWidget *parent) -{ - auto wgt = new EncouragementWidget(parent); - connect(this, &OutputPane::providerChanged, wgt, &EncouragementWidget::setProvider); - - m_outputPaneWidget = wgt; -} - -std::shared_ptr<KUserFeedback::Provider> OutputPane::provider() const -{ - return m_provider; -} - -void OutputPane::setProvider(std::shared_ptr<KUserFeedback::Provider> provider) -{ - m_provider = std::move(provider); - Q_EMIT providerChanged(m_provider); -} - -} // namespace Internal -} // namespace UsageStatistic diff --git a/src/ui/outputpane.h b/src/ui/outputpane.h deleted file mode 100644 index 039b3f2..0000000 --- a/src/ui/outputpane.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company -** 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. -** -****************************************************************************/ -#pragma once - -#include <memory> - -#include <QtCore/QPointer> -#include <QtWidgets/QWidget> - -#include <coreplugin/ioutputpane.h> - -QT_BEGIN_NAMESPACE -class QHBoxLayout; -QT_END_NAMESPACE - -namespace KUserFeedback { class Provider; } - -namespace UsageStatistic { -namespace Internal { - -class EncouragementWidget; - -//! Output pane for displayed different different information (telemetry level, surveys, etc.) -class OutputPane : public Core::IOutputPane -{ - Q_OBJECT - -public: - OutputPane(); - ~OutputPane() override; - -public: // IOutputPane interface - QWidget *outputWidget(QWidget *parent) override; - - QList<QWidget *> toolBarWidgets() const override; - - QString displayName() const override; - - int priorityInStatusBar() const override; - - void clearContents() override; - - void visibilityChanged(bool visible) override; - - void setFocus() override; - bool hasFocus() const override; - - bool canFocus() const override; - bool canNavigate() const override; - bool canNext() const override; - bool canPrevious() const override; - - void goToNext() override; - void goToPrev() override; - - std::shared_ptr<KUserFeedback::Provider> provider() const; - void setProvider(std::shared_ptr<KUserFeedback::Provider> provider); - -Q_SIGNALS: - void providerChanged(std::shared_ptr<KUserFeedback::Provider>); - -private: // Methods - void createEncouragementWidget(QWidget *parent); - -private: // Data - std::shared_ptr<KUserFeedback::Provider> m_provider; - QPointer<QWidget> m_outputPaneWidget; -}; - -} // namespace Internal -} // namespace UsageStatistic - -Q_DECLARE_METATYPE(std::shared_ptr<KUserFeedback::Provider>) diff --git a/src/usagestatisticconstants.h b/src/usagestatisticconstants.h index 0abde08..b7e9904 100644 --- a/src/usagestatisticconstants.h +++ b/src/usagestatisticconstants.h @@ -37,5 +37,7 @@ static constexpr char USAGE_STATISTIC_PAGE_ID[] = "UsageStatistic"; static constexpr char PRIVACY_POLICY_URL[] = "https://www.qt.io/terms-conditions/#privacy"; +static constexpr char ENC_MSG_INFOBAR_ENTRY_ID[] = "UsageStatisticPlugin_EncMsg_InfoBarEntry_Id"; + } // namespace UsageStatistic } // namespace Constants diff --git a/src/usagestatisticplugin.cpp b/src/usagestatisticplugin.cpp index 5f04486..bcd5856 100644 --- a/src/usagestatisticplugin.cpp +++ b/src/usagestatisticplugin.cpp @@ -31,6 +31,7 @@ #include <coreplugin/actionmanager/command.h> #include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/coreconstants.h> +#include <coreplugin/infobar.h> #include <KUserFeedback/Provider> #include <KUserFeedback/ApplicationVersionSource> @@ -58,7 +59,6 @@ #include "services/datasubmitter.h" #include "ui/usagestatisticpage.h" -#include "ui/outputpane.h" #include "common/utils.h" @@ -74,9 +74,6 @@ bool UsageStatisticPlugin::initialize(const QStringList &arguments, QString *err Q_UNUSED(arguments) Q_UNUSED(errorString) - // We have to create a pane here because of OutputPaneManager internal initialization order - createOutputPane(); - return true; } @@ -132,7 +129,7 @@ bool UsageStatisticPlugin::delayedInitialize() restoreSettings(); - configureOutputPane(); + showFirstTimeMessage(); return true; } @@ -152,21 +149,6 @@ void UsageStatisticPlugin::createUsageStatisticPage() this, &UsageStatisticPlugin::storeSettings); } -void UsageStatisticPlugin::createOutputPane() -{ - m_outputPane = std::make_unique<OutputPane>(); -} - -void UsageStatisticPlugin::configureOutputPane() -{ - Q_ASSERT(m_outputPane); - - m_outputPane->setProvider(m_provider); - - connect(m_provider.get(), &KUserFeedback::Provider::showEncouragementMessage, - m_outputPane.get(), &OutputPane::flash); -} - void UsageStatisticPlugin::storeSettings() { if (m_provider) { @@ -200,5 +182,68 @@ void UsageStatisticPlugin::createProvider() m_provider->setSubmissionInterval(submissionIntervalDays()); } +static bool runFirstTime(const KUserFeedback::Provider &provider) +{ + static const auto startCountSourceId = QStringLiteral("startCount"); + if (auto startCountSource = provider.dataSource(startCountSourceId)) { + auto data = startCountSource->data().toMap(); + + static const auto startCountKey = QStringLiteral("value"); + const auto startCountIt = data.find(startCountKey); + if (startCountIt != data.end()) { + return startCountIt->toInt() == 1; + } + } + + return false; +} + +static bool telemetryLevelNotSet(const KUserFeedback::Provider &provider) +{ + return provider.telemetryMode() == KUserFeedback::Provider::NoTelemetry; +} + +void UsageStatisticPlugin::showFirstTimeMessage() +{ + if (m_provider && runFirstTime(*m_provider) && telemetryLevelNotSet(*m_provider)) { + showEncouragementMessage(); + } +} + +static Core::InfoBarEntry makeInfoBarEntry() +{ + static auto infoText = UsageStatisticPlugin::tr( + "We make Qt Creator for you. Would you like to help us make it even better?"); + static auto customButtonInfoText = UsageStatisticPlugin::tr("Adjust usage statistics settings"); + static auto cancelButtonInfoText = UsageStatisticPlugin::tr("Decide later"); + + static auto hideEncouragementMessageCallback = []() { + if (auto infoBar = Core::ICore::infoBar()) { + infoBar->removeInfo(Constants::ENC_MSG_INFOBAR_ENTRY_ID); + } + }; + + static auto showUsageStatisticsSettingsCallback = []() { + hideEncouragementMessageCallback(); + Core::ICore::showOptionsDialog(Constants::USAGE_STATISTIC_PAGE_ID); + }; + + Core::InfoBarEntry entry(Constants::ENC_MSG_INFOBAR_ENTRY_ID, infoText); + entry.setCustomButtonInfo(customButtonInfoText, showUsageStatisticsSettingsCallback); + entry.setCancelButtonInfo(cancelButtonInfoText, hideEncouragementMessageCallback); + + return entry; +} + +void UsageStatisticPlugin::showEncouragementMessage() +{ + if (auto infoBar = Core::ICore::infoBar()) { + if (!infoBar->containsInfo(Constants::ENC_MSG_INFOBAR_ENTRY_ID)) { + static auto infoBarEntry = makeInfoBarEntry(); + infoBar->addInfo(infoBarEntry); + } + } +} + } // namespace Internal } // namespace UsageStatistic diff --git a/src/usagestatisticplugin.h b/src/usagestatisticplugin.h index 139acc3..0fb6278 100644 --- a/src/usagestatisticplugin.h +++ b/src/usagestatisticplugin.h @@ -36,7 +36,6 @@ namespace UsageStatistic { namespace Internal { class UsageStatisticPage; -class OutputPane; //! Plugin for collecting and sending usage statistics class UsageStatisticPlugin : public ExtensionSystem::IPlugin @@ -55,16 +54,15 @@ public: private: void createUsageStatisticPage(); - void createOutputPane(); - void configureOutputPane(); void storeSettings(); void restoreSettings(); void createProvider(); + void showEncouragementMessage(); + void showFirstTimeMessage(); private: std::shared_ptr<KUserFeedback::Provider> m_provider; std::unique_ptr<UsageStatisticPage> m_usageStatisticPage; - std::unique_ptr<OutputPane> m_outputPane; }; } // namespace Internal |