language_controller.cpp
1.79 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
#include "language_controller.h"
#include "../global_preferences.h"
#include "../apps_container.h"
#include "../i18n.h"
namespace Shared {
LanguageController::LanguageController(Responder * parentResponder, KDCoordinate topMargin) :
ViewController(parentResponder),
m_selectableTableView(this, this, 0, 1, topMargin, Metric::CommonRightMargin, 0, Metric::CommonLeftMargin, this)
{
for (int i = 0; i < I18n::NumberOfLanguages; i++) {
m_cells[i].setMessageFontSize(KDText::FontSize::Large);
}
}
void LanguageController::resetSelection() {
m_selectableTableView.deselectTable();
int index = (int)GlobalPreferences::sharedGlobalPreferences()->language()-1;
selectCellAtLocation(0, index);
}
const char * LanguageController::title() {
return I18n::translate(I18n::Message::Language);
}
View * LanguageController::view() {
return &m_selectableTableView;
}
void LanguageController::didBecomeFirstResponder() {
app()->setFirstResponder(&m_selectableTableView);
}
void LanguageController::viewWillAppear() {
resetSelection();
}
bool LanguageController::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
GlobalPreferences::sharedGlobalPreferences()->setLanguage((I18n::Language)(selectedRow()+1));
return true;
}
return false;
}
int LanguageController::numberOfRows() {
return I18n::NumberOfLanguages;
}
KDCoordinate LanguageController::cellHeight() {
return Metric::ParameterCellHeight;
}
HighlightCell * LanguageController::reusableCell(int index) {
return &m_cells[index];
}
int LanguageController::reusableCellCount() {
return I18n::NumberOfLanguages;
}
void LanguageController::willDisplayCellForIndex(HighlightCell * cell, int index) {
static_cast<MessageTableCell *>(cell)->setMessage(I18n::LanguageNames[index]);
}
}