apps_window.cpp
1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "apps_window.h"
extern "C" {
#include <assert.h>
}
AppsWindow::AppsWindow() :
Window(),
m_titleBarView(),
m_hideTitleBarView(false)
{
}
void AppsWindow::setTitle(I18n::Message title) {
m_titleBarView.setTitle(title);
}
bool AppsWindow::updateBatteryLevel() {
return m_titleBarView.setChargeState(Ion::Battery::level());
}
bool AppsWindow::updateIsChargingState() {
return m_titleBarView.setIsCharging(Ion::Battery::isCharging());
}
bool AppsWindow::updatePluggedState() {
return m_titleBarView.setIsPlugged(Ion::USB::isPlugged());
}
void AppsWindow::refreshPreferences() {
m_titleBarView.refreshPreferences();
}
bool AppsWindow::updateAlphaLock() {
return m_titleBarView.setShiftAlphaLockStatus(Ion::Events::shiftAlphaStatus());
}
void AppsWindow::hideTitleBarView(bool hide) {
if (m_hideTitleBarView != hide) {
m_hideTitleBarView = hide;
layoutSubviews();
}
}
void AppsWindow::reloadTitleBar() {
m_titleBarView.reload();
}
int AppsWindow::numberOfSubviews() const {
return (m_contentView == nullptr ? 1 : 2);
}
View * AppsWindow::subviewAtIndex(int index) {
if (index == 0) {
return &m_titleBarView;
}
assert(m_contentView != nullptr && index == 1);
return m_contentView;
}
void AppsWindow::layoutSubviews() {
KDCoordinate titleHeight = m_hideTitleBarView ? 0 : k_titleBarHeight;
m_titleBarView.setFrame(KDRect(0, 0, bounds().width(), titleHeight));
if (m_contentView != nullptr) {
m_contentView->setFrame(KDRect(0, titleHeight, bounds().width(), bounds().height()-titleHeight));
}
}
#if ESCHER_VIEW_LOGGING
const char * AppsWindow::className() const {
return "Window";
}
#endif