From 387f754092fbf0942b24b93942582f8cf8857751 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 19 Oct 2011 14:36:25 +0200 Subject: [PATCH] fixed translation on dialog --- src/core/UBApplicationController.cpp | 4 +-- src/core/UBPersistenceManager.cpp | 7 ++--- src/gui/UBMainWindow.cpp | 24 ++++++++++++++- src/gui/UBMainWindow.h | 5 ++++ src/gui/UBUpdateDlg.cpp | 41 +++++++++++++------------- src/network/UBNetworkAccessManager.cpp | 20 ++++++++----- src/web/browser/WBWebView.cpp | 3 +- 7 files changed, 64 insertions(+), 40 deletions(-) diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index 4fad106a..2ac37db1 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -563,9 +563,7 @@ void UBApplicationController::downloadJsonFinished(QString currentJson) } else { if (isNoUpdateDisplayed) { - QMessageBox msgBox; - msgBox.setText (tr ("No update available")); - msgBox.exec(); + mMainWindow->information(tr("Update"), tr("No update available")); } } } diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 3987f615..bdb0a11b 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -14,6 +14,7 @@ */ #include "UBPersistenceManager.h" +#include "gui/UBMainWindow.h" #include @@ -1005,11 +1006,7 @@ void UBPersistenceManager::checkIfDocumentRepositoryExists() QString humanPath = QDir::cleanPath(mDocumentRepositoryPath); humanPath = QDir::toNativeSeparators(humanPath); - QMessageBox::question( - QApplication::activeWindow(), - tr("Document Repository Loss"), - tr("Sankore has lost access to the document repository '%1'. Unfortunately the application must shut down to avoid data corruption. Latest changes may be lost as well.").arg(humanPath), - QMessageBox::Yes); + UBApplication::mainWindow->warning(tr("Document Repository Loss"),tr("Sankore has lost access to the document repository '%1'. Unfortunately the application must shut down to avoid data corruption. Latest changes may be lost as well.").arg(humanPath)); UBApplication::quit(); } diff --git a/src/gui/UBMainWindow.cpp b/src/gui/UBMainWindow.cpp index 11d8b41c..1bc2cab5 100644 --- a/src/gui/UBMainWindow.cpp +++ b/src/gui/UBMainWindow.cpp @@ -16,7 +16,6 @@ #include #include "UBMainWindow.h" - #include "core/UBApplication.h" #include "core/UBApplicationController.h" #include "board/UBBoardController.h" @@ -160,3 +159,26 @@ bool UBMainWindow::yesNoQuestion(QString windowTitle, QString text) return messageBox.clickedButton() == yesButton; } + +void UBMainWindow::oneButtonMessageBox(QString windowTitle, QString text, QMessageBox::Icon type) +{ + QMessageBox messageBox; + messageBox.setParent(this); + messageBox.setWindowFlags(Qt::Dialog); + messageBox.setWindowTitle(windowTitle); + messageBox.setText(text); + messageBox.addButton(tr("Ok"),QMessageBox::YesRole); + messageBox.setIcon(type); + messageBox.exec(); +} + +void UBMainWindow::warning(QString windowTitle, QString text) +{ + oneButtonMessageBox(windowTitle,text, QMessageBox::Warning); +} + +void UBMainWindow::information(QString windowTitle, QString text) +{ + oneButtonMessageBox(windowTitle, text, QMessageBox::Information); +} + diff --git a/src/gui/UBMainWindow.h b/src/gui/UBMainWindow.h index 2bd6fc25..4150bbec 100644 --- a/src/gui/UBMainWindow.h +++ b/src/gui/UBMainWindow.h @@ -20,6 +20,7 @@ #include #include #include +#include class QStackedLayout; @@ -41,7 +42,10 @@ class UBMainWindow : public QMainWindow, public Ui::MainWindow void addDocumentsWidget(QWidget *pWidget); void switchToDocumentsWidget(); + bool yesNoQuestion(QString windowTitle, QString text); + void warning(QString windowTitle, QString text); + void information(QString windowTitle, QString text); signals: void closeEvent_Signal( QCloseEvent *event ); @@ -50,6 +54,7 @@ class UBMainWindow : public QMainWindow, public Ui::MainWindow void onExportDone(); protected: + void oneButtonMessageBox(QString windowTitle, QString text, QMessageBox::Icon type); virtual void keyPressEvent(QKeyEvent *event); virtual void closeEvent (QCloseEvent *event); diff --git a/src/gui/UBUpdateDlg.cpp b/src/gui/UBUpdateDlg.cpp index 2c2ba56b..c0651258 100644 --- a/src/gui/UBUpdateDlg.cpp +++ b/src/gui/UBUpdateDlg.cpp @@ -12,28 +12,29 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include #include #include "UBUpdateDlg.h" +#include "core/UBApplication.h" +#include "UBMainWindow.h" #include "core/memcheck.h" UBUpdateDlg::UBUpdateDlg(QWidget *parent, int nbFiles, const QString& bkpPath) - : QDialog(parent) - , mMainLayout(NULL) - , mNbFilesLabel(NULL) - , mBkpLabel(NULL) - , mBkpPath(NULL) - , mBrowseBttn(NULL) - , mpDlgBttn(NULL) - , mLayout(NULL) - , mHLayout(NULL) - , mStackedWidget(NULL) - , mDialogWidget(NULL) - , mProgressWidget(NULL) - , mProgressLayout(NULL) - , mProgressLabel(NULL) + : QDialog(parent) + , mMainLayout(NULL) + , mNbFilesLabel(NULL) + , mBkpLabel(NULL) + , mBkpPath(NULL) + , mBrowseBttn(NULL) + , mpDlgBttn(NULL) + , mLayout(NULL) + , mHLayout(NULL) + , mStackedWidget(NULL) + , mDialogWidget(NULL) + , mProgressWidget(NULL) + , mProgressLayout(NULL) + , mProgressLabel(NULL) { mDialogWidget = new QWidget(this); @@ -178,18 +179,16 @@ void UBUpdateDlg::onUpdate() void UBUpdateDlg::onFilesUpdated(bool bResult) { - this->hide(); + this->hide(); QString qsMsg; - if (bResult) - { + if (bResult) { qsMsg = tr("Files update successful!\nPlease reboot the application to access the updated documents."); } - else - { + else { qsMsg = tr("An error occured during the update. The files have not been affected."); } - QMessageBox::information(this, tr("Files update results"), qsMsg, QMessageBox::Ok); + UBApplication::mainWindow->information(tr("Files update results"), qsMsg); } QString UBUpdateDlg::backupPath() diff --git a/src/network/UBNetworkAccessManager.cpp b/src/network/UBNetworkAccessManager.cpp index 6529c388..c2b7aa10 100644 --- a/src/network/UBNetworkAccessManager.cpp +++ b/src/network/UBNetworkAccessManager.cpp @@ -160,14 +160,18 @@ void UBNetworkAccessManager::sslErrors(QNetworkReply *reply, const QListurl().toString()).arg(errors), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No); - - if (ret == QMessageBox::Yes) - { + QMessageBox messageBox; + messageBox.setParent(mainWindow); + messageBox.setWindowFlags(Qt::Dialog); + messageBox.setWindowTitle(QCoreApplication::applicationName()); + messageBox.setText(tr("SSL Errors:\n\n%1\n\n%2\n\n" + "Do you want to ignore these errors for this host?").arg(reply->url().toString()).arg(errors)); + QPushButton* yesButton = messageBox.addButton(tr("Yes"),QMessageBox::YesRole); + messageBox.addButton(tr("No"),QMessageBox::NoRole); + messageBox.setIcon(QMessageBox::Question); + messageBox.exec(); + + if(messageBox.clickedButton() == yesButton) { reply->ignoreSslErrors(); sslTrustedHostList.append(replyHost); } diff --git a/src/web/browser/WBWebView.cpp b/src/web/browser/WBWebView.cpp index 23fb6cb5..eb0be66f 100644 --- a/src/web/browser/WBWebView.cpp +++ b/src/web/browser/WBWebView.cpp @@ -168,8 +168,7 @@ void WBWebPage::handleUnsupportedContent(QNetworkReply *reply) messageBox.setText(tr("Download PDF Document: would you prefer to download the PDF file or add it to the current Sankore document?")); messageBox.addButton(tr("Download"), QMessageBox::AcceptRole); - QAbstractButton *addButton = - messageBox.addButton(tr("Add to Current Document"), QMessageBox::AcceptRole); + QAbstractButton *addButton = messageBox.addButton(tr("Add to Current Document"), QMessageBox::AcceptRole); messageBox.exec(); if (messageBox.clickedButton() == addButton)