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:
Lenny McLennington
2022-05-17 05:00:06 +01:00
parent caf6d02728
commit e2ad3b0183
5 changed files with 169 additions and 14 deletions

View 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);
}

View 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

View 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>