diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-11-06 05:23:22 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-11-06 07:45:02 -0500 |
| commit | 642ddacab802df75d21a1ccf7508268d3efa141a (patch) | |
| tree | 2b9cc615fd747da2bd049c9a5625d4b6cedfcb3c /src/lockwidget.h | |
| parent | 3d0197fa5e6c4209d021398415f779994c21bd24 (diff) | |
moved LockWidget back to OrganizerCore to support having multiple locks active
moved the ui out of LockWidget into LockInterface
added LockWidget::Session to manage multi locks
Diffstat (limited to 'src/lockwidget.h')
| -rw-r--r-- | src/lockwidget.h | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/src/lockwidget.h b/src/lockwidget.h index d3ff2f7d..8062c478 100644 --- a/src/lockwidget.h +++ b/src/lockwidget.h @@ -2,8 +2,12 @@ #include <QMainWindow> +class LockInterface; + class LockWidget { + friend class LockInterface; + public: // reason to show the widget // @@ -37,51 +41,50 @@ public: Cancelled }; - // if `reason` is not NoReason, lock() is called with it - // - 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 + class Session { public: - std::function<void ()> resized; - std::function<void ()> closed; + ~Session(); - protected: - bool eventFilter(QObject* o, QEvent* e) override - { - if (e->type() == QEvent::Resize) { - if (resized) { - resized(); - } - } else if (e->type() == QEvent::Close) { - if (closed) { - closed(); - } - } + void setInfo(DWORD pid, const QString& name); + Results result() const; - return QObject::eventFilter(o, e); - } + DWORD pid() const; + const QString& name() const; + + private: + DWORD m_pid; + QString m_name; }; + // if `reason` is not NoReason, lock() is called with it + // + LockWidget(); + ~LockWidget(); + + static LockWidget& instance(); + + void setUserInterface(QWidget* parent); + + std::shared_ptr<Session> lock(Reasons reason); + + Results result() const; + +private: QWidget* m_parent; - std::unique_ptr<QWidget> m_overlay; - QLabel* m_info; + std::unique_ptr<LockInterface> m_ui; + std::vector<std::weak_ptr<Session>> m_sessions; Results m_result; - std::unique_ptr<Filter> m_filter; std::vector<QPointer<QWidget>> m_disabled; void createUi(Reasons reason); + void unlockCurrent(); + void unlock(Session* s); + void updateLabel(); + void onForceUnlock(); void onCancel(); |
