QElectroTech  0.70
dialogwaiting.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef DIALOGWAITING_H
20 #define DIALOGWAITING_H
21 
22 #include <QDialog>
23 #include <QMutex>
24 
25 namespace Ui {
26  class DialogWaiting;
27 }
28 
29 class DialogWaiting : public QDialog
30 {
31  Q_OBJECT
32  public:
33  static DialogWaiting* instance(QWidget *parent = nullptr)
34  {
35  static QMutex mutex;
36  if(!m_static_dialog)
37  {
38  mutex.lock();
39  if(!m_static_dialog)
40  m_static_dialog = new DialogWaiting(parent);
41  mutex.unlock();
42  }
43  return m_static_dialog;
44  }
45 
46  static bool hasInstance()
47  {
48  if(m_static_dialog == nullptr)
49  return false;
50  else
51  return true;
52  }
53 
54  static void dropInstance()
55  {
56  static QMutex mutex;
57  if(m_static_dialog)
58  {
59  mutex.lock();
60  m_static_dialog->deleteLater();
61  m_static_dialog = nullptr;
62  mutex.unlock();
63  }
64  }
65  private:
67 
68 
69  public:
70  explicit DialogWaiting(QWidget *parent = nullptr);
71  ~DialogWaiting() override;
72 
73  void setProgressBar(int val);
74  void setProgressBarRange(int min, int max);
75  void setProgressReset();
76  void setTitle(const QString& val);
77  void setDetail(const QString& val);
78  int progressBarValue() const;
79 
80  private:
81  Ui::DialogWaiting *ui;
82 };
83 
84 #endif // DIALOGWAITING_H
void setProgressBar(int val)
DialogWaiting::setProgressBar.
void setTitle(const QString &val)
DialogWaiting::setTitle of action.
static DialogWaiting * m_static_dialog
Definition: dialogwaiting.h:66
void setDetail(const QString &val)
DialogWaiting::setDetail of action.
static bool hasInstance()
Definition: dialogwaiting.h:46
~DialogWaiting() override
DialogWaiting::~DialogWaiting.
Ui::DialogWaiting * ui
Definition: dialogwaiting.h:81
void setProgressBarRange(int min, int max)
DialogWaiting::setProgressBarRange.
int progressBarValue() const
DialogWaiting::progressBarValue.
static DialogWaiting * instance(QWidget *parent=nullptr)
Definition: dialogwaiting.h:33
static void dropInstance()
Definition: dialogwaiting.h:54
void setProgressReset()
DialogWaiting::setProgressReset, clear progressBar and reset.
DialogWaiting(QWidget *parent=nullptr)
DialogWaiting::DialogWaiting.