MEPP2 Project
BasePluginDialogQt.h
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published
6 // by the Free Software Foundation; either version 3 of the License,
7 // or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #pragma once
12 
13 #include <QDialog>
14 
15 #include <QPushButton>
16 #include <QWhatsThis>
17 #include <QEvent>
18 
19 #include <QUrl>
20 #include <QDesktopServices>
21 
22 namespace FEVV {
23 
28 class BasePluginDialogQt : public QDialog
29 {
30 public:
31  BasePluginDialogQt(QWidget *parent) : QDialog(parent)
32  {
33  helpButton = new QPushButton("?");
34  helpButton->setMaximumSize(32, 32);
35 
36  // Qt5 only...
37  /*connect( helpButton, &QPushButton::clicked, []() {
38  QWhatsThis::enterWhatsThisMode();
39  } );*/
40  }
41 
43 
44  void helpTriggered() { QDesktopServices::openUrl(QUrl(link)); }
45 
46  bool event(QEvent *e)
47  {
48  if (e->type() == QEvent::EnterWhatsThisMode)
49  {
50  QWhatsThis::leaveWhatsThisMode();
51 
52  helpTriggered();
53 
54  return true;
55  }
56 
57  return QDialog::event(e);
58  }
59 
60 protected:
61  QPushButton *helpButton;
62 
63  QString link;
64 };
65 
66 } // namespace FEVV
FEVV::BasePluginDialogQt::BasePluginDialogQt
BasePluginDialogQt(QWidget *parent)
Definition: BasePluginDialogQt.h:31
FEVV::BasePluginDialogQt::~BasePluginDialogQt
~BasePluginDialogQt()
Definition: BasePluginDialogQt.h:42
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::BasePluginDialogQt::helpButton
QPushButton * helpButton
Definition: BasePluginDialogQt.h:61
FEVV::BasePluginDialogQt::helpTriggered
void helpTriggered()
Definition: BasePluginDialogQt.h:44
FEVV::BasePluginDialogQt::event
bool event(QEvent *e)
Definition: BasePluginDialogQt.h:46
FEVV::BasePluginDialogQt::link
QString link
Definition: BasePluginDialogQt.h:63
FEVV::BasePluginDialogQt
This class is intended to provide a help message to plugins dialogs.
Definition: BasePluginDialogQt.h:29