This repository has been archived by the owner on Sep 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #17
- Loading branch information
Showing
10 changed files
with
522 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#include "export_dialog.h" | ||
#include "utils.h" | ||
|
||
ExportDialog::ExportDialog(const QString& remote, const QDir& path, QWidget* parent) | ||
: QDialog(parent) | ||
{ | ||
ui.setupUi(this); | ||
resize(0, 0); | ||
|
||
mTarget = remote + ":" + path.path(); | ||
|
||
QObject::connect(ui.buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, [=]() | ||
{ | ||
ui.rbText->setChecked(true); | ||
ui.checkVerbose->setChecked(false); | ||
ui.checkSameFilesystem->setChecked(false); | ||
ui.textMinSize->clear(); | ||
ui.textMinAge->clear(); | ||
ui.textMaxAge->clear(); | ||
ui.spinMaxDepth->setValue(0); | ||
ui.textExclude->clear(); | ||
ui.textExtra->clear(); | ||
}); | ||
ui.buttonBox->button(QDialogButtonBox::RestoreDefaults)->click(); | ||
|
||
QObject::connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); | ||
QObject::connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); | ||
|
||
QObject::connect(ui.fileBrowse, &QToolButton::clicked, this, [=]() | ||
{ | ||
QString file = QFileDialog::getSaveFileName(this, "Choose destination file"); | ||
if (!file.isEmpty()) | ||
{ | ||
ui.textFile->setText(QDir::toNativeSeparators(file)); | ||
} | ||
}); | ||
|
||
QSettings settings; | ||
settings.beginGroup("Export"); | ||
ReadSettings(&settings, this); | ||
settings.endGroup(); | ||
} | ||
|
||
ExportDialog::~ExportDialog() | ||
{ | ||
if (result() == QDialog::Accepted) | ||
{ | ||
QSettings settings; | ||
settings.beginGroup("Export"); | ||
WriteSettings(&settings, this); | ||
settings.remove("textFile"); | ||
settings.endGroup(); | ||
} | ||
} | ||
|
||
QString ExportDialog::getDestination() const | ||
{ | ||
return ui.textFile->text(); | ||
} | ||
|
||
bool ExportDialog::onlyFilenames() const | ||
{ | ||
return ui.rbText->isChecked(); | ||
} | ||
|
||
QStringList ExportDialog::getOptions() const | ||
{ | ||
QStringList list; | ||
list << "lsl"; | ||
if (ui.checkVerbose->isChecked()) | ||
{ | ||
list << "--verbose"; | ||
} | ||
if (ui.checkSameFilesystem->isChecked()) | ||
{ | ||
list << "--one-file-system"; | ||
} | ||
if (!ui.textMinSize->text().isEmpty()) | ||
{ | ||
list << "--min-size" << ui.textMinSize->text(); | ||
} | ||
if (!ui.textMinAge->text().isEmpty()) | ||
{ | ||
list << "--min-age" << ui.textMinAge->text(); | ||
} | ||
if (!ui.textMaxAge->text().isEmpty()) | ||
{ | ||
list << "--max-age" << ui.textMaxAge->text(); | ||
} | ||
if (ui.spinMaxDepth->value() != 0) | ||
{ | ||
list << "--max-depth" << ui.spinMaxDepth->text(); | ||
} | ||
|
||
QString excluded = ui.textExclude->toPlainText().trimmed(); | ||
if (!excluded.isEmpty()) | ||
{ | ||
for (auto line : excluded.split('\n')) | ||
{ | ||
list << "--exclude" << line; | ||
} | ||
} | ||
|
||
QString extra = ui.textExtra->text().trimmed(); | ||
if (!extra.isEmpty()) | ||
{ | ||
for (auto arg : extra.split(' ')) | ||
{ | ||
list << arg; | ||
} | ||
} | ||
|
||
list << mTarget; | ||
|
||
return list; | ||
} | ||
|
||
void ExportDialog::done(int r) | ||
{ | ||
if (r == QDialog::Accepted) | ||
{ | ||
if (ui.textFile->text().isEmpty()) | ||
{ | ||
QMessageBox::warning(this, "Warning", "Please enter destination filename!"); | ||
return; | ||
} | ||
} | ||
QDialog::done(r); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include "pch.h" | ||
#include "ui_export_dialog.h" | ||
|
||
class ExportDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
ExportDialog(const QString& remote, const QDir& path, QWidget* parent = nullptr); | ||
~ExportDialog(); | ||
|
||
QString getDestination() const; | ||
bool onlyFilenames() const; | ||
QStringList getOptions() const; | ||
|
||
private: | ||
Ui::ExportDialog ui; | ||
QString mTarget; | ||
|
||
void done(int r) override; | ||
}; |
Oops, something went wrong.