mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
feat: add Quick Switcher item to open channel in a new popup window (#3828)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
6e0852fb49
commit
6a58ce1273
|
@ -22,6 +22,7 @@
|
|||
- Minor: Added ability to execute commands on chat messages using the message context menu. (#3738, #3765)
|
||||
- Minor: Added `/copy` command. Usage: `/copy <text>`. Copies provided text to clipboard - can be useful with custom commands. (#3763)
|
||||
- Minor: Removed total views from the usercard, as Twitch no longer updates the number. (#3792)
|
||||
- Minor: Add Quick Switcher item to open a channel in a new popup window. (#3828)
|
||||
- Bugfix: Connection to Twitch PubSub now recovers more reliably. (#3643, #3716)
|
||||
- Bugfix: Fix crash that can occur when changing channels. (#3799)
|
||||
- Bugfix: Fixed viewers list search not working when used before loading finishes. (#3774)
|
||||
|
|
|
@ -289,6 +289,7 @@ SOURCES += \
|
|||
src/widgets/dialogs/SelectChannelDialog.cpp \
|
||||
src/widgets/dialogs/SelectChannelFiltersDialog.cpp \
|
||||
src/widgets/dialogs/SettingsDialog.cpp \
|
||||
src/widgets/dialogs/switcher/NewPopupItem.cpp \
|
||||
src/widgets/dialogs/switcher/NewTabItem.cpp \
|
||||
src/widgets/dialogs/switcher/QuickSwitcherModel.cpp \
|
||||
src/widgets/dialogs/switcher/QuickSwitcherPopup.cpp \
|
||||
|
@ -570,6 +571,7 @@ HEADERS += \
|
|||
src/widgets/dialogs/SelectChannelFiltersDialog.hpp \
|
||||
src/widgets/dialogs/SettingsDialog.hpp \
|
||||
src/widgets/dialogs/switcher/AbstractSwitcherItem.hpp \
|
||||
src/widgets/dialogs/switcher/NewPopupItem.hpp \
|
||||
src/widgets/dialogs/switcher/NewTabItem.hpp \
|
||||
src/widgets/dialogs/switcher/QuickSwitcherModel.hpp \
|
||||
src/widgets/dialogs/switcher/QuickSwitcherPopup.hpp \
|
||||
|
|
|
@ -99,6 +99,7 @@
|
|||
<file>split/up.png</file>
|
||||
<file>streamerMode.png</file>
|
||||
<file>switcher/plus.svg</file>
|
||||
<file>switcher/popup.svg</file>
|
||||
<file>switcher/switch.svg</file>
|
||||
<file>tlds.txt</file>
|
||||
<file>twitch/admin.png</file>
|
||||
|
|
70
resources/switcher/popup.svg
Normal file
70
resources/switcher/popup.svg
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
width="210mm"
|
||||
height="297mm"
|
||||
viewBox="0 0 210 297"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.2 (dc2aedaf03, 2022-05-15)"
|
||||
sodipodi:docname="popup.svg"
|
||||
xml:space="preserve"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"><defs
|
||||
id="defs2"><style
|
||||
id="style388">.cls-1{fill:none;}</style><style
|
||||
id="style1160">.cls-1{fill:none;}</style></defs><sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.7"
|
||||
inkscape:cx="66.428571"
|
||||
inkscape:cy="575.71429"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:measure-start="627.601,711.894"
|
||||
inkscape:measure-end="628.106,660"
|
||||
inkscape:pagecheckerboard="true"
|
||||
inkscape:window-width="1918"
|
||||
inkscape:window-height="1053"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:document-rotation="0"
|
||||
inkscape:showpageshadow="0"
|
||||
inkscape:deskcolor="#d1d1d1"><inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid815" /></sodipodi:namedview><metadata
|
||||
id="metadata5"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><g
|
||||
inkscape:label="Ebene 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"><g
|
||||
id="g3350"><path
|
||||
id="path834"
|
||||
style="fill:#5e5e5e;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.71121;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 200.42323,136.43539 A 95.249999,95.249999 0 0 1 105.17324,231.68538 95.249999,95.249999 0 0 1 9.9232285,136.43539 95.249999,95.249999 0 0 1 105.17324,41.185387 95.249999,95.249999 0 0 1 200.42323,136.43539" /><g
|
||||
id="g3343"><rect
|
||||
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:10.5369;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect2224"
|
||||
width="109.79667"
|
||||
height="74.128075"
|
||||
x="38.075703"
|
||||
y="113.36413"
|
||||
ry="8.280633" /><path
|
||||
id="path3305"
|
||||
style="fill:#5e5e5e;fill-opacity:1;stroke:#5e5e5e;stroke-width:10.5369;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 163.66992,75.322266 c -31.78275,0.02718 -63.56804,-4.74e-4 -95.349078,0.154159 -8.936575,1.06582 -16.247011,9.621984 -15.919367,18.614196 0.08165,18.671429 -0.05261,37.344079 0.175458,56.014619 0.0534,2.13844 -0.0852,4.32319 0.616892,6.38143 2.22204,7.53879 9.721238,13.16474 17.596012,13.1069 2.840264,0.0212 5.679714,-0.1186 8.520319,-0.0452 28.997774,-0.0232 57.997934,0.0303 86.994094,-0.13934 3.53024,-0.38226 6.89811,-1.99437 9.51271,-4.27624 4.17017,-3.58105 6.78995,-9.03488 6.52507,-14.57265 -0.0541,-19.66979 -19.43932,-28.83334 -19.67173,-48.50168 -1.8758,-5.385371 -3.40124,3.17431 -6.77069,0.24558 -3.35797,-2.968501 12.27645,-27.133192 7.77031,-26.981794 z"
|
||||
sodipodi:nodetypes="scccccccccccss" /><path
|
||||
id="rect1407"
|
||||
style="fill:#5e5e5e;fill-opacity:1;stroke:#ffffff;stroke-width:10.5369;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 161.25391,85.388672 c -30.44767,0.0013 -60.89688,-0.03737 -91.34357,0.03023 -3.975377,0.331055 -7.390136,3.935876 -7.411326,7.944961 -0.07989,2.781453 0.02886,5.56687 -0.01488,8.350194 -0.0011,16.82024 -0.04701,33.6429 0.04259,50.46161 0.384161,4.19418 4.443158,7.66543 8.658429,7.31694 30.886424,0.0185 61.772964,0.0391 92.659344,-0.0252 4.54867,0.30536 8.71758,-3.96977 8.4112,-8.49787 0.0266,-19.38429 0.0409,-38.76887 -0.0272,-58.153134 -0.33181,-4.023043 -4.01075,-7.460374 -8.06702,-7.426321 -0.96848,-0.03967 -1.93867,-0.01223 -2.90759,-0.0014 z" /></g></g></g></svg>
|
After Width: | Height: | Size: 4.2 KiB |
|
@ -395,6 +395,8 @@ set(SOURCE_FILES
|
|||
widgets/dialogs/UserInfoPopup.hpp
|
||||
widgets/dialogs/WelcomeDialog.cpp
|
||||
widgets/dialogs/WelcomeDialog.hpp
|
||||
widgets/dialogs/switcher/NewPopupItem.cpp
|
||||
widgets/dialogs/switcher/NewPopupItem.hpp
|
||||
widgets/dialogs/switcher/NewTabItem.cpp
|
||||
widgets/dialogs/switcher/NewTabItem.hpp
|
||||
widgets/dialogs/switcher/QuickSwitcherModel.cpp
|
||||
|
|
57
src/widgets/dialogs/switcher/NewPopupItem.cpp
Normal file
57
src/widgets/dialogs/switcher/NewPopupItem.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include "widgets/dialogs/switcher/NewPopupItem.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||
#include "singletons/Fonts.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "singletons/WindowManager.hpp"
|
||||
#include "widgets/Notebook.hpp"
|
||||
#include "widgets/Window.hpp"
|
||||
#include "widgets/helper/NotebookTab.hpp"
|
||||
#include "widgets/splits/Split.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
NewPopupItem::NewPopupItem(const QString &channelName)
|
||||
: AbstractSwitcherItem(QIcon(":/switcher/popup.svg"))
|
||||
, channelName_(channelName)
|
||||
, text_(QString(TEXT_FORMAT).arg(channelName))
|
||||
{
|
||||
}
|
||||
|
||||
void NewPopupItem::action()
|
||||
{
|
||||
auto *app = getApp();
|
||||
auto &popup = app->windows->createWindow(WindowType::Popup, true);
|
||||
auto *split =
|
||||
popup.getNotebook().getOrAddSelectedPage()->appendNewSplit(false);
|
||||
split->setChannel(app->twitch->getOrAddChannel(this->channelName_));
|
||||
}
|
||||
|
||||
void NewPopupItem::paint(QPainter *painter, const QRect &rect) const
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
painter->setPen(getApp()->themes->splits.header.text);
|
||||
painter->setBrush(Qt::SolidPattern);
|
||||
painter->setFont(getApp()->fonts->getFont(FontStyle::UiMediumBold, 1.0));
|
||||
|
||||
QRect iconRect(rect.topLeft(), ICON_SIZE);
|
||||
this->icon_.paint(painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter);
|
||||
|
||||
QRect textRect =
|
||||
QRect(iconRect.topRight(),
|
||||
QSize(rect.width() - iconRect.width(), iconRect.height()));
|
||||
painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, this->text_);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QSize NewPopupItem::sizeHint(const QRect &rect) const
|
||||
{
|
||||
return QSize(rect.width(), ICON_SIZE.height());
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
33
src/widgets/dialogs/switcher/NewPopupItem.hpp
Normal file
33
src/widgets/dialogs/switcher/NewPopupItem.hpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include "widgets/dialogs/switcher/AbstractSwitcherItem.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class NewPopupItem : public AbstractSwitcherItem
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new NewPopupItem that opens a passed channel in a new
|
||||
* popup.
|
||||
*
|
||||
* @param channelName name of channel to open
|
||||
*/
|
||||
NewPopupItem(const QString &channelName);
|
||||
|
||||
/**
|
||||
* @brief Open the channel passed in the constructor in a new popup.
|
||||
*/
|
||||
virtual void action() override;
|
||||
|
||||
virtual void paint(QPainter *painter, const QRect &rect) const override;
|
||||
virtual QSize sizeHint(const QRect &rect) const override;
|
||||
|
||||
private:
|
||||
static constexpr const char *TEXT_FORMAT =
|
||||
"Open channel \"%1\" in new popup";
|
||||
QString channelName_;
|
||||
QString text_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
|
@ -6,6 +6,7 @@
|
|||
#include "util/LayoutCreator.hpp"
|
||||
#include "widgets/Notebook.hpp"
|
||||
#include "widgets/Window.hpp"
|
||||
#include "widgets/dialogs/switcher/NewPopupItem.hpp"
|
||||
#include "widgets/dialogs/switcher/NewTabItem.hpp"
|
||||
#include "widgets/dialogs/switcher/SwitchSplitItem.hpp"
|
||||
#include "widgets/helper/NotebookTab.hpp"
|
||||
|
@ -113,11 +114,14 @@ void QuickSwitcherPopup::updateSuggestions(const QString &text)
|
|||
nextPage:;
|
||||
}
|
||||
|
||||
// Add item for opening a channel in a new tab
|
||||
// Add item for opening a channel in a new tab or new popup
|
||||
if (!text.isEmpty())
|
||||
{
|
||||
auto item = std::make_unique<NewTabItem>(text);
|
||||
this->switcherModel_.addItem(std::move(item));
|
||||
auto newTabItem = std::make_unique<NewTabItem>(text);
|
||||
this->switcherModel_.addItem(std::move(newTabItem));
|
||||
|
||||
auto newPopupItem = std::make_unique<NewPopupItem>(text);
|
||||
this->switcherModel_.addItem(std::move(newPopupItem));
|
||||
}
|
||||
|
||||
const auto &startIdx = this->switcherModel_.index(0);
|
||||
|
|
Loading…
Reference in a new issue