]> Git trees. - qtvoc.git/commitdiff
change to settings window version-0.0.3
authorReto Zingg <g.d0b3rm4n@gmail.com>
Sat, 27 Mar 2010 14:46:43 +0000 (16:46 +0200)
committerReto Zingg <g.d0b3rm4n@gmail.com>
Sat, 27 Mar 2010 14:46:43 +0000 (16:46 +0200)
TinyVocTrainer/TinyVocTrainer.pro
TinyVocTrainer/tinyvoctrainer.cpp
TinyVocTrainer/tinyvoctrainer.h
TinyVocTrainer/tinyvoctrainersettings.cpp [new file with mode: 0644]
TinyVocTrainer/tinyvoctrainersettings.h [new file with mode: 0644]

index 407a95ef5e952327ab6390a19bec141ce1a8148c..3114a0dde48a0141f1f43d28ce538ec63a87689c 100644 (file)
@@ -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 += 
index b9fcc29ad62971ed3ba387bec38346979f1f05f5..09433b981e530df6d2e9b95ebc055f3319ae7748 100644 (file)
@@ -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();
+}
index b5835198a330061c5936c1ad3edcfd14647456ef..e6c25c476595537deaaeef00c7586a9cca8ac323 100644 (file)
@@ -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 (file)
index 0000000..226344b
--- /dev/null
@@ -0,0 +1,105 @@
+#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);
+}
diff --git a/TinyVocTrainer/tinyvoctrainersettings.h b/TinyVocTrainer/tinyvoctrainersettings.h
new file mode 100644 (file)
index 0000000..b32e28a
--- /dev/null
@@ -0,0 +1,41 @@
+#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