Added repository cloning

Minor internationalization fixes in the settings dialog

FossilOrigin-Name: cdd05759abc8ab5d29e102ceb059338b4347fe12
This commit is contained in:
kostas 2012-05-08 15:04:25 +00:00
parent ce93f92289
commit 9dc6342387
10 changed files with 409 additions and 97 deletions

92
CloneDialog.cpp Normal file
View File

@ -0,0 +1,92 @@
#include "CloneDialog.h"
#include "ui_CloneDialog.h"
#include <QFileDialog>
#include <QDir>
#include <QMessageBox>
#include <QClipboard>
#include <QUrl>
//-----------------------------------------------------------------------------
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));
}

27
CloneDialog.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef CLONEDIALOG_H
#define CLONEDIALOG_H
#include <QDialog>
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

156
CloneDialog.ui Normal file
View File

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CloneDialog</class>
<widget class="QDialog" name="CloneDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>478</width>
<height>173</height>
</rect>
</property>
<property name="windowTitle">
<string>Clone Repository</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>URL</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineURL">
<property name="toolTip">
<string>The URL of the source repository</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>User Name</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineUserName">
<property name="toolTip">
<string>The user name used to access the remote repository. Leave blank if not required</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="linePassword">
<property name="toolTip">
<string>The password used to access the remote repository. Leave blank if not required</string>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Repository</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLineEdit" name="lineRepository">
<property name="toolTip">
<string>Path to the local repository file</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSelectRepository">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CloneDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CloneDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -17,6 +17,7 @@
#include <QDebug>
#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("<b>&gt;"+logcmd.join(" ")+"</b><br>", 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);

View File

@ -176,7 +176,7 @@
<x>0</x>
<y>0</y>
<width>865</width>
<height>24</height>
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -184,6 +184,8 @@
<string>&amp;File</string>
</property>
<addaction name="actionNewRepository"/>
<addaction name="actionCloneRepository"/>
<addaction name="separator"/>
<addaction name="actionOpenRepository"/>
<addaction name="actionCloseRepository"/>
<addaction name="separator"/>
@ -408,10 +410,10 @@
<action name="actionCloneRepository">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/icons/Address Book-01.png</normaloff>:/icons/icons/Address Book-01.png</iconset>
<normaloff>:/icons/icons/My Websites-01.png</normaloff>:/icons/icons/My Websites-01.png</iconset>
</property>
<property name="text">
<string>Clone Repository...</string>
<string>Clone...</string>
</property>
</action>
<action name="actionPush">

View File

@ -3,16 +3,17 @@
#include <QFileDialog>
#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;
}
//-----------------------------------------------------------------------------

View File

@ -6,7 +6,7 @@
#include <QVariant>
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;
};

125
fuel.pro
View File

@ -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

View File

@ -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

View File

@ -1 +1 @@
666ca0231b74b904b0ffb1f360010d70b980d2fc
cdd05759abc8ab5d29e102ceb059338b4347fe12