diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-10-30 23:42:59 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-11-06 07:44:57 -0500 |
| commit | db0b92776b5c9a34ebb1a5ce5c3f0b105844ee16 (patch) | |
| tree | 4024b434840a21d37cac3c43f229fb2c3ce5a91a /src/lockwidget.h | |
| parent | 2aa70de49e89245467299d94d76825bad31c63a2 (diff) | |
added lockwidget to replace all the other dialogs
rewrote ProcessRunner to have a bunch of setters and then a run()
fixed bad exit code when waiting on a process that's already completed
removed lock()/unlock() from main window, ProcessRunner is in charge of that now
Diffstat (limited to 'src/lockwidget.h')
| -rw-r--r-- | src/lockwidget.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/lockwidget.h b/src/lockwidget.h new file mode 100644 index 00000000..bfb0b30f --- /dev/null +++ b/src/lockwidget.h @@ -0,0 +1,68 @@ +#pragma once + +#include <QMainWindow> + +class LockWidget +{ +public: + enum Reasons + { + NoReason = 0, + LockUI, + OutputRequired, + PreventExit + }; + + enum Results + { + NoResult = 0, + StillLocked, + ForceUnlocked, + Cancelled + }; + + LockWidget(QWidget* parent, Reasons reason=NoReason); + ~LockWidget(); + + void lock(Reasons reason); + void unlock(); + + void setInfo(DWORD pid, const QString& name); + Results result() const; + +private: + class Filter : public QObject + { + public: + std::function<void ()> resized; + + protected: + bool eventFilter(QObject* o, QEvent* e) override + { + if (e->type() == QEvent::Resize) { + if (resized) { + resized(); + } + } + + return QObject::eventFilter(o, e); + } + }; + + + QWidget* m_parent; + std::unique_ptr<QWidget> m_overlay; + QLabel* m_info; + Results m_result; + std::unique_ptr<Filter> m_filter; + std::vector<QWidget*> m_disabled; + + void createUi(Reasons reason); + + void onForceUnlock(); + void onCancel(); + + void disableAll(); + void enableAll(); + void disable(QWidget* w); +}; |
