summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/QtUI/QtChatView.cpp15
-rw-r--r--Swift/QtUI/QtChatView.h1
2 files changed, 15 insertions, 1 deletions
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 4738da3..9646afb 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -15,6 +15,7 @@
#include <QKeyEvent>
#include <QStackedWidget>
#include <QTimer>
+#include <QMessageBox>
#include "QtWebView.h"
#include "QtChatTheme.h"
@@ -32,7 +33,7 @@ QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent) : QWidget(parent) {
connect(webView_, SIGNAL(linkClicked(const QUrl&)), SLOT(handleLinkClicked(const QUrl&)));
connect(webView_, SIGNAL(loadFinished(bool)), SLOT(handleViewLoadFinished(bool)));
connect(webView_, SIGNAL(gotFocus()), SIGNAL(gotFocus()));
- connect(webView_, SIGNAL(clearRequested()), SLOT(resetView()));
+ connect(webView_, SIGNAL(clearRequested()), SLOT(handleClearRequested()));
#ifdef Q_WS_X11
/* To give a border on Linux, where it looks bad without */
QStackedWidget* stack = new QStackedWidget(this);
@@ -54,6 +55,18 @@ QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent) : QWidget(parent) {
resetView();
}
+void QtChatView::handleClearRequested() {
+ QMessageBox messageBox(this);
+ messageBox.setText("Clear log.");
+ messageBox.setInformativeText("Are you sure you want to clear your chat log?");
+ messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+ messageBox.setDefaultButton(QMessageBox::Yes);
+ int button = messageBox.exec();
+ if (button == QMessageBox::Yes) {
+ resetView();
+ }
+}
+
void QtChatView::handleKeyPressEvent(QKeyEvent* event) {
webView_->keyPressEvent(event);
}
diff --git a/Swift/QtUI/QtChatView.h b/Swift/QtUI/QtChatView.h
index 84738d4..58b33df 100644
--- a/Swift/QtUI/QtChatView.h
+++ b/Swift/QtUI/QtChatView.h
@@ -46,6 +46,7 @@ namespace Swift {
private slots:
void handleViewLoadFinished(bool);
void handleFrameSizeChanged();
+ void handleClearRequested();
private:
void headerEncode();