Add migration wizard, fix migration from custom paste instance
- Very basic wizard just to allow the user to choose whether to keep their old paste settings or use the new default settings. - People who used custom 0x0 instances would just be kept on those settings and won't see the wizard.
This commit is contained in:
parent
caf6d02728
commit
e2ad3b0183
@ -63,6 +63,7 @@
|
|||||||
#include "ui/setupwizard/SetupWizard.h"
|
#include "ui/setupwizard/SetupWizard.h"
|
||||||
#include "ui/setupwizard/LanguageWizardPage.h"
|
#include "ui/setupwizard/LanguageWizardPage.h"
|
||||||
#include "ui/setupwizard/JavaWizardPage.h"
|
#include "ui/setupwizard/JavaWizardPage.h"
|
||||||
|
#include "ui/setupwizard/PasteWizardPage.h"
|
||||||
|
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
|
|
||||||
@ -676,21 +677,17 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
// HACK: This code feels so stupid is there a less stupid way of doing this?
|
// HACK: This code feels so stupid is there a less stupid way of doing this?
|
||||||
{
|
{
|
||||||
m_settings->registerSetting("PastebinURL", "");
|
m_settings->registerSetting("PastebinURL", "");
|
||||||
|
m_settings->registerSetting("PastebinType", PasteUpload::PasteType::Mclogs);
|
||||||
|
m_settings->registerSetting("PastebinCustomAPIBase", "");
|
||||||
|
|
||||||
QString pastebinURL = m_settings->get("PastebinURL").toString();
|
QString pastebinURL = m_settings->get("PastebinURL").toString();
|
||||||
|
|
||||||
// If PastebinURL hasn't been set before then use the new default: mclo.gs
|
bool userHadNoPastebin = pastebinURL == "";
|
||||||
if (pastebinURL == "") {
|
bool userHadDefaultPastebin = pastebinURL == "https://0x0.st";
|
||||||
m_settings->registerSetting("PastebinType", PasteUpload::PasteType::Mclogs);
|
if (!(userHadNoPastebin || userHadDefaultPastebin))
|
||||||
m_settings->registerSetting("PastebinCustomAPIBase", "");
|
{
|
||||||
}
|
m_settings->set("PastebinType", PasteUpload::PasteType::NullPointer);
|
||||||
// Otherwise: use 0x0.st
|
m_settings->set("PastebinCustomAPIBase", pastebinURL);
|
||||||
else {
|
|
||||||
// The default custom endpoint would usually be "" (meaning there is no custom endpoint specified)
|
|
||||||
// But if the user had customised the paste URL then that should be carried over into the custom endpoint.
|
|
||||||
QString defaultCustomEndpoint = (pastebinURL == "https://0x0.st") ? "" : pastebinURL;
|
|
||||||
m_settings->registerSetting("PastebinType", PasteUpload::PasteType::NullPointer);
|
|
||||||
m_settings->registerSetting("PastebinCustomAPIBase", defaultCustomEndpoint);
|
|
||||||
|
|
||||||
m_settings->reset("PastebinURL");
|
m_settings->reset("PastebinURL");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -929,7 +926,8 @@ bool Application::createSetupWizard()
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}();
|
}();
|
||||||
bool wizardRequired = javaRequired || languageRequired;
|
bool pasteInterventionRequired = settings()->get("PastebinURL") != "";
|
||||||
|
bool wizardRequired = javaRequired || languageRequired || pasteInterventionRequired;
|
||||||
|
|
||||||
if(wizardRequired)
|
if(wizardRequired)
|
||||||
{
|
{
|
||||||
@ -943,6 +941,11 @@ bool Application::createSetupWizard()
|
|||||||
{
|
{
|
||||||
m_setupWizard->addPage(new JavaWizardPage(m_setupWizard));
|
m_setupWizard->addPage(new JavaWizardPage(m_setupWizard));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pasteInterventionRequired)
|
||||||
|
{
|
||||||
|
m_setupWizard->addPage(new PasteWizardPage(m_setupWizard));
|
||||||
|
}
|
||||||
connect(m_setupWizard, &QDialog::finished, this, &Application::setupWizardFinished);
|
connect(m_setupWizard, &QDialog::finished, this, &Application::setupWizardFinished);
|
||||||
m_setupWizard->show();
|
m_setupWizard->show();
|
||||||
return true;
|
return true;
|
||||||
|
@ -661,6 +661,8 @@ SET(LAUNCHER_SOURCES
|
|||||||
ui/setupwizard/JavaWizardPage.h
|
ui/setupwizard/JavaWizardPage.h
|
||||||
ui/setupwizard/LanguageWizardPage.cpp
|
ui/setupwizard/LanguageWizardPage.cpp
|
||||||
ui/setupwizard/LanguageWizardPage.h
|
ui/setupwizard/LanguageWizardPage.h
|
||||||
|
ui/setupwizard/PasteWizardPage.cpp
|
||||||
|
ui/setupwizard/PasteWizardPage.h
|
||||||
|
|
||||||
# GUI - themes
|
# GUI - themes
|
||||||
ui/themes/FusionTheme.cpp
|
ui/themes/FusionTheme.cpp
|
||||||
@ -890,6 +892,7 @@ SET(LAUNCHER_SOURCES
|
|||||||
)
|
)
|
||||||
|
|
||||||
qt5_wrap_ui(LAUNCHER_UI
|
qt5_wrap_ui(LAUNCHER_UI
|
||||||
|
ui/setupwizard/PasteWizardPage.ui
|
||||||
ui/pages/global/AccountListPage.ui
|
ui/pages/global/AccountListPage.ui
|
||||||
ui/pages/global/JavaPage.ui
|
ui/pages/global/JavaPage.ui
|
||||||
ui/pages/global/LauncherPage.ui
|
ui/pages/global/LauncherPage.ui
|
||||||
|
42
launcher/ui/setupwizard/PasteWizardPage.cpp
Normal file
42
launcher/ui/setupwizard/PasteWizardPage.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include "PasteWizardPage.h"
|
||||||
|
#include "ui_PasteWizardPage.h"
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
#include "net/PasteUpload.h"
|
||||||
|
|
||||||
|
PasteWizardPage::PasteWizardPage(QWidget *parent) :
|
||||||
|
BaseWizardPage(parent),
|
||||||
|
ui(new Ui::PasteWizardPage)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
PasteWizardPage::~PasteWizardPage()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PasteWizardPage::initializePage()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PasteWizardPage::validatePage()
|
||||||
|
{
|
||||||
|
auto s = APPLICATION->settings();
|
||||||
|
QString prevPasteURL = s->get("PastebinURL").toString();
|
||||||
|
s->reset("PastebinURL");
|
||||||
|
if (ui->previousSettingsRadioButton->isChecked())
|
||||||
|
{
|
||||||
|
bool usingDefaultBase = prevPasteURL == PasteUpload::PasteTypes.at(PasteUpload::PasteType::NullPointer).defaultBase;
|
||||||
|
s->set("PastebinType", PasteUpload::PasteType::NullPointer);
|
||||||
|
if (!usingDefaultBase)
|
||||||
|
s->set("PastebinCustomAPIBase", prevPasteURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PasteWizardPage::retranslate()
|
||||||
|
{
|
||||||
|
ui->retranslateUi(this);
|
||||||
|
}
|
27
launcher/ui/setupwizard/PasteWizardPage.h
Normal file
27
launcher/ui/setupwizard/PasteWizardPage.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef PASTEDEFAULTSCONFIRMATIONWIZARD_H
|
||||||
|
#define PASTEDEFAULTSCONFIRMATIONWIZARD_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "BaseWizardPage.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class PasteWizardPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
class PasteWizardPage : public BaseWizardPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PasteWizardPage(QWidget *parent = nullptr);
|
||||||
|
~PasteWizardPage();
|
||||||
|
|
||||||
|
void initializePage() override;
|
||||||
|
bool validatePage() override;
|
||||||
|
void retranslate() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::PasteWizardPage *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PASTEDEFAULTSCONFIRMATIONWIZARD_H
|
80
launcher/ui/setupwizard/PasteWizardPage.ui
Normal file
80
launcher/ui/setupwizard/PasteWizardPage.ui
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>PasteWizardPage</class>
|
||||||
|
<widget class="QWidget" name="PasteWizardPage">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>The default paste service has changed to mclo.gs, please choose what you want to do with your settings.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="defaultSettingsRadioButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use new default service</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">buttonGroup</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="previousSettingsRadioButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Keep previous settings</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="buttonGroup">
|
||||||
|
<string notr="true">buttonGroup</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>156</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
<buttongroups>
|
||||||
|
<buttongroup name="buttonGroup"/>
|
||||||
|
</buttongroups>
|
||||||
|
</ui>
|
Loading…
Reference in New Issue
Block a user