diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-09-15 10:16:42 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-09-15 15:55:57 +0200 |
commit | 19d03aa01fbb513294f51479946406bb03b7486b (patch) | |
tree | 0f63bfa8ef0382c6e22917f0c88a9abf67346dde | |
parent | 166be41502ac77fc355f7c28c3289c95ee45b543 (diff) |
Linguist: Port to typed signal-slot connections
Change-Id: I9967811117eb040c3a3ccf058454aee50ce385a6
Reviewed-by: hjk <hjk@qt.io>
-rw-r--r-- | src/linguist/linguist/batchtranslationdialog.cpp | 9 | ||||
-rw-r--r-- | src/linguist/linguist/finddialog.cpp | 9 | ||||
-rw-r--r-- | src/linguist/linguist/finddialog.h | 4 | ||||
-rw-r--r-- | src/linguist/linguist/mainwindow.cpp | 335 | ||||
-rw-r--r-- | src/linguist/linguist/mainwindow.h | 16 | ||||
-rw-r--r-- | src/linguist/linguist/messageeditor.cpp | 92 | ||||
-rw-r--r-- | src/linguist/linguist/messageeditor.h | 4 | ||||
-rw-r--r-- | src/linguist/linguist/messageeditorwidgets.cpp | 35 | ||||
-rw-r--r-- | src/linguist/linguist/messageeditorwidgets.h | 13 | ||||
-rw-r--r-- | src/linguist/linguist/messagemodel.cpp | 21 | ||||
-rw-r--r-- | src/linguist/linguist/phrasebookbox.cpp | 31 | ||||
-rw-r--r-- | src/linguist/linguist/phraseview.cpp | 16 | ||||
-rw-r--r-- | src/linguist/linguist/phraseview.h | 17 | ||||
-rw-r--r-- | src/linguist/linguist/recentfiles.cpp | 3 | ||||
-rw-r--r-- | src/linguist/linguist/translatedialog.cpp | 15 |
15 files changed, 354 insertions, 266 deletions
diff --git a/src/linguist/linguist/batchtranslationdialog.cpp b/src/linguist/linguist/batchtranslationdialog.cpp index 85961986b..69208db7d 100644 --- a/src/linguist/linguist/batchtranslationdialog.cpp +++ b/src/linguist/linguist/batchtranslationdialog.cpp @@ -50,9 +50,12 @@ BatchTranslationDialog::BatchTranslationDialog(MultiDataModel *dataModel, QWidge : QDialog(w), m_model(this), m_dataModel(dataModel) { m_ui.setupUi(this); - connect(m_ui.runButton, SIGNAL(clicked()), this, SLOT(startTranslation())); - connect(m_ui.moveUpButton, SIGNAL(clicked()), this, SLOT(movePhraseBookUp())); - connect(m_ui.moveDownButton, SIGNAL(clicked()), this, SLOT(movePhraseBookDown())); + connect(m_ui.runButton, &QAbstractButton::clicked, + this, &BatchTranslationDialog::startTranslation); + connect(m_ui.moveUpButton, &QAbstractButton::clicked, + this, &BatchTranslationDialog::movePhraseBookUp); + connect(m_ui.moveDownButton, &QAbstractButton::clicked, + this, &BatchTranslationDialog::movePhraseBookDown); m_ui.phrasebookList->setModel(&m_model); m_ui.phrasebookList->setSelectionBehavior(QAbstractItemView::SelectItems); diff --git a/src/linguist/linguist/finddialog.cpp b/src/linguist/linguist/finddialog.cpp index 9dd801a71..e2ca9f38e 100644 --- a/src/linguist/linguist/finddialog.cpp +++ b/src/linguist/linguist/finddialog.cpp @@ -43,9 +43,12 @@ FindDialog::FindDialog(QWidget *parent) findNxt->setEnabled(false); - connect(findNxt, SIGNAL(clicked()), this, SLOT(emitFindNext())); - connect(useRegExp, SIGNAL(stateChanged(int)), this, SLOT(verify())); - connect(led, SIGNAL(textChanged(QString)), this, SLOT(verify())); + connect(findNxt, &QAbstractButton::clicked, + this, &FindDialog::emitFindNext); + connect(useRegExp, &QCheckBox::stateChanged, + this, &FindDialog::verify); + connect(led, &QLineEdit::textChanged, + this, &FindDialog::verify); led->setFocus(); } diff --git a/src/linguist/linguist/finddialog.h b/src/linguist/linguist/finddialog.h index 039f0b9e7..529b343fd 100644 --- a/src/linguist/linguist/finddialog.h +++ b/src/linguist/linguist/finddialog.h @@ -48,10 +48,12 @@ signals: void findNext(const QString& text, DataModel::FindLocation where, bool matchCase, bool ignoreAccelerators, bool skipObsolete, bool useRegExp); +public slots: + void find(); + private slots: void emitFindNext(); void verify(); - void find(); private: QRegularExpression m_regExp; diff --git a/src/linguist/linguist/mainwindow.cpp b/src/linguist/linguist/mainwindow.cpp index 5c6c3edfa..6a49fae72 100644 --- a/src/linguist/linguist/mainwindow.cpp +++ b/src/linguist/linguist/mainwindow.cpp @@ -266,7 +266,7 @@ private: bool FocusWatcher::eventFilter(QObject *, QEvent *event) { if (event->type() == QEvent::FocusIn) - m_messageEditor->setEditorFocus(-1); + m_messageEditor->setEditorFocusForModel(-1); return false; } @@ -376,8 +376,6 @@ MainWindow::MainWindow() m_sourceAndFormDock->setWindowTitle(tr("Sources and Forms")); m_sourceAndFormView = new QStackedWidget(this); m_sourceAndFormDock->setWidget(m_sourceAndFormView); - //connect(m_sourceAndDock, SIGNAL(visibilityChanged(bool)), - // m_sourceCodeView, SLOT(setActivated(bool))); m_formPreviewView = new FormPreviewView(0, m_dataModel); m_sourceCodeView = new SourceCodeView(0); m_sourceAndFormView->addWidget(m_sourceCodeView); @@ -410,34 +408,36 @@ MainWindow::MainWindow() // Set up shortcuts for the dock widgets QShortcut *contextShortcut = new QShortcut(QKeySequence(Qt::Key_F6), this); - connect(contextShortcut, SIGNAL(activated()), this, SLOT(showContextDock())); + connect(contextShortcut, &QShortcut::activated, + this, &MainWindow::showContextDock); QShortcut *messagesShortcut = new QShortcut(QKeySequence(Qt::Key_F7), this); - connect(messagesShortcut, SIGNAL(activated()), this, SLOT(showMessagesDock())); + connect(messagesShortcut, &QShortcut::activated, + this, &MainWindow::showMessagesDock); QShortcut *errorsShortcut = new QShortcut(QKeySequence(Qt::Key_F8), this); - connect(errorsShortcut, SIGNAL(activated()), this, SLOT(showErrorDock())); + connect(errorsShortcut, &QShortcut::activated, + this, &MainWindow::showErrorDock); QShortcut *sourceCodeShortcut = new QShortcut(QKeySequence(Qt::Key_F9), this); - connect(sourceCodeShortcut, SIGNAL(activated()), this, SLOT(showSourceCodeDock())); + connect(sourceCodeShortcut, &QShortcut::activated, + this, &MainWindow::showSourceCodeDock); QShortcut *phrasesShortcut = new QShortcut(QKeySequence(Qt::Key_F10), this); - connect(phrasesShortcut, SIGNAL(activated()), this, SLOT(showPhrasesDock())); - - connect(m_phraseView, SIGNAL(phraseSelected(int,QString)), - m_messageEditor, SLOT(setTranslation(int,QString))); - connect(m_phraseView, SIGNAL(setCurrentMessageFromGuess(int,Candidate)), - this, SLOT(setCurrentMessage(int,Candidate))); - connect(m_contextView->selectionModel(), - SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), - this, SLOT(selectedContextChanged(QModelIndex,QModelIndex))); - connect(m_messageView->selectionModel(), - SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), - this, SLOT(selectedMessageChanged(QModelIndex,QModelIndex))); - connect(m_contextView->selectionModel(), - SIGNAL(currentColumnChanged(QModelIndex,QModelIndex)), - SLOT(updateLatestModel(QModelIndex))); - connect(m_messageView->selectionModel(), - SIGNAL(currentColumnChanged(QModelIndex,QModelIndex)), - SLOT(updateLatestModel(QModelIndex))); - - connect(m_messageEditor, SIGNAL(activeModelChanged(int)), SLOT(updateActiveModel(int))); + connect(phrasesShortcut, &QShortcut::activated, + this, &MainWindow::showPhrasesDock); + + connect(m_phraseView, &PhraseView::phraseSelected, + m_messageEditor, &MessageEditor::setTranslation); + connect(m_phraseView, &PhraseView::setCurrentMessageFromGuess, + this, &MainWindow::setCurrentMessageFromGuess); + connect(m_contextView->selectionModel(), &QItemSelectionModel::currentRowChanged, + this, &MainWindow::selectedContextChanged); + connect(m_messageView->selectionModel(), &QItemSelectionModel::currentRowChanged, + this, &MainWindow::selectedMessageChanged); + connect(m_contextView->selectionModel(), &QItemSelectionModel::currentColumnChanged, + this, &MainWindow::updateLatestModel); + connect(m_messageView->selectionModel(), &QItemSelectionModel::currentColumnChanged, + this, &MainWindow::updateLatestModel); + + connect(m_messageEditor, &MessageEditor::activeModelChanged, + this, &MainWindow::updateActiveModel); m_translateDialog = new TranslateDialog(this); m_batchTranslateDialog = new BatchTranslationDialog(m_dataModel, this); @@ -455,36 +455,38 @@ MainWindow::MainWindow() initViewHeaders(); resetSorting(); - connect(m_dataModel, SIGNAL(modifiedChanged(bool)), - this, SLOT(setWindowModified(bool))); - connect(m_dataModel, SIGNAL(modifiedChanged(bool)), - m_modifiedLabel, SLOT(setVisible(bool))); - connect(m_dataModel, SIGNAL(multiContextDataChanged(MultiDataIndex)), - SLOT(updateProgress())); - connect(m_dataModel, SIGNAL(messageDataChanged(MultiDataIndex)), - SLOT(maybeUpdateStatistics(MultiDataIndex))); - connect(m_dataModel, SIGNAL(translationChanged(MultiDataIndex)), - SLOT(translationChanged(MultiDataIndex))); - connect(m_dataModel, SIGNAL(languageChanged(int)), - SLOT(updatePhraseDict(int))); + connect(m_dataModel, &MultiDataModel::modifiedChanged, + this, &QWidget::setWindowModified); + connect(m_dataModel, &MultiDataModel::modifiedChanged, + m_modifiedLabel, &QWidget::setVisible); + connect(m_dataModel, &MultiDataModel::multiContextDataChanged, + this, &MainWindow::updateProgress); + connect(m_dataModel, &MultiDataModel::messageDataChanged, + this, &MainWindow::maybeUpdateStatistics); + connect(m_dataModel, &MultiDataModel::translationChanged, + this, &MainWindow::translationChanged); + connect(m_dataModel, &MultiDataModel::languageChanged, + this, &MainWindow::updatePhraseDict); setWindowModified(m_dataModel->isModified()); m_modifiedLabel->setVisible(m_dataModel->isModified()); - connect(m_messageView, SIGNAL(clicked(QModelIndex)), - this, SLOT(toggleFinished(QModelIndex))); - connect(m_messageView, SIGNAL(activated(QModelIndex)), - m_messageEditor, SLOT(setEditorFocus())); - connect(m_contextView, SIGNAL(activated(QModelIndex)), - m_messageView, SLOT(setFocus())); - connect(m_messageEditor, SIGNAL(translationChanged(QStringList)), - this, SLOT(updateTranslation(QStringList))); - connect(m_messageEditor, SIGNAL(translatorCommentChanged(QString)), - this, SLOT(updateTranslatorComment(QString))); - connect(m_findDialog, SIGNAL(findNext(QString,DataModel::FindLocation,bool,bool,bool,bool)), - this, SLOT(findNext(QString,DataModel::FindLocation,bool,bool,bool,bool))); - connect(m_translateDialog, SIGNAL(requestMatchUpdate(bool&)), SLOT(updateTranslateHit(bool&))); - connect(m_translateDialog, SIGNAL(activated(int)), SLOT(translate(int))); + connect(m_messageView, &QAbstractItemView::clicked, + this, &MainWindow::toggleFinished); + connect(m_messageView, &QAbstractItemView::activated, + m_messageEditor, &MessageEditor::setEditorFocus); + connect(m_contextView, &QAbstractItemView::activated, + m_messageView, qOverload<>(&QWidget::setFocus)); + connect(m_messageEditor, &MessageEditor::translationChanged, + this, &MainWindow::updateTranslation); + connect(m_messageEditor, &MessageEditor::translatorCommentChanged, + this, &MainWindow::updateTranslatorComment); + connect(m_findDialog, &FindDialog::findNext, + this, &MainWindow::findNext); + connect(m_translateDialog, &TranslateDialog::requestMatchUpdate, + this, &MainWindow::updateTranslateHit); + connect(m_translateDialog, &TranslateDialog::activated, + this, &MainWindow::translate); QSize as(screen()->size()); as -= QSize(30, 30); @@ -493,8 +495,8 @@ MainWindow::MainWindow() readConfig(); m_statistics = 0; - connect(m_ui.actionLengthVariants, SIGNAL(toggled(bool)), - m_messageEditor, SLOT(setLengthVariants(bool))); + connect(m_ui.actionLengthVariants, &QAction::toggled, + m_messageEditor, &MessageEditor::setLengthVariants); m_messageEditor->setLengthVariants(m_ui.actionLengthVariants->isChecked()); m_messageEditor->setVisualizeWhitespace(m_ui.actionVisualizeWhitespace->isChecked()); @@ -542,7 +544,7 @@ void MainWindow::modelCountChanged() if (!mc) { selectedMessageChanged(QModelIndex(), QModelIndex()); - updateLatestModel(-1); + doUpdateLatestModel(-1); } else { if (!m_contextView->currentIndex().isValid()) { // Ensure that something is selected @@ -557,9 +559,9 @@ void MainWindow::modelCountChanged() // Field insertions/removals are automatic, but not the re-fill m_messageEditor->showMessage(m_currentIndex); if (mc == 1) - updateLatestModel(0); + doUpdateLatestModel(0); else if (m_currentIndex.model() >= mc) - updateLatestModel(mc - 1); + doUpdateLatestModel(mc - 1); } m_contextView->setUpdatesEnabled(true); @@ -1173,7 +1175,7 @@ void MainWindow::newPhraseBook() return; m_phraseBookDir = QFileInfo(name).absolutePath(); if (savePhraseBook(&name, pb)) { - if (openPhraseBook(name)) + if (doOpenPhraseBook(name)) statusBar()->showMessage(tr("Phrase book created."), MessageMS); } } @@ -1197,7 +1199,7 @@ void MainWindow::openPhraseBook() if (!name.isEmpty()) { m_phraseBookDir = QFileInfo(name).absolutePath(); if (!isPhraseBookOpen(name)) { - if (PhraseBook *phraseBook = openPhraseBook(name)) { + if (PhraseBook *phraseBook = doOpenPhraseBook(name)) { int n = phraseBook->phrases().count(); statusBar()->showMessage(tr("%n phrase(s) loaded.", 0, n), MessageMS); } @@ -1222,7 +1224,8 @@ void MainWindow::closePhraseBook(QAction *action) m_ui.menuPrintPhraseBook->removeAction(act); m_phraseBooks.removeOne(pb); - disconnect(pb, SIGNAL(listChanged()), this, SLOT(updatePhraseDicts())); + disconnect(pb, &PhraseBook::listChanged, + this, &MainWindow::updatePhraseDicts); updatePhraseDicts(); delete pb; updatePhraseBookActions(); @@ -1722,7 +1725,7 @@ QModelIndex MainWindow::prevMessage(const QModelIndex ¤tIndex, bool checkU void MainWindow::nextUnfinished() { if (m_ui.actionNextUnfinished->isEnabled()) { - if (!next(true)) { + if (!doNext(true)) { // If no Unfinished message is left, the user has finished the job. We // congratulate on a job well done with this ringing bell. statusBar()->showMessage(tr("No untranslated translation units left."), MessageMS); @@ -1734,7 +1737,7 @@ void MainWindow::nextUnfinished() void MainWindow::prevUnfinished() { if (m_ui.actionNextUnfinished->isEnabled()) { - if (!prev(true)) { + if (!doPrev(true)) { // If no Unfinished message is left, the user has finished the job. We // congratulate on a job well done with this ringing bell. statusBar()->showMessage(tr("No untranslated translation units left."), MessageMS); @@ -1745,15 +1748,15 @@ void MainWindow::prevUnfinished() void MainWindow::prev() { - prev(false); + doPrev(false); } void MainWindow::next() { - next(false); + doNext(false); } -bool MainWindow::prev(bool checkUnfinished) +bool MainWindow::doPrev(bool checkUnfinished) { QModelIndex index = prevMessage(m_messageView->currentIndex(), checkUnfinished); if (index.isValid()) @@ -1765,7 +1768,7 @@ bool MainWindow::prev(bool checkUnfinished) return index.isValid(); } -bool MainWindow::next(bool checkUnfinished) +bool MainWindow::doNext(bool checkUnfinished) { QModelIndex index = nextMessage(m_messageView->currentIndex(), checkUnfinished); if (index.isValid()) @@ -1868,89 +1871,112 @@ void MainWindow::setupMenuBar() m_ui.actionWhatsThis->setIcon(QIcon(prefix + QStringLiteral("/whatsthis.png"))); // File menu - connect(m_ui.menuFile, SIGNAL(aboutToShow()), SLOT(fileAboutToShow())); - connect(m_ui.actionOpen, SIGNAL(triggered()), this, SLOT(open())); - connect(m_ui.actionOpenAux, SIGNAL(triggered()), this, SLOT(openAux())); - connect(m_ui.actionSaveAll, SIGNAL(triggered()), this, SLOT(saveAll())); - connect(m_ui.actionSave, SIGNAL(triggered()), this, SLOT(save())); - connect(m_ui.actionSaveAs, SIGNAL(triggered()), this, SLOT(saveAs())); - connect(m_ui.actionReleaseAll, SIGNAL(triggered()), this, SLOT(releaseAll())); - connect(m_ui.actionRelease, SIGNAL(triggered()), this, SLOT(release())); - connect(m_ui.actionReleaseAs, SIGNAL(triggered()), this, SLOT(releaseAs())); - connect(m_ui.actionPrint, SIGNAL(triggered()), this, SLOT(print())); - connect(m_ui.actionClose, SIGNAL(triggered()), this, SLOT(closeFile())); - connect(m_ui.actionCloseAll, SIGNAL(triggered()), this, SLOT(closeAll())); - connect(m_ui.actionExit, SIGNAL(triggered()), this, SLOT(close())); + connect(m_ui.menuFile, &QMenu::aboutToShow, this, &MainWindow::fileAboutToShow); + connect(m_ui.actionOpen, &QAction::triggered, this, &MainWindow::open); + connect(m_ui.actionOpenAux, &QAction::triggered, this, &MainWindow::openAux); + connect(m_ui.actionSaveAll, &QAction::triggered, this, &MainWindow::saveAll); + connect(m_ui.actionSave, &QAction::triggered, this, &MainWindow::save); + connect(m_ui.actionSaveAs, &QAction::triggered, this, &MainWindow::saveAs); + connect(m_ui.actionReleaseAll, &QAction::triggered, this, &MainWindow::releaseAll); + connect(m_ui.actionRelease, &QAction::triggered, this, &MainWindow::release); + connect(m_ui.actionReleaseAs, &QAction::triggered, this, &MainWindow::releaseAs); + connect(m_ui.actionPrint, &QAction::triggered, this, &MainWindow::print); + connect(m_ui.actionClose, &QAction::triggered, this, &MainWindow::closeFile); + connect(m_ui.actionCloseAll, &QAction::triggered, this, &MainWindow::closeAll); + connect(m_ui.actionExit, &QAction::triggered, this, &MainWindow::close); // Edit menu - connect(m_ui.menuEdit, SIGNAL(aboutToShow()), SLOT(editAboutToShow())); + connect(m_ui.menuEdit, &QMenu::aboutToShow, this, &MainWindow::editAboutToShow); - connect(m_ui.actionUndo, SIGNAL(triggered()), m_messageEditor, SLOT(undo())); - connect(m_messageEditor, SIGNAL(undoAvailable(bool)), m_ui.actionUndo, SLOT(setEnabled(bool))); + connect(m_ui.actionUndo, &QAction::triggered, m_messageEditor, &MessageEditor::undo); + connect(m_messageEditor, &MessageEditor::undoAvailable, m_ui.actionUndo, &QAction::setEnabled); - connect(m_ui.actionRedo, SIGNAL(triggered()), m_messageEditor, SLOT(redo())); - connect(m_messageEditor, SIGNAL(redoAvailable(bool)), m_ui.actionRedo, SLOT(setEnabled(bool))); + connect(m_ui.actionRedo, &QAction::triggered, m_messageEditor, &MessageEditor::redo); + connect(m_messageEditor, &MessageEditor::redoAvailable, m_ui.actionRedo, &QAction::setEnabled); - connect(m_ui.actionCopy, SIGNAL(triggered()), m_messageEditor, SLOT(copy())); - connect(m_messageEditor, SIGNAL(copyAvailable(bool)), m_ui.actionCopy, SLOT(setEnabled(bool))); +#ifndef QT_NO_CLIPBOARD + connect(m_ui.actionCut, &QAction::triggered, m_messageEditor, &MessageEditor::cut); + connect(m_messageEditor, &MessageEditor::cutAvailable, m_ui.actionCut, &QAction::setEnabled); - connect(m_messageEditor, SIGNAL(cutAvailable(bool)), m_ui.actionCut, SLOT(setEnabled(bool))); - connect(m_ui.actionCut, SIGNAL(triggered()), m_messageEditor, SLOT(cut())); + connect(m_ui.actionCopy, &QAction::triggered, m_messageEditor, &MessageEditor::copy); + connect(m_messageEditor, &MessageEditor::copyAvailable, m_ui.actionCopy, &QAction::setEnabled); - connect(m_messageEditor, SIGNAL(pasteAvailable(bool)), m_ui.actionPaste, SLOT(setEnabled(bool))); - connect(m_ui.actionPaste, SIGNAL(triggered()), m_messageEditor, SLOT(paste())); - - connect(m_ui.actionSelectAll, SIGNAL(triggered()), m_messageEditor, SLOT(selectAll())); - connect(m_ui.actionFind, SIGNAL(triggered()), m_findDialog, SLOT(find())); - connect(m_ui.actionFindNext, SIGNAL(triggered()), this, SLOT(findAgain())); - connect(m_ui.actionSearchAndTranslate, SIGNAL(triggered()), this, SLOT(showTranslateDialog())); - connect(m_ui.actionBatchTranslation, SIGNAL(triggered()), this, SLOT(showBatchTranslateDialog())); - connect(m_ui.actionTranslationFileSettings, SIGNAL(triggered()), this, SLOT(showTranslationSettings())); + connect(m_ui.actionPaste, &QAction::triggered, m_messageEditor, &MessageEditor::paste); + connect(m_messageEditor, &MessageEditor::pasteAvailable, m_ui.actionPaste, &QAction::setEnabled); +#endif - connect(m_batchTranslateDialog, SIGNAL(finished()), SLOT(refreshItemViews())); + connect(m_ui.actionSelectAll, &QAction::triggered, + m_messageEditor, &MessageEditor::selectAll); + connect(m_ui.actionFind, &QAction::triggered, + m_findDialog, &FindDialog::find); + connect(m_ui.actionFindNext, &QAction::triggered, + this, &MainWindow::findAgain); + connect(m_ui.actionSearchAndTranslate, &QAction::triggered, + this, &MainWindow::showTranslateDialog); + connect(m_ui.actionBatchTranslation, &QAction::triggered, + this, &MainWindow::showBatchTranslateDialog); + connect(m_ui.actionTranslationFileSettings, &QAction::triggered, + this, &MainWindow::showTranslationSettings); + + connect(m_batchTranslateDialog, &BatchTranslationDialog::finished, + this, &MainWindow::refreshItemViews); // Translation menu // when updating the accelerators, remember the status bar - connect(m_ui.actionPrevUnfinished, SIGNAL(triggered()), this, SLOT(prevUnfinished())); - connect(m_ui.actionNextUnfinished, SIGNAL(triggered()), this, SLOT(nextUnfinished())); - connect(m_ui.actionNext, SIGNAL(triggered()), this, SLOT(next())); - connect(m_ui.actionPrev, SIGNAL(triggered()), this, SLOT(prev())); - connect(m_ui.actionDone, SIGNAL(triggered()), this, SLOT(done())); - connect(m_ui.actionDoneAndNext, SIGNAL(triggered()), this, SLOT(doneAndNext())); - connect(m_ui.actionBeginFromSource, SIGNAL(triggered()), m_messageEditor, SLOT(beginFromSource())); - connect(m_messageEditor, SIGNAL(beginFromSourceAvailable(bool)), m_ui.actionBeginFromSource, SLOT(setEnabled(bool))); + connect(m_ui.actionPrevUnfinished, &QAction::triggered, this, &MainWindow::prevUnfinished); + connect(m_ui.actionNextUnfinished, &QAction::triggered, this, &MainWindow::nextUnfinished); + connect(m_ui.actionNext, &QAction::triggered, this, &MainWindow::next); + connect(m_ui.actionPrev, &QAction::triggered, this, &MainWindow::prev); + connect(m_ui.actionDone, &QAction::triggered, this, &MainWindow::done); + connect(m_ui.actionDoneAndNext, &QAction::triggered, this, &MainWindow::doneAndNext); + connect(m_ui.actionBeginFromSource, &QAction::triggered, m_messageEditor, &MessageEditor::beginFromSource); + connect(m_messageEditor, &MessageEditor::beginFromSourceAvailable, + m_ui.actionBeginFromSource, &QAction::setEnabled); // Phrasebook menu - connect(m_ui.actionNewPhraseBook, SIGNAL(triggered()), this, SLOT(newPhraseBook())); - connect(m_ui.actionOpenPhraseBook, SIGNAL(triggered()), this, SLOT(openPhraseBook())); - connect(m_ui.menuClosePhraseBook, SIGNAL(triggered(QAction*)), - this, SLOT(closePhraseBook(QAction*))); - connect(m_ui.menuEditPhraseBook, SIGNAL(triggered(QAction*)), - this, SLOT(editPhraseBook(QAction*))); - connect(m_ui.menuPrintPhraseBook, SIGNAL(triggered(QAction*)), - this, SLOT(printPhraseBook(QAction*))); - connect(m_ui.actionAddToPhraseBook, SIGNAL(triggered()), this, SLOT(addToPhraseBook())); + connect(m_ui.actionNewPhraseBook, &QAction::triggered, this, &MainWindow::newPhraseBook); + connect(m_ui.actionOpenPhraseBook, &QAction::triggered, this, &MainWindow::openPhraseBook); + connect(m_ui.menuClosePhraseBook, &QMenu::triggered, + this, &MainWindow::closePhraseBook); + connect(m_ui.menuEditPhraseBook, &QMenu::triggered, + this, &MainWindow::editPhraseBook); + connect(m_ui.menuPrintPhraseBook, &QMenu::triggered, + this, &MainWindow::printPhraseBook); + connect(m_ui.actionAddToPhraseBook, &QAction::triggered, + this, &MainWindow::addToPhraseBook); // Validation menu - connect(m_ui.actionAccelerators, SIGNAL(triggered()), this, SLOT(revalidate())); - connect(m_ui.actionSurroundingWhitespace, SIGNAL(triggered()), this, SLOT(revalidate())); - connect(m_ui.actionEndingPunctuation, SIGNAL(triggered()), this, SLOT(revalidate())); - connect(m_ui.actionPhraseMatches, SIGNAL(triggered()), this, SLOT(revalidate())); - connect(m_ui.actionPlaceMarkerMatches, SIGNAL(triggered()), this, SLOT(revalidate())); + connect(m_ui.actionAccelerators, &QAction::triggered, this, &MainWindow::revalidate); + connect(m_ui.actionSurroundingWhitespace, &QAction::triggered, this, &MainWindow::revalidate); + connect(m_ui.actionEndingPunctuation, &QAction::triggered, this, &MainWindow::revalidate); + connect(m_ui.actionPhraseMatches, &QAction::triggered, this, &MainWindow::revalidate); + connect(m_ui.actionPlaceMarkerMatches, &QAction::triggered, this, &MainWindow::revalidate); // View menu - connect(m_ui.actionResetSorting, SIGNAL(triggered()), this, SLOT(resetSorting())); - connect(m_ui.actionDisplayGuesses, SIGNAL(triggered()), m_phraseView, SLOT(toggleGuessing())); - connect(m_ui.actionStatistics, SIGNAL(triggered()), this, SLOT(toggleStatistics())); - connect(m_ui.actionVisualizeWhitespace, SIGNAL(triggered()), this, SLOT(toggleVisualizeWhitespace())); - connect(m_ui.menuView, SIGNAL(aboutToShow()), this, SLOT(updateViewMenu())); - connect(m_ui.actionIncreaseZoom, SIGNAL(triggered()), m_messageEditor, SLOT(increaseFontSize())); - connect(m_ui.actionDecreaseZoom, SIGNAL(triggered()), m_messageEditor, SLOT(decreaseFontSize())); - connect(m_ui.actionResetZoomToDefault, SIGNAL(triggered()), m_messageEditor, SLOT(resetFontSize())); - connect(m_ui.actionShowMoreGuesses, SIGNAL(triggered()), m_phraseView, SLOT(moreGuesses())); - connect(m_ui.actionShowFewerGuesses, SIGNAL(triggered()), m_phraseView, SLOT(fewerGuesses())); - connect(m_phraseView, SIGNAL(showFewerGuessesAvailable(bool)), m_ui.actionShowFewerGuesses, SLOT(setEnabled(bool))); - connect(m_ui.actionResetGuessesToDefault, SIGNAL(triggered()), m_phraseView, SLOT(resetNumGuesses())); + connect(m_ui.actionResetSorting, &QAction::triggered, + this, &MainWindow::resetSorting); + connect(m_ui.actionDisplayGuesses, &QAction::triggered, + m_phraseView, &PhraseView::toggleGuessing); + connect(m_ui.actionStatistics, &QAction::triggered, + this, &MainWindow::toggleStatistics); + connect(m_ui.actionVisualizeWhitespace, &QAction::triggered, + this, &MainWindow::toggleVisualizeWhitespace); + connect(m_ui.menuView, &QMenu::aboutToShow, + this, &MainWindow::updateViewMenu); + connect(m_ui.actionIncreaseZoom, &QAction::triggered, + m_messageEditor, &MessageEditor::increaseFontSize); + connect(m_ui.actionDecreaseZoom, &QAction::triggered, + m_messageEditor, &MessageEditor::decreaseFontSize); + connect(m_ui.actionResetZoomToDefault, &QAction::triggered, + m_messageEditor, &MessageEditor::resetFontSize); + connect(m_ui.actionShowMoreGuesses, &QAction::triggered, + m_phraseView, &PhraseView::moreGuesses); + connect(m_ui.actionShowFewerGuesses, &QAction::triggered, + m_phraseView, &PhraseView::fewerGuesses); + connect(m_phraseView, &PhraseView::showFewerGuessesAvailable, + m_ui.actionShowFewerGuesses, &QAction::setEnabled); + connect(m_ui.actionResetGuessesToDefault, &QAction::triggered, + m_phraseView, &PhraseView::resetNumGuesses); m_ui.menuViewViews->addAction(m_contextDock->toggleViewAction()); m_ui.menuViewViews->addAction(m_messagesDock->toggleViewAction()); m_ui.menuViewViews->addAction(m_phrasesDock->toggleViewAction()); @@ -1962,17 +1988,17 @@ void MainWindow::setupMenuBar() QMenu *windowMenu = new QMenu(tr("&Window"), this); menuBar()->insertMenu(m_ui.menuHelp->menuAction(), windowMenu); windowMenu->addAction(tr("Minimize"), this, - SLOT(showMinimized()), QKeySequence(tr("Ctrl+M"))); + &QWidget::showMinimized, QKeySequence(tr("Ctrl+M"))); #endif // Help - connect(m_ui.actionManual, SIGNAL(triggered()), this, SLOT(manual())); - connect(m_ui.actionAbout, SIGNAL(triggered()), this, SLOT(about())); - connect(m_ui.actionAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt())); - connect(m_ui.actionWhatsThis, SIGNAL(triggered()), this, SLOT(onWhatsThis())); + connect(m_ui.actionManual, &QAction::triggered, this, &MainWindow::manual); + connect(m_ui.actionAbout, &QAction::triggered, this, &MainWindow::about); + connect(m_ui.actionAboutQt, &QAction::triggered, this, &MainWindow::aboutQt); + connect(m_ui.actionWhatsThis, &QAction::triggered, this, &MainWindow::onWhatsThis); - connect(m_ui.menuRecentlyOpenedFiles, SIGNAL(triggered(QAction*)), this, - SLOT(recentFileActivated(QAction*))); + connect(m_ui.menuRecentlyOpenedFiles, &QMenu::triggered, + this, &MainWindow::recentFileActivated); m_ui.actionManual->setWhatsThis(tr("Display the manual for %1.").arg(tr("Qt Linguist"))); m_ui.actionAbout->setWhatsThis(tr("Display information about %1.").arg(tr("Qt Linguist"))); @@ -1984,25 +2010,26 @@ void MainWindow::setupMenuBar() << QKeySequence(QLatin1String("Ctrl+Enter"))); // Disable the Close/Edit/Print phrasebook menuitems if they are not loaded - connect(m_ui.menuPhrases, SIGNAL(aboutToShow()), this, SLOT(setupPhrase())); + connect(m_ui.menuPhrases, &QMenu::aboutToShow, this, &MainWindow::setupPhrase); - connect(m_ui.menuRecentlyOpenedFiles, SIGNAL(aboutToShow()), SLOT(setupRecentFilesMenu())); + connect(m_ui.menuRecentlyOpenedFiles, &QMenu::aboutToShow, + this, &MainWindow::setupRecentFilesMenu); } void MainWindow::updateActiveModel(int model) { if (model >= 0) - updateLatestModel(model); + doUpdateLatestModel(model); } // Arriving here implies that the messageEditor does not have focus void MainWindow::updateLatestModel(const QModelIndex &index) { if (index.column() && (index.column() - 1 < m_dataModel->modelCount())) - updateLatestModel(index.column() - 1); + doUpdateLatestModel(index.column() - 1); } -void MainWindow::updateLatestModel(int model) +void MainWindow::doUpdateLatestModel(int model) { m_currentIndex = MultiDataIndex(model, m_currentIndex.context(), m_currentIndex.message()); bool enable = false; @@ -2254,10 +2281,10 @@ void MainWindow::setCurrentMessage(const QModelIndex &index, int model) { const QModelIndex &theIndex = m_messageModel->index(index.row(), model + 1, index.parent()); setCurrentMessage(theIndex); - m_messageEditor->setEditorFocus(model); + m_messageEditor->setEditorFocusForModel(model); } -void MainWindow::setCurrentMessage(int modelIndex, const Candidate &cand) +void MainWindow::setCurrentMessageFromGuess(int modelIndex, const Candidate &cand) { int contextIndex = m_dataModel->findContextIndex(cand.context); int messageIndex = m_dataModel->multiContextItem(contextIndex)->findMessage(cand.source, @@ -2276,7 +2303,7 @@ QModelIndex MainWindow::currentMessageIndex() const return m_sortedMessagesModel->mapToSource(m_messageView->currentIndex()); } -PhraseBook *MainWindow::openPhraseBook(const QString& name) +PhraseBook *MainWindow::doOpenPhraseBook(const QString& name) { PhraseBook *pb = new PhraseBook(); bool langGuessed; @@ -2308,7 +2335,7 @@ PhraseBook *MainWindow::openPhraseBook(const QString& name) m_phraseBookMenu[PhrasePrintMenu].insert(a, pb); a->setWhatsThis(tr("Print the entries in this phrase book.")); - connect(pb, SIGNAL(listChanged()), this, SLOT(updatePhraseDicts())); + connect(pb, &PhraseBook::listChanged, this, &MainWindow::updatePhraseDicts); updatePhraseDicts(); updatePhraseBookActions(); @@ -2662,7 +2689,7 @@ void MainWindow::readConfig() int size = config.beginReadArray(settingPath("OpenedPhraseBooks")); for (int i = 0; i < size; ++i) { config.setArrayIndex(i); - openPhraseBook(config.value(QLatin1String("FileName")).toString()); + doOpenPhraseBook(config.value(QLatin1String("FileName")).toString()); } config.endArray(); } @@ -2730,8 +2757,8 @@ void MainWindow::toggleStatistics() if (m_ui.actionStatistics->isChecked()) { if (!m_statistics) { m_statistics = new Statistics(this); - connect(m_dataModel, SIGNAL(statsChanged(StatisticalData)), - m_statistics, SLOT(updateStats(StatisticalData))); + connect(m_dataModel, &MultiDataModel::statsChanged, + m_statistics, &Statistics::updateStats); } m_statistics->show(); updateStatistics(); @@ -2762,7 +2789,7 @@ void MainWindow::updateStatistics() m_dataModel->model(m_currentIndex.model())->updateStatistics(); } -void MainWindow::showTranslationSettings(int model) +void MainWindow::doShowTranslationSettings(int model) { if (!m_translationSettingsDialog) m_translationSettingsDialog = new TranslationSettingsDialog(this); @@ -2772,7 +2799,7 @@ void MainWindow::showTranslationSettings(int model) void MainWindow::showTranslationSettings() { - showTranslationSettings(m_currentIndex.model()); + doShowTranslationSettings(m_currentIndex.model()); } bool MainWindow::eventFilter(QObject *object, QEvent *event) diff --git a/src/linguist/linguist/mainwindow.h b/src/linguist/linguist/mainwindow.h index 90cb1b627..e6313898f 100644 --- a/src/linguist/linguist/mainwindow.h +++ b/src/linguist/linguist/mainwindow.h @@ -79,6 +79,9 @@ public: static RecentFiles &recentFiles(); static QString friendlyString(const QString &str); +public slots: + void updateViewMenu(); + protected: void readConfig(); void writeConfig(); @@ -120,7 +123,6 @@ private slots: void about(); void aboutQt(); - void updateViewMenu(); void fileAboutToShow(); void editAboutToShow(); @@ -140,7 +142,7 @@ private slots: void updateLatestModel(const QModelIndex &index); void selectedContextChanged(const QModelIndex &sortedIndex, const QModelIndex &oldIndex); void selectedMessageChanged(const QModelIndex &sortedIndex, const QModelIndex &oldIndex); - void setCurrentMessage(int modelIndex, const Candidate &tm); + void setCurrentMessageFromGuess(int modelIndex, const Candidate &tm); // To synchronize from the message editor to the model ... void updateTranslation(const QStringList &translations); @@ -165,8 +167,8 @@ private: QModelIndex prevContext(const QModelIndex &index) const; QModelIndex nextMessage(const QModelIndex ¤tIndex, bool checkUnfinished = false) const; QModelIndex prevMessage(const QModelIndex ¤tIndex, bool checkUnfinished = false) const; - bool next(bool checkUnfinished); - bool prev(bool checkUnfinished); + bool doNext(bool checkUnfinished); + bool doPrev(bool checkUnfinished); void updateStatistics(); void initViewHeaders(); @@ -178,14 +180,14 @@ private: QModelIndex setMessageViewRoot(const QModelIndex &index); QModelIndex currentContextIndex() const; QModelIndex currentMessageIndex() const; - PhraseBook *openPhraseBook(const QString &name); + PhraseBook *doOpenPhraseBook(const QString &name); bool isPhraseBookOpen(const QString &name); bool savePhraseBook(QString *name, PhraseBook &pb); bool maybeSavePhraseBook(PhraseBook *phraseBook); bool maybeSavePhraseBooks(); QStringList pickTranslationFiles(); - void showTranslationSettings(int model); - void updateLatestModel(int model); + void doShowTranslationSettings(int model); + void doUpdateLatestModel(int model); void updateSourceView(int model, MessageItem *item); void updatePhraseBookActions(); void updatePhraseDictInternal(int model); diff --git a/src/linguist/linguist/messageeditor.cpp b/src/linguist/linguist/messageeditor.cpp index b02aa1859..d1bc155c1 100644 --- a/src/linguist/linguist/messageeditor.cpp +++ b/src/linguist/linguist/messageeditor.cpp @@ -82,20 +82,21 @@ MessageEditor::MessageEditor(MultiDataModel *dataModel, QMainWindow *parent) // Signals #ifndef QT_NO_CLIPBOARD - connect(qApp->clipboard(), SIGNAL(dataChanged()), - SLOT(clipboardChanged())); + connect(qApp->clipboard(), &QClipboard::dataChanged, + this, &MessageEditor::clipboardChanged); #endif - connect(m_dataModel, SIGNAL(modelAppended()), - SLOT(messageModelAppended())); - connect(m_dataModel, SIGNAL(modelDeleted(int)), - SLOT(messageModelDeleted(int))); - connect(m_dataModel, SIGNAL(allModelsDeleted()), - SLOT(allModelsDeleted())); - connect(m_dataModel, SIGNAL(languageChanged(int)), - SLOT(setTargetLanguage(int))); + connect(m_dataModel, &MultiDataModel::modelAppended, + this, &MessageEditor::messageModelAppended); + connect(m_dataModel, &MultiDataModel::modelDeleted, + this, &MessageEditor::messageModelDeleted); + connect(m_dataModel, &MultiDataModel::allModelsDeleted, + this, &MessageEditor::allModelsDeleted); + connect(m_dataModel, &MultiDataModel::languageChanged, + this, &MessageEditor::setTargetLanguage); m_tabOrderTimer.setSingleShot(true); - connect(&m_tabOrderTimer, SIGNAL(timeout()), SLOT(reallyFixTabOrder())); + connect(&m_tabOrderTimer, &QTimer::timeout, + this, &MessageEditor::reallyFixTabOrder); #ifndef QT_NO_CLIPBOARD clipboardChanged(); @@ -114,14 +115,14 @@ void MessageEditor::setupEditorPage() m_source = new FormWidget(tr("Source text"), false); m_source->setHideWhenEmpty(true); m_source->setWhatsThis(tr("This area shows the source text.")); - connect(m_source, SIGNAL(selectionChanged(QTextEdit*)), - SLOT(selectionChanged(QTextEdit*))); + connect(m_source, &FormWidget::selectionChanged, + this, &MessageEditor::selectionChanged); m_pluralSource = new FormWidget(tr("Source text (Plural)"), false); m_pluralSource->setHideWhenEmpty(true); m_pluralSource->setWhatsThis(tr("This area shows the plural form of the source text.")); - connect(m_pluralSource, SIGNAL(selectionChanged(QTextEdit*)), - SLOT(selectionChanged(QTextEdit*))); + connect(m_pluralSource, &FormWidget::selectionChanged, + this, &MessageEditor::selectionChanged); m_commentText = new FormWidget(tr("Developer comments"), false); m_commentText->setHideWhenEmpty(true); @@ -129,8 +130,8 @@ void MessageEditor::setupEditorPage() m_commentText->setWhatsThis(tr("This area shows a comment that" " may guide you, and the context in which the text" " occurs.") ); - connect(m_commentText, SIGNAL(selectionChanged(QTextEdit*)), - SLOT(selectionChanged(QTextEdit*))); + connect(m_commentText, &FormWidget::selectionChanged, + this, &MessageEditor::selectionChanged); QBoxLayout *subLayout = new QVBoxLayout; @@ -191,12 +192,14 @@ void MessageEditor::messageModelAppended() " They have no effect on the translated applications.") ); ed.transCommentText->getEditor()->installEventFilter(this); ed.transCommentText->getEditor()->setVisualizeWhitespace(m_visualizeWhitespace); - connect(ed.transCommentText, SIGNAL(selectionChanged(QTextEdit*)), - SLOT(selectionChanged(QTextEdit*))); - connect(ed.transCommentText, SIGNAL(textChanged(QTextEdit*)), - SLOT(emitTranslatorCommentChanged(QTextEdit*))); - connect(ed.transCommentText, SIGNAL(textChanged(QTextEdit*)), SLOT(resetHoverSelection())); - connect(ed.transCommentText, SIGNAL(cursorPositionChanged()), SLOT(resetHoverSelection())); + connect(ed.transCommentText, &FormWidget::selectionChanged, + this, &MessageEditor::selectionChanged); + connect(ed.transCommentText, &FormWidget::textChanged, + this, &MessageEditor::emitTranslatorCommentChanged); + connect(ed.transCommentText, &FormWidget::textChanged, + this, &MessageEditor::resetHoverSelection); + connect(ed.transCommentText, &FormWidget::cursorPositionChanged, + this, &MessageEditor::resetHoverSelection); fixTabOrder(); QBoxLayout *box = new QVBoxLayout(ed.container); box->setContentsMargins(5, 5, 5, 5); @@ -244,7 +247,8 @@ void MessageEditor::messageModelDeleted(int model) void MessageEditor::addPluralForm(int model, const QString &label, bool writable) { FormMultiWidget *transEditor = new FormMultiWidget(label); - connect(transEditor, SIGNAL(editorCreated(QTextEdit*)), SLOT(editorCreated(QTextEdit*))); + connect(transEditor, &FormMultiWidget::editorCreated, + this, &MessageEditor::editorCreated); transEditor->setEditingEnabled(writable); transEditor->setHideWhenEmpty(!writable); if (!m_editors[model].transTexts.isEmpty()) @@ -253,12 +257,14 @@ void MessageEditor::addPluralForm(int model, const QString &label, bool writable static_cast<QBoxLayout *>(m_editors[model].container->layout())->insertWidget( m_editors[model].transTexts.count(), transEditor); - connect(transEditor, SIGNAL(selectionChanged(QTextEdit*)), - SLOT(selectionChanged(QTextEdit*))); - connect(transEditor, SIGNAL(textChanged(QTextEdit*)), - SLOT(emitTranslationChanged(QTextEdit*))); - connect(transEditor, SIGNAL(textChanged(QTextEdit*)), SLOT(resetHoverSelection())); - connect(transEditor, SIGNAL(cursorPositionChanged()), SLOT(resetHoverSelection())); + connect(transEditor, &FormMultiWidget::selectionChanged, + this, &MessageEditor::selectionChanged); + connect(transEditor, &FormMultiWidget::textChanged, + this, &MessageEditor::emitTranslationChanged); + connect(transEditor, &FormMultiWidget::textChanged, + this, &MessageEditor::resetHoverSelection); + connect(transEditor, &FormMultiWidget::cursorPositionChanged, + this, &MessageEditor::resetHoverSelection); m_editors[model].transTexts << transEditor; } @@ -348,11 +354,16 @@ void MessageEditor::selectionChanged(QTextEdit *te) if (te != m_selectionHolder) { if (m_selectionHolder) { clearSelection(m_selectionHolder); - disconnect(this, SLOT(editorDestroyed())); + if (FormatTextEdit *fte = qobject_cast<FormatTextEdit*>(m_selectionHolder)) { + disconnect(fte, &FormatTextEdit::editorDestroyed, + this, &MessageEditor::editorDestroyed); + } + } + m_selectionHolder = (te->textCursor().hasSelection() ? te : nullptr); + if (FormatTextEdit *fte = qobject_cast<FormatTextEdit*>(m_selectionHolder)) { + connect(fte, &FormatTextEdit::editorDestroyed, + this, &MessageEditor::editorDestroyed); } - m_selectionHolder = (te->textCursor().hasSelection() ? te : 0); - if (FormatTextEdit *fte = qobject_cast<FormatTextEdit*>(m_selectionHolder)) - connect(fte, SIGNAL(editorDestroyed()), SLOT(editorDestroyed())); #ifndef QT_NO_CLIPBOARD updateCanCutCopy(); #endif @@ -371,7 +382,10 @@ void MessageEditor::resetSelection() { if (m_selectionHolder) { clearSelection(m_selectionHolder); - disconnect(this, SLOT(editorDestroyed())); + if (FormatTextEdit *fte = qobject_cast<FormatTextEdit*>(m_selectionHolder)) { + disconnect(fte, &FormatTextEdit::editorDestroyed, + this, &MessageEditor::editorDestroyed); + } m_selectionHolder = 0; #ifndef QT_NO_CLIPBOARD updateCanCutCopy(); @@ -626,9 +640,9 @@ void MessageEditor::showMessage(const MultiDataIndex &index) for (int i = 0; i < ed.transTexts.size(); ++i) { bool shouldShow = (i < normalizedTranslations.count()); if (shouldShow) - setTranslation(j, normalizedTranslations.at(i), i); + setNumerusTranslation(j, normalizedTranslations.at(i), i); else - setTranslation(j, QString(), i); + setNumerusTranslation(j, QString(), i); ed.transTexts.at(i)->setVisible(i == 0 || shouldShow); } } @@ -639,7 +653,7 @@ void MessageEditor::showMessage(const MultiDataIndex &index) updateUndoRedo(); } -void MessageEditor::setTranslation(int model, const QString &translation, int numerus) +void MessageEditor::setNumerusTranslation(int model, const QString &translation, int numerus) { MessageEditorData &ed = m_editors[model]; if (numerus >= ed.transTexts.count()) @@ -819,7 +833,7 @@ void MessageEditor::setEditorFocus() activeEditor->setFocus(); } -void MessageEditor::setEditorFocus(int model) +void MessageEditor::setEditorFocusForModel(int model) { if (m_currentModel != model) { if (model < 0) { diff --git a/src/linguist/linguist/messageeditor.h b/src/linguist/linguist/messageeditor.h index 386384ec6..1a16ff1d5 100644 --- a/src/linguist/linguist/messageeditor.h +++ b/src/linguist/linguist/messageeditor.h @@ -69,9 +69,9 @@ public: void showMessage(const MultiDataIndex &index); void setNumerusForms(int model, const QStringList &numerusForms); bool eventFilter(QObject *, QEvent *) override; - void setTranslation(int model, const QString &translation, int numerus); + void setNumerusTranslation(int model, const QString &translation, int numerus); int activeModel() const { return (m_editors.count() != 1) ? m_currentModel : 0; } - void setEditorFocus(int model); + void setEditorFocusForModel(int model); void setUnfinishedEditorFocus(); bool focusNextUnfinished(); void setVisualizeWhitespace(bool value); diff --git a/src/linguist/linguist/messageeditorwidgets.cpp b/src/linguist/linguist/messageeditorwidgets.cpp index 6bcf41b75..d869fe31a 100644 --- a/src/linguist/linguist/messageeditorwidgets.cpp +++ b/src/linguist/linguist/messageeditorwidgets.cpp @@ -58,8 +58,10 @@ ExpandingTextEdit::ExpandingTextEdit(QWidget *parent) setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QAbstractTextDocumentLayout *docLayout = document()->documentLayout(); - connect(docLayout, SIGNAL(documentSizeChanged(QSizeF)), SLOT(updateHeight(QSizeF))); - connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(reallyEnsureCursorVisible())); + connect(docLayout, &QAbstractTextDocumentLayout::documentSizeChanged, + this, &ExpandingTextEdit::updateHeight); + connect(this, &QTextEdit::cursorPositionChanged, + this, &ExpandingTextEdit::reallyEnsureCursorVisible); m_minimumHeight = qRound(docLayout->documentSize().height()) + frameWidth() * 2; } @@ -187,9 +189,12 @@ FormWidget::FormWidget(const QString &label, bool isEditable, QWidget *parent) setLayout(layout); - connect(m_editor, SIGNAL(textChanged()), SLOT(slotTextChanged())); - connect(m_editor, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged())); - connect(m_editor, SIGNAL(cursorPositionChanged()), SIGNAL(cursorPositionChanged())); + connect(m_editor, &QTextEdit::textChanged, + this, &FormWidget::slotTextChanged); + connect(m_editor, &QTextEdit::selectionChanged, + this, &FormWidget::slotSelectionChanged); + connect(m_editor, &QTextEdit::cursorPositionChanged, + this, &FormWidget::cursorPositionChanged); } void FormWidget::slotTextChanged() @@ -257,16 +262,15 @@ FormMultiWidget::FormMultiWidget(const QString &label, QWidget *parent) m_label->setText(label); m_plusButtons.append( - new ButtonWrapper(makeButton(m_plusIcon, SLOT(plusButtonClicked())), 0)); + new ButtonWrapper(makeButton(m_plusIcon, &FormMultiWidget::plusButtonClicked), 0)); } -QAbstractButton *FormMultiWidget::makeButton(const QIcon &icon, const char *slot) +QAbstractButton *FormMultiWidget::makeButton(const QIcon &icon) { QAbstractButton *btn = new QToolButton(this); btn->setIcon(icon); btn->setFixedSize(icon.availableSizes().first() /* + something */); btn->setFocusPolicy(Qt::NoFocus); - connect(btn, SIGNAL(clicked()), slot); return btn; } @@ -275,13 +279,16 @@ void FormMultiWidget::addEditor(int idx) FormatTextEdit *editor = new FormatTextEdit(this); m_editors.insert(idx, editor); - m_minusButtons.insert(idx, makeButton(m_minusIcon, SLOT(minusButtonClicked()))); + m_minusButtons.insert(idx, makeButton(m_minusIcon, &FormMultiWidget::minusButtonClicked)); m_plusButtons.insert(idx + 1, - new ButtonWrapper(makeButton(m_plusIcon, SLOT(plusButtonClicked())), editor)); - - connect(editor, SIGNAL(textChanged()), SLOT(slotTextChanged())); - connect(editor, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged())); - connect(editor, SIGNAL(cursorPositionChanged()), SIGNAL(cursorPositionChanged())); + new ButtonWrapper(makeButton(m_plusIcon, &FormMultiWidget::plusButtonClicked), editor)); + + connect(editor, &QTextEdit::textChanged, + this, &FormMultiWidget::slotTextChanged); + connect(editor, &QTextEdit::selectionChanged, + this, &FormMultiWidget::slotSelectionChanged); + connect(editor, &QTextEdit::cursorPositionChanged, + this, &FormMultiWidget::cursorPositionChanged); editor->installEventFilter(this); emit editorCreated(editor); diff --git a/src/linguist/linguist/messageeditorwidgets.h b/src/linguist/linguist/messageeditorwidgets.h index 086c4ec2d..508021b60 100644 --- a/src/linguist/linguist/messageeditorwidgets.h +++ b/src/linguist/linguist/messageeditorwidgets.h @@ -29,6 +29,7 @@ #ifndef MESSAGEEDITORWIDGETS_H #define MESSAGEEDITORWIDGETS_H +#include <QAbstractButton> #include <QIcon> #include <QImage> #include <QLabel> @@ -39,7 +40,6 @@ QT_BEGIN_NAMESPACE -class QAbstractButton; class QAction; class QContextMenuEvent; class QKeyEvent; @@ -158,7 +158,16 @@ private slots: private: void addEditor(int idx); void updateLayout(); - QAbstractButton *makeButton(const QIcon &icon, const char *slot); + + template<typename Func> + QAbstractButton *makeButton(const QIcon &icon, Func slot) + { + auto *button = makeButton(icon); + connect(button, &QAbstractButton::clicked, + this, slot); + return button; + } + QAbstractButton *makeButton(const QIcon &icon); void insertEditor(int idx); void deleteEditor(int idx); diff --git a/src/linguist/linguist/messagemodel.cpp b/src/linguist/linguist/messagemodel.cpp index 133cd0fc0..c241a5be3 100644 --- a/src/linguist/linguist/messagemodel.cpp +++ b/src/linguist/linguist/messagemodel.cpp @@ -787,9 +787,12 @@ void MultiDataModel::append(DataModel *dm, bool readWrite) } dm->setWritable(readWrite); updateCountsOnAdd(modelCount() - 1, readWrite); - connect(dm, SIGNAL(modifiedChanged()), SLOT(onModifiedChanged())); - connect(dm, SIGNAL(languageChanged()), SLOT(onLanguageChanged())); - connect(dm, SIGNAL(statsChanged(StatisticalData)), SIGNAL(statsChanged(StatisticalData))); + connect(dm, &DataModel::modifiedChanged, + this, &MultiDataModel::onModifiedChanged); + connect(dm, &DataModel::languageChanged, + this, &MultiDataModel::onLanguageChanged); + connect(dm, &DataModel::statsChanged, + this, &MultiDataModel::statsChanged); emit modelAppended(); } @@ -1200,12 +1203,12 @@ MessageModel::MessageModel(QObject *parent, MultiDataModel *data) : QAbstractItemModel(parent), m_data(data) { data->m_msgModel = this; - connect(m_data, SIGNAL(multiContextDataChanged(MultiDataIndex)), - SLOT(multiContextItemChanged(MultiDataIndex))); - connect(m_data, SIGNAL(contextDataChanged(MultiDataIndex)), - SLOT(contextItemChanged(MultiDataIndex))); - connect(m_data, SIGNAL(messageDataChanged(MultiDataIndex)), - SLOT(messageItemChanged(MultiDataIndex))); + connect(m_data, &MultiDataModel::multiContextDataChanged, + this, &MessageModel::multiContextItemChanged); + connect(m_data, &MultiDataModel::contextDataChanged, + this, &MessageModel::contextItemChanged); + connect(m_data, &MultiDataModel::messageDataChanged, + this, &MessageModel::messageItemChanged); } QModelIndex MessageModel::index(int row, int column, const QModelIndex &parent) const diff --git a/src/linguist/linguist/phrasebookbox.cpp b/src/linguist/linguist/phrasebookbox.cpp index 035ca09ff..dc6215f21 100644 --- a/src/linguist/linguist/phrasebookbox.cpp +++ b/src/linguist/linguist/phrasebookbox.cpp @@ -68,19 +68,24 @@ PhraseBookBox::PhraseBookBox(PhraseBook *phraseBook, QWidget *parent) 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))); + connect(sourceLed, &QLineEdit::textChanged, + this, &PhraseBookBox::sourceChanged); + connect(targetLed, &QLineEdit::textChanged, + this, &PhraseBookBox::targetChanged); + connect(definitionLed, &QLineEdit::textChanged, + this, &PhraseBookBox::definitionChanged); + connect(phraseList->selectionModel(), &QItemSelectionModel::currentChanged, + this, &PhraseBookBox::selectionChanged); + connect(newBut, &QAbstractButton::clicked, + this, &PhraseBookBox::newPhrase); + connect(removeBut, &QAbstractButton::clicked, + this, &PhraseBookBox::removePhrase); + connect(settingsBut, &QAbstractButton::clicked, + this, &PhraseBookBox::settings); + connect(saveBut, &QAbstractButton::clicked, + this, &PhraseBookBox::save); + connect(m_phraseBook, &PhraseBook::modifiedChanged, + this, &PhraseBookBox::setWindowModified); sourceLed->installEventFilter(this); targetLed->installEventFilter(this); diff --git a/src/linguist/linguist/phraseview.cpp b/src/linguist/linguist/phraseview.cpp index b0199fc16..03fbc7390 100644 --- a/src/linguist/linguist/phraseview.cpp +++ b/src/linguist/linguist/phraseview.cpp @@ -68,13 +68,14 @@ PhraseView::PhraseView(MultiDataModel *model, QList<QHash<QString, QList<Phrase setItemsExpandable(false); for (int i = 0; i < 10; i++) - (void) new GuessShortcut(i, this, SLOT(guessShortcut(int))); + (void) new GuessShortcut(i, this, &PhraseView::guessShortcut); header()->setSectionResizeMode(QHeaderView::Interactive); header()->setSectionsClickable(true); header()->restoreState(QSettings().value(phraseViewHeaderKey()).toByteArray()); - connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(selectPhrase(QModelIndex))); + connect(this, &QAbstractItemView::activated, + this, &PhraseView::selectPhrase); } PhraseView::~PhraseView() @@ -104,15 +105,18 @@ void PhraseView::contextMenuEvent(QContextMenuEvent *event) QMenu *contextMenu = new QMenu(this); QAction *insertAction = new QAction(tr("Insert"), contextMenu); - connect(insertAction, SIGNAL(triggered()), this, SLOT(selectPhrase())); + connect(insertAction, &QAction::triggered, + this, &PhraseView::selectCurrentPhrase); QAction *editAction = new QAction(tr("Edit"), contextMenu); - connect(editAction, SIGNAL(triggered()), this, SLOT(editPhrase())); + connect(editAction, &QAction::triggered, + this, &PhraseView::editPhrase); Qt::ItemFlags isFromPhraseBook = model()->flags(index) & Qt::ItemIsEditable; editAction->setEnabled(isFromPhraseBook); QAction *gotoAction = new QAction(tr("Go to"), contextMenu); - connect(gotoAction, SIGNAL(triggered()), this, SLOT(gotoMessageFromGuess())); + connect(gotoAction, &QAction::triggered, + this, &PhraseView::gotoMessageFromGuess); gotoAction->setEnabled(!isFromPhraseBook); contextMenu->addAction(insertAction); @@ -147,7 +151,7 @@ void PhraseView::selectPhrase(const QModelIndex &index) emit phraseSelected(m_modelIndex, m_phraseModel->phrase(index)->target()); } -void PhraseView::selectPhrase() +void PhraseView::selectCurrentPhrase() { emit phraseSelected(m_modelIndex, m_phraseModel->phrase(currentIndex())->target()); } diff --git a/src/linguist/linguist/phraseview.h b/src/linguist/linguist/phraseview.h index 6e5b42703..118bc250a 100644 --- a/src/linguist/linguist/phraseview.h +++ b/src/linguist/linguist/phraseview.h @@ -45,13 +45,16 @@ class GuessShortcut : public QShortcut { Q_OBJECT public: - GuessShortcut(int nkey, QWidget *parent, const char *member) + template<class Obj, typename Func> + GuessShortcut(int nkey, Obj *parent, Func member) : QShortcut(parent), nrkey(nkey) { const auto key = static_cast<Qt::Key>(int(Qt::Key_1) + nrkey); setKey(Qt::CTRL | key); - connect(this, SIGNAL(activated()), this, SLOT(keyActivated())); - connect(this, SIGNAL(activated(int)), parent, member); + connect(this, &GuessShortcut::activated, + this, &GuessShortcut::keyActivated); + connect(this, &GuessShortcut::activated, + parent, member); } private slots: @@ -79,6 +82,9 @@ public slots: int getMaxCandidates() const { return m_maxCandidates; } void setMaxCandidates(const int max); static int getDefaultMaxCandidates() { return DefaultMaxCandidates; } + void moreGuesses(); + void fewerGuesses(); + void resetNumGuesses(); signals: void phraseSelected(int latestModel, const QString &phrase); @@ -94,12 +100,9 @@ protected: private slots: void guessShortcut(int nkey); void selectPhrase(const QModelIndex &index); - void selectPhrase(); + void selectCurrentPhrase(); void editPhrase(); void gotoMessageFromGuess(); - void moreGuesses(); - void fewerGuesses(); - void resetNumGuesses(); private: QList<Phrase *> getPhrases(int model, const QString &sourceText); diff --git a/src/linguist/linguist/recentfiles.cpp b/src/linguist/linguist/recentfiles.cpp index c39e44088..07f61dd18 100644 --- a/src/linguist/linguist/recentfiles.cpp +++ b/src/linguist/linguist/recentfiles.cpp @@ -50,7 +50,8 @@ RecentFiles::RecentFiles(const int maxEntries) { m_timer.setSingleShot(true); m_timer.setInterval(3 * 60 * 1000); - connect(&m_timer, SIGNAL(timeout()), SLOT(closeGroup())); + connect(&m_timer, &QTimer::timeout, + this, &RecentFiles::closeGroup); } /* diff --git a/src/linguist/linguist/translatedialog.cpp b/src/linguist/linguist/translatedialog.cpp index 2dc955254..bb52be371 100644 --- a/src/linguist/linguist/translatedialog.cpp +++ b/src/linguist/linguist/translatedialog.cpp @@ -34,11 +34,16 @@ TranslateDialog::TranslateDialog(QWidget *parent) : QDialog(parent) { m_ui.setupUi(this); - connect(m_ui.findNxt, SIGNAL(clicked()), this, SLOT(emitFindNext())); - connect(m_ui.translate, SIGNAL(clicked()), this, SLOT(emitTranslateAndFindNext())); - connect(m_ui.translateAll, SIGNAL(clicked()), this, SLOT(emitTranslateAll())); - connect(m_ui.ledFindWhat, SIGNAL(textChanged(QString)), SLOT(verifyText())); - connect(m_ui.ckMatchCase, SIGNAL(toggled(bool)), SLOT(verifyText())); + connect(m_ui.findNxt, &QAbstractButton::clicked, + this, &TranslateDialog::emitFindNext); + connect(m_ui.translate, &QAbstractButton::clicked, + this, &TranslateDialog::emitTranslateAndFindNext); + connect(m_ui.translateAll, &QAbstractButton::clicked, + this, &TranslateDialog::emitTranslateAll); + connect(m_ui.ledFindWhat, &QLineEdit::textChanged, + this, &TranslateDialog::verifyText); + connect(m_ui.ckMatchCase, &QAbstractButton::toggled, + this, &TranslateDialog::verifyText); } void TranslateDialog::showEvent(QShowEvent *) |