diff --git a/CMakeLists.txt b/CMakeLists.txt index 671175b..bb2207a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,47 +1,42 @@ project(kbruch) cmake_minimum_required(VERSION 2.8.12) +set(QT_MIN_VERSION "5.9.0") +set(KF5_VERSION "5.46.0") -find_package(ECM 1.7.0 REQUIRED NO_MODULE) +find_package(ECM ${KF5_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) include(ECMInstallIcons) -find_package(Qt5 5.2.0 CONFIG REQUIRED +find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Widgets ) -find_package(KF5 5.15 REQUIRED +find_package(KF5 ${KF5_VERSION} REQUIRED Config Crash DocTools I18n WidgetsAddons XmlGui ) include(KDEInstallDirs) include(KDECMakeSettings) -include(KDECompilerSettings NO_POLICY_SCOPE) +include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(FeatureSummary) include(ECMAddAppIcon) # use sane compile flags add_definitions( -fexceptions - -DQT_USE_QSTRINGBUILDER - -DQT_NO_CAST_TO_ASCII - -DQT_NO_CAST_FROM_ASCII - -DQT_STRICT_ITERATORS -DQT_NO_URL_CAST_FROM_STRING - -DQT_NO_CAST_FROM_BYTEARRAY - -DQT_NO_SIGNALS_SLOTS_KEYWORDS - -DQT_USE_FAST_OPERATOR_PLUS ) add_subdirectory( doc ) add_subdirectory( src ) install(FILES org.kde.kbruch.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/ExerciseBase.h b/src/ExerciseBase.h index ae68819..46aec30 100644 --- a/src/ExerciseBase.h +++ b/src/ExerciseBase.h @@ -1,45 +1,45 @@ /*************************************************************************** ExerciseBase.h ------------------- begin : 2004/06/03 copyright : (C) 2004 by Sebastian Stein email : seb.kde@hpfsc.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef EXERCISEBASE_H #define EXERCISEBASE_H #define _CHECK_TASK 0 #define _NEXT_TASK 1 #include /*! Constructs a QWidget. * * It is the base class for showing the different exercises. * * \author Sebastian Stein * */ class ExerciseBase : public QWidget { public: /** constructor */ - explicit ExerciseBase(QWidget * parent = 0); + explicit ExerciseBase(QWidget * parent = nullptr); /** destructor */ ~ExerciseBase(); /** force the creation of a new task */ virtual void forceNewTask() = 0; }; #endif diff --git a/src/ExerciseCompare.h b/src/ExerciseCompare.h index 17ce9d0..2cf40c1 100644 --- a/src/ExerciseCompare.h +++ b/src/ExerciseCompare.h @@ -1,119 +1,119 @@ /*************************************************************************** ExerciseCompare.h ------------------- begin : 2004/06/03 copyright : (C) 2004 by Sebastian Stein email : seb.kde@hpfsc.de copyright : (C) 2008 by Tadeu Araujo, tadeu.araujo@ltia.fc.unesp.br copyright : (C) 2008 by Danilo Balzaque, danilo.balzaque@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef EXERCISECOMPARE_H #define EXERCISECOMPARE_H #include #include #include #include #include "ExerciseBase.h" #include "Ratio.h" #include "RatioWidget.h" #include "ResultWidget.h" class QGridLayout; class QLabel; class QPushButton; class QVBoxLayout; /*! Constructs a QWidget, which shows the task to the user. * The class also provides input fields, so that the user can enter the result. * It also controls the interaction, so that the entered result gets checked * and a new task can be generated. * \author Sebastian Stein * */ class ExerciseCompare : public ExerciseBase { Q_OBJECT public: /** constructor */ - explicit ExerciseCompare(QWidget * parent = 0); + explicit ExerciseCompare(QWidget * parent = nullptr); /** destructor */ ~ExerciseCompare(); /** force the creation of a new task */ void forceNewTask() Q_DECL_OVERRIDE; void setQuestionMixed(bool value); void update(); Q_SIGNALS: /** class emits this signal, if the task was solved correctly by the user */ void signalExerciseSolvedCorrect(); /** class emits this signal, if the task was skipped by the user */ void signalExerciseSkipped(); /** class emits this signal, if the task was solved not correctly by the user * */ void signalExerciseSolvedWrong(); private: short m_currentState; bool m_questionMixed; RatioWidget * m_firstRatioWidget; RatioWidget * m_secondRatioWidget; // Buttons to select the comparison QPushButton * m_skipButton; QPushButton * m_moreButton; QPushButton * m_minorButton; QPushButton * m_equalButton; Ratio m_firstRatio; Ratio m_secondRatio; // Layout Structures QGridLayout * checkLayout; QGridLayout * taskLayout; QGridLayout * baseGrid; enum SignButtonState { lessThen, greaterThen, equalTo }; SignButtonState m_signButtonState; QWidget * checkWidget; QWidget * taskWidget; ResultWidget* m_resultWidget; void createTask(); void showResult(); void nextTask(); void slotSkipButtonClicked(); void slotMinorButtonClicked(); void slotMoreButtonClicked(); void slotEqualButtonClicked(); }; #endif diff --git a/src/ExerciseConvert.h b/src/ExerciseConvert.h index 779ada7..05d95af 100644 --- a/src/ExerciseConvert.h +++ b/src/ExerciseConvert.h @@ -1,113 +1,113 @@ /*************************************************************************** ExerciseConvert.h ------------------- begin : 2004/06/04 copyright : (C) 2004 by Sebastian Stein email : seb.kde@hpfsc.de copyright : (C) 2008 by Tadeu Araujo, tadeu.araujo@ltia.fc.unesp.br copyright : (C) 2008 by Danilo Balzaque, danilo.balzaque@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef EXERCISECONVERT_H #define EXERCISECONVERT_H #include "ExerciseBase.h" #include "Ratio.h" #include #include #include class RationalWidget; class ResultWidget; class QGridLayout; class QLabel; class QLineEdit; class QPushButton; class QString; class QVBoxLayout; /*! Construct the exercise widget to convert rational numbers into fractions * * \author Sebastian Stein * */ class ExerciseConvert : public ExerciseBase { Q_OBJECT public: /** constructor */ - explicit ExerciseConvert(QWidget * parent = 0); + explicit ExerciseConvert(QWidget * parent = nullptr); /** destructor */ ~ExerciseConvert(); /** force the creation of a new task */ void forceNewTask() Q_DECL_OVERRIDE; void update(); Q_SIGNALS: /** class emits this signal, if the task was solved correctly by the user */ void signalExerciseSolvedCorrect(); /** class emits this signal, if the task was skipped by the user */ void signalExerciseSkipped(); /** class emits this signal, if the task was solved not correctly by the user * */ void signalExerciseSolvedWrong(); private: short m_currentState; QString m_number; uint m_periodStart; uint m_periodLength; Ratio m_result; // Visible components RationalWidget * m_rationalWidget; ResultWidget * m_resultWidget; QLineEdit * numer_edit; QFrame * edit_line; QLineEdit * deno_edit; QPushButton* m_checkButton; QPushButton* m_skipButton; // Layout Structures QGridLayout* checkLayout; QGridLayout* taskLayout; QGridLayout* baseGrid; QWidget * checkWidget; QWidget * taskWidget; // Operation functions void createTask(); void showResult(); void nextTask(); void slotCheckButtonClicked(); void slotSkipButtonClicked(); void numeratorReturnPressed(); void denominatorReturnPressed(); protected: void showEvent(QShowEvent * event) Q_DECL_OVERRIDE; }; #endif diff --git a/src/ExerciseFactorize.h b/src/ExerciseFactorize.h index 9829653..0e31f17 100644 --- a/src/ExerciseFactorize.h +++ b/src/ExerciseFactorize.h @@ -1,150 +1,150 @@ /*************************************************************************** ExerciseFactorize.h ------------------- begin : 2004/06/04 copyright : (C) 2004 by Sebastian Stein email : seb.kde@hpfsc.de copyright : (C) 2008 by Tadeu Araujo, tadeu.araujo@ltia.fc.unesp.br copyright : (C) 2008 by Danilo Balzaque, danilo.balzaque@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef EXERCISEFACTORIZE_H #define EXERCISEFACTORIZE_H #include #include #include #include "ExerciseBase.h" #include "ResultWidget.h" #include "Ratio.h" #include "PrimeFactorsLineEdit.h" class ResultWidget; class QGridLayout; class QLabel; class QPushButton; // a list containing uints typedef QList uintList; // set a macro how much numbers are given to factorize #define numberPossibleTasks 45 // set all possible numbers to factorize const uint possibleTasks[numberPossibleTasks] = {4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 30, 32, 33, 34, 35, 38, 39, 49, 50, 51, 54, 55, 57, 60, 65, 70, 77, 75, 85, 95, 98, 121, 125, 169, 242, 250, 289, 361 }; /*! Construct the exercise widget to factorize a given number * * \author Sebastian Stein * */ class ExerciseFactorize : public ExerciseBase { Q_OBJECT public: /** constructor */ - explicit ExerciseFactorize(QWidget * parent = 0); + explicit ExerciseFactorize(QWidget * parent = nullptr); /** destructor */ ~ExerciseFactorize(); /** force the creation of a new task */ void forceNewTask() Q_DECL_OVERRIDE; void update(); Q_SIGNALS: /** class emits this signal, if the task was solved correctly by the user */ void signalExerciseSolvedCorrect(); /** class emits this signal, if the task was skipped by the user */ void signalExerciseSkipped(); /** class emits this signal, if the task was solved not correctly by the user * */ void signalExerciseSolvedWrong(); private: short m_currentState; bool m_edit; // Get the last number typped by keyboard for keyboard handler uint m_buffer; uint m_taskNumber; uintList m_factorsEntered; uintList m_factorsResult; QLabel * m_taskLabel; QLabel * m_equalSignLabel; PrimeFactorsLineEdit * m_factorsEnteredEdit; // buttons for the different prime factors QPushButton * m_factor2Button; QPushButton * m_factor3Button; QPushButton * m_factor5Button; QPushButton * m_factor7Button; QPushButton * m_factor11Button; QPushButton * m_factor13Button; QPushButton * m_factor17Button; QPushButton * m_factor19Button; // button to remove the last entered factor QPushButton * m_removeLastFactorButton; QPushButton * m_checkButton; QPushButton * m_skipButton; QGridLayout * checkLayout; QGridLayout * taskLayout; QGridLayout * baseGrid; QWidget * checkWidget; QWidget * taskWidget; ResultWidget * m_resultWidget; void createTask(); void showResult(); void nextTask(); void addFactor(uint factor); void updateEnteredEdit(); void slotFactorsEditReturnPressed(); void slotCheckButtonClicked(); void slotSkipButtonClicked(); void slotFactor2ButtonClicked(); void slotFactor3ButtonClicked(); void slotFactor5ButtonClicked(); void slotFactor7ButtonClicked(); void slotFactor11ButtonClicked(); void slotFactor13ButtonClicked(); void slotFactor17ButtonClicked(); void slotFactor19ButtonClicked(); void slotRemoveLastFactorButtonClicked(); void editContentChanged(bool correct); void setButtonsEnabled(bool enabled); protected: void showEvent(QShowEvent * event) Q_DECL_OVERRIDE; }; #endif diff --git a/src/ExerciseMixedNumbers.h b/src/ExerciseMixedNumbers.h index d2ef37d..ed1b6fd 100644 --- a/src/ExerciseMixedNumbers.h +++ b/src/ExerciseMixedNumbers.h @@ -1,129 +1,129 @@ /* KBruch - exercise to convert mixed numbers in ratios and vice versa Copyright 2011 - Sebastian Stein This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef EXERCISEMIXEDNUMBERS_H #define EXERCISEMIXEDNUMBERS_H #include "ExerciseBase.h" #include "ResultWidget.h" #include "Task.h" #include "TaskWidget.h" class QLineEdit; class QFrame; class QGridLayout; class QPushButton; class QWidget; /** * exercise to convert mixed numbers in ordinary ratios and vice versa * \author Sebastian Stein */ class ExerciseMixedNumbers: public ExerciseBase { Q_OBJECT public: /** constructor */ - explicit ExerciseMixedNumbers(QWidget* parent = 0); + explicit ExerciseMixedNumbers(QWidget* parent = nullptr); /** destructor */ virtual ~ExerciseMixedNumbers(); /** resets the current state, creates a new task and counts the last task * as wrong, if it wasn't solved (in _NEXT_TASK state) yet mainly used * after changing the task parameters */ void forceNewTask() Q_DECL_OVERRIDE; Q_SIGNALS: /** signal emitted if task solved correctly */ void signalExerciseSolvedCorrect(); /** signal emitted if task skipped */ void signalExerciseSkipped(); /** signal emitted if task solved not correctly */ void signalExerciseSolvedWrong(); private: /** holds current state of this exercise */ short m_currentState; /** true if task is a mixed number and user must enter ratio */ bool m_isMixedTask; /** task currently to be solved */ Task m_task; // components to enter result QLineEdit * m_integerEdit; QLineEdit * m_numerEdit; QFrame * m_editLine; QLineEdit * m_denoEdit; // check and skip buttons QPushButton * m_checkButton; QPushButton * m_skipButton; // base grid layout QGridLayout * m_baseGrid; QWidget * m_checkWidget; QWidget * m_tmpTaskWidget; // layout to show task and input fields QGridLayout * m_taskLayout; TaskWidget * m_taskWidget; // layout to show solution QGridLayout * m_checkLayout; ResultWidget * m_resultWidget; /** creates a new task */ void createTask(); /** shows next task; hides previous solution */ void nextTask(); /** checks result and shows solution */ void showResult(); /** handle check button click */ void slotCheckButtonClicked(); /** handle skip button click */ void slotSkipButtonClicked(); /** focus set to numerator edit if return pressed in integer edit */ void integerReturnPressed(); /** focus set to denominator edit if return pressed in numerator edit */ void numerReturnPressed(); /** invokes check button if return pressed in denominator edit */ void denoReturnPressed(); protected: /** sets focus to input fields */ void showEvent(QShowEvent * event) Q_DECL_OVERRIDE; }; #endif // EXERCISEMIXEDNUMBERS_H diff --git a/src/ExercisePercentage.h b/src/ExercisePercentage.h index 9c2901a..5ef7656 100644 --- a/src/ExercisePercentage.h +++ b/src/ExercisePercentage.h @@ -1,103 +1,103 @@ /*************************************************************************** ExercisePercentage.h ------------------- begin : 2008/10/10 copyright : (C) 2008 by Tiago Porangaba email : tiago.porangaba@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef EXERCISEPERCENTAGE_H #define EXERCISEPERCENTAGE_H #include "ExerciseBase.h" #include "Ratio.h" #include class RationalWidget; class ResultWidget; class QLineEdit; class QGridLayout; class QLabel; class QPushButton; /*! Construct the exercise widget to work with percentage * * \author Sebastian Stein * \author Tiago Porangaba * */ class ExercisePercentage : public ExerciseBase { Q_OBJECT public: /** constructor */ - explicit ExercisePercentage(QWidget * parent = 0); + explicit ExercisePercentage(QWidget * parent = nullptr); /** destructor */ ~ExercisePercentage(); /** force the creation of a new task */ void forceNewTask() Q_DECL_OVERRIDE; void update(); Q_SIGNALS: /** class emits this signal, if the task was solved correctly by the user */ void signalExerciseSolvedCorrect(); /** class emits this signal, if the task was skipped by the user */ void signalExerciseSkipped(); /** class emits this signal, if the task was solved not correctly by the user * */ void signalExerciseSolvedWrong(); private: short m_currentState; Ratio m_result; QString m_numberPercentage; QString m_numberPercentageOf; QString m_resultPercentage; QLabel * m_taskLabel; RationalWidget * m_rationalWidget; ResultWidget * m_resultWidget; QFrame * edit_line; QLineEdit * answer_edit; QPushButton* m_checkButton; QPushButton* m_skipButton; QGridLayout* checkLayout; QGridLayout* taskLayout; QGridLayout* baseGrid; QWidget * checkWidget; QWidget * taskWidget; void createTask(); void showResult(); void nextTask(); void slotCheckButtonClicked(); void slotSkipButtonClicked(); void answerReturnPressed(); }; #endif diff --git a/src/FractionBaseWidget.h b/src/FractionBaseWidget.h index 7d02754..b20121d 100644 --- a/src/FractionBaseWidget.h +++ b/src/FractionBaseWidget.h @@ -1,75 +1,75 @@ /*************************************************************************** FractionBaseWidget.h - base fraction painting ------------------- begin : 2004/05/30 copyright : (C) 2004 by Sebastian Stein email : seb.kde@hpfsc.de copyright : (C) 2008 by Tiago Porangaba, tiago.porangaba@ltia.fc.unesp.br copyright : (C) 2008 by Tadeu Araujo, tadeu.araujo@ltia.fc.unesp.br copyright : (C) 2008 by Danilo Balzaque, danilo.balzaque@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef FRACTIONBASEWIDGET_H #define FRACTIONBASEWIDGET_H /** the space between a ratio and an operation */ #define _MARGIN_X 5 #include "Ratio.h" #include #include /*! base class for painting fractions * * \author Sebastian Stein */ class FractionBaseWidget : public QWidget { public: /** constructor */ - explicit FractionBaseWidget(QWidget * parent = 0); + explicit FractionBaseWidget(QWidget * parent = nullptr); /** destructor */ ~FractionBaseWidget(); /** updates the widget by first getting the settings and then repainting */ void updateAndRepaint(); protected: QSize minimumSizeHint() const Q_DECL_OVERRIDE { return QSize(20, 10); } /* store the different colors */ QColor m_colorNumber; QColor m_colorLine; QColor m_colorOperation; /* the font to paint with */ QFont m_font; /** overwriting the paint event of QWidget */ //virtual void paintEvent(QPaintEvent*) = 0; /** paints a ratio at the given position */ void paintRatio(QPainter & paint, Ratio tmp_ratio, int & x_pos, int & y_pos, QFontMetrics & fm, bool addMargin = true, bool show_mixed = true, bool show_center = false); /** paints a string in the vertical middle (aligned to the operation signs) */ void paintMiddle(QPainter & paint, const QString& paint_str, int & x_pos, int & y_pos, QFontMetrics & fm, const QColor &color, bool addMargin = true); private: /** sets the font and color; values taken from settings class */ void setColorAndFont(); }; #endif diff --git a/src/FractionPainter.h b/src/FractionPainter.h index 47a4436..3ae604d 100644 --- a/src/FractionPainter.h +++ b/src/FractionPainter.h @@ -1,61 +1,61 @@ /*************************************************************************** FractionPainter.h ------------------- begin : 2008/09/18 copyright : (C) 2008 by Danilo Balzaque email : danilo.balzaque@ltia.fc.unesp.br copyright : (C) 2008 by Tadeu Araujo, tadeu.araujo@ltia.fc.unesp.br copyright : (C) 2008 by Tiago Porangaba, tiago.porangaba@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef FRACTIONPAINTER_H #define FRACTIONPAINTER_H #include "Ratio.h" #include "RatioWidget.h" #include class QPainter; class QPaintEvent; /*! Constructs a QWidget bla bla bla * \author Danilo Balzaque * */ class FractionPainter : public FractionBaseWidget { public: /** constructor */ - explicit FractionPainter(QWidget * parent = 0); + explicit FractionPainter(QWidget * parent = nullptr); /** destructor */ ~FractionPainter(); void paintFraction(const QString & str_operation, Ratio & leftRatio, int leftMult, Ratio & rightRatio, int rightMult); void update(); protected: /** Function is called every time the screen need to be painted. **/ void paintEvent(QPaintEvent * event) Q_DECL_OVERRIDE; void paintWidget(QPainter & paint); private: QString str_operation; Ratio leftRatio; int leftMult; Ratio rightRatio; int rightMult; }; #endif diff --git a/src/MainQtWidget.cpp b/src/MainQtWidget.cpp index 5a0e4dd..bc2d96e 100644 --- a/src/MainQtWidget.cpp +++ b/src/MainQtWidget.cpp @@ -1,1014 +1,1014 @@ /*************************************************************************** MainQtWidget.cpp - The main Qt/KDE window ------------------- begin : Tue Mar 16 00:00:00 CET 2003 copyright : (C) 2003-2004 by Sebastian Stein email : seb.kde@hpfsc.de copyright : (C) 2008 by Tiago Porangaba, tiago.porangaba@ltia.fc.unesp.br copyright : (C) 2008 by Tadeu Araujo, tadeu.araujo@ltia.fc.unesp.br copyright : (C) 2008 by Danilo Balzaque, danilo.balzaque@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "MainQtWidget.h" /* these includes are needed for KDE support */ #include #include #include #include #include /* these includes are needed for Qt support */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef DEBUG #include #endif #include #include "ExerciseCompare.h" #include "ExerciseConvert.h" #include "ExerciseFactorize.h" #include "ExercisePercentage.h" #include "ExerciseMixedNumbers.h" #include "TaskView.h" #include "ui_taskfontsbase.h" #include "StatisticsView.h" #include "AppMenuWidget.h" #include "TaskColors.h" #include "settingsclass.h" #include #include class TaskFonts : public QWidget, public Ui::TaskFontsBase { public: TaskFonts(QWidget * parent) : QWidget(parent) { setupUi(this); } }; /* ------ public member functions ------ */ MainQtWidget::MainQtWidget() { #ifdef DEBUG qDebug() << QStringLiteral("constructor MainQtWidget"); #endif // get the settings readOptions(); // creating KActions, used by the kbruchui.rc file setupActions(); setCaption(i18n("Exercise")); // Create layout QGridLayout * layoutExercises = new QGridLayout(); layoutExercises->setObjectName(QStringLiteral("layoutExercises")); layoutExercises->setRowStretch(2, 1); QGridLayout * layoutOptions = new QGridLayout(); layoutOptions->setObjectName(QStringLiteral("layoutOptions")); layoutOptions->setRowStretch(0, 1); layoutOptions->setRowStretch(6, 1); QGridLayout * layoutQuestion = new QGridLayout(); layoutQuestion->setObjectName(QStringLiteral("layoutQuestion")); layoutQuestion->setColumnMinimumWidth(0, 110); layoutQuestion->setColumnStretch(1, 1); QGridLayout * layoutAnswer = new QGridLayout(); layoutAnswer->setObjectName(QStringLiteral("layoutAnswer")); layoutAnswer->setColumnMinimumWidth(0, 110); layoutAnswer->setColumnStretch(1, 1); QGridLayout * layoutOperations = new QGridLayout(); layoutOperations->setObjectName(QStringLiteral("layoutOperations")); layoutOperations->setColumnMinimumWidth(0, 110); layoutOperations->setColumnStretch(1, 1); QSplitter* splitter = new QSplitter(Qt::Horizontal, this); splitter->setObjectName(QStringLiteral("QSplitter")); setCentralWidget(splitter); QWidget * pageExercises = new QWidget(); QWidget * pageOptions = new QWidget(); // Create visible components m_QuestionGroup = new QGroupBox(i18n("Question:"), pageOptions); m_AnswerGroup = new QGroupBox(i18n("Answer:"), pageOptions); m_OperationsGroup = new QGroupBox(i18n("Operations:"), pageOptions); defaultFont = SettingsClass::taskFont(); defaultFont.setBold(true); defaultFont.setPointSize(14); m_TitleLabel = new QLabel(i18n("Arithmetic"), pageExercises); m_TitleLabel->setAlignment(Qt::AlignLeft); m_TitleLabel->setFont(defaultFont); m_TitleLabel->setFixedHeight(35); m_TitleLabel->setAlignment(Qt::AlignVCenter); m_statview = new StatisticsView; m_statview->setObjectName(QStringLiteral("StatisticsView")); m_statview->setFixedHeight(120); m_footerline = new QFrame(pageExercises); m_footerline->setGeometry(QRect(pageExercises->width(), 100, 20, 20)); m_footerline->setFrameStyle(QFrame::HLine | QFrame::Sunken); m_headerline = new QFrame(pageExercises); m_headerline->setGeometry(QRect(pageExercises->width(), 100, 20, 20)); m_headerline->setFrameStyle(QFrame::HLine | QFrame::Sunken); m_taskview = new TaskView(pageExercises, m_addAdd, m_addDiv, m_addMult, m_addSub, m_nrRatios, m_maxMainDenominator); m_taskview->setObjectName(QStringLiteral("TaskView")); m_taskview->hide(); m_exerciseCompare = new ExerciseCompare(pageExercises); m_exerciseCompare->setObjectName(QStringLiteral("ExerciseCompare")); m_exerciseCompare->hide(); m_exerciseConvert = new ExerciseConvert(pageExercises); m_exerciseConvert->setObjectName(QStringLiteral("ExerciseConvert")); m_exerciseConvert->hide(); m_exerciseMixedNumbers = new ExerciseMixedNumbers(pageExercises); m_exerciseMixedNumbers->setObjectName(QStringLiteral("ExerciseMixedNumbers")); m_exerciseMixedNumbers->hide(); m_exerciseFactorize = new ExerciseFactorize(pageExercises); m_exerciseFactorize->setObjectName(QStringLiteral("ExerciseFactorize")); m_exerciseFactorize->hide(); m_exercisePercentage = new ExercisePercentage(pageExercises); m_exercisePercentage->setObjectName(QStringLiteral("ExercisePercentage")); m_exercisePercentage->hide(); m_OptionsLabel = new QLabel(i18n("Options:"), pageOptions); m_OptionsLabel->setToolTip(i18n("Set the options to solve the exercises.")); m_OptionsLabel->setWhatsThis(i18n("This part of the window shows the options to solve the exercises. Use the handle between the options and main window to change the size of this window part or to hide it by moving the handle to the left border of the main window.")); m_OptionsLabel->setObjectName(QStringLiteral("OptionsLabel")); m_OptionsLabel->setFont(defaultFont); m_QuestionMixedLabel = new QLabel(i18n("Mixed number:"), pageOptions); m_QuestionMixedLabel->setToolTip(i18n("Set if the fractions will appear as mixed numbers or not in the question expression (mixed number example: 1 4/5 = 9/5 ).")); m_QuestionMixedLabel->setObjectName(QStringLiteral("QuestionMixedLabel")); m_QuestionMixedLabel->setAlignment(Qt::AlignRight); m_QuestionMixedCheck = new QCheckBox(pageOptions); m_QuestionMixedCheck->setObjectName(QStringLiteral("QuestionMixedCheck")); m_QuestionMixedCheck->setChecked(m_questionMixed); m_taskview->setQuestionMixed(m_questionMixed); QObject::connect(m_QuestionMixedCheck, &QCheckBox::stateChanged, this, &MainQtWidget::QuestionMixedCheckSlot); m_AnswerMixedLabel = new QLabel(i18n("Mixed number:"), pageOptions); m_AnswerMixedLabel->setToolTip(i18n("Set if the fractions will appear as mixed numbers or not in the answer (mixed number example: 1 4/5 = 9/5 ).")); m_AnswerMixedLabel->setObjectName(QStringLiteral("AnswerMixedLabel")); m_AnswerMixedLabel->setAlignment(Qt::AlignRight); m_AnswerMixedCheck = new QRadioButton(pageOptions); m_AnswerMixedCheck->setObjectName(QStringLiteral("AnswerMixedCheck")); m_AnswerMixedCheck->setChecked(m_answerMixed); m_taskview->setAnswerMixed(m_answerMixed); QObject::connect(m_AnswerMixedCheck, &QRadioButton::toggled, this, &MainQtWidget::AnswerMixedCheckSlot); m_AdditionLabel = new QLabel(i18n("Addition:"), pageOptions); m_AdditionLabel->setToolTip(i18n("Check this to use addition operator.")); m_AdditionLabel->setObjectName(QStringLiteral("AdditionLabel")); m_AdditionLabel->setAlignment(Qt::AlignRight); m_AdditionCheck = new QCheckBox(pageOptions); m_AdditionCheck->setObjectName(QStringLiteral("AdditionCheck")); m_AdditionCheck->setChecked(m_addAdd); QObject::connect(m_AdditionCheck, &QCheckBox::stateChanged, this, &MainQtWidget::AdditionCheckSlot); m_SubtractionLabel = new QLabel(i18n("Subtraction:"), pageOptions); m_SubtractionLabel->setToolTip(i18n("Check this to use subtraction operator.")); m_SubtractionLabel->setObjectName(QStringLiteral("SubtractionLabel")); m_SubtractionLabel->setAlignment(Qt::AlignRight); m_SubtractionCheck = new QCheckBox(pageOptions); m_SubtractionCheck->setObjectName(QStringLiteral("SubtractionCheck")); m_SubtractionCheck->setChecked(m_addSub); QObject::connect(m_SubtractionCheck, &QCheckBox::stateChanged, this, &MainQtWidget::SubtractionCheckSlot); m_MultiplicationLabel = new QLabel(i18n("Multiplication:"), pageOptions); m_MultiplicationLabel->setToolTip(i18n("Check this to use multiplication operator.")); m_MultiplicationLabel->setObjectName(QStringLiteral("MultiplicationLabel")); m_MultiplicationLabel->setAlignment(Qt::AlignRight); m_MultiplicationCheck = new QCheckBox(pageOptions); m_MultiplicationCheck->setObjectName(QStringLiteral("MultiplicationCheck")); m_MultiplicationCheck->setChecked(m_addMult); QObject::connect(m_MultiplicationCheck, &QCheckBox::stateChanged, this, &MainQtWidget::MultiplicationCheckSlot); m_DivisionLabel = new QLabel(i18n("Division:"), pageOptions); m_DivisionLabel->setToolTip(i18n("Check this to use division operator.")); m_DivisionLabel->setObjectName(QStringLiteral("DivisionLabel")); m_DivisionLabel->setAlignment(Qt::AlignRight); m_DivisionCheck = new QCheckBox(pageOptions); m_DivisionCheck->setObjectName(QStringLiteral("DivisionCheck")); m_DivisionCheck->setChecked(m_addDiv); QObject::connect(m_DivisionCheck, &QCheckBox::stateChanged, this, &MainQtWidget::DivisionCheckSlot); m_ReducedLabel = new QLabel(i18n("Reduced form:"), pageOptions); m_ReducedLabel->setToolTip(i18n("Check this to force the use of the reduced form.")); m_ReducedLabel->setObjectName(QStringLiteral("ReducedLabel")); m_ReducedLabel->setAlignment(Qt::AlignRight); m_ReducedCheck = new QRadioButton(pageOptions); m_ReducedCheck->setObjectName(QStringLiteral("ReducedCheck")); m_ReducedCheck->setChecked(m_reducedForm); m_taskview->setReducedForm(m_reducedForm); QObject::connect(m_ReducedCheck, &QRadioButton::toggled, this, &MainQtWidget::ReducedFormCheckSlot); m_NrOfTermsLabel = new QLabel(i18n("Number of terms:"), pageOptions); m_NrOfTermsLabel->setToolTip(i18n("The number of \nterms you want")); m_NrOfTermsLabel->setObjectName(QStringLiteral("NrOfTermsLabel")); m_NrOfTermsLabel->setAlignment(Qt::AlignRight); m_NrOfTermsBox = new QComboBox(pageOptions); m_NrOfTermsBox->addItem(QStringLiteral("2")); m_NrOfTermsBox->addItem(QStringLiteral("3")); m_NrOfTermsBox->addItem(QStringLiteral("4")); m_NrOfTermsBox->addItem(QStringLiteral("5")); m_NrOfTermsBox->setCurrentIndex(m_nrRatios - 2); m_NrOfTermsBox->setToolTip(i18n("The number of \nterms you want")); m_NrOfTermsBox->setWhatsThis(i18n("Choose the number of terms (2, 3, 4 or 5) you \nwant for calculating fractions.")); QObject::connect(m_NrOfTermsBox, static_cast(&QComboBox::activated), this, &MainQtWidget::NrOfTermsBoxSlot); m_MaxMainDenominatorLabel = new QLabel(i18n("Maximum denominator:"), pageOptions); m_MaxMainDenominatorLabel->setObjectName(QStringLiteral("MaxMainDenominatorLabel")); m_MaxMainDenominatorLabel->setAlignment(Qt::AlignRight); m_MaxMainDenominatorLabel->setWordWrap(true); m_MaxMainDenominatorBox = new QComboBox(pageOptions); m_MaxMainDenominatorBox->addItem(QStringLiteral("10")); m_MaxMainDenominatorBox->addItem(QStringLiteral("20")); m_MaxMainDenominatorBox->addItem(QStringLiteral("30")); m_MaxMainDenominatorBox->addItem(QStringLiteral("50")); m_MaxMainDenominatorBox->setToolTip(i18n("The maximum number you can have as main denominator")); m_MaxMainDenominatorBox->setWhatsThis(i18n("Choose the number which will be the maximum for the main denominator: 10, 20, 30, 40 or 50.")); switch (m_maxMainDenominator) { case 10 : m_MaxMainDenominatorBox->setCurrentIndex(0); break; case 20 : m_MaxMainDenominatorBox->setCurrentIndex(1); break; case 30 : m_MaxMainDenominatorBox->setCurrentIndex(2); break; case 50 : m_MaxMainDenominatorBox->setCurrentIndex(3); break; } QObject::connect(m_MaxMainDenominatorBox, static_cast(&QComboBox::activated), this, &MainQtWidget::MaxMainDenominatorBoxSlot); layoutExercises->addWidget(m_TitleLabel, 0, 0); layoutExercises->addWidget(m_headerline, 1, 0); layoutExercises->addWidget(m_taskview, 2, 0); layoutExercises->addWidget(m_exerciseCompare, 2, 0); layoutExercises->addWidget(m_exerciseConvert, 2, 0); layoutExercises->addWidget(m_exerciseMixedNumbers, 2, 0); layoutExercises->addWidget(m_exerciseFactorize, 2, 0); layoutExercises->addWidget(m_exercisePercentage, 2, 0); layoutExercises->addWidget(m_footerline, 3, 0); layoutExercises->addWidget(m_statview, 4, 0); layoutOptions->addWidget(m_OptionsLabel, 1, 0); layoutOptions->addWidget(m_QuestionGroup, 2, 0); layoutOptions->addWidget(m_AnswerGroup, 3, 0); layoutOptions->addWidget(m_OperationsGroup, 5, 0); layoutQuestion->addWidget(m_QuestionMixedLabel, 0, 0); layoutQuestion->addWidget(m_QuestionMixedCheck, 0, 1); layoutQuestion->addWidget(m_NrOfTermsLabel, 1, 0); layoutQuestion->addWidget(m_NrOfTermsBox, 1, 1); layoutQuestion->addWidget(m_MaxMainDenominatorLabel, 2, 0); layoutQuestion->addWidget(m_MaxMainDenominatorBox, 2, 1); layoutAnswer->addWidget(m_AnswerMixedLabel, 0, 0); layoutAnswer->addWidget(m_AnswerMixedCheck, 0, 1); layoutAnswer->addWidget(m_ReducedLabel, 1, 0); layoutAnswer->addWidget(m_ReducedCheck, 1, 1); layoutOperations->addWidget(m_AdditionLabel, 0, 0); layoutOperations->addWidget(m_AdditionCheck, 0, 1); layoutOperations->addWidget(m_SubtractionLabel, 1, 0); layoutOperations->addWidget(m_SubtractionCheck, 1, 1); layoutOperations->addWidget(m_MultiplicationLabel, 2, 0); layoutOperations->addWidget(m_MultiplicationCheck, 2, 1); layoutOperations->addWidget(m_DivisionLabel, 3, 0); layoutOperations->addWidget(m_DivisionCheck, 3, 1); m_QuestionGroup->setLayout(layoutQuestion); m_AnswerGroup->setLayout(layoutAnswer); m_OperationsGroup->setLayout(layoutOperations); // set layouts to both parts pageOptions->setLayout(layoutOptions); pageExercises->setLayout(layoutExercises); // preventing resizing of left sidebar pageOptions->setFixedWidth(pageOptions->sizeHint().width()); // add left and right part to the splitter splitter->addWidget(pageOptions); splitter->addWidget(pageExercises); // connect signals of the exercises and StatisticView, so that StatisticView // gets informed about how the user solved a given task (wrong or correct) QObject::connect(m_taskview, &TaskView::signalTaskSolvedCorrect, m_statview, &StatisticsView::addCorrect); QObject::connect(m_taskview, &TaskView::signalTaskSkipped, m_statview, &StatisticsView::addSkipped); QObject::connect(m_taskview, &TaskView::signalTaskSolvedWrong, m_statview, &StatisticsView::addWrong); QObject::connect(m_exerciseCompare, &ExerciseCompare::signalExerciseSolvedCorrect, m_statview, &StatisticsView::addCorrect); QObject::connect(m_exerciseCompare, &ExerciseCompare::signalExerciseSkipped, m_statview, &StatisticsView::addSkipped); QObject::connect(m_exerciseCompare, &ExerciseCompare::signalExerciseSolvedWrong, m_statview, &StatisticsView::addWrong); QObject::connect(m_exerciseConvert, &ExerciseConvert::signalExerciseSolvedCorrect, m_statview, &StatisticsView::addCorrect); QObject::connect(m_exerciseConvert, &ExerciseConvert::signalExerciseSkipped, m_statview, &StatisticsView::addSkipped); QObject::connect(m_exerciseConvert, &ExerciseConvert::signalExerciseSolvedWrong, m_statview, &StatisticsView::addWrong); QObject::connect(m_exerciseMixedNumbers, &ExerciseMixedNumbers::signalExerciseSolvedCorrect, m_statview, &StatisticsView::addCorrect); QObject::connect(m_exerciseMixedNumbers, &ExerciseMixedNumbers::signalExerciseSkipped, m_statview, &StatisticsView::addSkipped); QObject::connect(m_exerciseMixedNumbers, &ExerciseMixedNumbers::signalExerciseSolvedWrong, m_statview, &StatisticsView::addWrong); QObject::connect(m_exerciseFactorize, &ExerciseFactorize::signalExerciseSolvedCorrect, m_statview, &StatisticsView::addCorrect); QObject::connect(m_exerciseFactorize, &ExerciseFactorize::signalExerciseSkipped, m_statview, &StatisticsView::addSkipped); QObject::connect(m_exerciseFactorize, &ExerciseFactorize::signalExerciseSolvedWrong, m_statview, &StatisticsView::addWrong); QObject::connect(m_exercisePercentage, &ExercisePercentage::signalExerciseSolvedCorrect, m_statview, &StatisticsView::addCorrect); QObject::connect(m_exercisePercentage, &ExercisePercentage::signalExerciseSkipped, m_statview, &StatisticsView::addSkipped); QObject::connect(m_exercisePercentage, &ExercisePercentage::signalExerciseSolvedWrong, m_statview, &StatisticsView::addWrong); // Get and set the page of last exercise selectedTask = (ExerciseType) SettingsClass::activeExercise(); switch (selectedTask) { case Arithmetic: SelectArithmetic(); break; case Comparison: SelectComparison(); break; case Conversion: SelectConversion(); break; case Factorization: SelectFactorization(); break; case Percentage: SelectPercentage(); break; default: SelectArithmetic(); break; } move(50, 50); } MainQtWidget::~MainQtWidget() { } QFont MainQtWidget::DefaultFont() { QFont defaultFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont); defaultFont.setPointSize(24); defaultFont.setBold(true); return defaultFont; } /* ------ private member functions ------ */ void MainQtWidget::readOptions() { #ifdef DEBUG qDebug() << QStringLiteral("readOptions MainQtWidget"); #endif m_addSub = SettingsClass::addsub(); m_addAdd = SettingsClass::addadd(); m_addDiv = SettingsClass::adddiv(); m_addMult = SettingsClass::addmult(); m_nrRatios = SettingsClass::number_ratios(); m_maxMainDenominator = SettingsClass::max_main_denominator(); m_reducedForm = SettingsClass::reduceForm(); m_answerMixed = SettingsClass::answerMixed(); m_questionMixed = SettingsClass::questionMixed(); /* make sure that we can load config files with corrupted values */ if ((m_addMult == true && m_addDiv == true) && pow(2.0, (double) m_nrRatios) > m_maxMainDenominator) { m_nrRatios = 2; m_maxMainDenominator = 10; } } void MainQtWidget::writeOptions() { SettingsClass::setActiveExercise(selectedTask); // save settings for exercise solve task with fractions SettingsClass::setAddsub(m_addSub); SettingsClass::setAddadd(m_addAdd); SettingsClass::setAdddiv(m_addDiv); SettingsClass::setAddmult(m_addMult); SettingsClass::setNumber_ratios(m_nrRatios); SettingsClass::setMax_main_denominator(m_maxMainDenominator); SettingsClass::setReduceForm(m_reducedForm); SettingsClass::setAnswerMixed(m_answerMixed); SettingsClass::setQuestionMixed(m_questionMixed); SettingsClass::self()->save(); } void MainQtWidget::setupActions() { #ifdef DEBUG qDebug() << QStringLiteral("setupActions MainQtWidget"); #endif QString css = QStringLiteral("QToolButton {" "background-position: top center;" "background-repeat: none;" "}" "QToolButton#ArithmeticButton {" "background-image: url(") + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kbruch/pics/exercise_arithmetics.png")) + QStringLiteral(");" "}" "QToolButton#ComparisonButton {" "background-image: url(") + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kbruch/pics/exercise_compare.png")) + QStringLiteral(");" "}" "QToolButton#ConversionButton {" "background-image: url(") + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kbruch/pics/exercise_conversion.png")) + QStringLiteral(");" "}" "QToolButton#MixedNumbersButton {" "background-image: url(") + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kbruch/pics/exercise_mixed.png")) + QStringLiteral(");" "}" "QToolButton#Factorization {" "background-image: url(") + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kbruch/pics/exercise_factorization.png")) + QStringLiteral(");" "}" "QToolButton#Percentage {" "background-image: url(") + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kbruch/pics/exercise_percentage.png")) + QStringLiteral(");" "}"); setStyleSheet(css); m_NewTaskButton = new QToolButton(this); m_NewTaskButton->setObjectName(QStringLiteral("NewTaskButton")); m_NewTaskButton->setText(i18n("New")); m_NewTaskButton->setIcon(QIcon::fromTheme(QStringLiteral("document-new"))); m_NewTaskButton->setToolTip(i18n("Reset statistics and set a new task.")); m_NewTaskButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); m_BackTaskButton = new QToolButton(this); m_BackTaskButton->setObjectName(QStringLiteral("BackTaskButton")); m_BackTaskButton->setText(i18n("Back")); m_BackTaskButton->setIcon(QIcon::fromTheme(QStringLiteral("go-previous"))); m_BackTaskButton->setToolTip(i18n("Go back to Modes screen.")); m_BackTaskButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); m_ArithmeticButton = new QToolButton(this); m_ArithmeticButton->setObjectName(QStringLiteral("ArithmeticButton")); m_ArithmeticButton->setText(i18n("\n\nArithmetic")); m_ArithmeticButton->setToolTip(i18n("In this exercise you have to solve a given question with fractions.")); m_ArithmeticButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); m_ComparisonButton = new QToolButton(this); m_ComparisonButton->setObjectName(QStringLiteral("ComparisonButton")); m_ComparisonButton->setText(i18n("\n\nComparison")); m_ComparisonButton->setToolTip(i18n("In this exercise you have to compare two given fractions.")); m_ComparisonButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); m_ConversionButton = new QToolButton(this); m_ConversionButton->setObjectName(QStringLiteral("ConversionButton")); m_ConversionButton->setText(i18n("\n\nConversion")); m_ConversionButton->setToolTip(i18n("In this exercise you have to convert a number into a fraction.")); m_ConversionButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); m_MixedNumbersButton = new QToolButton(this); m_MixedNumbersButton->setObjectName(QStringLiteral("MixedNumbersButton")); m_MixedNumbersButton->setText(i18n("\n\nMixed Numbers")); m_MixedNumbersButton->setToolTip(i18n("In this exercise you have to convert a mixed number into a ratio and vice versa.")); m_MixedNumbersButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); m_FactorizationButton = new QToolButton(this); m_FactorizationButton->setObjectName(QStringLiteral("Factorization")); m_FactorizationButton->setText(i18n("\n\nFactorization")); m_FactorizationButton->setToolTip(i18n("In this exercise you have to factorize a given number.")); m_FactorizationButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); m_PercentageButton = new QToolButton(this); m_PercentageButton->setObjectName(QStringLiteral("Percentage")); m_PercentageButton->setText(i18n("\n\nPercentage")); m_PercentageButton->setToolTip(i18n("In this exercise you have to work with percentage questions.")); m_PercentageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); m_NewTaskActionMenu = new QWidgetAction(this); m_NewTaskActionMenu->setText(i18nc("@action opens a new question", "&New")); m_NewTaskActionMenu->setIcon(QIcon::fromTheme(QStringLiteral("document-new"))); actionCollection()->addAction(QStringLiteral("NewTaskMenu"), m_NewTaskActionMenu); actionCollection()->setDefaultShortcuts(m_NewTaskActionMenu, KStandardShortcut::shortcut(KStandardShortcut::New)); connect(m_NewTaskActionMenu, &QAction::triggered, this, &MainQtWidget::newTask); m_NewTaskActionTool = new QWidgetAction(this); m_NewTaskActionTool->setText(i18nc("@action opens a new question", "New")); m_NewTaskActionTool->setDefaultWidget(m_NewTaskButton); actionCollection()->addAction(QStringLiteral("NewTaskTool"), m_NewTaskActionTool); connect(m_NewTaskButton, &QToolButton::clicked, this, &MainQtWidget::newTask); m_BackActionMenu = new QWidgetAction(this); m_BackActionMenu->setText(i18nc("@action go to the main screen", "&Back")); m_BackActionMenu->setIcon(QIcon::fromTheme(QStringLiteral("go-previous"))); actionCollection()->addAction(QStringLiteral("BackMenu"), m_BackActionMenu); actionCollection()->setDefaultShortcuts(m_BackActionMenu, KStandardShortcut::shortcut(KStandardShortcut::Back)); connect(m_BackActionMenu, &QAction::triggered, this, &MainQtWidget::goBack); m_BackActionTool = new QWidgetAction(this); m_BackActionTool->setText(i18nc("@action go to the main screen", "Back")); m_BackActionTool->setDefaultWidget(m_BackTaskButton); actionCollection()->addAction(QStringLiteral("BackTool"), m_BackActionTool); connect(m_BackTaskButton, &QToolButton::clicked, this, &MainQtWidget::goBack); m_ArithmeticAction = new QWidgetAction(this); m_ArithmeticAction->setText(i18nc("Arithmetic Exercise", "Arithmetic")); m_ArithmeticAction->setDefaultWidget(m_ArithmeticButton); actionCollection()->addAction(QStringLiteral("Arithmetic"), m_ArithmeticAction); connect(m_ArithmeticButton, &QToolButton::clicked, this, &MainQtWidget::SelectArithmetic); m_ComparisonAction = new QWidgetAction(this); m_ComparisonAction->setText(i18nc("Comparison Exercise", "Comparison")); m_ComparisonAction->setDefaultWidget(m_ComparisonButton); actionCollection()->addAction(QStringLiteral("Comparison"), m_ComparisonAction); connect(m_ComparisonButton, &QToolButton::clicked, this, &MainQtWidget::SelectComparison); m_ConversionAction = new QWidgetAction(this); m_ConversionAction->setText(i18nc("Conversion Exercise", "Conversion")); m_ConversionAction->setDefaultWidget(m_ConversionButton); actionCollection()->addAction(QStringLiteral("Conversion"), m_ConversionAction); connect(m_ConversionButton, &QToolButton::clicked, this, &MainQtWidget::SelectConversion); m_MixedNumbersAction = new QWidgetAction(this); m_MixedNumbersAction->setText(i18nc("Mixed Numbers Exercise", "MixedNumbers")); m_MixedNumbersAction->setDefaultWidget(m_MixedNumbersButton); actionCollection()->addAction(QStringLiteral("MixedNumbers"), m_MixedNumbersAction); connect(m_MixedNumbersButton, &QToolButton::clicked, this, &MainQtWidget::SelectMixedNumbers); m_FactorizationAction = new QWidgetAction(this); m_MixedNumbersAction->setText(i18nc("Factorization Exercise", "Factorization")); m_FactorizationAction->setDefaultWidget(m_FactorizationButton); actionCollection()->addAction(QStringLiteral("Factorization"), m_FactorizationAction); connect(m_FactorizationButton, &QToolButton::clicked, this, &MainQtWidget::SelectFactorization); m_PercentageAction = new QWidgetAction(this); m_PercentageAction->setText(i18nc("Percentage Exercise", "Percentage")); m_PercentageAction->setDefaultWidget(m_PercentageButton); actionCollection()->addAction(QStringLiteral("Percentage"), m_PercentageAction); connect(m_PercentageButton, &QToolButton::clicked, this, &MainQtWidget::SelectPercentage); // quit action KStandardAction::quit(this, SLOT(close()), actionCollection()); KStandardAction::preferences(this, SLOT(slotPrefs()), actionCollection()); resize(QSize(742, 520).expandedTo(minimumSizeHint())); setupGUI(ToolBar | Keys | Create); setAutoSaveSettings(); } /* ------ private slots ------ */ void MainQtWidget::newTask() { #ifdef DEBUG qDebug() << QStringLiteral("NewTask MainQtWidget"); #endif // check which page should generate a new task switch (selectedTask) { case Arithmetic: m_taskview->forceNewTask(); break; case Comparison: m_exerciseCompare->forceNewTask(); break; case Conversion: m_exerciseConvert->forceNewTask(); break; case MixedNumbers: m_exerciseMixedNumbers->forceNewTask(); break; case Factorization: m_exerciseFactorize->forceNewTask(); break; case Percentage: m_exercisePercentage->forceNewTask(); break; } m_statview->resetStatistics(); return; } void MainQtWidget::NrOfTermsBoxSlot() { #ifdef DEBUG qDebug() << QStringLiteral("MainQtWidget::NrOfTermsBoxSlot()"); #endif int currentMaxDenom = m_MaxMainDenominatorBox->currentText().toInt(); QString curr_nr = m_NrOfTermsBox->currentText(); m_MaxMainDenominatorBox->clear(); if (m_addDiv == true || m_addMult == true) { if (curr_nr == QStringLiteral("2")) { m_MaxMainDenominatorBox->addItem(QStringLiteral("10")); m_MaxMainDenominatorBox->addItem(QStringLiteral("20")); m_MaxMainDenominatorBox->addItem(QStringLiteral("30")); m_MaxMainDenominatorBox->addItem(QStringLiteral("50")); } else if (curr_nr == QStringLiteral("3")) { m_MaxMainDenominatorBox->addItem(QStringLiteral("20")); m_MaxMainDenominatorBox->addItem(QStringLiteral("30")); m_MaxMainDenominatorBox->addItem(QStringLiteral("50")); } else if (curr_nr == QStringLiteral("4")) { m_MaxMainDenominatorBox->addItem(QStringLiteral("20")); m_MaxMainDenominatorBox->addItem(QStringLiteral("30")); m_MaxMainDenominatorBox->addItem(QStringLiteral("50")); } else { m_MaxMainDenominatorBox->addItem(QStringLiteral("50")); } m_nrRatios = curr_nr.toInt(); int index = m_MaxMainDenominatorBox->findText(QString::number(currentMaxDenom)); m_MaxMainDenominatorBox->setCurrentIndex(index > -1 ? index : 0); m_maxMainDenominator = m_MaxMainDenominatorBox->currentText().toInt(); } else { /* no multiplication or division allowed, so we add the default values */ m_MaxMainDenominatorBox->addItem(QStringLiteral("10")); m_MaxMainDenominatorBox->addItem(QStringLiteral("20")); m_MaxMainDenominatorBox->addItem(QStringLiteral("30")); m_MaxMainDenominatorBox->addItem(QStringLiteral("50")); int index = m_MaxMainDenominatorBox->findText(QString::number(currentMaxDenom)); m_MaxMainDenominatorBox->setCurrentIndex(index > -1 ? index : 0); m_nrRatios = curr_nr.toInt(); } // set the new task parameters (void) m_taskview->setTaskParameters(m_addAdd, m_addDiv, m_addMult, m_addSub, m_nrRatios, m_maxMainDenominator); } void MainQtWidget::MaxMainDenominatorBoxSlot() { #ifdef DEBUG qDebug() << QStringLiteral("MainQtWidget::MaxMainDenominatorBoxSlot()"); #endif // get the max. size from the ComboBox, convert it to a number and store // it in the private member QString curr_md = m_MaxMainDenominatorBox->currentText(); m_maxMainDenominator = curr_md.toUInt(); // set the new task parameters (void) m_taskview->setTaskParameters(m_addAdd, m_addDiv, m_addMult, m_addSub, m_nrRatios, m_maxMainDenominator); } void MainQtWidget::AnswerMixedCheckSlot() { #ifdef DEBUG qDebug() << QStringLiteral("MainQtWidget::AnswerMixedCheckSlot()"); #endif m_answerMixed = m_AnswerMixedCheck->isChecked(); m_taskview->setAnswerMixed(m_answerMixed); } void MainQtWidget::QuestionMixedCheckSlot() { #ifdef DEBUG qDebug() << QStringLiteral("MainQtWidget::QuestionMixedCheckSlot()"); #endif m_questionMixed = m_QuestionMixedCheck->isChecked(); if (selectedTask == Arithmetic) m_taskview->setQuestionMixed(m_questionMixed); else if (selectedTask == Comparison) m_exerciseCompare->setQuestionMixed(m_questionMixed); } void MainQtWidget::ReducedFormCheckSlot() { #ifdef DEBUG qDebug() << QStringLiteral("MainQtWidget::ChkReducedFormSlot()"); #endif m_reducedForm = m_ReducedCheck->isChecked(); m_taskview->setReducedForm(m_reducedForm); } void MainQtWidget::AdditionCheckSlot() { #ifdef DEBUG qDebug() << QStringLiteral("MainQtWidget::AdditionCheckSlot()"); #endif if (OperationsCheck() == true) { if (m_AdditionCheck->checkState() == Qt::Checked) m_addAdd = true; else m_addAdd = false; } else { m_addAdd = true; m_AdditionCheck->setCheckState(Qt::Checked); } (void) m_taskview->setTaskParameters(m_addAdd, m_addDiv, m_addMult, m_addSub, m_nrRatios, m_maxMainDenominator); } void MainQtWidget::SubtractionCheckSlot() { #ifdef DEBUG qDebug() << QStringLiteral("MainQtWidget::SubtractionCheckSlot()"); #endif if (OperationsCheck() == true) { if (m_SubtractionCheck->checkState() == Qt::Checked) m_addSub = true; else m_addSub = false; } else { m_addSub = true; m_SubtractionCheck->setCheckState(Qt::Checked); } (void) m_taskview->setTaskParameters(m_addAdd, m_addDiv, m_addMult, m_addSub, m_nrRatios, m_maxMainDenominator); } void MainQtWidget::MultiplicationCheckSlot() { #ifdef DEBUG qDebug() << QStringLiteral("MainQtWidget::MultiplicationCheckSlot()"); #endif if (OperationsCheck() == true) { if (m_MultiplicationCheck->checkState() == Qt::Checked) m_addMult = true; else m_addMult = false; } else { m_addMult = true; m_MultiplicationCheck->setCheckState(Qt::Checked); } (void) m_taskview->setTaskParameters(m_addAdd, m_addDiv, m_addMult, m_addSub, m_nrRatios, m_maxMainDenominator); } void MainQtWidget::DivisionCheckSlot() { #ifdef DEBUG qDebug() << QStringLiteral("MainQtWidget::DivisionCheckSlot()"); #endif if (OperationsCheck() == true) { if (m_DivisionCheck->checkState() == Qt::Checked) m_addDiv = true; else m_addDiv = false; } else { m_addDiv = true; m_DivisionCheck->setCheckState(Qt::Checked); } (void) m_taskview->setTaskParameters(m_addAdd, m_addDiv, m_addMult, m_addSub, m_nrRatios, m_maxMainDenominator); } void MainQtWidget::slotPrefs() { #ifdef DEBUG qDebug() << QStringLiteral("slotPrefs MainQtWidget"); #endif // do not show dialog twice if (KConfigDialog::showDialog(QStringLiteral("settings"))) return; //KConfigDialog didn't find an instance of this dialog, so lets create it : KConfigDialog* configDialog = new KConfigDialog(this, QStringLiteral("settings"), SettingsClass::self()); - TaskColors * taskColors = new TaskColors(0); + TaskColors * taskColors = new TaskColors(nullptr); configDialog->addPage(taskColors, i18n("Colors"), QStringLiteral("preferences-desktop-color")); - TaskFonts * taskFonts = new TaskFonts(0); + TaskFonts * taskFonts = new TaskFonts(nullptr); configDialog->addPage(taskFonts, i18n("Fonts"), QStringLiteral("preferences-desktop-font")); // User edited the configuration - update your local copies of the // configuration data connect(configDialog, &KConfigDialog::settingsChanged, this, &MainQtWidget::slotApplySettings); configDialog->show(); return; } void MainQtWidget::slotApplySettings() { #ifdef DEBUG qDebug() << QStringLiteral("slotApplySettings MainQtWidget"); #endif // update the task view m_taskview->update(); m_exerciseCompare->update(); m_exerciseConvert->update(); m_exerciseFactorize->update(); return; } void MainQtWidget::slotAboutToShowPage() { #ifdef DEBUG qDebug() << QStringLiteral("slotAboutToShowPage MainQtWidget"); #endif // check which page to show switch (selectedTask) { case Arithmetic: m_QuestionMixedCheck->setEnabled(true); m_NrOfTermsBox->setEnabled(true); m_MaxMainDenominatorBox->setEnabled(true); m_AnswerMixedCheck->setEnabled(true); m_ReducedCheck->setEnabled(true); m_SubtractionCheck->setEnabled(true); m_DivisionCheck->setEnabled(true); m_MultiplicationCheck->setEnabled(true); m_AdditionCheck->setEnabled(true); break; case Percentage: case Factorization: case Conversion: case MixedNumbers: m_QuestionMixedCheck->setEnabled(false); m_NrOfTermsBox->setEnabled(false); m_MaxMainDenominatorBox->setEnabled(false); m_AnswerMixedCheck->setEnabled(false); m_ReducedCheck->setEnabled(false); m_SubtractionCheck->setEnabled(false); m_DivisionCheck->setEnabled(false); m_MultiplicationCheck->setEnabled(false); m_AdditionCheck->setEnabled(false); break; case Comparison: m_QuestionMixedCheck->setEnabled(true); m_NrOfTermsBox->setEnabled(false); m_MaxMainDenominatorBox->setEnabled(false); m_AnswerMixedCheck->setEnabled(false); m_ReducedCheck->setEnabled(false); m_SubtractionCheck->setEnabled(false); m_DivisionCheck->setEnabled(false); m_MultiplicationCheck->setEnabled(false); m_AdditionCheck->setEnabled(false); break; } return; } void MainQtWidget::closeEvent(QCloseEvent *event) { writeOptions(); KXmlGuiWindow::closeEvent(event); } void MainQtWidget::SelectPercentage() { #ifdef DEBUG qDebug() << QStringLiteral("SelectPercentage MainQtWidget"); #endif m_TitleLabel->setText(i18n("Percentage")); selectedTask = Percentage; m_taskview->hide(); m_exerciseCompare->hide(); m_exerciseConvert->hide(); m_exerciseMixedNumbers->hide(); m_exerciseFactorize->hide(); m_exercisePercentage->show(); slotAboutToShowPage(); } void MainQtWidget::SelectArithmetic() { #ifdef DEBUG qDebug() << QStringLiteral("SelectArithmetic MainQtWidget"); #endif m_TitleLabel->setText(i18n("Arithmetic")); selectedTask = Arithmetic; m_taskview->show(); m_exerciseCompare->hide(); m_exerciseConvert->hide(); m_exerciseMixedNumbers->hide(); m_exerciseFactorize->hide(); m_exercisePercentage->hide(); slotAboutToShowPage(); } void MainQtWidget::SelectComparison() { #ifdef DEBUG qDebug() << QStringLiteral("SelectComparison MainQtWidget"); #endif m_TitleLabel->setText(i18n("Comparison")); selectedTask = Comparison; m_taskview->hide(); m_exerciseCompare->show(); m_exerciseConvert->hide(); m_exerciseMixedNumbers->hide(); m_exerciseFactorize->hide(); m_exercisePercentage->hide(); slotAboutToShowPage(); } void MainQtWidget::SelectConversion() { #ifdef DEBUG qDebug() << QStringLiteral("SelectConversion MainQtWidget"); #endif m_TitleLabel->setText(i18n("Conversion")); selectedTask = Conversion; m_taskview->hide(); m_exerciseCompare->hide(); m_exerciseConvert->show(); m_exerciseMixedNumbers->hide(); m_exerciseFactorize->hide(); m_exercisePercentage->hide(); slotAboutToShowPage(); } void MainQtWidget::SelectMixedNumbers() { #ifdef DEBUG qDebug() << QStringLiteral("SelectMixedNumbers MainQtWidget"); #endif m_TitleLabel->setText(i18n("Mixed Numbers")); selectedTask = MixedNumbers; m_taskview->hide(); m_exerciseCompare->hide(); m_exerciseConvert->hide(); m_exerciseMixedNumbers->show(); m_exerciseFactorize->hide(); m_exercisePercentage->hide(); slotAboutToShowPage(); } void MainQtWidget::SelectFactorization() { #ifdef DEBUG qDebug() << QStringLiteral("SelectFactorization MainQtWidget"); #endif m_TitleLabel->setText(i18n("Factorization")); selectedTask = Factorization; m_taskview->hide(); m_exerciseCompare->hide(); m_exerciseConvert->hide(); m_exerciseMixedNumbers->hide(); m_exercisePercentage->hide(); m_exerciseFactorize->show(); slotAboutToShowPage(); } bool MainQtWidget::OperationsCheck() { #ifdef DEBUG qDebug() << QStringLiteral("MainQtWidget::OperationsCheck()"); #endif if (m_AdditionCheck->checkState() == Qt::Unchecked && m_SubtractionCheck->checkState() == Qt::Unchecked && m_DivisionCheck->checkState() == Qt::Unchecked && m_MultiplicationCheck->checkState() == Qt::Unchecked) return false; else return true; } void MainQtWidget::goBack() { kbruchApp = new AppMenuWidget(); kbruchApp->show(); close(); } diff --git a/src/PrimeFactorsLineEdit.h b/src/PrimeFactorsLineEdit.h index f31c216..e1aba3f 100644 --- a/src/PrimeFactorsLineEdit.h +++ b/src/PrimeFactorsLineEdit.h @@ -1,74 +1,74 @@ /* KBruch - line edit used for entering prime factors Copyright 2011 - Sebastian Stein This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef PRIMEFACTORSLINEEDIT_H #define PRIMEFACTORSLINEEDIT_H #include #include class QString; /** * line edit used for entering prime factors * based on KRestrictedLine class * * \author Sebastian Stein */ class PrimeFactorsLineEdit : public QLineEdit { Q_OBJECT public: /** constructor */ - explicit PrimeFactorsLineEdit(QWidget* parent = 0); + explicit PrimeFactorsLineEdit(QWidget* parent = nullptr); /** destructor */ ~PrimeFactorsLineEdit(); /** return the factors entered */ QStringList getFactors() const; /** called when the text in QLineEdit's content changes */ void textHasChanged(QString text); Q_SIGNALS: /** emitted when QLineEdit's content changes and it's correct itIs is true if the content is correct otherwise. */ void contentIsRight(bool itIs); private: /** will content the factor the application will used: * 2, 3, 5, 7, 11, 13, 17, 19 */ QStringList m_usedFactors; /** the factors entered in the QLineEdit */ QStringList m_theFactors; /** will check if the QLineEdit's content is right */ bool checkCorrectness(const QString &text); /** will check if every factors' element is actually a factor */ bool areFactors(const QStringList &factors); /** reimplement keyPressEvent inherited from QWidget */ void keyPressEvent(QKeyEvent * event) Q_DECL_OVERRIDE; }; #endif // PRIMEFACTORSLINEEDIT_H diff --git a/src/RatioWidget.h b/src/RatioWidget.h index 2e2cc5f..ae9f34e 100644 --- a/src/RatioWidget.h +++ b/src/RatioWidget.h @@ -1,60 +1,60 @@ /*************************************************************************** RatioWidget.h - paint a ratio ------------------- begin : 2004/06/03 copyright : (C) 2004 by Sebastian Stein email : seb.kde@hpfsc.de copyright : (C) 2008 by Tadeu Araujo, tadeu.araujo@ltia.fc.unesp.br copyright : (C) 2008 by Danilo Balzaque, danilo.balzaque@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef RATIOWIDGET_H #define RATIOWIDGET_H #include "FractionBaseWidget.h" #include "Ratio.h" #include class QPaintEvent; /*! class to paint the ratio * * \author Sebastian Stein */ class RatioWidget : public FractionBaseWidget { public: /** constructor */ - explicit RatioWidget(QWidget * parent = 0, const Ratio para_ratio = Ratio()); + explicit RatioWidget(QWidget * parent = nullptr, const Ratio para_ratio = Ratio()); /** destructor */ ~RatioWidget(); /** set the task to be displayed */ void setRatio(const Ratio para_ratio); void setQuestionMixed(bool value); private: /** the ratio to be displayed */ Ratio m_ratio; /*identify if the fraction will appear in mixed form or not*/ bool m_questionMixed; /** overrideing the paint event of FractionBaseWidget */ void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE; }; #endif diff --git a/src/ResultWidget.h b/src/ResultWidget.h index 840450c..ffe763a 100644 --- a/src/ResultWidget.h +++ b/src/ResultWidget.h @@ -1,88 +1,88 @@ /*************************************************************************** ResultWidget.h - paint the result ------------------- begin : 2004/05/30 copyright : (C) 2004 by Sebastian Stein email : seb.kde@hpfsc.de copyright : (C) 2008 by Tadeu Araujo, tadeu.araujo@ltia.fc.unesp.br copyright : (C) 2008 by Danilo Balzaque, danilo.balzaque@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef RESULTWIDGET_H #define RESULTWIDGET_H #include "FractionBaseWidget.h" #include "Ratio.h" #include class QGridLayout; class QLabel; class QPaintEvent; // a list containing uints typedef QList uintList; /*! class to paint the result * * \author Sebastian Stein */ class ResultWidget : public FractionBaseWidget { public: /** constructors */ ResultWidget(QWidget * parent, const Ratio para_result); ResultWidget(QWidget * parent, const uintList para_factors); - explicit ResultWidget(QWidget * parent = 0); + explicit ResultWidget(QWidget * parent = nullptr); /** destructor */ ~ResultWidget(); /** set the task to be displayed */ void setResult(const Ratio para_result, int k); void setResult(int k); int KindView(); /** set the task to be displayed */ void setFactors(const uintList para_factors); void setAnswerMixed(bool value); private: bool m_answerMixed; /** the prime factors of the number */ uintList m_factors; QFont defaultFont; QLabel * m_primaryText; QLabel * m_secondaryText; QGridLayout * layout; // 1 = Correct, 0 = Incorrect (with solution), 2 = Incorrect (without solution), short m_kindView; short m_ExerciseView; /** the ratio to be displayed */ Ratio m_result; /** overrideing the paint event of FractionBaseWidget */ void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE; void Init(); void showResult() ; }; #endif diff --git a/src/StatisticsBarWidget.h b/src/StatisticsBarWidget.h index 128b746..f251974 100644 --- a/src/StatisticsBarWidget.h +++ b/src/StatisticsBarWidget.h @@ -1,61 +1,61 @@ /*************************************************************************** StatisticsBarWidget.h ------------------- begin : 2008/09/02 copyright : (C) 2008 by Danilo Balzaque email : danilo.balzaque@ltia.fc.unesp.br copyright : (C) 2008 by Tadeu Araujo, tadeu.araujo@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef STATISTICSBARWIDGET_H #define STATISTICSBARWIDGET_H #include class QProgressBar; class QLabel; /*! Constructs a QWidget bla bla bla * \author Danilo Balzaque * */ class StatisticsBarWidget : public QWidget { public: /** constructor */ - explicit StatisticsBarWidget(QWidget * parent = 0); + explicit StatisticsBarWidget(QWidget * parent = nullptr); /** destructor */ ~StatisticsBarWidget(); /** Update statisticsBar */ void updateBar(int correct, int skipped, int total); protected: private: int m_correct; int m_skipped; int m_total; QFont defaultFont; QLabel * m_correctLabel; QLabel * m_skippedLabel; QLabel * m_incorrectLabel; QProgressBar * m_correctBar; QProgressBar * m_skippedBar; QProgressBar * m_incorrectBar; }; #endif diff --git a/src/StatisticsView.h b/src/StatisticsView.h index ab59e2e..fabba3b 100644 --- a/src/StatisticsView.h +++ b/src/StatisticsView.h @@ -1,94 +1,94 @@ /*************************************************************************** StatisticsView.cpp - Header File ------------------- begin : Tue Mar 08 17:20:00 CET 2002 copyright : (C) 2001 - 2004 by Sebastian Stein, Eva Brucherseifer email : seb.kde@hpfsc.de copyright : (C) 2008 by Tadeu Araujo, tadeu.araujo@ltia.fc.unesp.br copyright : (C) 2008 by Danilo Balzaque, danilo.balzaque@ltia.fc.unesp.br copyright : (C) 2008 by Tiago Porangaba, tiago.porangaba@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef STATISTICSVIEW_H #define STATISTICSVIEW_H #include #include class QLabel; class QPushButton; class QVBoxLayout; class QHBoxLayout; class QGridLayout; class StatisticsBarWidget; /*! * StatisticsView takes care of the statistics of a test. * It saves the number of correct and wrong answers and * displays this data to the user. * \author Sebastian Stein * \author Eva Brucherseifer */ class StatisticsView : public QFrame { public: /** constructor */ - explicit StatisticsView(QWidget * parent = 0); + explicit StatisticsView(QWidget * parent = nullptr); /** destructor */ ~StatisticsView(); /** increment number of correct answers */ void addCorrect(); /** increment number of skipped answers */ void addSkipped(); /** increment number of wrong answers */ void addWrong(); /** set statistics to zero. * Triggered by internal button or when a new test is started */ void resetStatistics(); private: /** calculate percentages and update view */ void calc(); unsigned int m_count; unsigned int m_correct; unsigned int m_skipped; QHBoxLayout * buttonLayout; QVBoxLayout * layout1; QGridLayout * labelGrid; QLabel * result1Label; QLabel * result2Label; QLabel * result3Label; QLabel * result4Label; QLabel * info1Label; QLabel * info2Label; QLabel * info3Label; QLabel * info4Label; QFont defaultFont; QPushButton * resetButton; StatisticsBarWidget * statisticsBar; }; #endif diff --git a/src/TaskView.h b/src/TaskView.h index 26d1f86..49d3bae 100644 --- a/src/TaskView.h +++ b/src/TaskView.h @@ -1,138 +1,138 @@ /*************************************************************************** TaskView.cpp - Header File ------------------- begin : Tue Feb 08 13:42:00 CET 2002 copyright : (C) 2001 - 2004 by Sebastian Stein email : seb.kde@hpfsc.de copyright : (C) 2008 by Tadeu Araujo, tadeu.araujo@ltia.fc.unesp.br copyright : (C) 2008 by Danilo Balzaque, danilo.balzaque@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef TASKVIEW_H #define TASKVIEW_H #define _CHECK_TASK 0 #define _NEXT_TASK 1 #include "ExerciseBase.h" #include "ResultWidget.h" #include "Task.h" #include "TaskWidget.h" #include #include class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QLabel; class QPushButton; class QLineEdit; /*! Constructs a QWidget, which shows the task to the user. * The class also provides input fields, so that the user can enter the result. * It also controls the interaction, so that the entered result gets checked * and a new task can be generated. * \author Sebastian Stein * */ class TaskView : public ExerciseBase { Q_OBJECT public: /** constructor */ - explicit TaskView(QWidget * parent = 0, + explicit TaskView(QWidget * parent = nullptr, bool padd_add = true, bool padd_div = false, bool padd_mult = false, bool padd_sub = false, unsigned int pnr_ratios = 2, unsigned int pmax_md = 10); /** destructor */ ~TaskView(); /** set new task parameters, which will be used for the next task to be * generated */ void setTaskParameters(bool padd_add = true, bool padd_div = false, bool padd_mult = false, bool padd_sub = false, unsigned int pnr_ratios = 2, unsigned int pmax_md = 2); /** force the creation of a new task */ void forceNewTask() Q_DECL_OVERRIDE; void setReducedForm(bool value); void setQuestionMixed(bool value); void setAnswerMixed(bool value); Q_SIGNALS: /** class emits this signal, if the task was solved correctly by the user */ void signalTaskSolvedCorrect(); /** class emits this signal, if the task was skipped by the user */ void signalTaskSkipped(); /** class emits this signal, if the task was solved not correctly by the user * */ void signalTaskSolvedWrong(); private: bool m_questionMixed; bool m_answerMixed; bool m_solutionMixed; bool m_reducedForm; bool m_addAdd; bool m_addDiv; bool m_addMult; bool m_addSub; unsigned int nr_ratios; unsigned int curr_nr_ratios; unsigned int max_md; short m_currentState; ResultWidget* m_resultWidget; QPushButton* m_checkButton; QPushButton* m_skipButton; TaskWidget* m_taskWidget; QLineEdit* numer_edit; QFrame* edit_line; QLineEdit* deno_edit; QLineEdit* integer_edit; QGridLayout* checkLayout; QGridLayout* taskLayout; QGridLayout* baseGrid; QWidget * checkWidget; QWidget * taskWidget; Task current_task; Ratio solution; Ratio entered_result; QFont defaultFont; void showResult(); void nextTask(); void slotCheckButtonClicked(); void slotSkipButtonClicked(); void numeratorReturnPressed(); void integerReturnPressed(); void denominatorReturnPressed(); protected: void showEvent(QShowEvent * event) Q_DECL_OVERRIDE; }; #endif diff --git a/src/TaskWidget.h b/src/TaskWidget.h index bd6687d..f04d1c8 100644 --- a/src/TaskWidget.h +++ b/src/TaskWidget.h @@ -1,69 +1,69 @@ /*************************************************************************** TaskWidget.h - paint a task ------------------- begin : 2004/05/30 copyright : (C) 2004 by Sebastian Stein email : seb.kde@hpfsc.de copyright : (C) 2008 by Tadeu Araujo, tadeu.araujo@ltia.fc.unesp.br copyright : (C) 2008 by Danilo Balzaque, danilo.balzaque@ltia.fc.unesp.br ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef TASKWIDGET_H #define TASKWIDGET_H #include "FractionBaseWidget.h" #include "Task.h" #include class QPaintEvent; /** important for add_sub and mul_div */ #define YES 1 #define NO 0 /** important for op_vector */ #define ADD 0 #define SUB 1 #define MUL 2 #define DIV 3 /*! class to paint task with fractions * * \author Sebastian Stein */ class TaskWidget : public FractionBaseWidget { public: /** constructor */ - explicit TaskWidget(QWidget * parent = 0, const Task para_task = Task()); + explicit TaskWidget(QWidget * parent = nullptr, const Task para_task = Task()); /** destructor */ ~TaskWidget(); /** set the task to be displayed */ void setTask(const Task para_task); void setQuestionMixed(bool value); private: /** the task to be displayed */ Task m_task; bool m_questionMixed; /** overrideing the paint event of FractionBaseWidget */ void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE; }; #endif