[settings] Added symbolic calculation in exam mode.

This commit is contained in:
M4x1m3
2019-12-09 22:28:22 +01:00
parent f9fb3a963e
commit db2807c57e
10 changed files with 34 additions and 5 deletions

View File

@@ -47,3 +47,4 @@ SymbolMultiplicationCross = "Kreuz"
SymbolMultiplicationMiddleDot = "Mittelpunkt"
SymbolMultiplicationStar = "Stern"
SymbolMultiplicationAutoSymbol = "automatisch"
SymbolicEnabled = "Symbolic calc."

View File

@@ -47,3 +47,4 @@ SymbolMultiplicationCross = "Cross"
SymbolMultiplicationMiddleDot = "Middle dot"
SymbolMultiplicationStar = "Star"
SymbolMultiplicationAutoSymbol = "Automatic"
SymbolicEnabled = "Symbolic calc."

View File

@@ -47,3 +47,4 @@ SymbolMultiplicationCross = "contrariar"
SymbolMultiplicationMiddleDot = "punto medio"
SymbolMultiplicationStar = "estrella"
SymbolMultiplicationAutoSymbol = "automático"
SymbolicEnabled = "Symbolic calc."

View File

@@ -47,3 +47,4 @@ SymbolMultiplicationCross = "Croix"
SymbolMultiplicationMiddleDot = "Point"
SymbolMultiplicationStar = "Etoile"
SymbolMultiplicationAutoSymbol = "Automatique"
SymbolicEnabled = "Symbolic calc."

View File

@@ -47,3 +47,4 @@ SymbolMultiplicationCross = "crómio"
SymbolMultiplicationMiddleDot = "ponto médio"
SymbolMultiplicationStar = "estrela"
SymbolMultiplicationAutoSymbol = "automático"
SymbolicEnabled = "Symbolic calc."

View File

@@ -15,7 +15,7 @@ constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::M
//sub-menus
constexpr SettingsMessageTree s_modelMathOptionsChildren[5] = {SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren, 3), SettingsMessageTree(I18n::Message::DisplayMode, s_modelFloatDisplayModeChildren, 4), SettingsMessageTree(I18n::Message::EditionMode, s_modelEditionModeChildren, 2), SettingsMessageTree(I18n::Message::ComplexFormat, s_modelComplexFormatChildren, 3), SettingsMessageTree(I18n::Message::SymbolMultiplication, s_symbolChildren, 4)};
constexpr SettingsMessageTree s_modelExamChildren[2] = {SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren, 4), SettingsMessageTree(I18n::Message::ActivateExamMode)};
constexpr SettingsMessageTree s_modelExamChildren[3] = {SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren, 4), SettingsMessageTree(I18n::Message::SymbolicEnabled), SettingsMessageTree(I18n::Message::ActivateExamMode)};
constexpr SettingsMessageTree s_accessibilityChildren[6] = {SettingsMessageTree(I18n::Message::AccessibilityInvertColors), SettingsMessageTree(I18n::Message::AccessibilityMagnify),SettingsMessageTree(I18n::Message::AccessibilityGamma),SettingsMessageTree(I18n::Message::AccessibilityGammaRed),SettingsMessageTree(I18n::Message::AccessibilityGammaGreen),SettingsMessageTree(I18n::Message::AccessibilityGammaBlue)};
#ifdef USERNAME
constexpr SettingsMessageTree s_modelAboutChildren[7] = {SettingsMessageTree(I18n::Message::Username), SettingsMessageTree(I18n::Message::SoftwareVersion), SettingsMessageTree(I18n::Message::CustomSoftwareVersion), SettingsMessageTree(I18n::Message::MicroPythonVersion), SettingsMessageTree(I18n::Message::SerialNumber), SettingsMessageTree(I18n::Message::FccId), SettingsMessageTree(I18n::Message::Contributors, s_contributorsChildren, 5)};
@@ -27,7 +27,7 @@ constexpr SettingsMessageTree s_modelMenu[] =
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren, 5),
SettingsMessageTree(I18n::Message::Brightness),
SettingsMessageTree(I18n::Message::Language),
SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 2),
SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 3),
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren, 6),
#ifdef USERNAME
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren, 7)};

View File

@@ -15,7 +15,8 @@ ExamModeController::ExamModeController(Responder * parentResponder) :
GenericSubController(parentResponder),
m_preferencesController(this),
m_examModeCell(I18n::Message::Default, KDFont::LargeFont),
m_ledCell(KDFont::LargeFont, KDFont::SmallFont)
m_ledCell(KDFont::LargeFont, KDFont::SmallFont),
m_symbolicCell(I18n::Message::SymbolicEnabled, KDFont::LargeFont)
{
}
@@ -40,6 +41,12 @@ bool ExamModeController::handleEvent(Ion::Events::Event event) {
stack->push(subController);
return true;
}
if (childLabel == I18n::Message::SymbolicEnabled) {
Preferences * preferences = Preferences::sharedPreferences();
preferences->setExamSymbolic(!preferences->isExamSymbolic());
m_selectableTableView.reloadData();
return true;
}
}
return GenericSubController::handleEvent(event);
}
@@ -49,6 +56,9 @@ HighlightCell * ExamModeController::reusableCell(int index, int type) {
if (type == 0) {
return &m_ledCell;
}
if (type == 1) {
return &m_symbolicCell;
}
return &m_examModeCell;
}
@@ -58,6 +68,8 @@ int ExamModeController::reusableCellCount(int type) {
return 1;
case 1:
return 1;
case 2:
return 1;
default:
assert(false);
return 0;
@@ -78,6 +90,11 @@ void ExamModeController::willDisplayCellForIndex(HighlightCell * cell, int index
I18n::Message message = (I18n::Message) m_messageTreeModel->children(index)->children((int)preferences->colorOfLED())->label();
myTextCell->setSubtitle(message);
}
if (thisLabel == I18n::Message::SymbolicEnabled) {
MessageTableCellWithSwitch * mySwitchCell = (MessageTableCellWithSwitch *)cell;
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
mySwitch->setState(preferences->isExamSymbolic());
}
}
int ExamModeController::typeAtLocation(int i, int j) {
@@ -86,6 +103,8 @@ int ExamModeController::typeAtLocation(int i, int j) {
return 0;
case 1:
return 1;
case 2:
return 2;
default:
assert(false);
return 0;

View File

@@ -19,6 +19,7 @@ private:
MessageTableCell m_examModeCell;
MessageTableCellWithChevronAndMessage m_ledCell;
PreferencesController m_preferencesController;
MessageTableCellWithSwitch m_symbolicCell;
};
}

View File

@@ -64,6 +64,8 @@ public:
void setColorOfLED(LEDColor color) { m_colorOfLED = color; }
SymbolMultiplication symbolofMultiplication() const {return m_symbolMultiplication;}
void setSymbolMultiplication(SymbolMultiplication symbolofMultiplication) {m_symbolMultiplication = symbolofMultiplication;}
bool isExamSymbolic() const {return m_examSymbolic;}
void setExamSymbolic(bool examSymbolic) {m_examSymbolic = examSymbolic;}
private:
AngleUnit m_angleUnit;
PrintFloatMode m_displayMode;
@@ -71,7 +73,8 @@ private:
ComplexFormat m_complexFormat;
uint8_t m_numberOfSignificantDigits;
LEDColor m_colorOfLED;
SymbolMultiplication m_symbolMultiplication;
SymbolMultiplication m_symbolMultiplication;
bool m_examSymbolic;
};
}

View File

@@ -14,7 +14,8 @@ Preferences::Preferences() :
m_complexFormat(Preferences::ComplexFormat::Real),
m_numberOfSignificantDigits(PrintFloat::k_numberOfPrintedSignificantDigits),
m_colorOfLED(Preferences::LEDColor::White),
m_symbolMultiplication(Preferences::SymbolMultiplication::Cross)
m_symbolMultiplication(Preferences::SymbolMultiplication::Cross),
m_examSymbolic(true)
{}
Preferences * Preferences::sharedPreferences() {