From d24f813f3f2a05c112e803e4256b53535895fc98 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 14 Jul 2021 11:49:10 +1200 Subject: Initial mirror commit --- src/study/IStudyWindow.h | 107 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 src/study/IStudyWindow.h (limited to 'src/study/IStudyWindow.h') diff --git a/src/study/IStudyWindow.h b/src/study/IStudyWindow.h new file mode 100644 index 0000000..1f0bd0d --- /dev/null +++ b/src/study/IStudyWindow.h @@ -0,0 +1,107 @@ +#ifndef ISTUDYWINDOW_H +#define ISTUDYWINDOW_H + +#include +#include + +#include "../main-view/AppModel.h" + +class IStudyModel; +class Card; +class Dictionary; +class QProgressBar; +class CardSideView; +class DictTableView; +class CardEditDialog; + +class IStudyWindow: public QWidget +{ + Q_OBJECT + +protected: + enum + { + StateAnswerHidden, + StateAnswerVisible, + StateNoCards, + StatesNum + }; + +public: + IStudyWindow(IStudyModel* aModel, QString aStudyName, QWidget* aParent); + virtual ~IStudyWindow(); + + AppModel::StudyType getStudyType() const { return studyType; } + IStudyModel* studyModel() const { return m_model; } + const DictTableView* cardEditView() const; + +protected: + void createUI(); + virtual QVBoxLayout* createLowerPanel() = 0; + virtual void setStateForNextCard(); + virtual void processState() = 0; + virtual void ReadSettings() = 0; + virtual QWidget* getAnswerEdit() { return NULL; } + virtual QWidget* getUserAnswerLabel() { return NULL; } + QString ShortcutToStr( QAbstractButton* aButton ); + bool bigScreen() { return QApplication::desktop()->screenGeometry().height()> 250; } + +private: + QVBoxLayout* createMessageLayout(); + QLabel* createMessageLabel(); + QWidget* createWrapper(QBoxLayout* layout); + QPushButton* createClosePackButton(); + QHBoxLayout* createUpperPanel(); + QToolButton* createEditCardButton(); + QToolButton* createDeleteCardButton(); + QVBoxLayout* createCardView(); + QBoxLayout* createAnswerButtonLayout(); + QPushButton* createAnswerButton(); + QBoxLayout* createAnswerLayout(); + +protected slots: + void OnDictionaryRemoved(); + void showNextCard(); ///< Entry point for showing a new card + void showAnswer(); ///< Entry point for showing the answer + void updateCurCard(); ///< Update the card after pack re-generation + void invalidateCurCard() { curCard = NULL; } + void openCardEditDialog(); + void deleteCard(); + void updateToolBarVisibility(int index); + +protected: + static const int AnsButtonPage; + static const int AnsLabelPage; + static const int CardPage; + static const int MessagePage; + + AppModel::StudyType studyType; + IStudyModel* m_model; + const Card* curCard; + int state; + + QString m_studyName; + QToolButton* editCardBtn; + QToolButton* deleteCardBtn; + + QStackedLayout* centralStackedLt; + QLabel* messageLabel; + + QStackedLayout* answerStackedLt; + QPushButton* answerBtn; + CardSideView* questionLabel; + CardSideView* answerLabel; + +private: + static const int MinWidth = 500; + static const int MaxWidth = 800; + static const int ToolBarButtonSize = 24; + static const int ToolBarIconSize = 16; + static const int BigButtonWidth = 160; + static const int BigButtonHeight = 50; + + QWidget* m_parentWidget; + CardEditDialog* m_cardEditDialog; +}; + +#endif -- cgit