コード例 #1
0
ファイル: setupdialog.cpp プロジェクト: contian/tarsnap-gui
void SetupDialog::restoreNo()
{
    _haveKey = false;
    _ui->machineKeyLabel->hide();
    _ui->machineKeyLineEdit->hide();
    _ui->locateMachineKeyLabel->hide();
    _ui->tarsnapUserLabel->show();
    _ui->tarsnapUserLineEdit->show();
    _ui->tarsnapPasswordLabel->show();
    _ui->tarsnapPasswordLineEdit->show();
    _ui->registerPageInfoLabel->setText(tr("Please use your Tarsnap account "
                                           "credentials. Don't have an account? "
                                           "Register one <a href=\"http://tarsnap.com\">here</a>."));
    _ui->errorLabel->clear();
    setNextPage();
}
コード例 #2
0
ファイル: setupdialog.cpp プロジェクト: contian/tarsnap-gui
void SetupDialog::restoreYes()
{
    _haveKey = true;
    _ui->tarsnapUserLabel->hide();
    _ui->tarsnapUserLineEdit->hide();
    _ui->tarsnapPasswordLabel->hide();
    _ui->tarsnapPasswordLineEdit->hide();
    _ui->machineKeyLabel->show();
    _ui->machineKeyLineEdit->show();
    _ui->locateMachineKeyLabel->show();
    _ui->registerPageInfoLabel->setText(tr("Please use your existing machine key "
                                           "and a machine name of your liking. "
                                           "The registration might take a bit to "
                                           "verify archive consistency and integrity "
                                           "using the cache, thus please be patient."));
    _ui->errorLabel->clear();
    setNextPage();
}
コード例 #3
0
ファイル: setupdialog.cpp プロジェクト: contian/tarsnap-gui
void SetupDialog::registerMachineStatus(TaskStatus status, QString reason)
{
    switch(status)
    {
        case TaskStatus::Completed:
            _ui->errorLabel->clear();
            _ui->doneInfoTextBrowser->setHtml(_ui->doneInfoTextBrowser->toHtml().arg(_tarsnapKeyFile).arg(_tarsnapKeyFile));
            _ui->doneButton->setEnabled(true);
            setNextPage();
            break;
        case TaskStatus::Failed:
            _ui->errorLabel->setText(reason);
            _ui->errorLabel->show();
            _ui->registerMachineButton->setEnabled(true);
            resize(sizeHint());
            break;
        default:
            break;
    }
}
コード例 #4
0
void SetupDialog::restoreYes()
{
    _haveKey = true;
    _ui->tarsnapUserLabel->hide();
    _ui->tarsnapUserLineEdit->hide();
    _ui->tarsnapPasswordLabel->hide();
    _ui->tarsnapPasswordLineEdit->hide();
    _ui->machineKeyLabel->show();
    _ui->machineKeyCombo->show();
    _ui->browseKeyButton->show();
    _ui->registerPageInfoLabel->setText(
        tr("Please use your existing machine key "
           "and a machine name of your liking. "
           "The registration might take a bit to "
           "verify archive consistency and integrity "
           "using the cache, thus please be patient."));
    _ui->errorLabel->clear();
    _ui->machineKeyCombo->clear();
    foreach(QFileInfo file, Utils::findKeysInPath(_appDataDir))
        _ui->machineKeyCombo->addItem(file.canonicalFilePath());
    setNextPage();
}
コード例 #5
0
ファイル: setupdialog.cpp プロジェクト: contian/tarsnap-gui
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);
}