QT_BEGIN_NAMESPACE PhraseBookBox::PhraseBookBox(PhraseBook *phraseBook, QWidget *parent) : QDialog(parent), m_phraseBook(phraseBook), m_translationSettingsDialog(0) { // This definition needs to be within class context for lupdate to find it #define NewPhrase tr("(New Entry)") setupUi(this); setWindowTitle(tr("%1[*] - Qt Linguist").arg(m_phraseBook->friendlyPhraseBookName())); setWindowModified(m_phraseBook->isModified()); phrMdl = new PhraseModel(this); m_sortedPhraseModel = new QSortFilterProxyModel(this); m_sortedPhraseModel->setSortCaseSensitivity(Qt::CaseInsensitive); m_sortedPhraseModel->setSortLocaleAware(true); m_sortedPhraseModel->setDynamicSortFilter(true); m_sortedPhraseModel->setSourceModel(phrMdl); phraseList->setModel(m_sortedPhraseModel); phraseList->header()->setDefaultSectionSize(150); phraseList->header()->setSectionResizeMode(QHeaderView::Interactive); connect(sourceLed, SIGNAL(textChanged(QString)), this, SLOT(sourceChanged(QString))); connect(targetLed, SIGNAL(textChanged(QString)), this, SLOT(targetChanged(QString))); connect(definitionLed, SIGNAL(textChanged(QString)), this, SLOT(definitionChanged(QString))); connect(phraseList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(selectionChanged())); connect(newBut, SIGNAL(clicked()), this, SLOT(newPhrase())); connect(removeBut, SIGNAL(clicked()), this, SLOT(removePhrase())); connect(settingsBut, SIGNAL(clicked()), this, SLOT(settings())); connect(saveBut, SIGNAL(clicked()), this, SLOT(save())); connect(m_phraseBook, SIGNAL(modifiedChanged(bool)), this, SLOT(setWindowModified(bool))); sourceLed->installEventFilter(this); targetLed->installEventFilter(this); definitionLed->installEventFilter(this); foreach (Phrase *p, phraseBook->phrases()) phrMdl->addPhrase(p); phraseList->sortByColumn(0, Qt::AscendingOrder); enableDisable(); }
void InterlinearLineLabel::contextMenuEvent ( QContextMenuEvent * event ) { QMenu menu(this); menu.addAction(tr("Approve all"), this, SLOT(approveAll()) ); menu.addAction(tr("Edit baseline text"), this, SLOT(editBaselineText()) ); menu.addAction(tr("Copy baseline text"), this, SLOT(copyBaselineTextToClipboard())); // this seems like the most intuitive thing to me, from a user interface standpoint QAction *playSound = menu.addAction(tr("Play sound"), this, SLOT(playSound()) ); playSound->setEnabled( mPhrase->interval()->isValid() ); menu.addAction(tr("New paragraph here"), this, SLOT(newParagraphAt()) ); menu.addAction(tr("Merge with previous line"), this, SLOT(mergePhraseWithPrevious()) ); menu.addAction(tr("Delete this line"), this, SLOT(removePhrase()) ); menu.exec(event->globalPos()); }
PhraseBookBox::PhraseBookBox( const QString& filename, const PhraseBook& phraseBook, QWidget *parent, const char *name, bool modal ) : QDialog( parent, name, modal ), fn( filename ), pb( phraseBook ) { QGridLayout *gl = new QGridLayout( this, 4, 3, 11, 11, "phrase book outer layout" ); QVBoxLayout *bl = new QVBoxLayout( 6, "phrase book button layout" ); sourceLed = new QLineEdit( this, "source line edit" ); QLabel *source = new QLabel( sourceLed, tr("S&ource phrase:"), this, "source label" ); targetLed = new QLineEdit( this, "target line edit" ); QLabel *target = new QLabel( targetLed, tr("&Translation:"), this, "target label" ); definitionLed = new QLineEdit( this, "definition line edit" ); QLabel *definition = new QLabel( definitionLed, tr("&Definition:"), this, "target label" ); lv = new PhraseLV( this, "phrase book list view" ); newBut = new QPushButton( tr("&New Phrase"), this ); newBut->setDefault( TRUE ); removeBut = new QPushButton( tr("&Remove Phrase"), this ); removeBut->setEnabled( FALSE ); QPushButton *saveBut = new QPushButton( tr("&Save"), this ); QPushButton *closeBut = new QPushButton( tr("Close"), this ); gl->addWidget( source, 0, 0 ); gl->addWidget( sourceLed, 0, 1 ); gl->addWidget( target, 1, 0 ); gl->addWidget( targetLed, 1, 1 ); gl->addWidget( definition, 2, 0 ); gl->addWidget( definitionLed, 2, 1 ); gl->addMultiCellWidget( lv, 3, 3, 0, 1 ); gl->addMultiCell( bl, 0, 3, 2, 2 ); bl->addWidget( newBut ); bl->addWidget( removeBut ); bl->addWidget( saveBut ); bl->addWidget( closeBut ); bl->addStretch( 1 ); connect( sourceLed, SIGNAL(textChanged(const QString&)), this, SLOT(sourceChanged(const QString&)) ); connect( targetLed, SIGNAL(textChanged(const QString&)), this, SLOT(targetChanged(const QString&)) ); connect( definitionLed, SIGNAL(textChanged(const QString&)), this, SLOT(definitionChanged(const QString&)) ); connect( lv, SIGNAL(selectionChanged(QListViewItem *)), this, SLOT(selectionChanged(QListViewItem *)) ); connect( newBut, SIGNAL(clicked()), this, SLOT(newPhrase()) ); connect( removeBut, SIGNAL(clicked()), this, SLOT(removePhrase()) ); connect( saveBut, SIGNAL(clicked()), this, SLOT(save()) ); connect( closeBut, SIGNAL(clicked()), this, SLOT(accept()) ); PhraseBook::ConstIterator it; for ( it = phraseBook.begin(); it != phraseBook.end(); ++it ) (void) new PhraseLVI( lv, (*it) ); enableDisable(); QWhatsThis::add( this, tr("This window allows you to add, modify, or delete" " phrases in a phrase book.") ); QWhatsThis::add( sourceLed, tr("This is the phrase in the source" " language.") ); QWhatsThis::add( targetLed, tr("This is the phrase in the target language" " corresponding to the source phrase.") ); QWhatsThis::add( definitionLed, tr("This is a definition for the source" " phrase.") ); QWhatsThis::add( newBut, tr("Click here to add the phrase to the phrase" " book.") ); QWhatsThis::add( removeBut, tr("Click here to remove the phrase from the" " phrase book.") ); QWhatsThis::add( saveBut, tr("Click here to save the changes made.") ); QWhatsThis::add( closeBut, tr("Click here to close this window.") ); }