TipDialog.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::
17 * @author Mirko Waechter ( mirko.waechter at kit dot edu)
18 * @date 2015
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 #include <QDialog>
26 
27 namespace armarx::Ui
28 {
29  class TipDialog;
30 }
31 
32 namespace armarx
33 {
34  /**
35  * @brief The TipDialog is a dialog to show tips/hints to the user, which are optionally only shown once.
36  * This dialog contains a textfield in which the developer can show a tip to the user.
37  * It also contains a checkbox "Do not show again", which upon selection puts the shown string into a blacklist
38  * of messages, which are not shown again.
39  *
40  * To show the dialog use the function showMessage().
41  * The dialog should only be created once and passed around or the blacklist must be passed on each creation to the dialog via
42  * setBlackListedStrings().
43  *
44  *
45  * @see \ref armarx::ArmarXWidgetController::getTipDialog, armarx::ArmarXMainWindow
46  */
47  class TipDialog : public QDialog
48  {
49  Q_OBJECT
50 
51  public:
52  explicit TipDialog(QWidget* parent = 0);
53  ~TipDialog() override;
54 
55  /**
56  * @brief Shows this dialog and shows the message, if it was not blacklisted.
57  * If the message was blacklisted, nothing happens.
58  * @param tipText Text that should be shown in the dialog. If stringIdentifier is empty, this string is used for blacklisting the
59  * message.
60  * @param windowTitle WindowTitle of the Dialog
61  * @param stringIdentifier If not empty, this string is used for the blacklisting instead of the tiptext.
62  */
63  void showMessage(const QString& tipText,
64  const QString& windowTitle,
65  const QString& stringIdentifier = "");
66 
67  /**
68  * @brief Returns all currently blacklisted strings.
69  *
70  */
71  QStringList getBlackListedStrings() const;
72 
73  /**
74  * @brief Sets list of blacklisted strings. Pass empty list to clear.
75  * All previously set strings are forgotten.
76  */
77  void setBlackListedStrings(const QStringList& strings);
78 
79  /**
80  * @brief Checks whether a specific string is blacklisted.
81  * @param stringId String to check
82  * @return True if blacklisted.
83  */
84  bool isBlackListed(const QString& stringId) const;
85  // QWidget interface
86  protected:
87  void hideEvent(QHideEvent*) override;
88 
89  private:
90  Ui::TipDialog* ui;
91  QStringList blackList;
92  QString lastId;
93  };
94 
95 
96 } // namespace armarx
armarx::Ui
Definition: GuiUseCaseSelector.h:33
armarx::TipDialog::~TipDialog
~TipDialog() override
Definition: TipDialog.cpp:37
armarx::TipDialog::TipDialog
TipDialog(QWidget *parent=0)
Definition: TipDialog.cpp:32
armarx::TipDialog::isBlackListed
bool isBlackListed(const QString &stringId) const
Checks whether a specific string is blacklisted.
Definition: TipDialog.cpp:78
armarx::TipDialog::getBlackListedStrings
QStringList getBlackListedStrings() const
Returns all currently blacklisted strings.
Definition: TipDialog.cpp:66
armarx::TipDialog
The TipDialog is a dialog to show tips/hints to the user, which are optionally only shown once.
Definition: TipDialog.h:47
armarx::TipDialog::showMessage
void showMessage(const QString &tipText, const QString &windowTitle, const QString &stringIdentifier="")
Shows this dialog and shows the message, if it was not blacklisted.
Definition: TipDialog.cpp:43
armarx::TipDialog::hideEvent
void hideEvent(QHideEvent *) override
Definition: TipDialog.cpp:84
armarx::TipDialog::setBlackListedStrings
void setBlackListedStrings(const QStringList &strings)
Sets list of blacklisted strings.
Definition: TipDialog.cpp:72
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27