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();
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()
CorrectID = random_int;
}
+
+void TinyVocTrainer::slotSettings(bool clicked){
+ Q_UNUSED(clicked);
+
+ dialog->exec();
+ slotInit();
+}
--- /dev/null
+#include "tinyvoctrainersettings.h"
+
+#include <QApplication>
+#include <QtDebug>
+
+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<KEduVocLesson *>(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);
+}
--- /dev/null
+#ifndef TINYVOCTRAINERSETTINGS_H
+#define TINYVOCTRAINERSETTINGS_H
+
+#include <QObject>
+#include <QDialog>
+#include <QComboBox>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QDialogButtonBox>
+
+#include "keduvoclesson.h"
+#include "keduvocexpression.h"
+#include "keduvocdocument.h"
+
+
+class TinyVocTrainerSettings : public QDialog
+{
+
+Q_OBJECT
+
+public:
+ explicit TinyVocTrainerSettings(QWidget *parent = 0);
+
+ QList<KEduVocContainer *> lessons;
+ QList<KEduVocLesson *> 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