• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mbits-os / quick_dra / 29015719047

09 Jul 2026 11:42AM UTC coverage: 99.951% (-0.05%) from 100.0%
29015719047

Pull #110

github

web-flow
Merge f0d8cf0a6 into cfad1dead
Pull Request #110: feat: add mouse back navigation

11 of 15 new or added lines in 2 files covered. (73.33%)

8098 of 8102 relevant lines covered (99.95%)

1319.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.74
/libs/gui/gui/src/app/gui/PagedWidget.cpp
1
// Copyright (c) 2026 midnightBITS
2
// This code is licensed under MIT license (see LICENSE for details)
3

4
#include <QApplication>
5
#include <QMouseEvent>
6
#include <app/gui/PageFocusEvent.hpp>
7
#include <app/gui/PagedWidget.hpp>
8

9
namespace quick_dra::gui {
10
        namespace {
11
                void broadcastPageFocusEvent(QWidget* parent, bool hasFocus) {
227✔
12
                        auto const children = parent->findChildren<QWidget*>();
227✔
13
                        for (auto const child : children) {
3,883✔
14
                                qApp->notify(child, new PageFocusEvent{hasFocus});
3,657✔
15
                        }
1✔
16
                }
227✔
17

18
                QWidget* focusToStore(QWidget* self) {
101✔
19
                        auto focused = qApp->focusWidget();
101✔
20
                        if (focused) {
101✔
21
                                auto parent = focused->parentWidget();
7✔
22
                                while (parent && parent != self) {
25✔
23
                                        parent = parent->parentWidget();
19✔
24
                                }
1✔
25
                                if (parent) {
7✔
26
                                        return focused;
7✔
27
                                }
28
                        }
29
                        return nullptr;
95✔
30
                }
1✔
31

32
                void restoreFocus(QPointer<QWidget>& stored) {
127✔
33
                        QPointer<QWidget> local{};
127✔
34
                        local.swap(stored);
127✔
35
                        auto focused = local.data();
127✔
36
                        if (focused && !local.isNull()) {
127✔
37
                                focused->setFocus();
5✔
38
                        }
39
                }
127✔
40
        }  // namespace
41

42
        PagedWidget::PagedWidget(QWidget* parent) : QWidget{parent} {
87✔
43
                QObject::connect(this, &QWidget::windowTitleChanged, this, &PagedWidget::onTitleChange);
87✔
44
        }
87✔
45

46
        void PagedWidget::pageAdded(Globals* globals) {
81✔
47
                globals_ = globals;
81✔
48
                connectPage();
81✔
49
        }
81✔
50

51
        void PagedWidget::connectPage() {}
49✔
52
        void PagedWidget::beforePageFocus() {}
127✔
53

54
        void PagedWidget::pageFocus() {
127✔
55
                restoreFocus(storedFocus_);
127✔
56
                broadcastPageFocusEvent(this, true);
127✔
57
        }
127✔
58

59
        void PagedWidget::beforePageBlur() {
101✔
60
                broadcastPageFocusEvent(this, false);
101✔
61
                storedFocus_ = focusToStore(this);
101✔
62
        }
101✔
63

64
        void PagedWidget::pageBlur() {}
101✔
65
        void PagedWidget::pageRemoved() {}
37✔
66
        void PagedWidget::accept() { accepted(); }
3✔
67
        void PagedWidget::leavePage() { stack().navigateBack(); }
15✔
68
        void PagedWidget::setupPageUI() {
127✔
69
                stack().setFormDirty(formDirty_);
127✔
70
                stack().setFormValid(formValid_);
127✔
71
                onTitleChange(windowTitle());
127✔
72
        }
127✔
73
        bool PagedWidget::survivesReload() const { return false; }
9✔
74

NEW
75
        void PagedWidget::mouseReleaseEvent(QMouseEvent* event) {
×
NEW
76
                if (event->button() == Qt::BackButton) {
×
NEW
77
                        stack().navigateBack();
×
78
                }
NEW
79
        }
×
80

81
        void PagedWidget::setFormDirty(bool value) {
103✔
82
                if (formDirty_ == value) {
103✔
83
                        return;
63✔
84
                }
85

86
                formDirty_ = value;
41✔
87

88
                if (stack().page() != this) {
41✔
89
                        return;
3✔
90
                }
91
                stack().setFormDirty(formDirty_);
39✔
92
        }
1✔
93

94
        void PagedWidget::setFormValid(bool value) {
27✔
95
                if (formValid_ == value) {
27✔
96
                        return;
5✔
97
                }
98

99
                formValid_ = value;
23✔
100

101
                if (stack().page() != this) {
23✔
102
                        return;
5✔
103
                }
104
                stack().setFormValid(formValid_);
19✔
105
        }
1✔
106

107
        void PagedWidget::onTitleChange(QString const& title) {
209✔
108
                if (!globals_ || !globals().hasStack() || stack().page() != this) {
209✔
109
                        return;
69✔
110
                }
111
                stack().setHeaderTitle(title);
141✔
112
        }
1✔
113
}  // namespace quick_dra::gui
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc