Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Telemetry plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Telemetry
Telemetry plugin
Commits
4f435677
Commit
4f435677
authored
6 years ago
by
Vitaly Fanaskov
Browse files
Options
Downloads
Patches
Plain Diff
Basic implementation of Settings Functionality
parent
566d0b91
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/settings.cpp
+91
-0
91 additions, 0 deletions
common/settings.cpp
common/settings.h
+42
-0
42 additions, 0 deletions
common/settings.h
usagestatistic.pro
+4
-2
4 additions, 2 deletions
usagestatistic.pro
with
137 additions
and
2 deletions
common/settings.cpp
0 → 100644
+
91
−
0
View file @
4f435677
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company
** Contact: https://www.qt.io/licensing/
**
** Created 8/3/2019.
**
** 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
"settings.h"
#include
<QtCore/QSettings>
#include
<KUserFeedback/AbstractDataSource>
#include
<KUserFeedback/Provider>
namespace
UsageStatistic
::
Internal
::
Settings
{
using
namespace
KUserFeedback
;
static
const
QString
telemetryModeKey
()
{
return
QStringLiteral
(
"telemetryMode"
);
}
static
const
QString
sourcesActiveStateKey
()
{
return
QStringLiteral
(
"sourcesActiveState"
);
}
using
ActiveStateById
=
QPair
<
QString
,
bool
>
;
static
QVariantList
sourcesStatesById
(
const
QVector
<
AbstractDataSource
*>
&
dataSources
)
{
QVariantList
result
;
for
(
auto
&&
src
:
dataSources
)
{
if
(
src
)
{
result
<<
QVariant
::
fromValue
(
qMakePair
(
src
->
id
(),
src
->
isActive
()));
}
}
return
result
;
}
static
void
restoreSourceStates
(
const
QVector
<
AbstractDataSource
*>
&
dataSources
,
const
QVariantList
&
states
)
{
QHash
<
QString
,
AbstractDataSource
*>
sourcesById
;
for
(
auto
&&
src
:
dataSources
)
{
if
(
src
)
{
sourcesById
[
src
->
id
()]
=
src
;
}
}
for
(
auto
&&
p
:
states
)
{
auto
idAndActiveState
=
p
.
value
<
ActiveStateById
>
();
if
(
auto
it
=
sourcesById
.
find
(
idAndActiveState
.
first
);
it
!=
sourcesById
.
end
())
{
(
*
it
)
->
setActive
(
idAndActiveState
.
second
);
}
}
}
static
constexpr
KUserFeedback
::
Provider
::
TelemetryMode
telemetryModeDflt
()
{
return
KUserFeedback
::
Provider
::
NoTelemetry
;
}
void
restore
(
const
QSettings
&
settings
,
KUserFeedback
::
Provider
&
p
)
{
p
.
setTelemetryMode
(
Provider
::
TelemetryMode
(
settings
.
value
(
telemetryModeKey
(),
telemetryModeDflt
()).
toInt
()));
restoreSourceStates
(
p
.
dataSources
(),
settings
.
value
(
sourcesActiveStateKey
()).
toList
());
}
void
store
(
QSettings
&
settings
,
const
KUserFeedback
::
Provider
&
p
)
{
settings
.
setValue
(
telemetryModeKey
(),
int
(
p
.
telemetryMode
()));
settings
.
setValue
(
sourcesActiveStateKey
(),
sourcesStatesById
(
p
.
dataSources
()));
}
}
// namespace UsageStatistic::Internal::Settings
Q_DECLARE_METATYPE
(
UsageStatistic
::
Internal
::
Settings
::
ActiveStateById
)
This diff is collapsed.
Click to expand it.
common/settings.h
0 → 100644
+
42
−
0
View file @
4f435677
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company
** Contact: https://www.qt.io/licensing/
**
** Created 8/3/2019.
**
** 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
<QtCore/QtGlobal>
QT_BEGIN_NAMESPACE
class
QSettings
;
QT_END_NAMESPACE
namespace
KUserFeedback
{
class
Provider
;
}
namespace
UsageStatistic
::
Internal
::
Settings
{
void
restore
(
const
QSettings
&
settings
,
KUserFeedback
::
Provider
&
p
);
void
store
(
QSettings
&
settings
,
const
KUserFeedback
::
Provider
&
p
);
}
// namespace UsageStatistic::Internal::Settings
This diff is collapsed.
Click to expand it.
usagestatistic.pro
+
4
−
2
View file @
4f435677
...
...
@@ -20,7 +20,8 @@ SOURCES += \
datasources
/
examplesdatasource
.
cpp
\
datasources
/
kitsource
.
cpp
\
datasources
/
qmldesignerusagetimesource
.
cpp
\
ui
/
usagestatisticpage
.
cpp
ui
/
usagestatisticpage
.
cpp
\
common
/
settings
.
cpp
HEADERS
+=
\
usagestatisticplugin
.
h
\
...
...
@@ -35,7 +36,8 @@ HEADERS += \
datasources
/
examplesdatasource
.
h
\
datasources
/
kitsource
.
h
\
datasources
/
qmldesignerusagetimesource
.
h
\
ui
/
usagestatisticpage
.
h
ui
/
usagestatisticpage
.
h
\
common
/
settings
.
h
#
Qt
Creator
linking
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment