mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-03 17:02:41 +00:00
Qt: Improve updater
This commit is contained in:
parent
2e92d95888
commit
ee3d64145c
11 changed files with 240 additions and 42 deletions
|
@ -20,6 +20,17 @@
|
|||
#include "Core/ConfigManager.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "UICommon/AutoUpdate.h"
|
||||
|
||||
constexpr int AUTO_UPDATE_DISABLE_INDEX = 0;
|
||||
constexpr int AUTO_UPDATE_STABLE_INDEX = 1;
|
||||
constexpr int AUTO_UPDATE_BETA_INDEX = 2;
|
||||
constexpr int AUTO_UPDATE_DEV_INDEX = 3;
|
||||
|
||||
constexpr const char* AUTO_UPDATE_DISABLE_STRING = "";
|
||||
constexpr const char* AUTO_UPDATE_STABLE_STRING = "stable";
|
||||
constexpr const char* AUTO_UPDATE_BETA_STRING = "beta";
|
||||
constexpr const char* AUTO_UPDATE_DEV_STRING = "dev";
|
||||
|
||||
GeneralPane::GeneralPane(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
|
@ -34,6 +45,10 @@ void GeneralPane::CreateLayout()
|
|||
m_main_layout = new QVBoxLayout;
|
||||
// Create layout here
|
||||
CreateBasic();
|
||||
|
||||
if (AutoUpdateChecker::SystemSupportsAutoUpdates())
|
||||
CreateAutoUpdate();
|
||||
|
||||
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
||||
CreateAnalytics();
|
||||
#endif
|
||||
|
@ -48,6 +63,16 @@ void GeneralPane::ConnectLayout()
|
|||
{
|
||||
connect(m_checkbox_dualcore, &QCheckBox::clicked, this, &GeneralPane::OnSaveConfig);
|
||||
connect(m_checkbox_cheats, &QCheckBox::clicked, this, &GeneralPane::OnSaveConfig);
|
||||
|
||||
if (AutoUpdateChecker::SystemSupportsAutoUpdates())
|
||||
{
|
||||
connect(m_combobox_update_track,
|
||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&GeneralPane::OnSaveConfig);
|
||||
connect(&Settings::Instance(), &Settings::AutoUpdateTrackChanged, this,
|
||||
&GeneralPane::LoadConfig);
|
||||
}
|
||||
|
||||
// Advanced
|
||||
connect(m_combobox_speedlimit,
|
||||
static_cast<void (QComboBox::*)(const QString&)>(&QComboBox::activated),
|
||||
|
@ -96,6 +121,22 @@ void GeneralPane::CreateBasic()
|
|||
speed_limit_layout->addRow(tr("&Speed Limit:"), m_combobox_speedlimit);
|
||||
}
|
||||
|
||||
void GeneralPane::CreateAutoUpdate()
|
||||
{
|
||||
auto* auto_update_group = new QGroupBox(tr("Auto Update Settings"));
|
||||
auto* layout = new QFormLayout;
|
||||
auto_update_group->setLayout(layout);
|
||||
m_main_layout->addWidget(auto_update_group);
|
||||
|
||||
m_combobox_update_track = new QComboBox(this);
|
||||
|
||||
layout->addRow(tr("&Auto Update:"), m_combobox_update_track);
|
||||
|
||||
for (const QString& option : {tr("Don't Update"), tr("Stable (once a year)"),
|
||||
tr("Beta (once a month)"), tr("Dev (multiple times a day)")})
|
||||
m_combobox_update_track->addItem(option);
|
||||
}
|
||||
|
||||
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
||||
void GeneralPane::CreateAnalytics()
|
||||
{
|
||||
|
@ -135,6 +176,20 @@ void GeneralPane::CreateAdvanced()
|
|||
|
||||
void GeneralPane::LoadConfig()
|
||||
{
|
||||
if (AutoUpdateChecker::SystemSupportsAutoUpdates())
|
||||
{
|
||||
const auto track = Settings::Instance().GetAutoUpdateTrack().toStdString();
|
||||
|
||||
if (track == AUTO_UPDATE_DISABLE_STRING)
|
||||
m_combobox_update_track->setCurrentIndex(AUTO_UPDATE_DISABLE_INDEX);
|
||||
else if (track == AUTO_UPDATE_STABLE_STRING)
|
||||
m_combobox_update_track->setCurrentIndex(AUTO_UPDATE_STABLE_INDEX);
|
||||
else if (track == AUTO_UPDATE_BETA_STRING)
|
||||
m_combobox_update_track->setCurrentIndex(AUTO_UPDATE_BETA_INDEX);
|
||||
else
|
||||
m_combobox_update_track->setCurrentIndex(AUTO_UPDATE_DEV_INDEX);
|
||||
}
|
||||
|
||||
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
||||
m_checkbox_enable_analytics->setChecked(SConfig::GetInstance().m_analytics_enabled);
|
||||
#endif
|
||||
|
@ -164,8 +219,37 @@ void GeneralPane::LoadConfig()
|
|||
}
|
||||
}
|
||||
|
||||
static QString UpdateTrackFromIndex(int index)
|
||||
{
|
||||
QString value;
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case AUTO_UPDATE_DISABLE_INDEX:
|
||||
value = QString::fromStdString(AUTO_UPDATE_DISABLE_STRING);
|
||||
break;
|
||||
case AUTO_UPDATE_STABLE_INDEX:
|
||||
value = QString::fromStdString(AUTO_UPDATE_STABLE_STRING);
|
||||
break;
|
||||
case AUTO_UPDATE_BETA_INDEX:
|
||||
value = QString::fromStdString(AUTO_UPDATE_BETA_STRING);
|
||||
break;
|
||||
case AUTO_UPDATE_DEV_INDEX:
|
||||
value = QString::fromStdString(AUTO_UPDATE_DEV_STRING);
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void GeneralPane::OnSaveConfig()
|
||||
{
|
||||
if (AutoUpdateChecker::SystemSupportsAutoUpdates())
|
||||
{
|
||||
Settings::Instance().SetAutoUpdateTrack(
|
||||
UpdateTrackFromIndex(m_combobox_update_track->currentIndex()));
|
||||
}
|
||||
|
||||
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
||||
SConfig::GetInstance().m_analytics_enabled = m_checkbox_enable_analytics->isChecked();
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue