diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-09-05 12:59:02 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-09-05 12:59:02 (GMT) |
commit | 89f18c8af344fc94bb5cf19035c74385d1c9df9c (patch) | |
tree | d215e1ad1267431ea10d511d6f429985b5bf2800 /Swift | |
parent | 5b974445a8ce78ca73bdfae9a8114857e4fc3d36 (diff) | |
download | swift-89f18c8af344fc94bb5cf19035c74385d1c9df9c.zip swift-89f18c8af344fc94bb5cf19035c74385d1c9df9c.tar.bz2 |
Added "Clear" context menu for chat log.
Resolves: #225
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/QtUI/QtChatView.cpp | 37 | ||||
-rw-r--r-- | Swift/QtUI/QtChatView.h | 1 | ||||
-rw-r--r-- | Swift/QtUI/QtWebView.cpp | 7 | ||||
-rw-r--r-- | Swift/QtUI/QtWebView.h | 1 |
4 files changed, 27 insertions, 19 deletions
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp index 145371f..4bae755 100644 --- a/Swift/QtUI/QtChatView.cpp +++ b/Swift/QtUI/QtChatView.cpp @@ -31,6 +31,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())); #ifdef Q_WS_X11 /* To give a border on Linux, where it looks bad without */ QStackedWidget* stack = new QStackedWidget(this); @@ -51,22 +52,7 @@ QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent) : QWidget(parent) { connect(webPage_, SIGNAL(selectionChanged()), SLOT(copySelectionToClipboard())); viewReady_ = false; - QString pageHTML = theme_->getTemplate(); - pageHTML.replace("==bodyBackground==", "background-color:#e3e3e3"); - pageHTML.replace(pageHTML.indexOf("%@"), 2, theme_->getBase()); - if (pageHTML.count("%@") > 3) { - pageHTML.replace(pageHTML.indexOf("%@"), 2, theme_->getMainCSS()); - } - pageHTML.replace(pageHTML.indexOf("%@"), 2, "Variants/Blue on Green.css"); - pageHTML.replace(pageHTML.indexOf("%@"), 2, ""/*headerSnippet.getContent()*/); - pageHTML.replace(pageHTML.indexOf("%@"), 2, ""/*footerSnippet.getContent()*/); - webPage_->mainFrame()->setHtml(pageHTML); - document_ = webPage_->mainFrame()->documentElement(); - QWebElement chatElement = document_.findFirst("#Chat"); - newInsertPoint_ = chatElement.clone(); - newInsertPoint_.setOuterXml("<div id='swift_insert'/>"); - chatElement.appendInside(newInsertPoint_); - Q_ASSERT(!newInsertPoint_.isNull()); + resetView(); } void QtChatView::handleKeyPressEvent(QKeyEvent* event) { @@ -163,4 +149,23 @@ void QtChatView::handleViewLoadFinished(bool ok) { addQueuedSnippets(); } +void QtChatView::resetView() { + QString pageHTML = theme_->getTemplate(); + pageHTML.replace("==bodyBackground==", "background-color:#e3e3e3"); + pageHTML.replace(pageHTML.indexOf("%@"), 2, theme_->getBase()); + if (pageHTML.count("%@") > 3) { + pageHTML.replace(pageHTML.indexOf("%@"), 2, theme_->getMainCSS()); + } + pageHTML.replace(pageHTML.indexOf("%@"), 2, "Variants/Blue on Green.css"); + pageHTML.replace(pageHTML.indexOf("%@"), 2, ""/*headerSnippet.getContent()*/); + pageHTML.replace(pageHTML.indexOf("%@"), 2, ""/*footerSnippet.getContent()*/); + webPage_->mainFrame()->setHtml(pageHTML); + document_ = webPage_->mainFrame()->documentElement(); + QWebElement chatElement = document_.findFirst("#Chat"); + newInsertPoint_ = chatElement.clone(); + newInsertPoint_.setOuterXml("<div id='swift_insert'/>"); + chatElement.appendInside(newInsertPoint_); + Q_ASSERT(!newInsertPoint_.isNull()); +} + } diff --git a/Swift/QtUI/QtChatView.h b/Swift/QtUI/QtChatView.h index e60c92f..8c1a99a 100644 --- a/Swift/QtUI/QtChatView.h +++ b/Swift/QtUI/QtChatView.h @@ -41,6 +41,7 @@ namespace Swift { void scrollToBottom(); void handleLinkClicked(const QUrl&); void handleKeyPressEvent(QKeyEvent* event); + void resetView(); private slots: void handleViewLoadFinished(bool); diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp index 93ecc18..df8479d 100644 --- a/Swift/QtUI/QtWebView.cpp +++ b/Swift/QtUI/QtWebView.cpp @@ -31,17 +31,18 @@ void QtWebView::keyPressEvent(QKeyEvent* event) { delete translatedEvent; } -void QtWebView::dragEnterEvent(QDragEnterEvent *event) { +void QtWebView::dragEnterEvent(QDragEnterEvent*) { } void QtWebView::contextMenuEvent(QContextMenuEvent* ev) { + QMenu menu(this); QAction* copyLinkAction = pageAction(QWebPage::CopyLinkToClipboard); if (copyLinkAction) { - QMenu menu(this); menu.addAction(copyLinkAction); - menu.exec(ev->globalPos()); } + menu.addAction("Clear", this, SIGNAL(clearRequested())); + menu.exec(ev->globalPos()); } void QtWebView::focusInEvent(QFocusEvent* event) { diff --git a/Swift/QtUI/QtWebView.h b/Swift/QtUI/QtWebView.h index 171330d..f60e5ef 100644 --- a/Swift/QtUI/QtWebView.h +++ b/Swift/QtUI/QtWebView.h @@ -20,6 +20,7 @@ namespace Swift { signals: void gotFocus(); + void clearRequested(); protected: void focusInEvent(QFocusEvent* event); |