# HG changeset patch
# User Chris Cannam
# Date 1290101813 0
# Node ID 121cb103271768740a180dc471b2764a5df0b40c
# Parent eaabc54de103a1c09fa447abca91a845314bd4cf
* Bit more work on Open dialog
diff -r eaabc54de103 -r 121cb1032717 mainwindow.cpp
--- a/mainwindow.cpp Thu Nov 18 15:29:48 2010 +0000
+++ b/mainwindow.cpp Thu Nov 18 17:36:53 2010 +0000
@@ -79,6 +79,10 @@
cs->addDefaultName("");
cs->addDefaultName(getUserInfo());
+ if (workFolderPath == "") {
+ open();
+ }
+
hgStat();
}
@@ -699,13 +703,13 @@
{
MultiChoiceDialog *d = new MultiChoiceDialog
(tr("Open Repository"),
- tr("What would you like to open?"),
+ tr("What would you like to open?"),
this);
d->addChoice("remote",
tr("
Remote repository"),
- tr("Open an existing remote repository, by cloning a Mercurial repository URL into a local folder."),
- MultiChoiceDialog::UrlArg);
+ tr("Open a remote Mercurial repository, by cloning from its URL into a local folder."),
+ MultiChoiceDialog::UrlToDirectoryArg);
d->addChoice("local",
tr("
Local repository"),
@@ -726,7 +730,8 @@
if (choice == "local") {
workFolderPath = arg;
- } else {
+ } else if (choice == "remote") {
+ DEBUG << "clone " << arg << " to " << d->getAdditionalArgument().trimmed() << endl;
//!!!
}
@@ -1029,6 +1034,7 @@
case ACT_CLONEFROMREMOTE:
MultiChoiceDialog::addRecentArgument("local", workFolderPath);
MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
+ MultiChoiceDialog::addRecentArgument("remote", workFolderPath, true);
QMessageBox::information(this, "Clone", runner -> getStdOut());
enableDisableActions();
shouldHgStat = true;
diff -r eaabc54de103 -r 121cb1032717 multichoicedialog.cpp
--- a/multichoicedialog.cpp Thu Nov 18 15:29:48 2010 +0000
+++ b/multichoicedialog.cpp Thu Nov 18 17:36:53 2010 +0000
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
MultiChoiceDialog::MultiChoiceDialog(QString title, QString heading, QWidget *parent) :
QDialog(parent)
@@ -51,23 +52,32 @@
f.setPointSize(f.pointSize() * 0.9);
m_descriptionLabel->setFont(f);
- m_argLabel = new QLabel();
- outer->addWidget(m_argLabel, 3, 0);
+ m_urlLabel = new QLabel(tr("URL:"));
+ outer->addWidget(m_urlLabel, 3, 0);
- m_argEdit = new QComboBox();
- m_argEdit->setEditable(true);
- outer->addWidget(m_argEdit, 3, 1);
+ m_urlCombo = new QComboBox();
+ m_urlCombo->setEditable(true);
+ connect(m_urlCombo, SIGNAL(editTextChanged(const QString &)),
+ this, SLOT(urlChanged(const QString &)));
+ outer->addWidget(m_urlCombo, 3, 1, 1, 2);
+
+ m_fileLabel = new QLabel(tr("File:"));
+ outer->addWidget(m_fileLabel, 4, 0);
+
+ m_fileCombo = new QComboBox();
+ m_fileCombo->setEditable(true);
+ outer->addWidget(m_fileCombo, 4, 1);
outer->setColumnStretch(1, 20);
m_browseButton = new QPushButton(tr("Browse..."));
- outer->addWidget(m_browseButton, 3, 2);
+ outer->addWidget(m_browseButton, 4, 2);
connect(m_browseButton, SIGNAL(clicked()), this, SLOT(browse()));
QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok |
QDialogButtonBox::Cancel);
connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
connect(bbox, SIGNAL(rejected()), this, SLOT(reject()));
- outer->addWidget(bbox, 4, 0, 1, 3);
+ outer->addWidget(bbox, 5, 0, 1, 3);
setMinimumWidth(480);
}
@@ -88,13 +98,33 @@
QString
MultiChoiceDialog::getArgument()
{
- return m_argEdit->currentText();
+ if (m_argTypes[m_currentChoice] == UrlArg ||
+ m_argTypes[m_currentChoice] == UrlToDirectoryArg) {
+ return m_urlCombo->currentText();
+ } else {
+ return m_fileCombo->currentText();
+ }
+}
+
+QString
+MultiChoiceDialog::getAdditionalArgument()
+{
+ if (m_argTypes[m_currentChoice] == UrlToDirectoryArg) {
+ return m_fileCombo->currentText();
+ } else {
+ return "";
+ }
}
void
-MultiChoiceDialog::addRecentArgument(QString id, QString arg)
+MultiChoiceDialog::addRecentArgument(QString id, QString arg,
+ bool additionalArgument)
{
- RecentFiles(QString("Recent-%1").arg(id)).addFile(arg);
+ if (additionalArgument) {
+ RecentFiles(QString("Recent-%1-add").arg(id)).addFile(arg);
+ } else {
+ RecentFiles(QString("Recent-%1").arg(id)).addFile(arg);
+ }
}
void
@@ -142,13 +172,14 @@
QString path = origin;
- if (m_argTypes[m_currentChoice] == DirectoryArg) {
+ if (m_argTypes[m_currentChoice] == DirectoryArg ||
+ m_argTypes[m_currentChoice] == UrlToDirectoryArg) {
path = QFileDialog::getExistingDirectory
(this, tr("Open Directory"), origin,
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (path != QString()) {
- m_argEdit->lineEdit()->setText(path + QDir::separator());
+ m_fileCombo->lineEdit()->setText(path + QDir::separator());
}
} else {
@@ -156,12 +187,34 @@
path = QFileDialog::getOpenFileName
(this, tr("Open File"), origin);
if (path != QString()) {
- m_argEdit->lineEdit()->setText(path);
+ m_fileCombo->lineEdit()->setText(path);
}
}
}
void
+MultiChoiceDialog::urlChanged(const QString &s)
+{
+ if (m_argTypes[m_currentChoice] != UrlToDirectoryArg) {
+ return;
+ }
+ QDir dirPath(m_fileCombo->currentText());
+ if (!dirPath.exists()) {
+ if (!dirPath.cdUp()) return;
+ }
+ QString url = m_urlCombo->currentText();
+ if (QRegExp("^\\w+://").indexIn(url) < 0) {
+ return;
+ }
+ QString urlDirName = url;
+ urlDirName.replace(QRegExp("^.*//.*/"), "");
+ if (urlDirName == "" || urlDirName == url) {
+ return;
+ }
+ m_fileCombo->lineEdit()->setText(dirPath.filePath(urlDirName));
+}
+
+void
MultiChoiceDialog::choiceChanged()
{
DEBUG << "choiceChanged" << endl;
@@ -194,49 +247,54 @@
m_descriptionLabel->setText(m_descriptions[id]);
+ m_fileLabel->hide();
+ m_fileCombo->hide();
+ m_browseButton->hide();
+ m_urlLabel->hide();
+ m_urlCombo->hide();
+
+ QSharedPointer rf = m_recentFiles[id];
+ m_fileCombo->clear();
+ m_urlCombo->clear();
+
switch (m_argTypes[id]) {
case NoArg:
- m_argLabel->hide();
- m_argEdit->hide();
- m_browseButton->hide();
break;
case FileArg:
- m_argLabel->setText(tr("File:"));
- m_argLabel->show();
- m_argEdit->show();
+ m_fileLabel->setText(tr("File:"));
+ m_fileLabel->show();
+ m_fileCombo->show();
+ m_fileCombo->addItems(rf->getRecent());
m_browseButton->show();
break;
case DirectoryArg:
- m_argLabel->setText(tr("Folder:"));
- m_argLabel->show();
- m_argEdit->show();
+ m_fileLabel->setText(tr("Folder:"));
+ m_fileLabel->show();
+ m_fileCombo->show();
+ m_fileCombo->addItems(rf->getRecent());
m_browseButton->show();
break;
case UrlArg:
- m_argLabel->setText(tr("URL:"));
- m_argLabel->show();
- m_argEdit->show();
- m_browseButton->hide();
+ m_urlLabel->show();
+ m_urlCombo->show();
break;
- case FileOrUrlArg:
- m_argLabel->setText(tr("File or URL:"));
- m_argLabel->show();
- m_argEdit->show();
+ case UrlToDirectoryArg:
+ m_urlLabel->show();
+ m_urlCombo->show();
+ m_urlCombo->addItems(rf->getRecent());
+ m_fileLabel->setText(tr("Folder:"));
+ m_fileLabel->show();
+ m_fileCombo->show();
+ m_fileCombo->lineEdit()->setText(QDir::homePath());
m_browseButton->show();
break;
}
- if (m_argTypes[id] != NoArg) {
- QSharedPointer rf = m_recentFiles[id];
- m_argEdit->clear();
- m_argEdit->addItems(rf->getRecent());
- }
-
adjustSize();
}
diff -r eaabc54de103 -r 121cb1032717 multichoicedialog.h
--- a/multichoicedialog.h Thu Nov 18 15:29:48 2010 +0000
+++ b/multichoicedialog.h Thu Nov 18 17:36:53 2010 +0000
@@ -44,7 +44,7 @@
FileArg,
DirectoryArg,
UrlArg,
- FileOrUrlArg
+ UrlToDirectoryArg
};
void addChoice(QString identifier, QString text,
@@ -53,11 +53,14 @@
void setCurrentChoice(QString);
QString getCurrentChoice();
QString getArgument();
+ QString getAdditionalArgument();
- static void addRecentArgument(QString identifier, QString name);
+ static void addRecentArgument(QString identifier, QString name,
+ bool additionalArgument = false);
private slots:
void choiceChanged();
+ void urlChanged(const QString &);
void browse();
private:
@@ -71,9 +74,11 @@
QHBoxLayout *m_choiceLayout;
QLabel *m_descriptionLabel;
- QLabel *m_argLabel;
- QComboBox *m_argEdit;
+ QLabel *m_fileLabel;
+ QComboBox *m_fileCombo;
QAbstractButton *m_browseButton;
+ QLabel *m_urlLabel;
+ QComboBox *m_urlCombo;
};
#endif // MULTICHOICEDIALOG_H
diff -r eaabc54de103 -r 121cb1032717 selectablelabel.cpp
--- a/selectablelabel.cpp Thu Nov 18 15:29:48 2010 +0000
+++ b/selectablelabel.cpp Thu Nov 18 17:36:53 2010 +0000
@@ -27,8 +27,6 @@
m_selected(false)
{
setTextFormat(Qt::RichText);
-// setLineWidth(2);
-// setFixedWidth(480);
setupStyle();
setOpenExternalLinks(true);
}
@@ -70,20 +68,12 @@
if (m_selected) {
setStyleSheet
- (QString("QLabel:hover { background: %1; color: %3; } "
- "QLabel:!hover { background: %2; color: %3 } "
- "QLabel { padding: 7px }")
- .arg(palette.highlight().color().name())
- .arg(palette.highlight().color().name())
- .arg(palette.text().color().name()));
+ (QString("QLabel { background: %1; border: 1px solid %2; padding: 7px } ")
+ .arg(palette.light().color().name())
+ .arg(palette.dark().color().name()));
} else {
setStyleSheet
- (QString("QLabel:hover { background: %1; color: %3; } "
- "QLabel:!hover { background: %2; color: %3 } "
- "QLabel { padding: 7px }")
- .arg(palette.button().color().name())
- .arg(palette.light().color().name())
- .arg(palette.text().color().name()));
+ (QString("QLabel { border: 0; padding: 7px } "));
}
}
diff -r eaabc54de103 -r 121cb1032717 startupdialog.cpp
--- a/startupdialog.cpp Thu Nov 18 15:29:48 2010 +0000
+++ b/startupdialog.cpp Thu Nov 18 17:36:53 2010 +0000
@@ -36,7 +36,7 @@
QGridLayout *layout = new QGridLayout;
int row = 0;
- layout->addWidget(new QLabel(tr("Welcome to EasyMercurial!
How would you like to be identified in commit messages?")),
+ layout->addWidget(new QLabel(tr("Welcome to EasyMercurial!
How would you like to be identified in commit messages?")),
row++, 0, 1, 2);
layout->addWidget(new QLabel(tr("Name:")), row, 0);