Debian Codegraph @

src/Gui/ProgressDialog.h

raw
1 /***************************************************************************
2 * Copyright (c) 2009 Werner Mayer <[email protected]> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23 #ifndef GUI_PROGRESSDIALOG_H
24 #define GUI_PROGRESSDIALOG_H
25
26 #include <Base/Sequencer.h>
27 #include <QProgressDialog>
28 #ifdef QT_WINEXTRAS_LIB
29 # include <QWinTaskbarButton>
30 # include <QWinTaskbarProgress>
31 #endif
32
33
34 namespace Gui
35 {
36
37 struct SequencerDialogPrivate;
38
39 class ProgressDialog;
40 class GuiExport SequencerDialog: public Base::SequencerBase
41 {
42 public:
43 static SequencerDialog* instance();
44 void pause() override;
45 void resume() override;
46 bool isBlocking() const override;
47 bool canAbort() const;
48
49 protected:
50 /** Construction */
51 SequencerDialog();
52 /** Destruction */
53 ~SequencerDialog() override;
54
55 /** Puts text to the progress dialog */
56 void setText(const char* pszTxt) override;
57 /** Starts the progress dialog */
58 void startStep() override;
59 /** Increase the step indicator of the progress dialog. */
60 void nextStep(bool canAbort) override;
61 /** Sets the progress indicator to a certain position. */
62 void setProgress(size_t) override;
63 /** Resets the sequencer */
64 void resetData() override;
65 void showRemainingTime();
66
67 private:
68 /** @name for internal use only */
69 //@{
70 void setValue(int step);
71 /** Throws an exception to stop the pending operation. */
72 void abort();
73 //@}
74
75 SequencerDialogPrivate* d;
76 static SequencerDialog* _pclSingleton;
77
78 friend class ProgressDialog;
79 };
80
81 class ProgressDialog: public QProgressDialog
82 {
83 Q_OBJECT
84
85 public:
86 /** Construction */
87 explicit ProgressDialog(SequencerDialog* s, QWidget* parent = nullptr);
88 /** Destruction */
89 ~ProgressDialog() override;
90
91 protected Q_SLOTS:
92 void onCancel();
93
94 private Q_SLOTS:
95 void resetEx();
96 void setRangeEx(int minimum, int maximum);
97 void setValueEx(int value);
98 void aboutToShow();
99 void aboutToHide();
100 void showEvent(QShowEvent*) override;
101 void hideEvent(QHideEvent*) override;
102
103 protected:
104 bool canAbort() const;
105
106 private:
107 SequencerDialog* sequencer;
108
109 #ifdef QT_WINEXTRAS_LIB
110 /* Set up the taskbar progress in windows */
111 void setupTaskBarProgress(void);
112 QWinTaskbarProgress* m_taskbarProgress;
113 QWinTaskbarButton* m_taskbarButton;
114 #endif
115 friend class SequencerDialog;
116 };
117
118 } // namespace Gui
119
120 #endif // GUI_PROGRESSDIALOG_H