From afe981aa33e6f306e35b8ef080d84b23986cba0e Mon Sep 17 00:00:00 2001 From: in3otd Date: Fri, 5 Feb 2016 23:30:59 +0100 Subject: [PATCH] Add Help button on the Edit Component Properties dialog Needs corresponding updated qucs manual on the GitHub pages --- qucs/qucs/components/componentdialog.cpp | 30 +++++++++++++++++++++--- qucs/qucs/components/componentdialog.h | 1 + 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/qucs/qucs/components/componentdialog.cpp b/qucs/qucs/components/componentdialog.cpp index bafcffdcea..f1d3e9c458 100644 --- a/qucs/qucs/components/componentdialog.cpp +++ b/qucs/qucs/components/componentdialog.cpp @@ -15,6 +15,10 @@ * * ***************************************************************************/ +#ifdef HAVE_CONFIG_H +# include +#endif + #include "componentdialog.h" #include "qucs.h" #include "schematic.h" @@ -33,6 +37,8 @@ #include #include #include +#include +#include #include #include #include @@ -403,12 +409,17 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d) hbox2->setLayout(h2); h2->setSpacing(5); all->addWidget(hbox2); + QPushButton *help = new QPushButton(tr("Help")); QPushButton *ok = new QPushButton(tr("OK")); QPushButton *apply = new QPushButton(tr("Apply")); QPushButton *cancel = new QPushButton(tr("Cancel")); - h2->addWidget(ok); - h2->addWidget(apply); - h2->addWidget(cancel); + // set stretch factors to limit the space taken by the added stretch + h2->addWidget(help, 1); + h2->addStretch(1); + h2->addWidget(ok, 1); + h2->addWidget(apply, 1); + h2->addWidget(cancel, 1); + connect(help, SIGNAL(clicked()), SLOT(slotButtHelp())); connect(ok, SIGNAL(clicked()), SLOT(slotButtOK())); connect(apply, SIGNAL(clicked()), SLOT(slotApplyInput())); connect(cancel, SIGNAL(clicked()), SLOT(slotButtCancel())); @@ -1056,6 +1067,19 @@ void ComponentDialog::slotApplyInput() } +// ------------------------------------------------------------------------- +// Is called if the "Help"-button is pressed. +void ComponentDialog::slotButtHelp() +{ + QString linkName = QString(Comp->Model); + + qDebug() << "HELP : model = " << linkName; + // for local testing use something like + // QDesktopServices::openUrl(QUrl::fromLocalFile("/qucs-manual/build/html/component_reference.html").toString() + "#" + linkName.toLower()); + + QDesktopServices::openUrl(QUrl("http://qucs.github.io/qucs-manual/" PACKAGE_VERSION "/html-en/component_reference.html#" + linkName.toLower(), QUrl::TolerantMode)); +} + // ------------------------------------------------------------------------- void ComponentDialog::slotBrowseFile() { diff --git a/qucs/qucs/components/componentdialog.h b/qucs/qucs/components/componentdialog.h index 706a804c12..33da7269d5 100644 --- a/qucs/qucs/components/componentdialog.h +++ b/qucs/qucs/components/componentdialog.h @@ -47,6 +47,7 @@ class ComponentDialog : public QDialog { private slots: void slotButtOK(); void slotButtCancel(); + void slotButtHelp(); void slotSelectProperty(QTableWidgetItem *item); void slotApplyInput(); void slotApplyState(int State);