summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtChatView.cpp3
-rw-r--r--Swift/QtUI/QtChatView.h3
-rw-r--r--Swift/QtUI/QtChatWindow.cpp10
-rw-r--r--Swift/QtUI/QtWebView.cpp39
-rw-r--r--Swift/QtUI/QtWebView.h24
-rw-r--r--Swift/QtUI/SConscript1
6 files changed, 60 insertions, 20 deletions
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 3324108..90b567f 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -19,15 +19,14 @@
namespace Swift {
QtChatView::QtChatView(QWidget* parent) : QWidget(parent) {
- setFocusPolicy(Qt::NoFocus);
QVBoxLayout* mainLayout = new QVBoxLayout(this);
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0,0,0,0);
webView_ = new QtWebView(this);
- webView_->setFocusPolicy(Qt::NoFocus);
connect(webView_, SIGNAL(linkClicked(const QUrl&)), SLOT(handleLinkClicked(const QUrl&)));
connect(webView_, SIGNAL(loadFinished(bool)), SLOT(handleViewLoadFinished(bool)));
+ connect(webView_, SIGNAL(gotFocus()), SIGNAL(gotFocus()));
#ifdef Q_WS_X11
/* To give a border on Linux, where it looks bad without */
QStackedWidget* stack = new QStackedWidget(this);
diff --git a/Swift/QtUI/QtChatView.h b/Swift/QtUI/QtChatView.h
index ea64265..f60d049 100644
--- a/Swift/QtUI/QtChatView.h
+++ b/Swift/QtUI/QtChatView.h
@@ -25,6 +25,9 @@ namespace Swift {
void addMessage(const ChatSnippet& snippet);
bool isScrolledToBottom() const;
+ signals:
+ void gotFocus();
+
public slots:
void copySelectionToClipboard();
void scrollToBottom();
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index f39353c..5b73fec 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -44,7 +44,6 @@ QtChatWindow::QtChatWindow(const QString &contact, UIEventStream* eventStream) :
layout->addWidget(logRosterSplitter);
messageLog_ = new QtChatView(this);
- messageLog_->setFocusPolicy(Qt::NoFocus);
logRosterSplitter->addWidget(messageLog_);
treeWidget_ = new QtTreeWidget(eventStream_);
@@ -59,6 +58,7 @@ QtChatWindow::QtChatWindow(const QString &contact, UIEventStream* eventStream) :
midBarLayout->setContentsMargins(0,0,0,0);
midBarLayout->setSpacing(2);
midBarLayout->addStretch();
+
labelsWidget_ = new QComboBox(this);
labelsWidget_->setFocusPolicy(Qt::NoFocus);
labelsWidget_->hide();
@@ -76,9 +76,13 @@ QtChatWindow::QtChatWindow(const QString &contact, UIEventStream* eventStream) :
connect(input_, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
connect(input_, SIGNAL(textChanged()), this, SLOT(handleInputChanged()));
setFocusProxy(input_);
+ logRosterSplitter->setFocusProxy(input_);
+ midBar->setFocusProxy(input_);
+ messageLog_->setFocusProxy(input_);
connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(qAppFocusChanged(QWidget*, QWidget*)));
-
+ connect(messageLog_, SIGNAL(gotFocus()), input_, SLOT(setFocus()));
resize(400,300);
+ input_->setFocus();
}
QtChatWindow::~QtChatWindow() {
@@ -347,6 +351,7 @@ void QtChatWindow::handleInputChanged() {
void QtChatWindow::show() {
QWidget::show();
emit windowOpening();
+ input_->setFocus();
}
void QtChatWindow::activate() {
@@ -354,6 +359,7 @@ void QtChatWindow::activate() {
QWidget::show();
}
emit wantsToActivate();
+ input_->setFocus();
}
void QtChatWindow::resizeEvent(QResizeEvent*) {
diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp
new file mode 100644
index 0000000..a97357d
--- /dev/null
+++ b/Swift/QtUI/QtWebView.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+
+#include "Swift/QtUI/QtWebView.h"
+
+#include <QKeyEvent>
+#include <QFocusEvent>
+
+namespace Swift {
+QtWebView::QtWebView(QWidget* parent) : QWebView(parent) {
+
+}
+
+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::focusInEvent(QFocusEvent* event) {
+ QWebView::focusInEvent(event);
+ emit gotFocus();
+}
+
+}
diff --git a/Swift/QtUI/QtWebView.h b/Swift/QtUI/QtWebView.h
index 8ed5842..3ab5c64 100644
--- a/Swift/QtUI/QtWebView.h
+++ b/Swift/QtUI/QtWebView.h
@@ -11,22 +11,14 @@
namespace Swift {
class QtWebView : public QWebView {
+ Q_OBJECT
public:
- QtWebView(QWidget* parent) : QWebView(parent) {}
- void 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;
- };
+ QtWebView(QWidget* parent);
+ void keyPressEvent(QKeyEvent* event);
+ signals:
+ void gotFocus();
+
+ protected:
+ void focusInEvent(QFocusEvent* event);
};
}
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index ddc0b31..6c30f42 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -105,6 +105,7 @@ sources = [
"ContextMenus/QtContextMenu.cpp",
"QtSubscriptionRequestWindow.cpp",
"QtRosterHeader.cpp",
+ "QtWebView.cpp",
"qrc_DefaultTheme.cc",
"qrc_Swift.cc",
]