]> Git trees. - qtvoc.git/commitdiff
add menu and mainwindow version-0.0.4
authorReto Zingg <g.d0b3rm4n@gmail.com>
Sat, 27 Mar 2010 16:13:05 +0000 (18:13 +0200)
committerReto Zingg <g.d0b3rm4n@gmail.com>
Sat, 27 Mar 2010 16:13:05 +0000 (18:13 +0200)
TinyVocTrainer/TinyVocTrainer.pro
TinyVocTrainer/main.cpp
TinyVocTrainer/mainwindow.cpp [new file with mode: 0644]
TinyVocTrainer/mainwindow.h [new file with mode: 0644]
TinyVocTrainer/tinyvoctrainer.cpp

index 3114a0dde48a0141f1f43d28ce538ec63a87689c..52aabe55f99b14c8218ef003a260f6bd0fa83902 100644 (file)
@@ -12,7 +12,9 @@ INCLUDEPATH += . \
 QMAKE_LFLAGS += -Wl,-rpath,../lib
 SOURCES += main.cpp \
     tinyvoctrainer.cpp \
-    tinyvoctrainersettings.cpp
+    tinyvoctrainersettings.cpp \
+    mainwindow.cpp
 HEADERS += tinyvoctrainer.h \
-    tinyvoctrainersettings.h
+    tinyvoctrainersettings.h \
+    mainwindow.h
 FORMS += 
index 703a4c42d8e5c0c78cd56c17a34a0b55eef15755..a6b982f044639770aecf8bd59e9157900cb39bd8 100644 (file)
@@ -1,10 +1,13 @@
 #include <QtGui/QApplication>
-#include "tinyvoctrainer.h"
+#include "mainwindow.h"
 
 int main(int argc, char *argv[])
 {
     QApplication a(argc, argv);
-    TinyVocTrainer w;
-    w.show();
+//    TinyVocTrainer w;
+//    w.show();
+
+    MainWindow *mainWin = new MainWindow;
+    mainWin->show();
     return a.exec();
 }
diff --git a/TinyVocTrainer/mainwindow.cpp b/TinyVocTrainer/mainwindow.cpp
new file mode 100644 (file)
index 0000000..a4fe458
--- /dev/null
@@ -0,0 +1,25 @@
+#include <QtGui>
+
+#include "mainwindow.h"
+#include "tinyvoctrainer.h"
+#include "tinyvoctrainersettings.h"
+
+MainWindow::MainWindow()
+{
+    trainer = new TinyVocTrainer;
+
+    createActions();
+    createMenus();
+
+    setCentralWidget(trainer);
+}
+
+void MainWindow::createActions(){
+    settingAction = new QAction("Settings", this);
+    connect(settingAction,SIGNAL(triggered()), trainer, SLOT(slotSettings()));
+}
+
+void MainWindow::createMenus(){
+    mainMenu = menuBar()->addMenu("Main");
+    mainMenu->addAction(settingAction);
+}
diff --git a/TinyVocTrainer/mainwindow.h b/TinyVocTrainer/mainwindow.h
new file mode 100644 (file)
index 0000000..141f51b
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+class QAction;
+class TinyVocTrainer;
+class TinyVocTrainerSettings;
+
+class MainWindow : public QMainWindow
+{
+public:
+    MainWindow();
+private:
+    QAction *settingAction;
+    QMenu *mainMenu;
+    void createActions();
+    void createMenus();
+
+    TinyVocTrainer *trainer;
+};
+
+#endif // MAINWINDOW_H
index 145b3921fed4f0cc2e3a01d78ea26dff4a692f0e..f2137512f42a85942ff88c74772b6ddf2681a055 100644 (file)
@@ -21,11 +21,11 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent)
 //    QHBoxLayout *hbox_question_lang = new QHBoxLayout();
 //    QHBoxLayout *hbox_answer_lang = new QHBoxLayout();
     QVBoxLayout *vbox_label = new QVBoxLayout();
-    QHBoxLayout *hbox_buttons = new QHBoxLayout();
+//    QHBoxLayout *hbox_buttons = new QHBoxLayout();
 
-    QPushButton *button = new QPushButton("Settings");
-    hbox_buttons->addWidget(button);
-    connect(button, SIGNAL(clicked(bool)), this, SLOT(slotSettings(bool)));
+//    QPushButton *button = new QPushButton("Settings");
+//    hbox_buttons->addWidget(button);
+//    connect(button, SIGNAL(clicked(bool)), this, SLOT(slotSettings(bool)));
 
 //
 //    QComboBox *combox_lesson = new QComboBox();
@@ -68,7 +68,7 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent)
     connect(answer4,SIGNAL(clicked(bool)),this,SLOT(slotAnswer4(bool)));
 
     questionID = 0;
-    answerID = 0;
+    answerID = 1;
     lessonID = 0;
     CorrectID = 0;
 
@@ -122,7 +122,7 @@ TinyVocTrainer::TinyVocTrainer(QWidget *parent)
     // vbox->addLayout(hbox_less);
     // vbox->addLayout(hbox_question_lang);
     // vbox->addLayout(hbox_answer_lang);
-    vbox->addLayout(hbox_buttons);
+//    vbox->addLayout(hbox_buttons);
     vbox->addLayout(vbox_label);
     setLayout(vbox);
 
@@ -210,14 +210,14 @@ void TinyVocTrainer::slotInit(bool clicked){
 
     choiceList.clear();
     for (int i=0; i < 4; ++i){
-        choiceList.append( getAnyEntryFromLesson(lessonsList.at(lessonID), questionID) );
-        answerButtonsList.at(i)->setText( choiceList.at(i)->translation(questionID)->text() );
+        choiceList.append( getAnyEntryFromLesson(lessonsList.at(lessonID), answerID) );
+        answerButtonsList.at(i)->setText( choiceList.at(i)->translation(answerID)->text() );
     }
 
     int random_int = rand() %  3  + 0;
     qDebug() << "ask for random_int: " <<  random_int;
 
-    QuestionLabel->setText(choiceList.at(random_int)->translation(answerID)->text());
+    QuestionLabel->setText(choiceList.at(random_int)->translation(questionID)->text());
     CorrectID = random_int;
 
 }