Пример #1
0
void QuizFrame::editCurrentTerm() {
    if( controller->isQuizInProgress() ) {
        Folder* vocabTree = controller->getVocabTree();
        Term* term = controller->getCurrentTerm();
        if( !term ) {
            QMessageBox::warning( this, QObject::tr( "Information" ), tr( "DissociatedWord" ) );
            return;
        }

        Vocabulary* vocab = vocabTree->getVocabulary( term->getVocabId() );
        if( vocab == NULL || !vocab->isTermExists( term->getId() ) ) {
            QMessageBox::warning( this, QObject::tr( "Information" ), tr( "DissociatedWord" ) );
            return;
        }

        TermDialog dialog( *vocab, controller, this, *term );
        int result = dialog.exec();
        if( result ) { 
            QString firstLang( controller->getQuizFirstLanguage() );
            QString testLang( controller->getQuizTestLanguage() );
            Term newTerm = dialog.getTerm();
            Translation firstLangTrans = newTerm.getTranslation( firstLang );
            Translation testLangTrans = newTerm.getTranslation( testLang );
            term->addTranslation( firstLangTrans );
            term->addTranslation( testLangTrans );
            BilingualKey commentKey( firstLang, testLang );
            term->addComment( commentKey, newTerm.getComment( commentKey ) );
            term->setImagePath( newTerm.getImagePath() );
            vocab->setModificationDate( QDateTime::currentDateTime() );
            vocab->setDirty( true );
            setTerm( newTerm );
        }
    }
}
Пример #2
0
void QuizFrame::updateFonts() {
    QFont largeFont( controller->getPreferences().getLargeFont() );
    QFont mediumFont( controller->getPreferences().getMediumFont() );
    QFont labelsFont( controller->getPreferences().getLabelsFont() );
    QString firstLang( controller->getQuizFirstLanguage() );
    QString testLang( controller->getQuizTestLanguage() );

    firstLangTermLabel->setFont( labelsFont );
    firstLangTermLineEdit->setFont( controller->getPreferences().getMediumFont( firstLang ) );
    firstLangTermButton->setFont( labelsFont );
    firstLangPanel->setFont( labelsFont );

    testLangTermAltLabel->setFont( labelsFont );
    testLangTermAltLineEdit->setFont( controller->getPreferences().getMediumFont( testLang ) );
    testLangTermLabel->setFont( labelsFont );

    testLangTermLineEdit->setFont( controller->getPreferences().getLargeFont( testLang ) );

    testLangPanel->setFont( labelsFont );

    commentLabel->setFont( labelsFont );
    commentMultiLineEdit->setFont( controller->getPreferences().getBestFont( firstLang, testLang ) );

    firstLangTermPanel->updateGeometry();
    firstLangTermPanel->layout()->invalidate();

    firstLangTermStack->updateGeometry();
   
    testLangLabelsPanel->updateGeometry();
    testLangLabelsPanel->layout()->invalidate();

    testLangFieldsPanel->updateGeometry();
    testLangFieldsPanel->layout()->invalidate();

    revealAllDataButton->setFont( labelsFont );
    rightAnswerButton->setFont( labelsFont );
    wrongAnswerButton->setFont( labelsFont );
    editionButton->setFont( labelsFont );

    update();
    updateGeometry();
}
Пример #3
0
int main(int argc, char **argv) {

  genie::Logger::setLogLevel(genie::Logger::L_INFO);
  std::cout << "Hello" << std::endl;
  
  std::ofstream log_out;
  log_out.open("log.txt");
  
  genie::Logger::setGlobalOutputStream(log_out);
  
//   testDrs();
  
//   testScn();
  testLang();
  
  /*
  std::ifstream ifs;
  std::ofstream ofs;
  
  ifs.open("tmp/empires2.dat", std::ios::binary);
  ofs.open("q.dat", std::ios::binary);
 
  genie::Compressor c;
  
  boost::shared_ptr<std::istream> unc = c.startDecompression(&ifs);
  
  boost::iostreams::copy((*unc), ofs);
  
  c.stopDecompression();
  
//   delete unc;
  
  ifs.close();
  ofs.close();
   */
  
  return 0;
}
Пример #4
0
void QuizFrame::init() {
    Preferences& prefs = controller->getPreferences();
    QFont largeFont = prefs.getLargeFont();
    QFont mediumFont = prefs.getMediumFont();
    QFont labelsFont = prefs.getLabelsFont();
    QString firstLang( controller->getQuizFirstLanguage() );
    QString testLang( controller->getQuizTestLanguage() );

    topPanel = new QWidget();
    topPanelLayout = new QHBoxLayout();
    topPanel->setLayout( topPanelLayout );

    topLeftPanel = new QWidget();
    topLeftPanel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); 
    topLeftPanelLayout = new QVBoxLayout();
    topLeftPanelLayout->setContentsMargins( 0, 0, 0, 0 );
    topLeftPanel->setLayout( topLeftPanelLayout );
    topPanelLayout->addWidget( topLeftPanel, 1 );

    firstLangPanel = new QWidget();
    firstLangPanelLayout = new QBoxLayout( QBoxLayout::TopToBottom );
    firstLangPanelLayout->setContentsMargins( 0, 0, 0, 0 );
    firstLangPanel->setLayout( firstLangPanelLayout );
    topLeftPanelLayout->addWidget( firstLangPanel );

    testLangPanel = new QWidget();
    testLangPanelLayout = new QBoxLayout( QBoxLayout::TopToBottom );
    testLangPanelLayout->setContentsMargins( 0, 0, 0, 0 );
    testLangPanel->setLayout( testLangPanelLayout );
    topLeftPanelLayout->addWidget( testLangPanel );

    controlPanel = new QWidget();
    controlPanelLayout = new QVBoxLayout();
    controlPanelLayout->setContentsMargins( 0, 0, 0, 0 );
    controlPanel->setLayout( controlPanelLayout );

    answerControlPanel = new QWidget();
    answerControlPanelLayout = new QVBoxLayout();
    answerControlPanelLayout->setContentsMargins( 0, 0, 0, 0 );
    answerControlPanel->setLayout( answerControlPanelLayout );
    controlPanelLayout->addWidget( answerControlPanel );

    revealAllDataButton = new QPushButton( /*tr( "Reveal" )*/ );
    revealAllDataButton->setIcon( QIcon( ZPIXMAP( eye_xpm ) ) );
    revealAllDataButton->setIconSize( QSize( 32, 32 ) );
    revealAllDataButton->setEnabled( false );
    //revealAllDataButton->setToolTip( tr( "Reveal" ) );
    connect( revealAllDataButton, SIGNAL( clicked() ), this, SLOT( reveal() ) );

    rightAnswerButton = new QPushButton( /*tr( "RightAnswer" )*/ );
    rightAnswerButton->setIcon( QIcon( ZPIXMAP( goodAns_xpm ) ) ); 
    rightAnswerButton->setIconSize( QSize( 32, 32 ) );
    rightAnswerButton->setEnabled( false );
    //rightAnswerButton->setToolTip( tr( "RightAnswer" ) );
    connect( rightAnswerButton, SIGNAL( clicked() ), this, SLOT( rightAnswer() ) );

    wrongAnswerButton = new QPushButton( /*tr( "WrongAnswer" )*/ );
    wrongAnswerButton->setIcon( QIcon( ZPIXMAP( badAns_xpm ) ) );
    wrongAnswerButton->setIconSize( QSize( 32, 32 ) );
    wrongAnswerButton->setEnabled( false );
    //wrongAnswerButton->setToolTip( tr( "WrongAnswer" ) );
    connect( wrongAnswerButton, SIGNAL( clicked() ), this, SLOT( wrongAnswer() ) );

    answerControlPanelLayout->addWidget( revealAllDataButton );
    answerControlPanelLayout->addWidget( rightAnswerButton );
    answerControlPanelLayout->addWidget( wrongAnswerButton );

    editionButton = new QPushButton( /*tr( "EditWord" )*/ );
    editionButton->setIcon( QIcon( ZPIXMAP( editTerm_xpm ) ) ); 
    editionButton->setIconSize( QSize( 32, 32 ) );
    editionButton->setMinimumWidth( 100 );
    editionButton->setEnabled( false );
    //editionButton->setToolTip( tr( "EditWord" ) );
    connect( editionButton, SIGNAL( clicked() ), this, SLOT( editCurrentTerm() ) );

    controlPanelLayout->addWidget( answerControlPanel, 1 );
    controlPanelLayout->addWidget( editionButton, 0 );
    
    firstLangTermPanel = new QWidget();
    firstLangTermPanelLayout = new QHBoxLayout();
    firstLangTermPanel->setLayout( firstLangTermPanelLayout );

    firstLangPanelLabel = new QLabel( QApplication::translate( "QObject", firstLang.toLatin1().data() ) );
    firstLangPanelLayout->addWidget( firstLangPanelLabel );
    firstLangPanelLayout->addWidget( firstLangTermPanel );

    firstLangTermLabel = new QLabel( tr( "Word/Expr." ) );

    firstLangTermStack = new QStackedWidget();
    firstLangTermLineEdit = new ScrollableLineEdit();
    firstLangTermLineEdit->setReadOnly( true );
    firstLangTermButton = new QPushButton( tr( "???" ) );
    //firstLangTermButton->setToolTip( tr( "Reveal" ) );
    connect( firstLangTermButton, SIGNAL( clicked() ), this, SLOT( revealFirstLangTerm() ) );  
    firstLangTermStack->addWidget( firstLangTermLineEdit );
    firstLangTermStack->addWidget( firstLangTermButton );

    firstLangTermPanelLayout->addWidget( firstLangTermLabel, 0 );
    firstLangTermPanelLayout->addWidget( firstLangTermStack, 1 );
    
    testLangPanelLabel = new QLabel( QApplication::translate( "QObject", testLang.toLatin1().data() ) );
    testLangPanelLayout->addWidget( testLangPanelLabel );

    testLangTopPanel = new QWidget();
    testLangPanelLayout->addWidget( testLangTopPanel );
    testLangTopPanelLayout = new QHBoxLayout();
    testLangTopPanel->setLayout( testLangTopPanelLayout );

    testLangLabelsPanel = new QWidget();
    testLangLabelsPanelLayout = new QVBoxLayout();
    testLangLabelsPanelLayout->setContentsMargins( 0, 0, 0, 0 );
    testLangLabelsPanel->setLayout( testLangLabelsPanelLayout );

    testLangTermAltLabel = new QLabel( tr( "Alt./Phon." ) );
    testLangLabelsPanelLayout->addWidget( testLangTermAltLabel );
    testLangTermLabel = new QLabel( tr( "Word/Expr." ) );
    testLangLabelsPanelLayout->addWidget( testLangTermLabel );

    testLangFieldsPanel = new QWidget();
    testLangFieldsPanelLayout = new QVBoxLayout();
    testLangFieldsPanelLayout->setContentsMargins( 0, 0, 0, 0 );
    testLangFieldsPanel->setLayout( testLangFieldsPanelLayout );
    testLangTermAltStack = new QStackedWidget();
    testLangFieldsPanelLayout->addWidget( testLangTermAltStack );
    testLangTermAltLineEdit = new ScrollableLineEdit();
    testLangTermAltLineEdit->setReadOnly( true );
    testLangTermAltButton = new QPushButton( tr( "???" ) );
    //testLangTermAltButton->setToolTip( tr( "Reveal" ) );
    connect( testLangTermAltButton, SIGNAL( clicked() ), this, SLOT( revealAltTerm() ) );  
    testLangTermAltStack->addWidget( testLangTermAltLineEdit );
    testLangTermAltStack->addWidget( testLangTermAltButton );

    testLangTermStack = new QStackedWidget();
    testLangFieldsPanelLayout->addWidget( testLangTermStack );
    testLangTermLineEdit = new ScrollableLineEdit();
    testLangTermLineEdit->setReadOnly( true );
    testLangTermButton = new QPushButton( tr( "???" ) );
    //testLangTermButton->setToolTip( tr( "Reveal" ) );
    connect( testLangTermButton, SIGNAL( clicked() ), this, SLOT( revealTestLangTerm() ) );  

    testLangTermStack->addWidget( testLangTermLineEdit );
    testLangTermStack->addWidget( testLangTermButton );

    testLangTopPanelLayout->addWidget( testLangLabelsPanel );
    testLangTopPanelLayout->addWidget( testLangFieldsPanel, 1 );

    commentBox = new QWidget();
    commentBoxLayout = new QVBoxLayout();
    commentBoxLayout->setContentsMargins( 0, 0, 0, 0 );
    commentBox->setLayout( commentBoxLayout );

    commentLabelPanel = new QWidget();
    commentLabelPanelLayout = new QHBoxLayout();
    commentLabelPanelLayout->setContentsMargins( 0, 0, 0, 0 );
    commentLabelPanel->setLayout( commentLabelPanelLayout );
    commentBoxLayout->addWidget( commentLabelPanel );
    commentLabel = new QLabel( tr( "Examples/Comments" ) );
    maximizeCommentButton = new QPushButton();
    maximizeCommentButton->setIcon( QIcon( ZPIXMAP( maximize_xpm ) ) );
    maximizeCommentButton->setIconSize( QSize( 32, 32 ) );
    maximizeCommentButton->setCheckable( true );
    maximizeCommentButton->setMaximumHeight( commentLabel->sizeHint().height() > 24 ? commentLabel->sizeHint().height() : 24 );
    maximizeCommentButton->setMaximumWidth( maximizeCommentButton->maximumHeight() );
    //maximizeCommentButton->setToolTip( tr( "MaximizeComment" ) );
    connect( maximizeCommentButton, SIGNAL( toggled( bool ) ), this, SLOT( toggleMaximizeComment( bool ) ) );
    commentLabelPanelLayout->addWidget( commentLabel );
    commentLabelPanelLayout->addStretch();
    commentLabelPanelLayout->addWidget( maximizeCommentButton );

    commentStack = new QStackedWidget();
    commentBoxLayout->addWidget( commentStack );

    commentMultiLineEdit = new ScrollableMultiLineEdit();
    commentMultiLineEdit->setReadOnly( true );
    commentButton = new QPushButton( tr( "???" ) );
    //commentButton->setToolTip( tr( "Reveal" ) );
    connect( commentButton, SIGNAL( clicked() ), this, SLOT( revealComment() ) );  
    commentStack->addWidget( commentMultiLineEdit );
    commentStack->addWidget( commentButton );

    imageBox = new QWidget();
    imageBoxLayout = new QBoxLayout( QBoxLayout::TopToBottom );
    imageBox->setLayout( imageBoxLayout );

    imageBoxLabel = new QLabel( tr( "Image" ) ); 
    imageBoxLayout->addWidget( imageBoxLabel );

    imageStack = new QStackedWidget();
    imageBoxLayout->addWidget( imageStack );
    imageButton = new QPushButton( tr( "???" ) );
    //imageButton->setToolTip( tr( "Reveal" ) );
    connect( imageButton, SIGNAL( clicked() ), this, SLOT( revealImage() ) );
    image = new QLabel();
    imageStack->addWidget( image );
    imageStack->addWidget( imageButton );

    topPanelLayout->addWidget( imageBox );

    scrollLeftAction = new QAction( this );
    scrollLeftAction->setShortcut( QKeySequence( QKeySequence::MoveToPreviousChar ) );
    connect( scrollLeftAction, SIGNAL( triggered() ), this, SLOT( scrollLeft() ) );
    addAction( scrollLeftAction );

    scrollRightAction = new QAction( this );
    scrollRightAction->setShortcut( QKeySequence( QKeySequence::MoveToNextChar ) );
    connect( scrollRightAction, SIGNAL( triggered() ), this, SLOT( scrollRight() ) );
    addAction( scrollRightAction );

    scrollUpAction = new QAction( this );
    scrollUpAction->setShortcut( QKeySequence( QKeySequence::MoveToPreviousLine ) );
    connect( scrollUpAction, SIGNAL( triggered() ), this, SLOT( scrollUp() ) );
    addAction( scrollUpAction );

    scrollDownAction = new QAction( this );
    scrollDownAction->setShortcut( QKeySequence( QKeySequence::MoveToNextLine ) );
    connect( scrollDownAction, SIGNAL( triggered() ), this, SLOT( scrollDown() ) );
    addAction( scrollDownAction );

    scrollPageUpAction = new QAction( this );
    scrollPageUpAction->setShortcut( QKeySequence( QKeySequence::MoveToPreviousPage ) );
    connect( scrollPageUpAction, SIGNAL( triggered() ), this, SLOT( scrollPageUp() ) );
    addAction( scrollPageUpAction );

    scrollPageDownAction = new QAction( this );
    scrollPageDownAction->setShortcut( QKeySequence( QKeySequence::MoveToNextPage ) );
    connect( scrollPageDownAction, SIGNAL( triggered() ), this, SLOT( scrollPageDown() ) );
    addAction( scrollPageDownAction );

    mainLayout = new QHBoxLayout( this );

    body = new QWidget();
    bodyLayout = new QVBoxLayout();
    bodyLayout->setContentsMargins( 0, 0, 0, 0 );
    body->setLayout( bodyLayout );
 
    bodyLayout->addWidget( topPanel );
    bodyLayout->addWidget( commentBox, 1 );

    bodyWrapper = new QScrollArea();
    bodyWrapper->setWidget( body );

    mainLayout->addWidget( bodyWrapper, 1 );
    mainLayout->addWidget( controlPanel );
    setLayout( mainLayout );
    mainLayout->activate();

    updateFonts();

    setButtonsHidden( prefs.areQuizButtonsHidden() );
}