summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-09-08 16:07:05 (GMT)
committerTobias Markmann <tm@ayena.de>2016-09-08 16:07:05 (GMT)
commit3fe4d78c15c289011493136c6360c14e755cabb3 (patch)
tree2306aa96d59aa1b0977aa5cc160c63e44a4c6cc3 /Swift/QtUI
parent615b87497cd8d4eedc386f002931d6d353f53ccd (diff)
downloadswift-3fe4d78c15c289011493136c6360c14e755cabb3.zip
swift-3fe4d78c15c289011493136c6360c14e755cabb3.tar.bz2
Improve visibility of currently focused chat input in trellis mode
The default focus indicator on the text input fields in chat windows becomes harder to notice in trellis mode as there are many similar looking chat windows visible at the same time. This change increases the visibility of the focus indication border on Windows and will enable the standard blue focus halo on OS X for focused chat inputs in trellis mode. Test-Information: Tested with Qt 5.5.1 on OS X 10.11.6 and Qt 5.5.1 on Windows 8. Change-Id: If9fe9edea6fef292bb99eabbb125c7a9ec20dcc2
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtChatWindow.cpp7
-rw-r--r--Swift/QtUI/QtChatWindow.h1
-rw-r--r--Swift/QtUI/QtTabbable.h3
-rw-r--r--Swift/QtUI/QtTextEdit.cpp23
-rw-r--r--Swift/QtUI/QtTextEdit.h3
-rw-r--r--Swift/QtUI/Trellis/QtDynamicGridLayout.cpp20
-rw-r--r--Swift/QtUI/Trellis/QtDynamicGridLayout.h1
7 files changed, 56 insertions, 2 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index a828210..0da4563 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -843,6 +843,13 @@ std::string QtChatWindow::getID() const {
return id_;
}
+void QtChatWindow::setEmphasiseFocus(bool emphasise) {
+ input_->setAttribute(Qt::WA_MacShowFocusRect, emphasise);
+#ifdef SWIFTEN_PLATFORM_WINDOWS
+ input_->setEmphasiseFocus(emphasise);
+#endif
+}
+
void QtChatWindow::showRoomConfigurationForm(Form::ref form) {
if (mucConfigurationWindow_) {
delete mucConfigurationWindow_.data();
diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h
index 25a1948..08ad7ad 100644
--- a/Swift/QtUI/QtChatWindow.h
+++ b/Swift/QtUI/QtChatWindow.h
@@ -134,6 +134,7 @@ namespace Swift {
virtual void showBookmarkWindow(const MUCBookmark& bookmark);
virtual void setBookmarkState(RoomBookmarkState bookmarkState);
virtual std::string getID() const;
+ virtual void setEmphasiseFocus(bool emphasise);
public slots:
void handleChangeSplitterState(QByteArray state);
diff --git a/Swift/QtUI/QtTabbable.h b/Swift/QtUI/QtTabbable.h
index c2d0961..4073ab4 100644
--- a/Swift/QtUI/QtTabbable.h
+++ b/Swift/QtUI/QtTabbable.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2015 Isode Limited.
+ * Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -20,6 +20,7 @@ namespace Swift {
virtual AlertType getWidgetAlertState() {return NoActivity;}
virtual int getCount() {return 0;}
virtual std::string getID() const = 0;
+ virtual void setEmphasiseFocus(bool /*emphasise*/) {}
protected:
QtTabbable();
diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp
index 4ffd32a..60dac9b 100644
--- a/Swift/QtUI/QtTextEdit.cpp
+++ b/Swift/QtUI/QtTextEdit.cpp
@@ -17,7 +17,6 @@
#include <QTextDocument>
#include <Swiften/Base/Log.h>
-#include <Swiften/Base/foreach.h>
#include <Swift/Controllers/SettingConstants.h>
@@ -81,14 +80,36 @@ void QtTextEdit::keyPressEvent(QKeyEvent* event) {
}
}
+void QtTextEdit::setEmphasiseFocus(bool emphasise) {
+ emphasiseFocus_ = emphasise;
+ updateEmphasisedFocus();
+}
+
+void QtTextEdit::updateEmphasisedFocus() {
+ if (emphasiseFocus_) {
+ if (hasFocus()) {
+ setStyleSheet("border: 2px solid palette(highlight);");
+ }
+ else {
+ setStyleSheet("");
+ }
+ }
+ else {
+ setStyleSheet("");
+ }
+ handleTextChanged();
+}
+
void QtTextEdit::focusInEvent(QFocusEvent* event) {
receivedFocus();
QTextEdit::focusInEvent(event);
+ updateEmphasisedFocus();
}
void QtTextEdit::focusOutEvent(QFocusEvent* event) {
lostFocus();
QTextEdit::focusOutEvent(event);
+ updateEmphasisedFocus();
}
void QtTextEdit::handleTextChanged() {
diff --git a/Swift/QtUI/QtTextEdit.h b/Swift/QtUI/QtTextEdit.h
index 0c2b740..921c4b9 100644
--- a/Swift/QtUI/QtTextEdit.h
+++ b/Swift/QtUI/QtTextEdit.h
@@ -26,6 +26,7 @@ namespace Swift {
QtTextEdit(SettingsProvider* settings, QWidget* parent = nullptr);
virtual ~QtTextEdit();
virtual QSize sizeHint() const;
+ void setEmphasiseFocus(bool emphasise);
signals:
void wordCorrected(QString& word);
@@ -52,6 +53,7 @@ namespace Swift {
void setUpSpellChecker();
void spellCheckerSettingsWindow();
PositionPair getWordFromCursor(int cursorPosition);
+ void updateEmphasisedFocus();
private:
SpellChecker* checker_;
@@ -59,5 +61,6 @@ namespace Swift {
std::vector<QAction*> replaceWordActions_;
SettingsProvider* settings_;
QPointer<QtSpellCheckerWindow> spellCheckerWindow_;
+ bool emphasiseFocus_ = false;
};
}
diff --git a/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp b/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp
index 3d80d95..5600cc8 100644
--- a/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp
+++ b/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp
@@ -48,6 +48,7 @@ int QtDynamicGridLayout::addTab(QtTabbable* tab, const QString& title) {
if (tabWidget) {
tabWidget->addTab(tab, title);
}
+ tab->setEmphasiseFocus(getDimension().width() > 1 || getDimension().height() > 1);
return tabWidget ? indexOf(tab) : -1;
}
@@ -318,6 +319,25 @@ void QtDynamicGridLayout::setDimensions(const QSize& dim) {
resizing_ = false;
setCurrentWidget(restoredWidget);
+
+ updateEmphasiseFocusOnTabs();
+}
+
+void QtDynamicGridLayout::updateEmphasiseFocusOnTabs() {
+ const auto currentDimensions = getDimension();
+
+ for (int y = 0; y < gridLayout_->rowCount(); y++) {
+ for (int x = 0; x < gridLayout_->columnCount(); x++) {
+ QLayoutItem* layoutItem = gridLayout_->itemAtPosition(y, x);
+ QtTabWidget* tabWidget = dynamic_cast<QtTabWidget*>(layoutItem->widget());
+ assert(tabWidget);
+ for (int index = 0; index < tabWidget->count(); index++) {
+ QtTabbable* tab = dynamic_cast<QtTabbable*>(tabWidget->widget(index));
+ assert(tab);
+ tab->setEmphasiseFocus(currentDimensions.height() > 1 || currentDimensions.width() > 1);
+ }
+ }
+ }
}
void QtDynamicGridLayout::moveCurrentTabRight() {
diff --git a/Swift/QtUI/Trellis/QtDynamicGridLayout.h b/Swift/QtUI/Trellis/QtDynamicGridLayout.h
index 4aed0df..682ae41 100644
--- a/Swift/QtUI/Trellis/QtDynamicGridLayout.h
+++ b/Swift/QtUI/Trellis/QtDynamicGridLayout.h
@@ -70,6 +70,7 @@ namespace Swift {
private:
void moveTab(QtTabWidget* tabWidget, int oldIndex, int newIndex);
QtTabWidget* createDNDTabWidget(QWidget* parent);
+ void updateEmphasiseFocusOnTabs();
private:
QGridLayout *gridLayout_;