[WIP] Fix settings

This commit is contained in:
Quentin Guidée
2020-02-16 10:50:34 +01:00
parent 17f4ef4c0d
commit b52626ed65
3 changed files with 39 additions and 20 deletions

View File

@@ -8,7 +8,7 @@
namespace ExamModeConfiguration {
// Settings menu
extern const Settings::SettingsMessageTree s_modelExamChildren[2];
extern const Settings::SettingsMessageTree s_modelExamChildren[3];
int numberOfAvailableExamMode();
GlobalPreferences::ExamMode examModeAtIndex(int index);
I18n::Message examModeActivationMessage(int index);

View File

@@ -1,13 +1,16 @@
#include "exam_mode_configuration.h"
constexpr Settings::SettingsMessageTree ExamModeConfiguration::s_modelExamChildren[] = {Settings::SettingsMessageTree(I18n::Message::ActivateExamMode), Settings::SettingsMessageTree(I18n::Message::Default)};
using namespace Poincare;
constexpr Settings::SettingsMessageTree s_ledColorChildren[] = {Settings::SettingsMessageTree(I18n::Message::ColorRed), Settings::SettingsMessageTree(I18n::Message::ColorWhite), Settings::SettingsMessageTree(I18n::Message::ColorGreen), Settings::SettingsMessageTree(I18n::Message::ColorBlue), Settings::SettingsMessageTree(I18n::Message::ColorYellow), Settings::SettingsMessageTree(I18n::Message::ColorPurple), Settings::SettingsMessageTree(I18n::Message::ColorOrange)};
constexpr Settings::SettingsMessageTree ExamModeConfiguration::s_modelExamChildren[] = {Settings::SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren), Settings::SettingsMessageTree(I18n::Message::ExamModeModeStandard), Settings::SettingsMessageTree(I18n::Message::ExamModeModeNoSym)};
int ExamModeConfiguration::numberOfAvailableExamMode() {
return 3;
}
GlobalPreferences::ExamMode ExamModeConfiguration::examModeAtIndex(int index) {
return GlobalPreferences::ExamMode::Standard;
return (s_modelExamChildren[index].label() == I18n::Message::ExamModeModeStandard) ? GlobalPreferences::ExamMode::Standard : GlobalPreferences::ExamMode::NoSym;
}
I18n::Message ExamModeConfiguration::examModeActivationMessage(int index) {
@@ -25,8 +28,25 @@ I18n::Message ExamModeConfiguration::examModeActivationWarningMessage(GlobalPref
}
KDColor ExamModeConfiguration::examModeColor(GlobalPreferences::ExamMode mode) {
assert(mode == GlobalPreferences::ExamMode::Standard);
return KDColorRed;
assert(mode == GlobalPreferences::ExamMode::Standard || mode == GlobalPreferences::ExamMode::NoSym);
Preferences * preferences = Preferences::sharedPreferences();
switch((int) preferences->colorOfLED()) {
case 1:
return KDColorWhite;
case 2:
return KDColorGreen;
case 3:
return KDColorBlue;
case 4:
return KDColorYellow;
case 5:
return KDColorPurple;
case 6:
return KDColorOrange;
default:
return KDColorRed;
}
}
bool ExamModeConfiguration::appIsForbiddenInExamMode(I18n::Message appName, GlobalPreferences::ExamMode mode) {

View File

@@ -89,16 +89,16 @@ bool MainController::handleEvent(Ion::Events::Event event) {
}
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) {
GenericSubController * subController = nullptr;
int rowIndex = selectedRow();
if (rowIndex == k_indexOfBrightnessCell || rowIndex == k_indexOfLanguageCell) {
I18n::Message title = model()->children(selectedRow())->label();
if (title == I18n::Message::Brightness || title == I18n::Message::Language) {
assert(false);
} else if (rowIndex == k_indexOfExamModeCell) {
} else if (title == I18n::Message::ExamMode) {
subController = &m_examModeController;
} else if (rowIndex == k_indexOfAboutCell + hasPrompt()) {
} else if (title == I18n::Message::About) {
subController = &m_aboutController;
} else if (model()->children(selectedRow())->label() == I18n::Message::Accessibility) {
} else if (title == I18n::Message::Accessibility) {
subController = &m_accessibilityController;
} else if (model()->children(selectedRow())->label() == I18n::Message::MathOptions) {
} else if (title == I18n::Message::MathOptions) {
subController = &m_mathOptionsController;
} else {
subController = &m_preferencesController;
@@ -116,7 +116,7 @@ int MainController::numberOfRows() const {
};
KDCoordinate MainController::rowHeight(int j) {
if (j == k_indexOfBrightnessCell) {
if (model()->children(j)->label() == I18n::Message::Brightness) {
return Metric::ParameterCellHeight + CellWithSeparator::k_margin;
}
return Metric::ParameterCellHeight;
@@ -159,10 +159,10 @@ int MainController::reusableCellCount(int type) {
}
int MainController::typeAtLocation(int i, int j) {
if (j == k_indexOfBrightnessCell) {
if (model()->children(j)->label() == I18n::Message::Brightness) {
return 1;
}
if (hasPrompt() && j == k_indexOfPopUpCell) {
if (model()->children(j)->label() == I18n::Message::UpdatePopUp || model()->children(j)->label() == I18n::Message::BetaPopUp) {
return 2;
}
return 0;
@@ -170,9 +170,8 @@ int MainController::typeAtLocation(int i, int j) {
void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) {
GlobalPreferences * globalPreferences = GlobalPreferences::sharedGlobalPreferences();
Preferences * preferences = Preferences::sharedPreferences();
I18n::Message title = model()->children(index)->label();
if (index == k_indexOfBrightnessCell) {
if (model()->children(index)->label() == I18n::Message::Brightness) {
MessageTableCellWithGaugeWithSeparator * myGaugeCell = (MessageTableCellWithGaugeWithSeparator *)cell;
myGaugeCell->setMessage(title);
GaugeView * myGauge = (GaugeView *)myGaugeCell->accessoryView();
@@ -181,12 +180,12 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) {
}
MessageTableCell * myCell = (MessageTableCell *)cell;
myCell->setMessage(title);
if (index == k_indexOfLanguageCell) {
if (model()->children(index)->label() == I18n::Message::Language) {
int index = (int)globalPreferences->language()-1;
static_cast<MessageTableCellWithChevronAndMessage *>(cell)->setSubtitle(I18n::LanguageNames[index]);
return;
}
if (hasPrompt() && index == k_indexOfPopUpCell) {
if (model()->children(index)->label() == I18n::Message::UpdatePopUp || model()->children(index)->label() == I18n::Message::BetaPopUp) {
MessageTableCellWithSwitch * mySwitchCell = (MessageTableCellWithSwitch *)cell;
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
mySwitch->setState(globalPreferences->showPopUp());
@@ -194,8 +193,8 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) {
}
MessageTableCellWithChevronAndMessage * myTextCell = (MessageTableCellWithChevronAndMessage *)cell;
int childIndex = -1;
switch (index) {
case k_indexOfFontCell:
switch (model()->children(index)->label()) {
case I18n::Message::FontSizes:
childIndex = GlobalPreferences::sharedGlobalPreferences()->font() == KDFont::LargeFont ? 0 : 1;
break;
}