diff --git a/CloneDialog.cpp b/CloneDialog.cpp new file mode 100644 index 0000000..afef5e1 --- /dev/null +++ b/CloneDialog.cpp @@ -0,0 +1,92 @@ +#include "CloneDialog.h" +#include "ui_CloneDialog.h" +#include +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +CloneDialog::CloneDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::CloneDialog) +{ + ui->setupUi(this); +} + +//----------------------------------------------------------------------------- +CloneDialog::~CloneDialog() +{ + delete ui; +} + +//----------------------------------------------------------------------------- +bool CloneDialog::run(QWidget *parent, QUrl &url, QString &repository) +{ + CloneDialog dlg(parent); + + // Try to parse a url from the clipboard + QClipboard *clipboard = QApplication::clipboard(); + if(clipboard) + { + QUrl nurl = QUrl::fromUserInput(clipboard->text()); + + // If we have a valid url + if(nurl.isValid() && !nurl.isEmpty()) + { + // Fill in dialog + dlg.ui->lineUserName->setText(nurl.userName()); + dlg.ui->linePassword->setText(nurl.password()); + nurl.setUserName(""); + nurl.setPassword(""); + dlg.ui->lineURL->setText(nurl.toString()); + } + } + + if(dlg.exec() != QDialog::Accepted) + return false; + + url.setUrl(dlg.ui->lineURL->text()); + if(url.isEmpty() || !url.isValid()) + { + QMessageBox::critical(parent, tr("Error"), tr("Invalid URL."), QMessageBox::Ok ); + return false; + } + + url.setUserName(dlg.ui->lineUserName->text()); + url.setPassword(dlg.ui->linePassword->text()); + + if(dlg.ui->lineRepository->text().isEmpty() ) + { + QMessageBox::critical(parent, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok ); + return false; + } + + repository = dlg.ui->lineRepository->text(); + return true; +} + +//----------------------------------------------------------------------------- +void CloneDialog::on_btnSelectRepository_clicked() +{ + QString filter(tr("Fossil Repository (*.fossil)")); + + QString path = QFileDialog::getSaveFileName( + this, + tr("Select Fossil Repository"), + QDir::toNativeSeparators(ui->lineRepository->text()), + filter, + &filter, + QFileDialog::DontConfirmOverwrite); + + if(path.isEmpty()) + return; + + if(QFile::exists(path)) + { + QMessageBox::critical(this, tr("Error"), tr("This repository file already exists."), QMessageBox::Ok ); + return; + } + + ui->lineRepository->setText(QDir::toNativeSeparators(path)); +} diff --git a/CloneDialog.h b/CloneDialog.h new file mode 100644 index 0000000..f9698ce --- /dev/null +++ b/CloneDialog.h @@ -0,0 +1,27 @@ +#ifndef CLONEDIALOG_H +#define CLONEDIALOG_H + +#include + +namespace Ui { +class CloneDialog; +} + +class CloneDialog : public QDialog +{ + Q_OBJECT + +public: + explicit CloneDialog(QWidget *parent = 0); + ~CloneDialog(); + + static bool run(QWidget *parent, class QUrl &url, QString &repository); + +private slots: + void on_btnSelectRepository_clicked(); + +private: + Ui::CloneDialog *ui; +}; + +#endif // CLONEDIALOG_H diff --git a/CloneDialog.ui b/CloneDialog.ui new file mode 100644 index 0000000..938a6b1 --- /dev/null +++ b/CloneDialog.ui @@ -0,0 +1,156 @@ + + + CloneDialog + + + Qt::WindowModal + + + + 0 + 0 + 478 + 173 + + + + Clone Repository + + + true + + + + + + + + URL + + + + + + + The URL of the source repository + + + + + + + User Name + + + + + + + The user name used to access the remote repository. Leave blank if not required + + + + + + + Password + + + + + + + The password used to access the remote repository. Leave blank if not required + + + QLineEdit::Password + + + + + + + Repository + + + + + + + + + Path to the local repository file + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + ... + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + CloneDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + CloneDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/MainWindow.cpp b/MainWindow.cpp index 902b810..b27afb9 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -17,6 +17,7 @@ #include #include "CommitDialog.h" #include "FileActionDialog.h" +#include "CloneDialog.h" #include "Utils.h" #define COUNTOF(array) (sizeof(array)/sizeof(array[0])) @@ -184,7 +185,7 @@ MainWindow::MainWindow(QWidget *parent, QString *workspacePath, bool portableMod // Windows: HKEY_CURRENT_USER\Software\organizationName\Fuel qsettings = new QSettings(QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName()); } - + loadSettings(); // Apply any explicit workspace path if available @@ -296,7 +297,7 @@ bool MainWindow::openWorkspace(const QString &path) } repositoryFile = fi.absoluteFilePath(); - + if(!runFossil(QStringList() << "open" << QuotePath(repositoryFile))) { QMessageBox::critical(this, tr("Error"), tr("Could not open repository."), QMessageBox::Ok ); @@ -434,7 +435,7 @@ void MainWindow::on_actionCloseRepository_triggered() // Close Repo if(!runFossil(QStringList() << "close")) { - QMessageBox::critical(this, tr("Error"), tr("Cannot close the workspace.\nAre there still uncommitted changes in available?"), QMessageBox::Ok ); + QMessageBox::critical(this, tr("Error"), tr("Cannot close the workspace.\nAre there still uncommitted changes available?"), QMessageBox::Ok ); return; } @@ -446,8 +447,33 @@ void MainWindow::on_actionCloseRepository_triggered() //------------------------------------------------------------------------------ void MainWindow::on_actionCloneRepository_triggered() { - // FIXME: Implement this + QUrl url; + QString repository; + + if(!CloneDialog::run(this, url, repository)) + return; + stopUI(); + + // Actual command + QStringList cmd = QStringList() << "clone" << url.toString() << repository; + + // Log Command + if(!url.password().isEmpty()) + url.setPassword("*****"); + QStringList logcmd = QStringList() << "fossil" << "clone" << url.toString() << repository; + + log(">"+logcmd.join(" ")+"
", true); + + // Clone Repo + if(!runFossil(cmd, 0, RUNGLAGS_SILENT_INPUT)) + { + QMessageBox::critical(this, tr("Error"), tr("Could not clone the repository"), QMessageBox::Ok); + return; + } + + openWorkspace(repository); + } //------------------------------------------------------------------------------ @@ -725,7 +751,7 @@ void MainWindow::scanWorkspace() QString name; // Finish at an anonymous stash or start of a new stash ? if(line_it==res.end() || stash_rx.indexIn(*line_it)!=-1) - name = line.trimmed(); + name = line.trimmed(); else // Named stash { // Parse stash name @@ -1342,8 +1368,8 @@ void MainWindow::getSelectionFilenames(QStringList &filenames, int includeMask, { if(QApplication::focusWidget() == ui->treeView) getDirViewSelection(filenames, includeMask, allIfEmpty); - else - getFileViewSelection(filenames, includeMask, allIfEmpty); + else + getFileViewSelection(filenames, includeMask, allIfEmpty); } //------------------------------------------------------------------------------ @@ -1691,8 +1717,8 @@ void MainWindow::on_actionCommit_triggered() comment_file.close(); // Generate fossil parameters. - QStringList params; - params << "commit" << "--message-file" << QuotePath(comment_fname); + QStringList params; + params << "commit" << "--message-file" << QuotePath(comment_fname); // When a subset of files has been selected, explicitely specify each file. // Otherwise all files will be implicitly committed by fossil. This is necessary @@ -1702,7 +1728,7 @@ void MainWindow::on_actionCommit_triggered() getAllFilenames(all_modified_files, RepoFile::TYPE_MODIFIED); if(commit_files.size() != all_modified_files.size()) - params << QuotePaths(commit_files); + params << QuotePaths(commit_files); runFossil(params); QFile::remove(comment_fname); @@ -2429,7 +2455,7 @@ void MainWindow::on_tableView_customContextMenuRequested(const QPoint &pos) } else #else - Q_UNUSED(pos); + Q_UNUSED(pos); #endif { QMenu *menu = new QMenu(this); diff --git a/MainWindow.ui b/MainWindow.ui index a71156c..68563f1 100644 --- a/MainWindow.ui +++ b/MainWindow.ui @@ -176,7 +176,7 @@ 0 0 865 - 24 + 23 @@ -184,6 +184,8 @@ &File + + @@ -408,10 +410,10 @@ - :/icons/icons/Address Book-01.png:/icons/icons/Address Book-01.png + :/icons/icons/My Websites-01.png:/icons/icons/My Websites-01.png - Clone Repository... + Clone... diff --git a/SettingsDialog.cpp b/SettingsDialog.cpp index fbd5801..b930b7f 100644 --- a/SettingsDialog.cpp +++ b/SettingsDialog.cpp @@ -3,16 +3,17 @@ #include #include "Utils.h" -static QString SelectExe(QWidget *parent, const QString &description) +QString SettingsDialog::SelectExe(QWidget *parent, const QString &description) { + QString filter(tr("Applications")); #ifdef Q_WS_WIN - QString filter("Applications (*.exe)"); + filter += " (*.exe)"); #else - QString filter("Applications (*)"); + filter += " (*)"; #endif QString path = QFileDialog::getOpenFileName( parent, - "Select "+description, + tr("Select %1").arg(description), QString(), filter, &filter); @@ -20,7 +21,7 @@ static QString SelectExe(QWidget *parent, const QString &description) if(!QFile::exists(path)) return QString(); - return path; + return path; } /////////////////////////////////////////////////////////////////////////////// @@ -30,7 +31,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, Settings &_settings) : settings(&_settings) { ui->setupUi(this); - + ui->cmbDoubleClickAction->addItem(tr("Diff File")); ui->cmbDoubleClickAction->addItem(tr("Open File")); ui->cmbDoubleClickAction->addItem(tr("Open Containing Folder")); @@ -50,7 +51,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, Settings &_settings) : //----------------------------------------------------------------------------- SettingsDialog::~SettingsDialog() { - delete ui; + delete ui; } //----------------------------------------------------------------------------- diff --git a/SettingsDialog.h b/SettingsDialog.h index d9040db..5b5c67f 100644 --- a/SettingsDialog.h +++ b/SettingsDialog.h @@ -6,7 +6,7 @@ #include namespace Ui { - class SettingsDialog; + class SettingsDialog; } #define FUEL_SETTING_FOSSIL_PATH "FossilPath" @@ -63,11 +63,11 @@ struct Settings class SettingsDialog : public QDialog { - Q_OBJECT + Q_OBJECT public: explicit SettingsDialog(QWidget *parent, Settings &_settings); - ~SettingsDialog(); + ~SettingsDialog(); static bool run(QWidget *parent, Settings &_settings); @@ -80,7 +80,9 @@ private slots: void on_btnClearMessageHistory_clicked(); private: - Ui::SettingsDialog *ui; + static QString SelectExe(QWidget *parent, const QString &description); + + Ui::SettingsDialog *ui; Settings *settings; }; diff --git a/fuel.pro b/fuel.pro index 222fdfb..663525e 100644 --- a/fuel.pro +++ b/fuel.pro @@ -1,61 +1,64 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2011-08-01T00:17:18 -# -#------------------------------------------------- - -QT += core gui - -TARGET = Fuel -TEMPLATE = app - -# OSX Icon -ICON = icons/fuel.icns - -# Win Icon -RC_FILE = fuel.rc - -SOURCES += main.cpp\ - MainWindow.cpp \ - CommitDialog.cpp \ - FileActionDialog.cpp \ - SettingsDialog.cpp \ - Utils.cpp \ - FileTableView.cpp - -HEADERS += MainWindow.h \ - CommitDialog.h \ - FileActionDialog.h \ - SettingsDialog.h \ - Utils.h \ - FileTableView.h - -FORMS += MainWindow.ui \ - CommitDialog.ui \ - FileActionDialog.ui \ - SettingsDialog.ui - -RESOURCES += \ - resources.qrc - - - - - - - - - - - - - - - - - - - - - - +#------------------------------------------------- +# +# Project created by QtCreator 2011-08-01T00:17:18 +# +#------------------------------------------------- + +QT += core gui + +TARGET = Fuel +TEMPLATE = app + +# OSX Icon +ICON = icons/fuel.icns + +# Win Icon +RC_FILE = fuel.rc + +SOURCES += main.cpp\ + MainWindow.cpp \ + CommitDialog.cpp \ + FileActionDialog.cpp \ + SettingsDialog.cpp \ + Utils.cpp \ + FileTableView.cpp \ + CloneDialog.cpp + +HEADERS += MainWindow.h \ + CommitDialog.h \ + FileActionDialog.h \ + SettingsDialog.h \ + Utils.h \ + FileTableView.h \ + CloneDialog.h + +FORMS += MainWindow.ui \ + CommitDialog.ui \ + FileActionDialog.ui \ + SettingsDialog.ui \ + CloneDialog.ui + +RESOURCES += \ + resources.qrc + + + + + + + + + + + + + + + + + + + + + + diff --git a/manifest b/manifest index 1112544..6061b24 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C The\sextension\scolumn\snow\sdisplays\sthe\slast\ssuffix\sonly\n\n -D 2012-05-07T14:42:31.856 +C Added\srepository\scloning\nMinor\sinternationalization\sfixes\sin\sthe\ssettings\sdialog +D 2012-05-08T15:04:25.589 +F CloneDialog.cpp 85bc6473d1e3a47d0f981e96357a376be63ab0bc +F CloneDialog.h 1c63da4346ca20b67d52016b7b64875b9c5b477f +F CloneDialog.ui 0fc820804df91f16506ee466a44519fdd44e468f F CommitDialog.cpp a46020a9361151d8d286a2670257d01d8967bf69 F CommitDialog.h f1ee8db92103164e7db55a8407ccdcff24571b72 F CommitDialog.ui 813d7cba316e226de1a22b7e480bb969fbe9b0c4 @@ -8,15 +11,15 @@ F FileActionDialog.h 15db1650b3a13d70bc338371e4c033c66e3b79ce F FileActionDialog.ui c63644428579741aeb5fa052e237ba799ced9ad7 F FileTableView.cpp 5ddf8c391c9a3ac449ec61fb1db837b577afeec2 F FileTableView.h 03e56d87c2d46411b9762b87f4d301619aaf18df -F MainWindow.cpp 256191268be74f2518c29d7996b2cde02443ed88 +F MainWindow.cpp 9202bea6f5017adc6f5e26b0e122695641658810 F MainWindow.h 90de1726e0961f73f637c4071d1cb0fe1049007f -F MainWindow.ui 8c8182e68aa1955a666997ad83ca692f3cb866d9 -F SettingsDialog.cpp e1fad18cc020d08b82c6d35dc94f6624deec9a3b -F SettingsDialog.h f5da6cab4ccc82e2eb78ec835fb849c4c104d6cc +F MainWindow.ui 5f4e40bfb3e93b00f2e06a6071187998eb617224 +F SettingsDialog.cpp 0abd25f1c25ff8c044ac8be3f07b24cd2c238e5a +F SettingsDialog.h 9592ec491cd44a5bff70ea42853d7e1f053f4040 F SettingsDialog.ui 8964629ea80c61971c0601624c84d1927902b1fd F Utils.cpp caca5268e3194abe77211040bf9511a82909d2e6 F Utils.h 32e5d344a7f4d27e3ee83006022df007c90470ef -F fuel.pro 880b013acb1136d97c7414372c4e58053cfb153d +F fuel.pro a3b9066870a01d96822d5545613f25786c219117 F fuel.rc 8e9ac966f283102c11a77cd7f936cdc09e09bd79 F icons/Address\sBook-01.png ef2cec80ea5a559b72e8be4a344a1869fe69cbd8 F icons/Adobe\sIllustrator\sCS3\sDocument-01.png 2e44e933d58eefee7ccfa1650fed4ceadcf3c2be @@ -176,7 +179,7 @@ F installer/fuel.iss 13b6a938bcdf273cbd3649d2549887baa1577214 F installer/license.txt 4cc77b90af91e615a64ae04893fdffa7939db84c F main.cpp f2913af0af1a5fcbebe93fb53b8a9cf6e7bbf65a F resources.qrc e98383ed205f4e37100c60057e0129c3b86dea53 -P 40121f1da0f9e61adee9e47c9ef21188672a95a6 -R a265aa4e14667e81f62455494a867df4 +P 666ca0231b74b904b0ffb1f360010d70b980d2fc +R 2fc26416d72d51a7827db8c9568311d9 U kostas -Z bea0a6a47c93ebe46d831a6ec5e9a0ab +Z 1322ab7d9129ebfd87be87a6edea5bba diff --git a/manifest.uuid b/manifest.uuid index 1cab60a..ece5b4c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -666ca0231b74b904b0ffb1f360010d70b980d2fc \ No newline at end of file +cdd05759abc8ab5d29e102ceb059338b4347fe12 \ No newline at end of file