# HG changeset patch
# User Chris Cannam
# Date 1300192586 0
# Node ID 1fc2e0269ae0b32ca4ad9c46e10492e21c7aaa59
# Parent bb189827f6d1d42365a21c93147e9a15d4eec701
Add Help button to multi-choice dialog
diff -r bb189827f6d1 -r 1fc2e0269ae0 mainwindow.cpp
--- a/mainwindow.cpp Tue Mar 15 12:00:31 2011 +0000
+++ b/mainwindow.cpp Tue Mar 15 12:36:26 2011 +0000
@@ -1053,6 +1053,7 @@
MultiChoiceDialog *d = new MultiChoiceDialog
(tr("Open Repository"),
tr("What would you like to open?"),
+ tr("https://code.soundsoftware.ac.uk/projects/easyhg/wiki/HelpOpenDialog"),
this);
d->addChoice("local",
@@ -1134,6 +1135,7 @@
MultiChoiceDialog *d = new MultiChoiceDialog
(tr("Change Remote Location"),
tr("Change the remote location"),
+ "",
this);
d->addChoice("remote",
diff -r bb189827f6d1 -r 1fc2e0269ae0 multichoicedialog.cpp
--- a/multichoicedialog.cpp Tue Mar 15 12:00:31 2011 +0000
+++ b/multichoicedialog.cpp Tue Mar 15 12:36:26 2011 +0000
@@ -27,10 +27,13 @@
#include
#include
#include
+#include
#include
-MultiChoiceDialog::MultiChoiceDialog(QString title, QString heading, QWidget *parent) :
- QDialog(parent)
+MultiChoiceDialog::MultiChoiceDialog(QString title, QString heading,
+ QString helpUrl, QWidget *parent) :
+ QDialog(parent),
+ m_helpUrl(helpUrl)
{
setModal(true);
setWindowTitle(title);
@@ -77,11 +80,21 @@
outer->addWidget(m_browseButton, 4, 2);
connect(m_browseButton, SIGNAL(clicked()), this, SLOT(browse()));
- QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok |
- QDialogButtonBox::Cancel);
+ outer->addItem(new QSpacerItem(2, 12), 5, 0);
+
+ QDialogButtonBox *bbox;
+ if (helpUrl != "") {
+ bbox = new QDialogButtonBox(QDialogButtonBox::Help |
+ QDialogButtonBox::Ok |
+ QDialogButtonBox::Cancel);
+ } else {
+ bbox = new QDialogButtonBox(QDialogButtonBox::Ok |
+ QDialogButtonBox::Cancel);
+ }
connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
connect(bbox, SIGNAL(rejected()), this, SLOT(reject()));
- outer->addWidget(bbox, 5, 0, 1, 3);
+ connect(bbox, SIGNAL(helpRequested()), this, SLOT(helpRequested()));
+ outer->addWidget(bbox, 6, 0, 1, 3);
m_okButton = bbox->button(QDialogButtonBox::Ok);
updateOkButton();
@@ -89,6 +102,12 @@
setMinimumWidth(480);
}
+void
+MultiChoiceDialog::helpRequested()
+{
+ QDesktopServices::openUrl(m_helpUrl);
+}
+
QString
MultiChoiceDialog::getCurrentChoice()
{
diff -r bb189827f6d1 -r 1fc2e0269ae0 multichoicedialog.h
--- a/multichoicedialog.h Tue Mar 15 12:00:31 2011 +0000
+++ b/multichoicedialog.h Tue Mar 15 12:36:26 2011 +0000
@@ -36,7 +36,9 @@
{
Q_OBJECT
public:
- explicit MultiChoiceDialog(QString title, QString heading,
+ explicit MultiChoiceDialog(QString title,
+ QString heading,
+ QString helpUrl = "",
QWidget *parent = 0);
enum ArgType {
@@ -62,11 +64,14 @@
void choiceChanged();
void urlChanged(const QString &);
void fileChanged(const QString &);
+ void helpRequested();
void browse();
private:
void updateOkButton();
+ QString m_helpUrl;
+
QMap m_texts;
QMap m_descriptions;
QMap m_argTypes;