diff options
author | ck <qt-info@nokia.com> | 2010-01-21 11:46:38 (GMT) |
---|---|---|
committer | ck <qt-info@nokia.com> | 2010-01-21 11:46:38 (GMT) |
commit | af30aeb6a1ebb7307f06c122c0c93d152f4d958c (patch) | |
tree | 33bb60fc8e0fdbd1dfbbc8bff69f096a999d7660 /tools | |
parent | d0cc0f02aa0ea2ac2a90fb19f53de37a5cad56d6 (diff) | |
download | Qt-af30aeb6a1ebb7307f06c122c0c93d152f4d958c.zip Qt-af30aeb6a1ebb7307f06c122c0c93d152f4d958c.tar.gz Qt-af30aeb6a1ebb7307f06c122c0c93d152f4d958c.tar.bz2 |
QtHelp: Enable dynamic translation.
Task-number: QTBUG-7420
Reviewed-by: kh1
Diffstat (limited to 'tools')
-rw-r--r-- | tools/assistant/lib/qhelpsearchquerywidget.cpp | 71 | ||||
-rw-r--r-- | tools/assistant/lib/qhelpsearchquerywidget.h | 3 | ||||
-rw-r--r-- | tools/assistant/lib/qhelpsearchresultwidget.cpp | 8 | ||||
-rw-r--r-- | tools/assistant/lib/qhelpsearchresultwidget.h | 1 |
4 files changed, 63 insertions, 20 deletions
diff --git a/tools/assistant/lib/qhelpsearchquerywidget.cpp b/tools/assistant/lib/qhelpsearchquerywidget.cpp index a2b3ca2..b614cb4 100644 --- a/tools/assistant/lib/qhelpsearchquerywidget.cpp +++ b/tools/assistant/lib/qhelpsearchquerywidget.cpp @@ -120,6 +120,22 @@ private: // nothing todo } + void retranslate() + { + simpleSearchLabel->setText(tr("Search for:")); + prevQueryButton->setToolTip(tr("Previous search")); + nextQueryButton->setToolTip(tr("Next search")); + searchButton->setText(tr("Search")); +#ifdef QT_CLUCENE_SUPPORT + advancedSearchLabel->setText(tr("Advanced search")); + similarLabel->setText(tr("words <B>similar</B> to:")); + withoutLabel->setText(tr("<B>without</B> the words:")); + exactLabel->setText(tr("with <B>exact phrase</B>:")); + allLabel->setText(tr("with <B>all</B> of the words:")); + atLeastLabel->setText(tr("with <B>at least one</B> of the words:")); +#endif + } + QString escapeString(const QString &text) { QString retValue = text; @@ -360,6 +376,13 @@ private: friend class QHelpSearchQueryWidget; bool simpleSearch; + QLabel *simpleSearchLabel; + QLabel *advancedSearchLabel; + QLabel *similarLabel; + QLabel *withoutLabel; + QLabel *exactLabel; + QLabel *allLabel; + QLabel *atLeastLabel; QPushButton *searchButton; QWidget* advancedSearchWidget; QToolButton *showHideAdvancedSearchButton; @@ -408,19 +431,17 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent) vLayout->setMargin(0); QHBoxLayout* hBoxLayout = new QHBoxLayout(); - QLabel *label = new QLabel(tr("Search for:"), this); + d->simpleSearchLabel = new QLabel(this); d->defaultQuery = new QLineEdit(this); d->defaultQuery->setCompleter(&d->searchCompleter); d->prevQueryButton = new QToolButton(this); d->prevQueryButton->setArrowType(Qt::LeftArrow); - d->prevQueryButton->setToolTip(tr("Previous search")); d->prevQueryButton->setEnabled(false); d->nextQueryButton = new QToolButton(this); d->nextQueryButton->setArrowType(Qt::RightArrow); - d->nextQueryButton->setToolTip(tr("Next search")); d->nextQueryButton->setEnabled(false); - d->searchButton = new QPushButton(tr("Search"), this); - hBoxLayout->addWidget(label); + d->searchButton = new QPushButton(this); + hBoxLayout->addWidget(d->simpleSearchLabel); hBoxLayout->addWidget(d->defaultQuery); hBoxLayout->addWidget(d->prevQueryButton); hBoxLayout->addWidget(d->nextQueryButton); @@ -439,15 +460,15 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent) d->showHideAdvancedSearchButton->setText(QLatin1String("+")); d->showHideAdvancedSearchButton->setMinimumSize(25, 20); - label = new QLabel(tr("Advanced search"), this); + d->advancedSearchLabel = new QLabel(this); QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); - sizePolicy.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); - label->setSizePolicy(sizePolicy); + sizePolicy.setHeightForWidth(d->advancedSearchLabel->sizePolicy().hasHeightForWidth()); + d->advancedSearchLabel->setSizePolicy(sizePolicy); QFrame* hLine = new QFrame(this); hLine->setFrameStyle(QFrame::HLine); hBoxLayout->addWidget(d->showHideAdvancedSearchButton); - hBoxLayout->addWidget(label); + hBoxLayout->addWidget(d->advancedSearchLabel); hBoxLayout->addWidget(hLine); vLayout->addLayout(hBoxLayout); @@ -457,32 +478,32 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent) QGridLayout *gLayout = new QGridLayout(d->advancedSearchWidget); gLayout->setMargin(0); - label = new QLabel(tr("words <B>similar</B> to:"), this); - gLayout->addWidget(label, 0, 0); + d->similarLabel = new QLabel(this); + gLayout->addWidget(d->similarLabel, 0, 0); d->similarQuery = new QLineEdit(this); d->similarQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->similarQuery, 0, 1); - label = new QLabel(tr("<B>without</B> the words:"), this); - gLayout->addWidget(label, 1, 0); + d->withoutLabel = new QLabel(this); + gLayout->addWidget(d->withoutLabel, 1, 0); d->withoutQuery = new QLineEdit(this); d->withoutQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->withoutQuery, 1, 1); - label = new QLabel(tr("with <B>exact phrase</B>:"), this); - gLayout->addWidget(label, 2, 0); + d->exactLabel = new QLabel(this); + gLayout->addWidget(d->exactLabel, 2, 0); d->exactQuery = new QLineEdit(this); d->exactQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->exactQuery, 2, 1); - label = new QLabel(tr("with <B>all</B> of the words:"), this); - gLayout->addWidget(label, 3, 0); + d->allLabel = new QLabel(this); + gLayout->addWidget(d->allLabel, 3, 0); d->allQuery = new QLineEdit(this); d->allQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->allQuery, 3, 1); - label = new QLabel(tr("with <B>at least one</B> of the words:"), this); - gLayout->addWidget(label, 4, 0); + d->atLeastLabel = new QLabel(this); + gLayout->addWidget(d->atLeastLabel, 4, 0); d->atLeastQuery = new QLineEdit(this); d->atLeastQuery->setCompleter(&d->searchCompleter); gLayout->addWidget(d->atLeastQuery, 4, 1); @@ -490,6 +511,8 @@ QHelpSearchQueryWidget::QHelpSearchQueryWidget(QWidget *parent) vLayout->addWidget(d->advancedSearchWidget); d->advancedSearchWidget->hide(); + d->retranslate(); + connect(d->exactQuery, SIGNAL(returnPressed()), this, SIGNAL(search())); connect(d->similarQuery, SIGNAL(returnPressed()), this, SIGNAL(search())); connect(d->withoutQuery, SIGNAL(returnPressed()), this, SIGNAL(search())); @@ -531,4 +554,14 @@ void QHelpSearchQueryWidget::focusInEvent(QFocusEvent *focusEvent) } } +/*! \reimp +*/ +void QHelpSearchQueryWidget::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::LanguageChange) + d->retranslate(); + else + QWidget::changeEvent(event); +} + QT_END_NAMESPACE diff --git a/tools/assistant/lib/qhelpsearchquerywidget.h b/tools/assistant/lib/qhelpsearchquerywidget.h index a99bae0..2afc4b4 100644 --- a/tools/assistant/lib/qhelpsearchquerywidget.h +++ b/tools/assistant/lib/qhelpsearchquerywidget.h @@ -74,7 +74,8 @@ Q_SIGNALS: void search(); private: - void focusInEvent(QFocusEvent *focusEvent); + virtual void focusInEvent(QFocusEvent *focusEvent); + virtual void changeEvent(QEvent *event); private: QHelpSearchQueryWidgetPrivate *d; diff --git a/tools/assistant/lib/qhelpsearchresultwidget.cpp b/tools/assistant/lib/qhelpsearchresultwidget.cpp index 3cac880..a3f5aed 100644 --- a/tools/assistant/lib/qhelpsearchresultwidget.cpp +++ b/tools/assistant/lib/qhelpsearchresultwidget.cpp @@ -408,6 +408,14 @@ QHelpSearchResultWidget::QHelpSearchResultWidget(QHelpSearchEngine *engine) connect(engine, SIGNAL(searchingFinished(int)), d, SLOT(setResults(int))); } +/*! \reimp +*/ +void QHelpSearchResultWidget::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::LanguageChange) + d->setResults(d->searchEngine->hitCount()); +} + /*! Destroys the search result widget. */ diff --git a/tools/assistant/lib/qhelpsearchresultwidget.h b/tools/assistant/lib/qhelpsearchresultwidget.h index d078079..ff29adc 100644 --- a/tools/assistant/lib/qhelpsearchresultwidget.h +++ b/tools/assistant/lib/qhelpsearchresultwidget.h @@ -75,6 +75,7 @@ private: QHelpSearchResultWidgetPrivate *d; QHelpSearchResultWidget(QHelpSearchEngine *engine); + virtual void changeEvent(QEvent *event); }; QT_END_NAMESPACE |