Пример #1
0
void SetupDialog::setNextPage()
{
    if(_ui->wizardStackedWidget->currentWidget() == _ui->welcomePage)
    {
        if(_ui->advancedSetupCheckBox->isChecked() || _tarsnapDir.isEmpty() ||
           _tarsnapCacheDir.isEmpty() || _appDataDir.isEmpty())
        {
            _ui->wizardStackedWidget->setCurrentWidget(_ui->advancedPage);
            _ui->advancedSetupCheckBox->setChecked(true);
            _ui->advancedPageRadioButton->setEnabled(true);
            validateAdvancedSetupPage();
        }
        else
        {
            _ui->wizardStackedWidget->setCurrentWidget(_ui->restorePage);
            _ui->restorePageRadioButton->setEnabled(true);
        }
    }
    else if(_ui->wizardStackedWidget->currentWidget() == _ui->advancedPage)
    {
        _ui->wizardStackedWidget->setCurrentWidget(_ui->restorePage);
        _ui->restorePageRadioButton->setEnabled(true);
    }
    else if(_ui->wizardStackedWidget->currentWidget() == _ui->restorePage)
    {
        _ui->wizardStackedWidget->setCurrentWidget(_ui->registerPage);
        _ui->registerPageRadioButton->setEnabled(true);
    }
    else if(_ui->wizardStackedWidget->currentWidget() == _ui->registerPage)
    {
        _ui->wizardStackedWidget->setCurrentWidget(_ui->donePage);
        _ui->donePageRadioButton->setEnabled(true);
    }
}
Пример #2
0
SetupDialog::SetupDialog(QWidget *parent) :
    QDialog(parent),
    _ui(new Ui::SetupDialog),
    _loadingAnimation(":/resources/icons/loading.gif"),
    _haveKey(false)
{
    _ui->setupUi(this);

    _ui->loadingIconLabel->setMovie(&_loadingAnimation);
    _ui->advancedPageRadioButton->hide();
    _ui->errorLabel->hide();
    _ui->machineKeyLabel->hide();
    _ui->machineKeyLineEdit->hide();
    _ui->locateMachineKeyLabel->hide();

    connect(_ui->welcomePageRadioButton, SIGNAL(clicked()), this, SLOT(skipToPage()));
    connect(_ui->restorePageRadioButton, SIGNAL(clicked()), this, SLOT(skipToPage()));
    connect(_ui->advancedPageRadioButton, SIGNAL(clicked()), this, SLOT(skipToPage()));
    connect(_ui->registerAccountPageRadioButton, SIGNAL(clicked()), this, SLOT(skipToPage()));
    connect(_ui->donePageRadioButton, SIGNAL(clicked()), this, SLOT(skipToPage()));

    connect(_ui->wizardStackedWidget, SIGNAL(currentChanged(int)), this, SLOT(wizardPageChanged(int)));

    // Welcome page
    connect(_ui->advancedSetupCheckBox, SIGNAL(toggled(bool)), _ui->advancedPageRadioButton, SLOT(setVisible(bool)));
    connect(_ui->welcomePageSkipButton, &QPushButton::clicked, [=](){commitSettings(true);});
    connect(_ui->welcomePageProceedButton, SIGNAL(clicked()), this, SLOT(setNextPage()));

    // Advanced setup page
    connect(_ui->tarsnapPathBrowseButton, SIGNAL(clicked()), this, SLOT(showTarsnapPathBrowse()));
    connect(_ui->tarsnapPathLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateAdvancedSetupPage()));
    connect(_ui->tarsnapCacheBrowseButton, SIGNAL(clicked()), this, SLOT(showTarsnapCacheBrowse()));
    connect(_ui->tarsnapCacheLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateAdvancedSetupPage()));
    connect(_ui->appDataBrowseButton, SIGNAL(clicked()), this, SLOT(showAppDataBrowse()));
    connect(_ui->appDataPathLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateAdvancedSetupPage()));
    connect(_ui->advancedPageProceedButton, SIGNAL(clicked()), this, SLOT(setNextPage()));

    // Restore page
    connect(_ui->restoreNoButton, SIGNAL(clicked()), this, SLOT(restoreNo()));
    connect(_ui->restoreYesButton, SIGNAL(clicked()), this, SLOT(restoreYes()));

    // Register page
    connect(_ui->tarsnapUserLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateRegisterPage()));
    connect(_ui->tarsnapPasswordLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateRegisterPage()));
    connect(_ui->machineNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateRegisterPage()));
    connect(_ui->machineKeyLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateRegisterPage()));
    connect(_ui->locateMachineKeyLabel, SIGNAL(linkActivated(QString)), this, SLOT(registerHaveKeyBrowse(QString)));
    connect(_ui->registerMachineButton, SIGNAL(clicked()), this, SLOT(registerMachine()));

    // Done page
    connect(_ui->doneButton, SIGNAL(clicked()), this, SLOT(commitSettings()));

#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
    _appDataDir = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
#else
    _appDataDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
#endif
    QDir keysDir(_appDataDir);
    if(!keysDir.exists())
        keysDir.mkpath(_appDataDir);
    _ui->appDataPathLineEdit->setText(_appDataDir);

    _tarsnapCacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
    QDir cacheDir(_tarsnapCacheDir);
    if(!cacheDir.exists())
        cacheDir.mkpath(_tarsnapCacheDir);
    _ui->tarsnapCacheLineEdit->setText(_tarsnapCacheDir);

    _tarsnapCLIDir = Utils::findTarsnapClientInPath("", true);
    _ui->tarsnapPathLineEdit->setText(_tarsnapCLIDir);
    _ui->machineNameLineEdit->setText(QHostInfo::localHostName());
    _ui->wizardStackedWidget->setCurrentWidget(_ui->welcomePage);
}