aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHartmut Riesenbeck <hartmut.riesenbeck@gmx.de>2016-10-31 20:55:39 (GMT)
committerHartmut Riesenbeck <hartmut.riesenbeck@gmx.de>2016-10-31 20:55:39 (GMT)
commit2505ea493940784f3c0d5f76bc50c7ceb29739c9 (patch)
treea7a9b8d94c61ebfe82c5505aebc97796d011d89c
parent63f15ce822537b82c25fc5462ccb01fe1c06acfc (diff)
Remember practice direction for each practice mode
New check box in StatistcsMainWindow is added. If check box is switched on the practice direction for the current practice mode is saved and will be restored when this practice mode is selected again. StatistcsMainWindow is partially redesigned. All practice controlling widgets were grouped into frames. REVIEW: 128078
-rw-r--r--src/settings/parley.kcfg10
-rw-r--r--src/statistics/statisticsmainwindow.cpp56
-rw-r--r--src/statistics/statisticsmainwindow.h5
-rw-r--r--src/statistics/statisticsmainwindow.ui362
4 files changed, 239 insertions, 194 deletions
diff --git a/src/settings/parley.kcfg b/src/settings/parley.kcfg
index 7eac0d2..e390683 100644
--- a/src/settings/parley.kcfg
+++ b/src/settings/parley.kcfg
@@ -371,6 +371,16 @@
<default param="6">5184000</default>
<default param="7">10368000</default>
</entry>
+ <entry name="RememberPracticeDirection" type="Bool">
+ <label>If true, the practice direction for each practice mode is stored.</label>
+ <whatsthis>Should the practice direction for each practice mode be stored?</whatsthis>
+ <default>false</default>
+ </entry>
+ <entry name="PracticeDirectionsByPracticeMode" type="IntList">
+ <label>Stored values of practice direction for each practice mode.</label>
+ <whatsthis>Stored values of practice direction for each practice mode.</whatsthis>
+ <default></default>
+ </entry>
</group>
<group name="KNewStuff">
<entry name="ProvidersUrl" type="Path">
diff --git a/src/statistics/statisticsmainwindow.cpp b/src/statistics/statisticsmainwindow.cpp
index 64c7ad6..c251f87 100644
--- a/src/statistics/statisticsmainwindow.cpp
+++ b/src/statistics/statisticsmainwindow.cpp
@@ -37,10 +37,11 @@
#include "conjugationoptions.h"
-StatisticsMainWindow::StatisticsMainWindow(KEduVocDocument* doc, ParleyMainWindow* parent)
+StatisticsMainWindow::StatisticsMainWindow(KEduVocDocument *doc, ParleyMainWindow *parent)
: KXmlGuiWindow(parent)
, m_mainWindow(parent)
, m_doc(doc)
+ , m_ui(new Ui::StatisticsMainWindow)
, m_conjugationOptions(0)
{
// KXmlGui
@@ -49,7 +50,6 @@ StatisticsMainWindow::StatisticsMainWindow(KEduVocDocument* doc, ParleyMainWindo
QWidget *mainWidget = new QWidget(this);
setCentralWidget(mainWidget);
- m_ui = new Ui::StatisticsMainWindow;
m_ui->setupUi(mainWidget);
//m_ui->caption->setText(i18nc("caption for an overview of the confidence levels for a document"
// "Statistics for \"%1\"", m_doc->title()));
@@ -204,27 +204,51 @@ void StatisticsMainWindow::initPracticeMode()
m_ui->practiceDirection->insertItem(2, i18n("Mixed Directions"));
//m_ui->practiceDirection->insertItem(3, i18n("Mixed Directions with Sound"));
- if (Prefs::practiceDirection() < 0 || 3 < Prefs::practiceDirection())
+ int practiceDirection(Prefs::rememberPracticeDirection()
+ ? practiceDirectionForPracticeMode(Prefs::practiceMode()) : Prefs::practiceDirection());
+
+ if (practiceDirection < 0 || 3 < practiceDirection)
Prefs::setPracticeDirection(Prefs::EnumPracticeDirection::MixedDirectionsWordsOnly);
- m_ui->practiceDirection->setCurrentIndex(Prefs::practiceDirection());
+ m_ui->practiceDirection->setCurrentIndex(practiceDirection);
+ connect(m_ui->practiceDirection, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ this, &StatisticsMainWindow::practiceDirectionChanged);
- connect(m_ui->practiceDirection, SIGNAL(currentIndexChanged(int)),
- this, SLOT(practiceDirectionChanged(int)));
+ m_ui->rememberPracticeDirection->setChecked(Prefs::rememberPracticeDirection());
+ connect(m_ui->rememberPracticeDirection, &QCheckBox::toggled,
+ this, &StatisticsMainWindow::rememberPracticeDirectionChanged);
}
void StatisticsMainWindow::practiceModeSelected(int mode)
{
+ int previousPracticeMode = Prefs::practiceMode();
Prefs::setPracticeMode(static_cast<Prefs::EnumPracticeMode::type>(mode));
//qDebug() << "mode: " << mode << Prefs::practiceMode();
showConjugationOptions(mode == Prefs::EnumPracticeMode::ConjugationPractice);
+
+ if (Prefs::rememberPracticeDirection()) {
+ setPracticeDirectionForPracticeMode(Prefs::practiceDirection(), previousPracticeMode);
+ m_ui->practiceDirection->setCurrentIndex(practiceDirectionForPracticeMode(mode));
+ }
}
void StatisticsMainWindow::practiceDirectionChanged(int mode)
{
//qDebug() << "new practice direction:" << mode;
Prefs::setPracticeDirection(static_cast<Prefs::EnumPracticeDirection::type>(mode));
+ if (Prefs::rememberPracticeDirection()) {
+ setPracticeDirectionForPracticeMode(mode, Prefs::practiceMode());
+ }
+}
+
+void StatisticsMainWindow::rememberPracticeDirectionChanged(bool checked)
+{
+// qDebug() << "remember practice direction changed to: " << checked;
+ Prefs::setRememberPracticeDirection(checked);
+ if (checked) {
+ setPracticeDirectionForPracticeMode(Prefs::practiceDirection(), Prefs::practiceMode());
+ }
}
void StatisticsMainWindow::updateVisibleColumns()
@@ -274,3 +298,23 @@ void StatisticsMainWindow::configurePractice()
ConfigurePracticeDialog dialog(m_doc, this, QStringLiteral("practice settings"), Prefs::self());
dialog.exec();
}
+
+int StatisticsMainWindow::practiceDirectionForPracticeMode(int mode) const
+{
+ int direction = Prefs::practiceDirectionsByPracticeMode().value(mode, Prefs::practiceDirection());
+ if ((direction < 0) || (direction > Prefs::EnumPracticeDirection::MixedDirectionsWordsOnly)) {
+ direction = Prefs::EnumPracticeDirection::MixedDirectionsWordsOnly;
+ }
+ return direction;
+}
+
+void StatisticsMainWindow::setPracticeDirectionForPracticeMode(int direction, int mode)
+{
+ QList<int> directions = Prefs::practiceDirectionsByPracticeMode();
+ // Expand list if fields not used before
+ for (int i = directions.size() - 1; i < mode; ++i) {
+ directions.append(Prefs::practiceDirection());
+ }
+ directions[mode] = direction;
+ Prefs::setPracticeDirectionsByPracticeMode(directions);
+}
diff --git a/src/statistics/statisticsmainwindow.h b/src/statistics/statisticsmainwindow.h
index f6c8723..838bccf 100644
--- a/src/statistics/statisticsmainwindow.h
+++ b/src/statistics/statisticsmainwindow.h
@@ -33,7 +33,7 @@ class StatisticsMainWindow : public KXmlGuiWindow
Q_OBJECT
public:
- StatisticsMainWindow(KEduVocDocument* doc, ParleyMainWindow* parent);
+ StatisticsMainWindow(KEduVocDocument *doc, ParleyMainWindow *parent);
~StatisticsMainWindow();
void setDocument(KEduVocDocument* doc);
@@ -48,6 +48,7 @@ private slots:
void languagesChanged();
void practiceModeSelected(int mode);
void practiceDirectionChanged(int mode);
+ void rememberPracticeDirectionChanged(bool checked);
void updateVisibleColumns();
private:
@@ -56,6 +57,8 @@ private:
void initLanguages();
void initPracticeMode();
void showConjugationOptions(bool visible = true);
+ int practiceDirectionForPracticeMode(int mode) const;
+ void setPracticeDirectionForPracticeMode(int direction, int mode);
ParleyMainWindow* m_mainWindow;
KEduVocDocument* m_doc;
diff --git a/src/statistics/statisticsmainwindow.ui b/src/statistics/statisticsmainwindow.ui
index 190017c..3070b3e 100644
--- a/src/statistics/statisticsmainwindow.ui
+++ b/src/statistics/statisticsmainwindow.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>602</width>
- <height>467</height>
+ <height>580</height>
</rect>
</property>
<property name="sizePolicy">
@@ -16,206 +16,194 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <layout class="QGridLayout" name="gridLayout">
+ <layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
<item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Language to Learn</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QComboBox" name="learnedLanguage"/>
- </item>
- <item row="0" column="1" rowspan="18">
- <widget class="QSplitter" name="splitter" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
-
- <widget class="LessonStatisticsView" name="lessonStatistics" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
-
- <widget class="StatisticsLegendWidget" name="statisticsLegend" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
+ <widget class="QGroupBox" name="groupBoxLanguages">
+ <property name="title">
+ <string>Languages</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Language to Learn</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="learnedLanguage"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Known Language</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="knownLanguage"/>
+ </item>
+ </layout>
</widget>
-
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Known Language</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QComboBox" name="knownLanguage"/>
</item>
- <item row="4" column="0">
- <spacer name="verticalSpacer_2">
+ <item row="0" column="1" rowspan="4">
+ <widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>10</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Practice Mode:</string>
- </property>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QRadioButton" name="flashCard">
- <property name="text">
- <string>Flash Cards</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="7" column="0">
- <widget class="QRadioButton" name="mixedLetters">
- <property name="text">
- <string>Mixed Letters</string>
- </property>
- </widget>
- </item>
- <item row="8" column="0">
- <widget class="QRadioButton" name="multipleChoice">
- <property name="text">
- <string>Multiple Choice</string>
- </property>
- </widget>
- </item>
- <item row="9" column="0">
- <widget class="QRadioButton" name="written">
- <property name="text">
- <string>Written</string>
- </property>
- </widget>
- </item>
- <item row="10" column="0">
- <widget class="QRadioButton" name="exampleSentence">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Example Sentences</string>
- </property>
- </widget>
- </item>
- <item row="11" column="0">
- <widget class="QRadioButton" name="gender">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Gender of Nouns</string>
- </property>
- </widget>
- </item>
- <item row="12" column="0">
- <widget class="QRadioButton" name="comparisonForms">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Comparison Forms</string>
- </property>
+ <widget class="LessonStatisticsView" name="lessonStatistics" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="StatisticsLegendWidget" name="statisticsLegend" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
</widget>
</item>
- <item row="13" column="0">
- <widget class="QRadioButton" name="conjugations">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Conjugations</string>
- </property>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="groupBoxPracticeMode">
+ <property name="title">
+ <string>Practice Mode</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QRadioButton" name="flashCard">
+ <property name="text">
+ <string>Flash Cards</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="mixedLetters">
+ <property name="text">
+ <string>Mixed &amp;Letters</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="multipleChoice">
+ <property name="text">
+ <string>M&amp;ultiple Choice</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="written">
+ <property name="text">
+ <string>Wri&amp;tten</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="exampleSentence">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>E&amp;xample Sentences</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="gender">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Gender of Nouns</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="comparisonForms">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Comparison Forms</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="conjugations">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Co&amp;njugations</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QWidget" name="modeSpecificOptions" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>200</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
</widget>
</item>
- <item row="14" column="0">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QWidget" name="modeSpecificOptions" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>200</width>
- <height>16777215</height>
- </size>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="15" column="0">
- <widget class="QLabel" name="label3">
- <property name="text">
+ <item row="2" column="0">
+ <widget class="QGroupBox" name="groupBoxPracticeDirection">
+ <property name="title">
<string>Practice Direction</string>
</property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QComboBox" name="practiceDirection"/>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="rememberPracticeDirection">
+ <property name="text">
+ <string>Remember for each Practice Mode</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
- <item row="16" column="0">
- <widget class="QComboBox" name="practiceDirection"/>
- </item>
- <item row="17" column="0">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
<customwidgets>