Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
- move calculations to GUI layer
- add unit to downloadTimeout and uploadTimeout
  • Loading branch information
t-h-e committed Oct 3, 2024
1 parent 46b4b15 commit a6bb713
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
18 changes: 9 additions & 9 deletions src/gui/remote/DatabaseSettingsWidgetRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ DatabaseSettingsWidgetRemote::DatabaseSettingsWidgetRemote(QWidget* parent)
connect(m_ui->nameLineEdit, &QLineEdit::textChanged, setModified);
connect(m_ui->downloadCommand, &QLineEdit::textChanged, setModified);
connect(m_ui->inputForDownload, &QPlainTextEdit::textChanged, setModified);
connect(m_ui->downloadTimeout, QOverload<int>::of(&QSpinBox::valueChanged), setModified);
connect(m_ui->downloadTimeoutSec, QOverload<int>::of(&QSpinBox::valueChanged), setModified);
connect(m_ui->uploadCommand, &QLineEdit::textChanged, setModified);
connect(m_ui->inputForUpload, &QPlainTextEdit::textChanged, setModified);
connect(m_ui->uploadTimeout, QOverload<int>::of(&QSpinBox::valueChanged), setModified);
connect(m_ui->uploadTimeoutSec, QOverload<int>::of(&QSpinBox::valueChanged), setModified);
}

DatabaseSettingsWidgetRemote::~DatabaseSettingsWidgetRemote() = default;
Expand Down Expand Up @@ -102,10 +102,10 @@ void DatabaseSettingsWidgetRemote::saveCurrentSettings()
params->name = m_ui->nameLineEdit->text();
params->downloadCommand = m_ui->downloadCommand->text();
params->downloadInput = m_ui->inputForDownload->toPlainText();
params->downloadTimeout = m_ui->downloadTimeout->value();
params->downloadTimeoutMsec = m_ui->downloadTimeoutSec->value() * 1000;
params->uploadCommand = m_ui->uploadCommand->text();
params->uploadInput = m_ui->inputForUpload->toPlainText();
params->uploadTimeout = m_ui->uploadTimeout->value();
params->uploadTimeoutMsec = m_ui->uploadTimeoutSec->value() * 1000;

m_remoteSettings->addRemoteParams(params);
updateSettingsList();
Expand Down Expand Up @@ -149,10 +149,10 @@ void DatabaseSettingsWidgetRemote::editCurrentSettings()
m_ui->nameLineEdit->setText(params->name);
m_ui->downloadCommand->setText(params->downloadCommand);
m_ui->inputForDownload->setPlainText(params->downloadInput);
m_ui->downloadTimeout->setValue(params->downloadTimeout);
m_ui->downloadTimeoutSec->setValue(params->downloadTimeoutMsec / 1000);
m_ui->uploadCommand->setText(params->uploadCommand);
m_ui->inputForUpload->setPlainText(params->uploadInput);
m_ui->uploadTimeout->setValue(params->uploadTimeout);
m_ui->uploadTimeoutSec->setValue(params->uploadTimeoutMsec / 1000);
m_modified = false;
}

Expand All @@ -171,10 +171,10 @@ void DatabaseSettingsWidgetRemote::clearFields()
m_ui->nameLineEdit->setText("");
m_ui->downloadCommand->setText("");
m_ui->inputForDownload->setPlainText("");
m_ui->downloadTimeout->setValue(10);
m_ui->downloadTimeoutSec->setValue(10);
m_ui->uploadCommand->setText("");
m_ui->inputForUpload->setPlainText("");
m_ui->uploadTimeout->setValue(10);
m_ui->uploadTimeoutSec->setValue(10);
m_modified = false;
}

Expand All @@ -184,7 +184,7 @@ void DatabaseSettingsWidgetRemote::testDownload()
params->name = m_ui->nameLineEdit->text();
params->downloadCommand = m_ui->downloadCommand->text();
params->downloadInput = m_ui->inputForDownload->toPlainText();
params->downloadTimeout = m_ui->downloadTimeout->value();
params->downloadTimeoutMsec = m_ui->downloadTimeoutSec->value() * 1000;

QScopedPointer<RemoteHandler> remoteHandler(new RemoteHandler(this));
if (params->downloadCommand.isEmpty()) {
Expand Down
4 changes: 2 additions & 2 deletions src/gui/remote/DatabaseSettingsWidgetRemote.ui
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ The command has to exit. In case of `sftp` as last command `exit` has to be sent
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="downloadTimeout">
<widget class="QSpinBox" name="downloadTimeoutSec">
<property name="suffix">
<string> seconds</string>
</property>
Expand Down Expand Up @@ -267,7 +267,7 @@ The command has to exit. In case of `sftp` as last command `exit` has to be sent
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="uploadTimeout">
<widget class="QSpinBox" name="uploadTimeoutSec">
<property name="suffix">
<string> seconds</string>
</property>
Expand Down
4 changes: 2 additions & 2 deletions src/gui/remote/RemoteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ RemoteHandler::RemoteResult RemoteHandler::download(const RemoteParams* params)
remoteProcess->closeWriteChannel();
}

bool finished = remoteProcess->waitForFinished(params->downloadTimeout * 1000);
bool finished = remoteProcess->waitForFinished(params->downloadTimeoutMsec);
int statusCode = remoteProcess->exitCode();

// TODO: For future use
Expand Down Expand Up @@ -118,7 +118,7 @@ RemoteHandler::RemoteResult RemoteHandler::upload(const QString& filePath, const
remoteProcess->closeWriteChannel();
}

bool finished = remoteProcess->waitForFinished(params->uploadTimeout * 1000);
bool finished = remoteProcess->waitForFinished(params->uploadTimeoutMsec);
int statusCode = remoteProcess->exitCode();

// TODO: For future use
Expand Down
8 changes: 4 additions & 4 deletions src/gui/remote/RemoteSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ QString RemoteSettings::toConfig() const
object["name"] = params->name;
object["downloadCommand"] = params->downloadCommand;
object["downloadCommandInput"] = params->downloadInput;
object["downloadTimeout"] = params->downloadTimeout;
object["downloadTimeoutMsec"] = params->downloadTimeoutMsec;
object["uploadCommand"] = params->uploadCommand;
object["uploadCommandInput"] = params->uploadInput;
object["uploadTimeout"] = params->uploadTimeout;
object["uploadTimeoutMsec"] = params->uploadTimeoutMsec;
config << object;
}
QJsonDocument doc(config);
Expand All @@ -110,10 +110,10 @@ void RemoteSettings::fromConfig(const QString& data)
params->name = itemMap["name"].toString();
params->downloadCommand = itemMap["downloadCommand"].toString();
params->downloadInput = itemMap["downloadCommandInput"].toString();
params->downloadTimeout = itemMap.value("downloadTimeout", 10).toInt();
params->downloadTimeoutMsec = itemMap.value("downloadTimeoutMsec", 10000).toInt();
params->uploadCommand = itemMap["uploadCommand"].toString();
params->uploadInput = itemMap["uploadCommandInput"].toString();
params->uploadTimeout = itemMap.value("uploadTimeout", 10).toInt();
params->uploadTimeoutMsec = itemMap.value("uploadTimeoutMsec", 10000).toInt();

m_remoteParams.insert(params->name, params);
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/remote/RemoteSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ struct RemoteParams
QString name;
QString downloadCommand;
QString downloadInput;
int downloadTimeout;
int downloadTimeoutMsec;
QString uploadCommand;
QString uploadInput;
int uploadTimeout;
int uploadTimeoutMsec;
};
Q_DECLARE_METATYPE(RemoteParams)

Expand Down

0 comments on commit a6bb713

Please sign in to comment.