swift
updatesettings.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_CORE_APPLICATION_UPDATESETTINGS_H
7 #define SWIFT_CORE_APPLICATION_UPDATESETTINGS_H
8 
9 #include <QStringList>
10 
11 #include "core/application.h"
12 #include "misc/platform.h"
13 #include "misc/settingscache.h"
14 
15 namespace swift::core::application
16 {
19  {
21  static const char *key() { return "updatepreferences"; }
22 
24  static const QStringList &defaultValue()
25  {
26  // guessing / preset-ing some default values
27  static const QStringList d =
28  (sApp && !sApp->getUpdateInfo().isEmpty()) ?
29  sApp->getUpdateInfo().anticipateMyDefaultChannelAndPlatform() : // from cached or loaded update info
30  QStringList({ "STABLE", misc::CPlatform::currentPlatform().getPlatformName() });
31  return d;
32  }
33 
35  static const QString &humanReadable()
36  {
37  static const QString name("Updates channel/platform");
38  return name;
39  }
40  };
41 } // namespace swift::core::application
42 
43 #endif // SWIFT_CORE_APPLICATION_UPDATESETTINGS_H
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
Definition: application.cpp:71
swift::misc::db::CUpdateInfo getUpdateInfo() const
Update info.
QString getPlatformName() const
Name of platform.
Definition: platform.cpp:53
static const CPlatform & currentPlatform()
Current platform.
Definition: platform.cpp:158
bool isEmpty() const
Empty (no data)
Definition: updateinfo.h:76
QStringList anticipateMyDefaultChannelAndPlatform() const
Default channel, OS.
Definition: updateinfo.cpp:83
Update info settings, QStringList with 2 values: channel/platform.
static const QStringList & defaultValue()
Return the value to use in case the supplied value does not satisfy the validator....
static const QString & humanReadable()
Optional human readable name.
static const char * key()
Key string of the value. Reimplemented in derived class.
Base class for traits to be used as template argument to swift::misc::CSetting.