changeset 677:0329bbd4b57c

Merge from branch "help"
author Chris Cannam
date Thu, 06 Dec 2018 13:54:34 +0000
parents cb4f7c3c01dd (current diff) 1fc2e0269ae0 (diff)
children c0b46d0514a7 ad3e5693cb76 21e03596dd93
files src/mainwindow.cpp src/multichoicedialog.cpp src/multichoicedialog.h
diffstat 3 files changed, 32 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/mainwindow.cpp	Thu Dec 06 13:45:23 2018 +0000
+++ b/src/mainwindow.cpp	Thu Dec 06 13:54:34 2018 +0000
@@ -1446,6 +1446,7 @@
         MultiChoiceDialog *d = new MultiChoiceDialog
                                (tr("Open Repository"),
                                 tr("<qt><big>What would you like to open?</big></qt>"),
+                                tr("https://code.soundsoftware.ac.uk/projects/easyhg/wiki/HelpOpenDialog"),
                                 this);
 
         d->addChoice("remote",
@@ -1540,6 +1541,7 @@
     MultiChoiceDialog *d = new MultiChoiceDialog
         (tr("Set Remote Location"),
          tr("<qt><big>Set the remote location</big></qt>"),
+         "",
          this);
 
     QString explanation;
--- a/src/multichoicedialog.cpp	Thu Dec 06 13:45:23 2018 +0000
+++ b/src/multichoicedialog.cpp	Thu Dec 06 13:54:34 2018 +0000
@@ -27,10 +27,13 @@
 #include <QFont>
 #include <QDir>
 #include <QFileDialog>
+#include <QDesktopServices>
 #include <QUrl>
 
-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()
 {
--- a/src/multichoicedialog.h	Thu Dec 06 13:45:23 2018 +0000
+++ b/src/multichoicedialog.h	Thu Dec 06 13:54:34 2018 +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 {
@@ -63,12 +65,15 @@
     void choiceChanged();
     void urlChanged(const QString &);
     void fileChanged(const QString &);
+    void helpRequested();
     void browse();
 
 private:
     void updateFileComboFromURL();
     void updateOkButton();
     
+    QString m_helpUrl;
+
     QMap<QString, QString> m_texts;
     QMap<QString, QString> m_descriptions;
     QMap<QString, ArgType> m_argTypes;