Make Launcher ratings settings persistent
This commit is contained in:
parent
d238393d2e
commit
a3731875a1
8 changed files with 57 additions and 1 deletions
|
@ -1,5 +1,8 @@
|
|||
#include "AircraftSearchFilterModel.hxx"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QDebug>
|
||||
|
||||
#include "AircraftModel.hxx"
|
||||
#include <simgear/package/Package.hxx>
|
||||
|
||||
|
@ -187,3 +190,28 @@ bool AircraftProxyModel::filterAircraft(const QModelIndex &sourceIndex) const
|
|||
return false;
|
||||
}
|
||||
|
||||
void AircraftProxyModel::loadRatingsSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
m_ratingsFilter = settings.value("enable-ratings-filter", true).toBool();
|
||||
QVariantList vRatings = settings.value("ratings-filter").toList();
|
||||
if (vRatings.size() == 4) {
|
||||
for (int i=0; i < 4; ++i) {
|
||||
m_ratings[i] = vRatings.at(i).toInt();
|
||||
}
|
||||
}
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void AircraftProxyModel::saveRatingsSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("enable-ratings-filter", m_ratingsFilter);
|
||||
QVariantList vRatings;
|
||||
for (int i=0; i < 4; ++i) {
|
||||
vRatings.append(m_ratings.at(i));
|
||||
}
|
||||
settings.setValue("ratings-filter", vRatings);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,10 @@ public:
|
|||
|
||||
Q_INVOKABLE void selectVariantForAircraftURI(QUrl uri);
|
||||
|
||||
Q_INVOKABLE void loadRatingsSettings();
|
||||
|
||||
Q_INVOKABLE void saveRatingsSettings();
|
||||
|
||||
QList<int> ratings() const
|
||||
{
|
||||
return m_ratings;
|
||||
|
|
|
@ -722,6 +722,20 @@ QVariantList LauncherController::defaultSplashUrls() const
|
|||
return urls;
|
||||
}
|
||||
|
||||
QVariant LauncherController::loadUISetting(QString name, QVariant defaultValue) const
|
||||
{
|
||||
QSettings settings;
|
||||
if (!settings.contains(name))
|
||||
return defaultValue;
|
||||
return settings.value(name);
|
||||
}
|
||||
|
||||
void LauncherController::saveUISetting(QString name, QVariant value) const
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue(name, value);
|
||||
}
|
||||
|
||||
void LauncherController::onAircraftInstalledCompleted(QModelIndex index)
|
||||
{
|
||||
maybeUpdateSelectedAircraft(index);
|
||||
|
|
|
@ -142,7 +142,8 @@ public:
|
|||
// used on the summary screen
|
||||
Q_INVOKABLE QVariantList defaultSplashUrls() const;
|
||||
|
||||
|
||||
Q_INVOKABLE QVariant loadUISetting(QString name, QVariant defaultValue) const;
|
||||
Q_INVOKABLE void saveUISetting(QString name, QVariant value) const;
|
||||
|
||||
LaunchConfig* config() const
|
||||
{ return m_config; }
|
||||
|
|
|
@ -17,6 +17,10 @@ FocusScope
|
|||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
_launcher.browseAircraftModel.loadRatingsSettings();
|
||||
}
|
||||
|
||||
Rectangle
|
||||
{
|
||||
id: tabBar
|
||||
|
|
|
@ -12,6 +12,9 @@ Item {
|
|||
|
||||
function updateSelectionFromLauncher()
|
||||
{
|
||||
if (!model)
|
||||
return;
|
||||
|
||||
model.selectVariantForAircraftURI(_launcher.selectedAircraft);
|
||||
var row = model.indexForURI(_launcher.selectedAircraft);
|
||||
if (row >= 0) {
|
||||
|
|
|
@ -15,6 +15,7 @@ ListHeaderBox
|
|||
|
||||
onCheckedChanged: {
|
||||
_launcher.browseAircraftModel.ratingsFilterEnabled = checked
|
||||
_launcher.saveUISetting("enable-ratings-filter", checked);
|
||||
}
|
||||
|
||||
label: qsTr("Filter using ratings")
|
||||
|
|
|
@ -15,5 +15,6 @@ Slider {
|
|||
|
||||
onValueChanged: {
|
||||
ratings[ratingIndex] = value
|
||||
_launcher.browseAircraftModel.saveRatingsSettings();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue