QElectroTech  0.8-dev
dialogwaiting.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 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
DialogWaiting::dropInstance
static void dropInstance()
Definition: dialogwaiting.h:54
DialogWaiting::setProgressReset
void setProgressReset()
DialogWaiting::setProgressReset, clear progressBar and reset.
Definition: dialogwaiting.cpp:57
DialogWaiting::ui
Ui::DialogWaiting * ui
Definition: dialogwaiting.h:81
DialogWaiting::setProgressBarRange
void setProgressBarRange(int min, int max)
DialogWaiting::setProgressBarRange.
Definition: dialogwaiting.cpp:66
DialogWaiting::~DialogWaiting
~DialogWaiting() override
DialogWaiting::~DialogWaiting.
Definition: dialogwaiting.cpp:41
DialogWaiting::setProgressBar
void setProgressBar(int val)
DialogWaiting::setProgressBar.
Definition: dialogwaiting.cpp:49
DialogWaiting
Definition: dialogwaiting.h:30
DialogWaiting::hasInstance
static bool hasInstance()
Definition: dialogwaiting.h:46
DialogWaiting::m_static_dialog
static DialogWaiting * m_static_dialog
Definition: dialogwaiting.h:66
dialogwaiting.h
Ui
Definition: autonumberingdockwidget.h:25
DialogWaiting::instance
static DialogWaiting * instance(QWidget *parent=nullptr)
Definition: dialogwaiting.h:33
DialogWaiting::setTitle
void setTitle(const QString &val)
DialogWaiting::setTitle of action.
Definition: dialogwaiting.cpp:75
DialogWaiting::progressBarValue
int progressBarValue() const
DialogWaiting::progressBarValue.
Definition: dialogwaiting.cpp:91
DialogWaiting::setDetail
void setDetail(const QString &val)
DialogWaiting::setDetail of action.
Definition: dialogwaiting.cpp:83
QET::Icons::tr
QIcon tr
Definition: qeticons.cpp:206
DialogWaiting::DialogWaiting
DialogWaiting(QWidget *parent=nullptr)
DialogWaiting::DialogWaiting.
Definition: dialogwaiting.cpp:29