summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-10-09 08:05:13 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-10-09 08:05:13 (GMT)
commitcc9f9ba0bb389b014929af6f8f53e3248463612d (patch)
tree48da8c516bb1745bb1b576f104c0def4e6377818
parent2c6f1075474f6b8086cc6abf7978aee9421761c8 (diff)
downloadswift-contrib-cc9f9ba0bb389b014929af6f8f53e3248463612d.zip
swift-contrib-cc9f9ba0bb389b014929af6f8f53e3248463612d.tar.bz2
Filter chat view actions again.
-rw-r--r--Swift/QtUI/QtChatView.cpp4
-rw-r--r--Swift/QtUI/QtWebView.cpp3
2 files changed, 2 insertions, 5 deletions
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 7bb5818..97ce992 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -25,73 +25,71 @@
#include "QtSwiftUtil.h"
namespace Swift {
QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent) : QWidget(parent), fontSizeSteps_(0) {
theme_ = theme;
QVBoxLayout* mainLayout = new QVBoxLayout(this);
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0,0,0,0);
webView_ = new QtWebView(this);
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(handleClearRequested()));
connect(webView_, SIGNAL(fontGrowRequested()), SLOT(increaseFontSize()));
connect(webView_, SIGNAL(fontShrinkRequested()), SLOT(decreaseFontSize()));
#ifdef Q_WS_X11
/* To give a border on Linux, where it looks bad without */
QStackedWidget* stack = new QStackedWidget(this);
stack->addWidget(webView_);
stack->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
stack->setLineWidth(2);
mainLayout->addWidget(stack);
#else
mainLayout->addWidget(webView_);
#endif
#ifdef SWIFT_EXPERIMENTAL_FT
setAcceptDrops(true);
#endif
webPage_ = new QWebPage(this);
webPage_->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
-#ifdef SWIFT_EXPERIMENTAL_FT
- webPage_->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
-#endif
+ //webPage_->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
webView_->setPage(webPage_);
connect(webPage_, SIGNAL(selectionChanged()), SLOT(copySelectionToClipboard()));
viewReady_ = false;
isAtBottom_ = true;
resetView();
}
void QtChatView::handleClearRequested() {
QMessageBox messageBox(this);
messageBox.setWindowTitle(tr("Clear log"));
messageBox.setText(tr("You are about to clear the contents of your chat log."));
messageBox.setInformativeText(tr("Are you sure?"));
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);
}
void QtChatView::addMessage(boost::shared_ptr<ChatSnippet> snippet) {
if (viewReady_) {
addToDOM(snippet);
} else {
/* If this asserts, the previous queuing code was necessary and should be reinstated */
assert(false);
}
}
QWebElement QtChatView::snippetToDOM(boost::shared_ptr<ChatSnippet> snippet) {
diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp
index d393b6c..388f06a 100644
--- a/Swift/QtUI/QtWebView.cpp
+++ b/Swift/QtUI/QtWebView.cpp
@@ -15,69 +15,68 @@ namespace Swift {
QtWebView::QtWebView(QWidget* parent) : QWebView(parent), fontSizeIsMinimal(false) {
setRenderHint(QPainter::SmoothPixmapTransform);
filteredActions.push_back(QWebPage::CopyLinkToClipboard);
filteredActions.push_back(QWebPage::CopyImageToClipboard);
filteredActions.push_back(QWebPage::Copy);
}
void QtWebView::keyPressEvent(QKeyEvent* event) {
Qt::KeyboardModifiers modifiers = event->modifiers();
int key = event->key();
if (modifiers == Qt::ShiftModifier && (key == Qt::Key_PageUp || key == Qt::Key_PageDown)) {
modifiers = Qt::NoModifier;
}
QKeyEvent* translatedEvent = new QKeyEvent(QEvent::KeyPress,
key,
modifiers,
event->text(),
event->isAutoRepeat(),
event->count());
QWebView::keyPressEvent(translatedEvent);
delete translatedEvent;
}
void QtWebView::dragEnterEvent(QDragEnterEvent*) {
}
void QtWebView::setFontSizeIsMinimal(bool minimum) {
fontSizeIsMinimal = minimum;
}
void QtWebView::contextMenuEvent(QContextMenuEvent* ev) {
// Filter out the relevant actions from the standard actions
QMenu* menu = page()->createStandardContextMenu();
- /*
QList<QAction*> actions(menu->actions());
for (int i = 0; i < actions.size(); ++i) {
QAction* action = actions.at(i);
bool removeAction = true;
for(size_t j = 0; j < filteredActions.size(); ++j) {
if (action == pageAction(filteredActions[j])) {
removeAction = false;
break;
}
}
if (removeAction) {
menu->removeAction(action);
}
- }*/
+ }
// Add our own custom actions
menu->addAction(tr("Clear"), this, SIGNAL(clearRequested()));
menu->addAction(tr("Increase font size"), this, SIGNAL(fontGrowRequested()));
QAction* shrink = new QAction(tr("Decrease font size"), this);
shrink->setEnabled(!fontSizeIsMinimal);
connect(shrink, SIGNAL(triggered()), this, SIGNAL(fontShrinkRequested()));
menu->addAction(shrink);
menu->exec(ev->globalPos());
delete menu;
}
void QtWebView::focusInEvent(QFocusEvent* event) {
QWebView::focusInEvent(event);
emit gotFocus();
}
}