Changeset View
Changeset View
Standalone View
Standalone View
src/statusbar/statusbarspaceinfo.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 43 | { | |||
---|---|---|---|---|---|
49 | } | 49 | } | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | QUrl StatusBarSpaceInfo::url() const | 52 | QUrl StatusBarSpaceInfo::url() const | ||
53 | { | 53 | { | ||
54 | return m_url; | 54 | return m_url; | ||
55 | } | 55 | } | ||
56 | 56 | | |||
57 | void StatusBarSpaceInfo::showEvent(QShowEvent* event) | 57 | void StatusBarSpaceInfo::enable() | ||
58 | { | 58 | { | ||
59 | KCapacityBar::showEvent(event); | 59 | if (!m_observer) { | ||
60 | m_observer.reset(new SpaceInfoObserver(m_url, this)); | 60 | m_observer.reset(new SpaceInfoObserver(m_url, this)); | ||
61 | slotValuesChanged(); | 61 | slotValuesChanged(); | ||
62 | connect(m_observer.data(), &SpaceInfoObserver::valuesChanged, this, &StatusBarSpaceInfo::slotValuesChanged); | 62 | connect(m_observer.data(), &SpaceInfoObserver::valuesChanged, this, &StatusBarSpaceInfo::slotValuesChanged); | ||
63 | } | 63 | } | ||
64 | } | ||||
64 | 65 | | |||
65 | void StatusBarSpaceInfo::hideEvent(QHideEvent* event) | 66 | void StatusBarSpaceInfo::disable() | ||
66 | { | 67 | { | ||
67 | m_observer.reset(); | 68 | m_observer.reset(); | ||
69 | } | ||||
70 | | ||||
71 | bool StatusBarSpaceInfo::event(QEvent *event) | ||||
72 | { | ||||
73 | if (event->type() == QEvent::WindowActivate) { | ||||
74 | enable(); | ||||
75 | } else if (event->type() == QEvent::WindowDeactivate) { | ||||
76 | disable(); | ||||
77 | } | ||||
78 | | ||||
79 | return QWidget::event(event); | ||||
80 | } | ||||
81 | | ||||
82 | void StatusBarSpaceInfo::showEvent(QShowEvent* event) | ||||
83 | { | ||||
84 | KCapacityBar::showEvent(event); | ||||
85 | enable(); | ||||
86 | } | ||||
87 | | ||||
88 | void StatusBarSpaceInfo::hideEvent(QHideEvent* event) | ||||
89 | { | ||||
90 | disable(); | ||||
68 | KCapacityBar::hideEvent(event); | 91 | KCapacityBar::hideEvent(event); | ||
69 | } | 92 | } | ||
70 | 93 | | |||
71 | void StatusBarSpaceInfo::mousePressEvent(QMouseEvent* event) | 94 | void StatusBarSpaceInfo::mousePressEvent(QMouseEvent* event) | ||
72 | { | 95 | { | ||
73 | if (event->button() == Qt::LeftButton) { | 96 | if (event->button() == Qt::LeftButton) { | ||
74 | // Creates a menu with tools that help to find out more about free | 97 | // Creates a menu with tools that help to find out more about free | ||
75 | // disk space for the given url. | 98 | // disk space for the given url. | ||
Show All 33 Lines |