From: Reto Zingg Date: Sat, 27 Mar 2010 14:46:43 +0000 (+0200) Subject: change to settings window X-Git-Tag: version-0.0.3^0 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=8746a3954da295bfb123a243dab8743065ca0bf3;p=qtvoc.git change to settings window --- diff --git a/TinyVocTrainer/TinyVocTrainer.pro b/TinyVocTrainer/TinyVocTrainer.pro index 407a95e..3114a0d 100644 --- a/TinyVocTrainer/TinyVocTrainer.pro +++ b/TinyVocTrainer/TinyVocTrainer.pro @@ -11,8 +11,8 @@ INCLUDEPATH += . \ ../lib QMAKE_LFLAGS += -Wl,-rpath,../lib SOURCES += main.cpp \ - tinyvoctrainer.cpp -# tinyvoctrainersettings.cpp -HEADERS += tinyvoctrainer.h -# tinyvoctrainersettings.h + tinyvoctrainer.cpp \ + tinyvoctrainersettings.cpp +HEADERS += tinyvoctrainer.h \ + tinyvoctrainersettings.h FORMS += diff --git a/TinyVocTrainer/tinyvoctrainer.cpp b/TinyVocTrainer/tinyvoctrainer.cpp index b9fcc29..09433b9 100644 --- a/TinyVocTrainer/tinyvoctrainer.cpp +++ b/TinyVocTrainer/tinyvoctrainer.cpp @@ -23,9 +23,9 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent) QVBoxLayout *vbox_label = new QVBoxLayout(); QHBoxLayout *hbox_buttons = new QHBoxLayout(); - QPushButton *button = new QPushButton("Apply"); + QPushButton *button = new QPushButton("Settings"); hbox_buttons->addWidget(button); - connect(button, SIGNAL(clicked(bool)), this, SLOT(slotInit(bool))); + connect(button, SIGNAL(clicked(bool)), this, SLOT(slotSettings(bool))); QComboBox *combox_lesson = new QComboBox(); @@ -109,14 +109,20 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent) combox_lesson->setCurrentIndex(0); hbox_less->addWidget(combox_lesson); - vbox->addLayout(hbox_less); - vbox->addLayout(hbox_question_lang); - vbox->addLayout(hbox_answer_lang); + // vbox->addLayout(hbox_less); + // vbox->addLayout(hbox_question_lang); + // vbox->addLayout(hbox_answer_lang); vbox->addLayout(hbox_buttons); vbox->addLayout(vbox_label); setLayout(vbox); - slotInit(); + dialog = new TinyVocTrainerSettings(); + + connect(dialog,SIGNAL(SignalToggleAnswer(int)),this,SLOT(reactToToggleAnswer(int))); + connect(dialog,SIGNAL(SignalToggleLesson(int)),this,SLOT(reactToToggleLesson(int))); + connect(dialog,SIGNAL(SignalToggleQuestion(int)),this,SLOT(reactToToggleQuestion(int))); + + slotSettings(); } TinyVocTrainer::~TinyVocTrainer() @@ -200,3 +206,10 @@ void TinyVocTrainer::slotInit(bool clicked){ CorrectID = random_int; } + +void TinyVocTrainer::slotSettings(bool clicked){ + Q_UNUSED(clicked); + + dialog->exec(); + slotInit(); +} diff --git a/TinyVocTrainer/tinyvoctrainer.h b/TinyVocTrainer/tinyvoctrainer.h index b583519..e6c25c4 100644 --- a/TinyVocTrainer/tinyvoctrainer.h +++ b/TinyVocTrainer/tinyvoctrainer.h @@ -12,6 +12,8 @@ #include "keduvocexpression.h" #include "keduvocleitnerbox.h" +#include "tinyvoctrainersettings.h" + class TinyVocTrainer : public QWidget { Q_OBJECT @@ -41,6 +43,8 @@ public: int lessonID; int CorrectID; + TinyVocTrainerSettings *dialog; + private slots: void reactToToggleQuestion(int id = 0); void reactToToggleAnswer(int id = 0); @@ -50,6 +54,7 @@ private slots: void slotAnswer2(bool clicked = 0); void slotAnswer3(bool clicked = 0); void slotInit(bool clicked = 0); + void slotSettings(bool clicked = 0); }; diff --git a/TinyVocTrainer/tinyvoctrainersettings.cpp b/TinyVocTrainer/tinyvoctrainersettings.cpp new file mode 100644 index 0000000..226344b --- /dev/null +++ b/TinyVocTrainer/tinyvoctrainersettings.cpp @@ -0,0 +1,105 @@ +#include "tinyvoctrainersettings.h" + +#include +#include + +TinyVocTrainerSettings::TinyVocTrainerSettings(QWidget *parent) + : QDialog(parent) +{ + QVBoxLayout *vbox = new QVBoxLayout(); + + QHBoxLayout *hbox_less = new QHBoxLayout(); + QHBoxLayout *hbox_question_lang = new QHBoxLayout(); + QHBoxLayout *hbox_answer_lang = new QHBoxLayout(); + + QComboBox *combox_lesson = new QComboBox(); + QComboBox *combox_question = new QComboBox(); + QComboBox *combox_answer = new QComboBox(); + + QLabel *label_question = new QLabel("Question:"); + hbox_question_lang->addWidget(label_question); + + QLabel *label_answer = new QLabel("Answer:"); + hbox_answer_lang->addWidget(label_answer); + + QLabel *label_lesson = new QLabel("Lesson:"); + hbox_less->addWidget(label_lesson); + + QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, this); + + connect(buttons, SIGNAL(accepted()),this,SLOT(accept())); + connect(buttons,SIGNAL(rejected()),this,SLOT(reject())); + + QStringList args = QApplication::arguments(); + args.removeFirst(); + + KEduVocDocument *docRead = new KEduVocDocument(); + docRead->open(args.at(0)); + + lessons = docRead->lesson()->childContainers(); + + for (int i = 0; i < docRead->identifierCount(); ++i) + { + combox_question->insertItem(i, docRead->identifier(i).name(), NULL); + combox_answer->insertItem(i, docRead->identifier(i).name(), NULL); + } + + connect(combox_question,SIGNAL(currentIndexChanged(int)),this,SLOT(reactToToggleQuestion(int))); + connect(combox_answer,SIGNAL(currentIndexChanged(int)),this,SLOT(reactToToggleAnswer(int))); + combox_question->setCurrentIndex(0); + combox_answer->setCurrentIndex(1); + hbox_question_lang->addWidget(combox_question); + hbox_answer_lang->addWidget(combox_answer); + + int lessonId = 0; + foreach(KEduVocContainer * c, lessons) { + if (c->containerType() == KEduVocLesson::Lesson) { + lessonsList.append( static_cast(c) ); + KEduVocLesson *m_lesson; + m_lesson = lessonsList.last() ; + qDebug () << "Lesson: " << m_lesson->name(); + + combox_lesson->insertItem(lessonId, m_lesson->name(), NULL); + } + ++lessonId; + } + + connect(combox_lesson,SIGNAL(currentIndexChanged(int)),this,SLOT(reactToToggleLesson(int))); + combox_lesson->setCurrentIndex(0); + hbox_less->addWidget(combox_lesson); + + vbox->addLayout(hbox_less); + vbox->addLayout(hbox_question_lang); + vbox->addLayout(hbox_answer_lang); + vbox->addWidget(buttons); + setLayout(vbox); + +} + +//void TinyVocTrainerSettings::accept(){ +// return; +//} +// +//void TinyVocTrainerSettings::reject(){ +// return; +//} + +void TinyVocTrainerSettings::reactToToggleQuestion(int id) +{ + qDebug() << "TinyVocTrainerSettings Toggle Question: " << id; + emit SignalToggleQuestion(id); +} + + +void TinyVocTrainerSettings::reactToToggleAnswer(int id) +{ + qDebug() << "TinyVocTrainerSettings Toggle Answer: " << id; + emit SignalToggleAnswer(id); +} + + +void TinyVocTrainerSettings::reactToToggleLesson(int id) +{ + qDebug() << "TinyVocTrainerSettings Toggle Lesson: " << id; + emit SignalToggleLesson(id); +} diff --git a/TinyVocTrainer/tinyvoctrainersettings.h b/TinyVocTrainer/tinyvoctrainersettings.h new file mode 100644 index 0000000..b32e28a --- /dev/null +++ b/TinyVocTrainer/tinyvoctrainersettings.h @@ -0,0 +1,41 @@ +#ifndef TINYVOCTRAINERSETTINGS_H +#define TINYVOCTRAINERSETTINGS_H + +#include +#include +#include +#include +#include +#include +#include + +#include "keduvoclesson.h" +#include "keduvocexpression.h" +#include "keduvocdocument.h" + + +class TinyVocTrainerSettings : public QDialog +{ + +Q_OBJECT + +public: + explicit TinyVocTrainerSettings(QWidget *parent = 0); + + QList lessons; + QList lessonsList; + +private slots: +// void accept(); +// void reject(); + void reactToToggleQuestion(int id = 0); + void reactToToggleAnswer(int id = 0); + void reactToToggleLesson(int id = 0); + +signals: + void SignalToggleQuestion(int id); + void SignalToggleAnswer(int id); + void SignalToggleLesson(int id); +}; + +#endif // TINYVOCTRAINERSETTINGS_H