1
// Copyright 2010, Google Inc.
2
// All rights reserved.
4
// Redistribution and use in source and binary forms, with or without
5
// modification, are permitted provided that the following conditions are
8
// * Redistributions of source code must retain the above copyright
9
// notice, this list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above
11
// copyright notice, this list of conditions and the following disclaimer
12
// in the documentation and/or other materials provided with the
14
// * Neither the name of Google Inc. nor the names of its
15
// contributors may be used to endorse or promote products derived from
16
// this software without specific prior written permission.
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
#include "gui/error_message_dialog/error_message_dialog.h"
32
#include <QtCore/QTimer>
33
#include <QtGui/QtGui>
34
#include <QtGui/QMessageBox>
35
#include "base/base.h"
37
DEFINE_string(error_type, "", "type of error");
43
void OnFatal(const QString &message) {
44
// we don't use QMessageBox::critical() here
45
// to set WindowStaysOnTopHint
46
QMessageBox message_box(QMessageBox::Critical,
47
QObject::tr("Mozc Fatal Error"),
48
message, QMessageBox::Ok, NULL,
50
Qt::MSWindowsFixedSizeDialogHint |
51
Qt::WindowStaysOnTopHint);
52
DeleyedMessageDialogHandler handler(&message_box);
57
DeleyedMessageDialogHandler::DeleyedMessageDialogHandler(
58
QMessageBox *message_box)
59
: message_box_(message_box) {}
61
DeleyedMessageDialogHandler::~DeleyedMessageDialogHandler() {}
63
void DeleyedMessageDialogHandler::Exec() {
64
const int kDisableInterval = 3000;
65
QTimer::singleShot(kDisableInterval, this, SLOT(EnableOkButton()));
66
QAbstractButton *button = message_box_->button(QMessageBox::Ok);
68
button->setEnabled(false);
73
void DeleyedMessageDialogHandler::EnableOkButton() {
74
QAbstractButton *button = message_box_->button(QMessageBox::Ok);
76
button->setEnabled(true);
80
void ErrorMessageDialog::Show() {
81
// defining all literal messages inside Show() method
83
if (FLAGS_error_type == "server_timeout") {
84
OnFatal(QObject::tr("Conversion engine is not responding. "
85
"Please restart this application."));
86
} else if (FLAGS_error_type == "server_broken_message") {
87
OnFatal(QObject::tr("Connecting to an incompatible conversion engine. "
88
"Please restart your computer to enable Mozc. "
89
"If this problem persists, please uninstall Mozc "
90
"and install it again."));
91
} else if (FLAGS_error_type == "server_version_mismatch") {
92
OnFatal(QObject::tr("Conversion engine has been upgraded. "
93
"Please restart this application to enable conversion engine. "
94
"If the problem persists, please restart your computer."));
95
} else if (FLAGS_error_type == "server_shutdown") {
96
OnFatal(QObject::tr("Conversion engine is killed unexceptionally. "
97
"Restarting the engine..."));
98
} else if (FLAGS_error_type == "server_fatal") {
99
OnFatal(QObject::tr("Cannot start conversion engine. "
100
"Please restart your computer."));
101
} else if (FLAGS_error_type == "renderer_version_mismatch") {
102
OnFatal(QObject::tr("Candidate window renderer has been upgraded. "
103
"Please restart this application to enable new candidate window renderer. "
104
"If the problem persists, please restart your computer."));
105
} else if (FLAGS_error_type == "renderer_fatal") {
106
OnFatal(QObject::tr("Cannot start candidate window renderer. "
107
"Please restart your computer."));