#include <QtGui>
+#include <QFlags>
#include "mainwindow.h"
#include "tinyvoctrainer.h"
MainWindow::MainWindow()
{
- trainer = new TinyVocTrainer;
+
+
+ curFile = "";
+ // setCurrentFile("");
+
+ QStringList args = QApplication::arguments();
+ args.removeFirst();
+
+ if (args.count() > 0){
+ if ( ! QString(args.at(0)).isEmpty() ){
+ qDebug() << "curFile is gonna be: " << args.at(0);
+ curFile = args.at(0);
+ }
+ else{
+ qDebug() << "something went wrong, lets the user choose for a file... args.at0: " << args.at(0);
+ open();
+ }
+ }
+ else{
+ qDebug() << "not enough arguments";
+ open();
+ }
+
+ trainer = new TinyVocTrainer(this, curFile);
createActions();
createMenus();
mainMenu = menuBar()->addMenu("Main");
mainMenu->addAction(settingAction);
}
+
+void MainWindow::open(){
+ curFile = QFileDialog::getOpenFileName(this, QString("Open kvmtl file"),
+ QString(""),
+ QString("kvtml file (*.kvtml)") );
+ if ( curFile.isEmpty() ){
+ open();
+ }
+}
#include <QPushButton>
#include <QComboBox>
-TinyVocTrainer::TinyVocTrainer(QWidget *parent)
+TinyVocTrainer::TinyVocTrainer(QWidget *parent, const QString &fileName)
: QWidget(parent)
{
srand(time(NULL));
QVBoxLayout *vbox = new QVBoxLayout();
-// QHBoxLayout *hbox_less = new QHBoxLayout();
-// QHBoxLayout *hbox_question_lang = new QHBoxLayout();
-// QHBoxLayout *hbox_answer_lang = new QHBoxLayout();
QVBoxLayout *vbox_label = new QVBoxLayout();
-// QHBoxLayout *hbox_buttons = new QHBoxLayout();
-// QPushButton *button = new QPushButton("Settings");
-// hbox_buttons->addWidget(button);
-// connect(button, SIGNAL(clicked(bool)), this, SLOT(slotSettings(bool)));
-
-//
-// QComboBox *combox_lesson = new QComboBox();
-// QComboBox *combox_question = new QComboBox();
-// QComboBox *combox_answer = new QComboBox();
bgroup_choice = new QButtonGroup();
QuestionLabel = new QLabel();
lessonID = 0;
CorrectID = 0;
-// 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);
-
- QStringList args = QApplication::arguments();
- args.removeFirst();
-
KEduVocDocument *docRead = new KEduVocDocument();
- docRead->open(args.at(0));
+ docRead->open(fileName);
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) {
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->addLayout(hbox_buttons);
vbox->addLayout(vbox_label);
setLayout(vbox);
- dialog = new TinyVocTrainerSettings();
+ dialog = new TinyVocTrainerSettings(this, fileName);
connect(dialog,SIGNAL(SignalToggleAnswer(int)),this,SLOT(reactToToggleAnswer(int)));
connect(dialog,SIGNAL(SignalToggleLesson(int)),this,SLOT(reactToToggleLesson(int)));
#include <QApplication>
#include <QtDebug>
-TinyVocTrainerSettings::TinyVocTrainerSettings(QWidget *parent)
+TinyVocTrainerSettings::TinyVocTrainerSettings(QWidget *parent, const QString &fileName)
: QDialog(parent)
{
QVBoxLayout *vbox = new QVBoxLayout();
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));
+ docRead->open(fileName);
lessons = docRead->lesson()->childContainers();
}
-//void TinyVocTrainerSettings::accept(){
-// return;
-//}
-//
-//void TinyVocTrainerSettings::reject(){
-// return;
-//}
-
void TinyVocTrainerSettings::reactToToggleQuestion(int id)
{
qDebug() << "TinyVocTrainerSettings Toggle Question: " << id;