TipDialog.cpp
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 #include "TipDialog.h"
24 #include <ArmarXGui/libraries/ArmarXGuiBase/ui_TipDialog.h>
26 
27 
28 
29 namespace armarx
30 {
31 
32  TipDialog::TipDialog(QWidget* parent) :
33  QDialog(parent),
34  ui(new Ui::TipDialog)
35  {
36  ui->setupUi(this);
37  }
38 
40  {
41  delete ui;
42  }
43 
44  void TipDialog::showMessage(const QString& tipText, const QString& windowTitle, const QString& stringIdentifier)
45  {
46  if (tipText.isEmpty())
47  {
48  return;
49  }
50 
51  if (isBlackListed(stringIdentifier.isEmpty() ? tipText : stringIdentifier))
52  {
53  this->setWindowTitle(windowTitle);
54  ui->editTip->setPlainText(tipText);
55  show();
56  lastId = stringIdentifier.isEmpty() ? tipText : stringIdentifier;
57  }
58  else
59  {
60  ARMARX_DEBUG_S << "Not showing because of blacklist";
61  }
62  }
63 
65  {
66  return blackList;
67  }
68 
69  void TipDialog::setBlackListedStrings(const QStringList& strings)
70  {
71  blackList = strings;
72  }
73 
74  bool TipDialog::isBlackListed(const QString& stringId) const
75  {
76  return !blackList.contains(stringId);
77  }
78 
79  void TipDialog::hideEvent(QHideEvent*)
80  {
81  if (ui->cbDoNotShowAgain->isChecked())
82  {
83  ARMARX_DEBUG_S << "Storing in blacklist";
84 
85  if (!blackList.contains(lastId))
86  {
87  blackList.append(lastId);
88  }
89  }
90  }
91 
92 } // namespace armarx
armarx::TipDialog::~TipDialog
~TipDialog() override
Definition: TipDialog.cpp:39
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:74
armarx::TipDialog::getBlackListedStrings
QStringList getBlackListedStrings() const
Returns all currently blacklisted strings.
Definition: TipDialog.cpp:64
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:44
ARMARX_DEBUG_S
#define ARMARX_DEBUG_S
Definition: Logging.h:198
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
armarx::TipDialog::hideEvent
void hideEvent(QHideEvent *) override
Definition: TipDialog.cpp:79
armarx::TipDialog::setBlackListedStrings
void setBlackListedStrings(const QStringList &strings)
Sets list of blacklisted strings.
Definition: TipDialog.cpp:69
TipDialog.h
Logging.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28