Commit b0f31cfc authored by Sébastien Blin's avatar Sébastien Blin Committed by Andreas Traczyk

wizard: add backup keys page

Change-Id: I66b1a8790ac2024d2ce8f514c564babb6d2493c5
parent 46556cdd
......@@ -270,6 +270,8 @@ void NewWizardWidget::changePage(QWidget* toPage)
ui->fileImportBtn->setText(tr("Archive (None)"));
ui->nextButton->setEnabled(false);
ui->backupInfoLabel->hide();
} else if (toPage == ui->backupKeysPage) {
setNavBarVisibility(false);
}
}
......@@ -341,6 +343,34 @@ NewWizardWidget::on_backupInfoBtn_clicked()
ui->backupInfoLabel->setVisible(!ui->backupInfoLabel->isVisible());
}
void
NewWizardWidget::on_neverShowAgainBox_clicked()
{
QSettings settings("jami.net", "Jami");
settings.setValue(SettingsKey::neverShowMeAgain, ui->neverShowAgainBox->isChecked());
}
void
NewWizardWidget::on_skipBtn_clicked()
{
emit NavigationRequested(ScreenEnum::CallScreen);
emit LRCInstance::instance().accountListChanged();
}
void
NewWizardWidget::on_exportBtn_clicked()
{
QFileDialog dialog(this);
QString dir = QFileDialog::getExistingDirectory(this, tr("Export Account Here"),
QDir::homePath() + "/Desktop", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (!dir.isEmpty()) {
LRCInstance::accountModel().exportToFile(LRCInstance::getCurrAccId(), (dir + "/export.gz").toStdString());
}
emit NavigationRequested(ScreenEnum::CallScreen);
emit LRCInstance::instance().accountListChanged();
}
void
NewWizardWidget::on_passwordEdit_textChanged(const QString& arg1)
{
......@@ -523,6 +553,7 @@ NewWizardWidget::createAccount()
{
bool isConnectingToManager = wizardMode_ == WizardMode::CONNECTMANAGER;
bool isRing = wizardMode_ == WizardMode::CREATE || wizardMode_ == WizardMode::IMPORT;
bool isCreating = wizardMode_ == WizardMode::CREATE;
if (isConnectingToManager) {
Utils::oneShotConnect(&LRCInstance::accountModel(), &lrc::api::NewAccountModel::accountAdded,
[this](const std::string& accountId) {
......@@ -535,7 +566,7 @@ NewWizardWidget::createAccount()
});
} else {
Utils::oneShotConnect(&LRCInstance::accountModel(), &lrc::api::NewAccountModel::accountAdded,
[this, isRing](const std::string& accountId) {
[this, isRing, isCreating](const std::string& accountId) {
//set default ringtone
auto confProps = LRCInstance::accountModel().getAccountConfig(accountId);
confProps.Ringtone.ringtonePath = Utils::GetRingtonePath().toStdString();
......@@ -548,14 +579,25 @@ NewWizardWidget::createAccount()
}
LRCInstance::accountModel().setAccountConfig(accountId, confProps);
if (isRing) {
QSettings settings("jami.net", "Jami");
if (not settings.contains(SettingsKey::neverShowMeAgain)) {
settings.setValue(SettingsKey::neverShowMeAgain, false);
}
auto showBackup = isCreating && !settings.value(SettingsKey::neverShowMeAgain).toBool();
if (!confProps.username.empty()) {
connect(&LRCInstance::accountModel(),
Utils::oneShotConnect(&LRCInstance::accountModel(),
&lrc::api::NewAccountModel::nameRegistrationEnded,
[this] {
[this, showBackup] {
lrc::api::account::ConfProperties_t accountProperties = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), accountProperties);
emit NavigationRequested(ScreenEnum::CallScreen);
emit LRCInstance::instance().accountListChanged();
QSettings settings("jami.net", "Jami");
if (showBackup) {
changePage(ui->backupKeysPage);
} else {
emit NavigationRequested(ScreenEnum::CallScreen);
emit LRCInstance::instance().accountListChanged();
}
});
LRCInstance::accountModel().registerName(
LRCInstance::getCurrAccId(),
......@@ -563,8 +605,12 @@ NewWizardWidget::createAccount()
registeredName_.toStdString()
);
} else {
emit NavigationRequested(ScreenEnum::CallScreen);
emit LRCInstance::instance().accountListChanged();
if (showBackup) {
changePage(ui->backupKeysPage);
} else {
emit NavigationRequested(ScreenEnum::CallScreen);
emit LRCInstance::instance().accountListChanged();
}
}
LRCInstance::setCurrAccAvatar(ui->setAvatarWidget->getAvatarPixmap());
} else {
......@@ -593,7 +639,7 @@ NewWizardWidget::createAccount()
inputPara_["password"].toStdString(),
inputPara_["manager"].toStdString()
);
} if (isRing) {
} else if (isRing) {
LRCInstance::accountModel().createNewAccount(
lrc::api::profile::Type::RING,
inputPara_["alias"].toStdString(),
......
......@@ -71,6 +71,9 @@ private slots:
void on_previousButton_clicked();
void on_pinInfoBtn_clicked();
void on_backupInfoBtn_clicked();
void on_neverShowAgainBox_clicked();
void on_skipBtn_clicked();
void on_exportBtn_clicked();
void on_passwordEdit_textChanged(const QString& arg1);
private slots:
......
......@@ -108,7 +108,7 @@
<string notr="true"/>
</property>
<property name="currentIndex">
<number>3</number>
<number>6</number>
</property>
<widget class="QWidget" name="welcomePage">
<layout class="QVBoxLayout" name="verticalLayout_3">
......@@ -316,6 +316,11 @@
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="toolTip">
<string>Import from account's archive</string>
</property>
......@@ -389,6 +394,11 @@
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="toolTip">
<string>Get your account via your credentials.</string>
</property>
......@@ -2113,7 +2123,7 @@ instead of using your ID.</string>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
......@@ -2135,6 +2145,11 @@ instead of using your ID.</string>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="inputMask">
<string/>
</property>
......@@ -2193,6 +2208,228 @@ instead of using your ID.</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="backupKeysPage">
<layout class="QVBoxLayout" name="verticalLayout_22">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="verticalSpacer_181">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_151">
<property name="spacing">
<number>12</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="backupKeysLabel">
<property name="minimumSize">
<size>
<width>256</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>13</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(63, 63, 63)</string>
</property>
<property name="text">
<string>Backup your account!</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="backupInfoLabel1">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>This account only exists on this device. If you lost your device or uninstall the application, your account will be deleted. You can backup your account now or later.</string>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="neverShowAgainBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Never show me this again</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="exportBtn">
<property name="minimumSize">
<size>
<width>85</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>85</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Export</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_14">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="skipBtn">
<property name="minimumSize">
<size>
<width>85</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>85</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Skip</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_19">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_241">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="importFromDevicePage">
<layout class="QVBoxLayout" name="verticalLayout_19">
<property name="spacing">
......@@ -2335,6 +2572,11 @@ instead of using your ID.</string>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
......@@ -2357,6 +2599,11 @@ instead of using your ID.</string>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="inputMask">
<string/>
</property>
......@@ -2494,6 +2741,11 @@ instead of using your ID.</string>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
......@@ -2516,6 +2768,11 @@ instead of using your ID.</string>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="inputMask">
<string/>
</property>
......@@ -2541,6 +2798,11 @@ instead of using your ID.</string>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="placeholderText">
<string>Account manager</string>
</property>
......@@ -2737,7 +2999,7 @@ instead of using your ID.</string>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_16">
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
......
......@@ -28,4 +28,5 @@ constexpr static char selectedAccount[] = "selectedAccount";
constexpr static char mainSplitterState[] = "mainSplitterState";
constexpr static char windowState[] = "windowState";
constexpr static char autoUpdate[] = "autoUpdate";
constexpr static char neverShowMeAgain[] = "neverShowMeAgain";
}
......@@ -297,6 +297,7 @@ QPushButton#photoButton,
QPushButton#fromDeviceButton, QPushButton#newAccountButton, QPushButton#previousButton, QPushButton#exportButton, QPushButton#newSIPAccountButton, QPushButton#fromBackupButton, QPushButton#connectAccountManagerButton,
QPushButton#cancelAddButton, QPushButton#exportOnRingButton, QPushButton#addDeviceButton, QPushButton#exportEndedOkButton,
QPushButton#errorPushButton, QPushButton#registerButton, QPushButton#acceptCRButton, QPushButton#discardCRButton, QPushButton#deleteCancelBtn,
QPushButton#skipBtn, QPushButton#exportBtn,
QPushButton#dhtImportBtn, QPushButton#fileImportBtn, QPushButton#changePassBtn, QPushButton#confirmChangeBtn, QPushButton#backButton {
background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #109ede, stop: 1.0 #2b5084);
border: 0px;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment