Discord-like Quick Switcher (#1588)

* Proof of Concept for Quick Switcher

* Fix crash when suggestions are empty

* QuickSwitcher: Use tab name instead of a single channel

* Rebase later

* Add missing include for <functional>

* Move QuickSwitcher related classes into own subfolder

* Refactor switcher list items

Now, items are responsible for taking the right action when selected in
the switcher list. This should allow for more focused code and
responsibilities.

* Add note about memory management

* Add option to open channel in a new tab

* Add support for using the mouse

* Spawn switcher popup in the middle of the window

Works reliably on i3 at least. Might need some additional testing on
other WMs (and especially on Windows!).

* Add some icons for switcher items

Note that the final design of the list is not final but I do plan to
incorporate these in the future.

* Set Qt::Dialog window flag on switcher popup

Prevents tiling window managers like i3 from trying to tile the window.

* Rename "SwitcherItem" to "AbstractSwitcherItem"

* Add comments about what items are inserted

* Use custom model and view

Still missing: Currently selected item is not highlighted yet. You can
move between selected items with tab and arrow keys though.

* Add helper function to convert QVariant to AbstractSwitcherItem *

* Remove useless constant

* Highlight currently selected switcher item

* Use a different method for centering QuickSwitcherPopup window

* QuickSwitcherModel: Add documentation

* Add default parameter to QuickSwitcherModel::rowCount

* QuickSwitcherPopup: Add comments

* Remove outdated TODO

* QuickSwitcherModel: Init vector with default capacity

* Remove outdated comment

* Add comment about 0 ms timeout interval

* NewTabItem: Simplify interface

* Only fetch opened splits once

This is better than the prior approach since opened splits cannot change
anyways while the switcher is open.

* Use SplitContainer to pass information instead of custom type

* Allow searching for tab titles as well

Before this commit, only channel names could be searched.

* Refactor switcher item interface to be more flexible

Also show tab name and channel name in the switcher list.

* Add documentation for AbstractSwitcherItem

* Add documentation for NewTabItem

* Add comments about {begin,end}{Insert,Remove}Rows

* Remove unused method

* Replace magic size with named constant

* Add change log entry

Co-authored-by: fourtf <tf.four@gmail.com>
This commit is contained in:
Leon Richardt
2020-08-13 19:25:51 +02:00
committed by GitHub
parent ce57ad9b0d
commit a9080ceb3c
20 changed files with 927 additions and 11 deletions
+21 -9
View File
@@ -156,10 +156,10 @@ SOURCES += \
src/messages/MessageColor.cpp \
src/messages/MessageContainer.cpp \
src/messages/MessageElement.cpp \
src/messages/SharedMessageBuilder.cpp \
src/messages/search/AuthorPredicate.cpp \
src/messages/search/LinkPredicate.cpp \
src/messages/search/SubstringPredicate.cpp \
src/messages/SharedMessageBuilder.cpp \
src/providers/bttv/BttvEmotes.cpp \
src/providers/bttv/LoadBttvChannelEmote.cpp \
src/providers/chatterino/ChatterinoBadges.cpp \
@@ -218,11 +218,11 @@ SOURCES += \
src/util/IncognitoBrowser.cpp \
src/util/InitUpdateButton.cpp \
src/util/JsonQuery.cpp \
src/util/RapidjsonHelpers.cpp \
src/util/StreamLink.cpp \
src/util/StreamerMode.cpp \
src/util/Twitch.cpp \
src/util/NuulsUploader.cpp \
src/util/RapidjsonHelpers.cpp \
src/util/StreamerMode.cpp \
src/util/StreamLink.cpp \
src/util/Twitch.cpp \
src/util/WindowsHelper.cpp \
src/widgets/AccountSwitchPopup.cpp \
src/widgets/AccountSwitchWidget.cpp \
@@ -239,6 +239,12 @@ SOURCES += \
src/widgets/dialogs/QualityPopup.cpp \
src/widgets/dialogs/SelectChannelDialog.cpp \
src/widgets/dialogs/SettingsDialog.cpp \
src/widgets/dialogs/switcher/AbstractSwitcherItem.cpp \
src/widgets/dialogs/switcher/NewTabItem.cpp \
src/widgets/dialogs/switcher/QuickSwitcherModel.cpp \
src/widgets/dialogs/switcher/QuickSwitcherPopup.cpp \
src/widgets/dialogs/switcher/SwitcherItemDelegate.cpp \
src/widgets/dialogs/switcher/SwitchSplitItem.cpp \
src/widgets/dialogs/TextInputDialog.cpp \
src/widgets/dialogs/UpdateDialog.cpp \
src/widgets/dialogs/UserInfoPopup.cpp \
@@ -358,12 +364,12 @@ HEADERS += \
src/messages/MessageContainer.hpp \
src/messages/MessageElement.hpp \
src/messages/MessageParseArgs.hpp \
src/messages/SharedMessageBuilder.hpp \
src/messages/search/AuthorPredicate.hpp \
src/messages/search/LinkPredicate.hpp \
src/messages/search/MessagePredicate.hpp \
src/messages/search/SubstringPredicate.hpp \
src/messages/Selection.hpp \
src/messages/SharedMessageBuilder.hpp \
src/PrecompiledHeader.hpp \
src/providers/bttv/BttvEmotes.hpp \
src/providers/bttv/LoadBttvChannelEmote.hpp \
@@ -433,13 +439,12 @@ HEADERS += \
src/util/JsonQuery.hpp \
src/util/LayoutCreator.hpp \
src/util/LayoutHelper.hpp \
src/util/NuulsUploader.hpp \
src/util/Overloaded.hpp \
src/util/PersistSignalVector.hpp \
src/util/PostToThread.hpp \
src/util/QObjectRef.hpp \
src/util/QStringHash.hpp \
src/util/StreamerMode.hpp \
src/util/Twitch.hpp \
src/util/rangealgorithm.hpp \
src/util/RapidjsonHelpers.hpp \
src/util/RapidJsonSerializeQString.hpp \
@@ -449,8 +454,9 @@ HEADERS += \
src/util/SharedPtrElementLess.hpp \
src/util/Shortcut.hpp \
src/util/StandardItemHelper.hpp \
src/util/StreamerMode.hpp \
src/util/StreamLink.hpp \
src/util/NuulsUploader.hpp \
src/util/Twitch.hpp \
src/util/WindowsHelper.hpp \
src/widgets/AccountSwitchPopup.hpp \
src/widgets/AccountSwitchWidget.hpp \
@@ -467,6 +473,12 @@ HEADERS += \
src/widgets/dialogs/QualityPopup.hpp \
src/widgets/dialogs/SelectChannelDialog.hpp \
src/widgets/dialogs/SettingsDialog.hpp \
src/widgets/dialogs/switcher/AbstractSwitcherItem.hpp \
src/widgets/dialogs/switcher/NewTabItem.hpp \
src/widgets/dialogs/switcher/QuickSwitcherModel.hpp \
src/widgets/dialogs/switcher/QuickSwitcherPopup.hpp \
src/widgets/dialogs/switcher/SwitcherItemDelegate.hpp \
src/widgets/dialogs/switcher/SwitchSplitItem.hpp \
src/widgets/dialogs/TextInputDialog.hpp \
src/widgets/dialogs/UpdateDialog.hpp \
src/widgets/dialogs/UserInfoPopup.hpp \