forked from qt-creator/qt-creator
StudioWelcome: Add option for UsageStatistic plugin
Change-Id: I865d4594ca8cd40390b561731259ddb51c83641c Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -28,6 +28,7 @@ import QtQuick.Controls 2.3
|
|||||||
import StudioFonts 1.0
|
import StudioFonts 1.0
|
||||||
import QtQuick.Layouts 1.0
|
import QtQuick.Layouts 1.0
|
||||||
import projectmodel 1.0
|
import projectmodel 1.0
|
||||||
|
import usagestatistics 1.0
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: welcome_splash
|
id: welcome_splash
|
||||||
@@ -249,5 +250,21 @@ Image {
|
|||||||
ProjectModel {
|
ProjectModel {
|
||||||
id: projectModel
|
id: projectModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UsageStatisticModel {
|
||||||
|
id: usageStatisticModel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NoShowCheckbox {
|
||||||
|
id: usageStatisticCheckBox
|
||||||
|
x: -47
|
||||||
|
y: 391
|
||||||
|
text: "Enable Usage Statistics"
|
||||||
|
padding: 0
|
||||||
|
scale: 0.5
|
||||||
|
checked: usageStatisticModel.usageStatisticEnabled
|
||||||
|
|
||||||
|
onCheckedChanged: usageStatisticModel.setPluginEnabled(usageStatisticCheckBox.checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ Project {
|
|||||||
directory: "."
|
directory: "."
|
||||||
}
|
}
|
||||||
/* List of plugin directories passed to QML runtime */
|
/* List of plugin directories passed to QML runtime */
|
||||||
importPaths: [ "imports", "mockData", "../../../../share/3rdparty/studiofonts" ]
|
importPaths: [ "imports", "../welcomepage/mockData", "../../../../share/3rdparty/studiofonts" ]
|
||||||
|
|
||||||
Environment {
|
Environment {
|
||||||
QT_AUTO_SCREEN_SCALE_FACTOR: "1"
|
QT_AUTO_SCREEN_SCALE_FACTOR: "1"
|
||||||
|
@@ -0,0 +1,30 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of 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.0
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
property bool usageStatisticEnabled: false
|
||||||
|
}
|
@@ -0,0 +1 @@
|
|||||||
|
UsageStatisticModel 1.0 UsageStatisticModel.qml
|
@@ -26,6 +26,7 @@
|
|||||||
#include "studiowelcomeplugin.h"
|
#include "studiowelcomeplugin.h"
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/dialogs/restartdialog.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/helpmanager.h>
|
#include <coreplugin/helpmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -64,6 +65,70 @@ const char DO_NOT_SHOW_SPLASHSCREEN_AGAIN_KEY[] = "StudioSplashScreen";
|
|||||||
|
|
||||||
QPointer<QQuickWidget> s_view = nullptr;
|
QPointer<QQuickWidget> s_view = nullptr;
|
||||||
|
|
||||||
|
static bool isUsageStatistic(const ExtensionSystem::PluginSpec *spec)
|
||||||
|
{
|
||||||
|
if (!spec)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return spec->name().contains("UsageStatistic");
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtensionSystem::PluginSpec *getUsageStatisticPlugin()
|
||||||
|
{
|
||||||
|
const auto plugins = ExtensionSystem::PluginManager::plugins();
|
||||||
|
return Utils::findOrDefault(plugins, &isUsageStatistic);
|
||||||
|
}
|
||||||
|
|
||||||
|
class UsageStatisticPluginModel : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(bool usageStatisticEnabled MEMBER m_usageStatisticEnabled NOTIFY usageStatisticChanged)
|
||||||
|
public:
|
||||||
|
explicit UsageStatisticPluginModel(QObject *parent = nullptr)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
setupModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupModel()
|
||||||
|
{
|
||||||
|
auto plugin = getUsageStatisticPlugin();
|
||||||
|
if (plugin)
|
||||||
|
m_usageStatisticEnabled = plugin->isEnabledBySettings();
|
||||||
|
else
|
||||||
|
m_usageStatisticEnabled = false;
|
||||||
|
|
||||||
|
emit usageStatisticChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_INVOKABLE void setPluginEnabled(bool b)
|
||||||
|
{
|
||||||
|
auto plugin = getUsageStatisticPlugin();
|
||||||
|
|
||||||
|
if (!plugin)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (plugin->isEnabledBySettings() == b)
|
||||||
|
return;
|
||||||
|
|
||||||
|
plugin->setEnabledBySettings(b);
|
||||||
|
ExtensionSystem::PluginManager::writeSettings();
|
||||||
|
|
||||||
|
const QString restartText = tr("The change will take effect after restart.");
|
||||||
|
Core::RestartDialog restartDialog(Core::ICore::dialogParent(), restartText);
|
||||||
|
restartDialog.exec();
|
||||||
|
|
||||||
|
setupModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void usageStatisticChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_usageStatisticEnabled = false;
|
||||||
|
};
|
||||||
|
|
||||||
class ProjectModel : public QAbstractListModel
|
class ProjectModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -210,6 +275,7 @@ bool StudioWelcomePlugin::initialize(const QStringList &arguments, QString *erro
|
|||||||
Q_UNUSED(errorString)
|
Q_UNUSED(errorString)
|
||||||
|
|
||||||
qmlRegisterType<ProjectModel>("projectmodel", 1, 0, "ProjectModel");
|
qmlRegisterType<ProjectModel>("projectmodel", 1, 0, "ProjectModel");
|
||||||
|
qmlRegisterType<UsageStatisticPluginModel>("usagestatistics", 1, 0, "UsageStatisticModel");
|
||||||
|
|
||||||
m_welcomeMode = new WelcomeMode;
|
m_welcomeMode = new WelcomeMode;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user