🎨 Added clang-format
This commit is contained in:
@ -1,107 +1,98 @@
|
||||
#include "RemoteDialog.h"
|
||||
#include "ui_RemoteDialog.h"
|
||||
#include <QFileDialog>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QClipboard>
|
||||
#include <QUrl>
|
||||
#include "Utils.h"
|
||||
#include "ui_RemoteDialog.h"
|
||||
#include <QClipboard>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QUrl>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
RemoteDialog::RemoteDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::RemoteDialog)
|
||||
RemoteDialog::RemoteDialog(QWidget *parent) : QDialog(parent), ui(new Ui::RemoteDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
RemoteDialog::~RemoteDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool RemoteDialog::run(QWidget *parent, QUrl &url, QString &name)
|
||||
{
|
||||
RemoteDialog dlg(parent);
|
||||
RemoteDialog dlg(parent);
|
||||
|
||||
// Set URL components
|
||||
if(!url.isEmpty())
|
||||
{
|
||||
dlg.ui->lineName->setText(name);
|
||||
// Set URL components
|
||||
if (!url.isEmpty())
|
||||
{
|
||||
dlg.ui->lineName->setText(name);
|
||||
|
||||
if(url.isLocalFile())
|
||||
dlg.ui->lineURL->setText(QDir::toNativeSeparators(url.toLocalFile()));
|
||||
else
|
||||
{
|
||||
QString url_no_credentials = UrlToStringNoCredentials(url);
|
||||
dlg.ui->lineURL->setText(url_no_credentials);
|
||||
dlg.ui->lineUserName->setText(url.userName());
|
||||
dlg.ui->linePassword->setText(url.password());
|
||||
}
|
||||
}
|
||||
if (url.isLocalFile())
|
||||
dlg.ui->lineURL->setText(QDir::toNativeSeparators(url.toLocalFile()));
|
||||
else
|
||||
{
|
||||
QString url_no_credentials = UrlToStringNoCredentials(url);
|
||||
dlg.ui->lineURL->setText(url_no_credentials);
|
||||
dlg.ui->lineUserName->setText(url.userName());
|
||||
dlg.ui->linePassword->setText(url.password());
|
||||
}
|
||||
}
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
|
||||
QString urltext = dlg.ui->lineURL->text();
|
||||
QString urltext = dlg.ui->lineURL->text();
|
||||
|
||||
// Check if the url is a local file
|
||||
if(QFileInfo(urltext).exists())
|
||||
url = QUrl::fromLocalFile(urltext);
|
||||
else
|
||||
{
|
||||
url = QUrl::fromUserInput(urltext);
|
||||
if(url.isEmpty() || !url.isValid())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid URL."), QMessageBox::Ok );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Check if the url is a local file
|
||||
if (QFileInfo(urltext).exists())
|
||||
url = QUrl::fromLocalFile(urltext);
|
||||
else
|
||||
{
|
||||
url = QUrl::fromUserInput(urltext);
|
||||
if (url.isEmpty() || !url.isValid())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid URL."), QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!dlg.ui->lineUserName->text().trimmed().isEmpty())
|
||||
url.setUserName(dlg.ui->lineUserName->text());
|
||||
if (!dlg.ui->lineUserName->text().trimmed().isEmpty())
|
||||
url.setUserName(dlg.ui->lineUserName->text());
|
||||
|
||||
if(!dlg.ui->linePassword->text().trimmed().isEmpty())
|
||||
url.setPassword(dlg.ui->linePassword->text());
|
||||
if (!dlg.ui->linePassword->text().trimmed().isEmpty())
|
||||
url.setPassword(dlg.ui->linePassword->text());
|
||||
|
||||
name = dlg.ui->lineName->text().trimmed();
|
||||
if(name.isEmpty())
|
||||
name = UrlToStringNoCredentials(url);
|
||||
name = dlg.ui->lineName->text().trimmed();
|
||||
if (name.isEmpty())
|
||||
name = UrlToStringNoCredentials(url);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RemoteDialog::GetRepositoryPath(QString &pathResult)
|
||||
{
|
||||
QString filter(tr("Fossil Repository") + QString(" (*." FOSSIL_EXT ")"));
|
||||
QString filter(tr("Fossil Repository") + QString(" (*." FOSSIL_EXT ")"));
|
||||
|
||||
pathResult = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
tr("Select Fossil Repository"),
|
||||
QDir::toNativeSeparators(pathResult),
|
||||
filter,
|
||||
&filter,
|
||||
QFileDialog::DontConfirmOverwrite);
|
||||
pathResult = QFileDialog::getSaveFileName(this, tr("Select Fossil Repository"), QDir::toNativeSeparators(pathResult), filter, &filter, QFileDialog::DontConfirmOverwrite);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RemoteDialog::on_btnSelectSourceRepo_clicked()
|
||||
{
|
||||
QString path = ui->lineURL->text();
|
||||
GetRepositoryPath(path);
|
||||
QString path = ui->lineURL->text();
|
||||
GetRepositoryPath(path);
|
||||
|
||||
if(path.trimmed().isEmpty())
|
||||
return;
|
||||
if (path.trimmed().isEmpty())
|
||||
return;
|
||||
|
||||
if(!QFile::exists(path))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
if (!QFile::exists(path))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->lineURL->setText(QDir::toNativeSeparators(path));
|
||||
ui->lineURL->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user