Commit 8f8cfb20 authored by Simon Persson's avatar Simon Persson

Disable "Generate recovery info" option if par2 is not installed

Looks a bit better to inform user that an option is actually not available.
parent 82f373d9
......@@ -183,7 +183,8 @@ void DirDialog::createNewFolder() {
mTreeView->setCurrentUrl(lPartialUrl);
}
BackupPlanWidget::BackupPlanWidget(BackupPlan *pBackupPlan, const QString &pBupVersion, const QString &pRsyncVersion)
BackupPlanWidget::BackupPlanWidget(BackupPlan *pBackupPlan, const QString &pBupVersion,
const QString &pRsyncVersion, bool pPar2Available)
: QWidget(), mBackupPlan(pBackupPlan)
{
mDescriptionEdit = new KLineEdit;
......@@ -200,7 +201,7 @@ BackupPlanWidget::BackupPlanWidget(BackupPlan *pBackupPlan, const QString &pBupV
mConfigPages->addPage(createSourcePage());
mConfigPages->addPage(createDestinationPage());
mConfigPages->addPage(createSchedulePage());
mConfigPages->addPage(createAdvancedPage());
mConfigPages->addPage(createAdvancedPage(pPar2Available));
QHBoxLayout *lHLayout1 = new QHBoxLayout;
lHLayout1->addWidget(mConfigureButton);
......@@ -501,7 +502,7 @@ KPageWidgetItem *BackupPlanWidget::createSchedulePage() {
return lPage;
}
KPageWidgetItem *BackupPlanWidget::createAdvancedPage() {
KPageWidgetItem *BackupPlanWidget::createAdvancedPage(bool pPar2Available) {
QWidget *lAdvancedWidget = new QWidget(this);
QVBoxLayout *lAdvancedLayout = new QVBoxLayout;
......@@ -524,7 +525,7 @@ KPageWidgetItem *BackupPlanWidget::createAdvancedPage() {
lShowHiddenLayout->addWidget(lShowHiddenLabel, 0, 1);
QWidget *lRecoveryWidget = new QWidget;
QCheckBox *lRecoveryCheckBox = new QCheckBox(i18nc("@option:check", "Generate recovery information"));
QCheckBox *lRecoveryCheckBox = new QCheckBox;
lRecoveryCheckBox->setObjectName(QLatin1String("kcfg_Generate recovery info"));
QLabel *lRecoveryLabel = new QLabel(i18nc("@info", "This will make your backups use around 10% more storage "
......@@ -532,6 +533,13 @@ KPageWidgetItem *BackupPlanWidget::createAdvancedPage() {
"return it will be possible to recover from a partially corrupted "
"backup."));
lRecoveryLabel->setWordWrap(true);
if(pPar2Available) {
lRecoveryCheckBox->setText(i18nc("@option:check", "Generate recovery information"));
} else {
lRecoveryCheckBox->setText(i18nc("@option:check", "Generate recovery information (not available because \"par2\" is not installed)"));
lRecoveryCheckBox->setEnabled(false);
lRecoveryLabel->setEnabled(false);
}
QGridLayout *lRecoveryLayout = new QGridLayout;
lRecoveryLayout->setContentsMargins(0, 0, 0, 0);
lRecoveryLayout->setSpacing(0);
......
......@@ -82,7 +82,8 @@ class BackupPlanWidget : public QWidget
{
Q_OBJECT
public:
BackupPlanWidget(BackupPlan *pBackupPlan, const QString &pBupVersion, const QString &pRsyncVersion);
BackupPlanWidget(BackupPlan *pBackupPlan, const QString &pBupVersion,
const QString &pRsyncVersion, bool pPar2Available);
void saveExtraData();
......@@ -90,7 +91,7 @@ public:
KPageWidgetItem *createSourcePage();
KPageWidgetItem *createDestinationPage();
KPageWidgetItem *createSchedulePage();
KPageWidgetItem *createAdvancedPage();
KPageWidgetItem *createAdvancedPage(bool pPar2Available);
KLineEdit *mDescriptionEdit;
KPushButton *mConfigureButton;
......
......@@ -63,6 +63,11 @@ KupKcm::KupKcm(QWidget *pParent, const QList<QVariant> &pArgs)
int lExitCode = lBupProcess.execute();
if(lExitCode >= 0) {
mBupVersion = QString::fromUtf8(lBupProcess.readAllStandardOutput());
KProcess lPar2Process;
lPar2Process << QLatin1String("bup") << QLatin1String("fsck") << QLatin1String("--par2-ok");
mPar2Available = lPar2Process.execute() == 0;
} else {
mPar2Available = false;
}
KProcess lRsyncProcess;
......@@ -256,7 +261,7 @@ void KupKcm::createSettingsFrontPage() {
}
void KupKcm::createPlanWidgets(int pIndex) {
BackupPlanWidget *lPlanWidget = new BackupPlanWidget(mPlans.at(pIndex), mBupVersion, mRsyncVersion);
BackupPlanWidget *lPlanWidget = new BackupPlanWidget(mPlans.at(pIndex), mBupVersion, mRsyncVersion, mPar2Available);
connect(lPlanWidget, SIGNAL(requestOverviewReturn()), this, SLOT(showFrontPage()));
KConfigDialogManager *lConfigManager = new KConfigDialogManager(lPlanWidget, mPlans.at(pIndex));
lConfigManager->setObjectName(objectName());
......
......@@ -75,6 +75,7 @@ private:
KPushButton *mAddPlanButton;
QString mBupVersion;
QString mRsyncVersion;
bool mPar2Available;
};
#endif // KUPKCM_H
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