mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fix: QuickSwitcherPopup now pops up in the selected window (#4819)
This commit is contained in:
parent
3265df7661
commit
e6df652a4f
6 changed files with 37 additions and 27 deletions
|
@ -11,6 +11,7 @@
|
|||
- Bugfix: Fixed Usercard popup not floating on tiling WMs on Linux when "Automatically close user popup when it loses focus" setting is enabled. (#3511)
|
||||
- Bugfix: Fixed selection of tabs after closing a tab when using "Live Tabs Only". (#4770)
|
||||
- Bugfix: Fixed input in reply thread popup losing focus when dragging. (#4815)
|
||||
- Bugfix: Fixed the Quick Switcher (CTRL+K) from sometimes showing up on the wrong window. (#4819)
|
||||
- Bugfix: Fixed too much text being copied when copying chat messages. (#4812)
|
||||
- Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791)
|
||||
- Dev: Temporarily disable High DPI scaling on Qt6 builds on Windows. (#4767)
|
||||
|
|
|
@ -492,9 +492,8 @@ void Window::addShortcuts()
|
|||
return "";
|
||||
}},
|
||||
{"openQuickSwitcher",
|
||||
[](std::vector<QString>) -> QString {
|
||||
auto quickSwitcher =
|
||||
new QuickSwitcherPopup(&getApp()->windows->getMainWindow());
|
||||
[this](std::vector<QString>) -> QString {
|
||||
auto *quickSwitcher = new QuickSwitcherPopup(this);
|
||||
quickSwitcher->show();
|
||||
return "";
|
||||
}},
|
||||
|
|
|
@ -12,16 +12,17 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
NewTabItem::NewTabItem(const QString &channelName)
|
||||
NewTabItem::NewTabItem(Window *window_, const QString &channelName)
|
||||
: AbstractSwitcherItem(QIcon(":/switcher/plus.svg"))
|
||||
, channelName_(channelName)
|
||||
, text_(QString(TEXT_FORMAT).arg(channelName))
|
||||
, window(window_)
|
||||
{
|
||||
}
|
||||
|
||||
void NewTabItem::action()
|
||||
{
|
||||
auto &nb = getApp()->windows->getMainWindow().getNotebook();
|
||||
auto &nb = this->window->getNotebook();
|
||||
SplitContainer *container = nb.addPage(true);
|
||||
|
||||
Split *split = new Split(container);
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
class Window;
|
||||
|
||||
class NewTabItem : public AbstractSwitcherItem
|
||||
{
|
||||
public:
|
||||
|
@ -13,7 +15,7 @@ public:
|
|||
*
|
||||
* @param channelName name of channel to open
|
||||
*/
|
||||
NewTabItem(const QString &channelName);
|
||||
NewTabItem(Window *window_, const QString &channelName);
|
||||
|
||||
/**
|
||||
* @brief Open the channel passed in the constructor in a new tab.
|
||||
|
@ -27,6 +29,7 @@ private:
|
|||
static constexpr const char *TEXT_FORMAT = "Open channel \"%1\" in new tab";
|
||||
QString channelName_;
|
||||
QString text_;
|
||||
Window *window{};
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -15,30 +15,33 @@
|
|||
#include "widgets/splits/SplitContainer.hpp"
|
||||
#include "widgets/Window.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
namespace {
|
||||
QList<SplitContainer *> openPages()
|
||||
{
|
||||
|
||||
using namespace chatterino;
|
||||
|
||||
QList<SplitContainer *> openPages(Window *window)
|
||||
{
|
||||
QList<SplitContainer *> pages;
|
||||
|
||||
auto &nb = getApp()->windows->getMainWindow().getNotebook();
|
||||
auto &nb = window->getNotebook();
|
||||
for (int i = 0; i < nb.getPageCount(); ++i)
|
||||
{
|
||||
pages.append(static_cast<SplitContainer *>(nb.getPageAt(i)));
|
||||
}
|
||||
|
||||
return pages;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const QSize QuickSwitcherPopup::MINIMUM_SIZE(500, 300);
|
||||
namespace chatterino {
|
||||
|
||||
QuickSwitcherPopup::QuickSwitcherPopup(QWidget *parent)
|
||||
QuickSwitcherPopup::QuickSwitcherPopup(Window *parent)
|
||||
: BasePopup({BaseWindow::Flags::Frameless, BaseWindow::Flags::TopMost,
|
||||
BaseWindow::DisableLayoutSave},
|
||||
parent)
|
||||
, switcherModel_(this)
|
||||
, window(parent)
|
||||
{
|
||||
this->setWindowFlag(Qt::Dialog);
|
||||
this->setActionOnFocusLoss(BaseWindow::ActionOnFocusLoss::Delete);
|
||||
|
@ -86,7 +89,7 @@ void QuickSwitcherPopup::updateSuggestions(const QString &text)
|
|||
this->switcherModel_.clear();
|
||||
|
||||
// Add items for navigating to different splits
|
||||
for (auto *sc : openPages())
|
||||
for (auto *sc : openPages(this->window))
|
||||
{
|
||||
const QString &tabTitle = sc->getTab()->getTitle();
|
||||
const auto splits = sc->getSplits();
|
||||
|
@ -119,7 +122,7 @@ void QuickSwitcherPopup::updateSuggestions(const QString &text)
|
|||
// Add item for opening a channel in a new tab or new popup
|
||||
if (!text.isEmpty())
|
||||
{
|
||||
auto newTabItem = std::make_unique<NewTabItem>(text);
|
||||
auto newTabItem = std::make_unique<NewTabItem>(this->window, text);
|
||||
this->switcherModel_.addItem(std::move(newTabItem));
|
||||
|
||||
auto newPopupItem = std::make_unique<NewPopupItem>(text);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace chatterino {
|
||||
|
||||
class GenericListView;
|
||||
class Window;
|
||||
|
||||
class QuickSwitcherPopup : public BasePopup
|
||||
{
|
||||
|
@ -17,19 +18,19 @@ public:
|
|||
/**
|
||||
* @brief Construct a new QuickSwitcherPopup.
|
||||
*
|
||||
* @param parent Parent widget of the popup. The popup will be placed
|
||||
* in the center of the parent widget.
|
||||
* @param parent Parent window of the popup. The popup will be placed
|
||||
* in the center of the window.
|
||||
*/
|
||||
explicit QuickSwitcherPopup(QWidget *parent = nullptr);
|
||||
explicit QuickSwitcherPopup(Window *parent);
|
||||
|
||||
protected:
|
||||
virtual void themeChangedEvent() override;
|
||||
void themeChangedEvent() override;
|
||||
|
||||
public slots:
|
||||
void updateSuggestions(const QString &text);
|
||||
|
||||
private:
|
||||
static const QSize MINIMUM_SIZE;
|
||||
constexpr static const QSize MINIMUM_SIZE{500, 300};
|
||||
|
||||
struct {
|
||||
QLineEdit *searchEdit{};
|
||||
|
@ -38,6 +39,8 @@ private:
|
|||
|
||||
QuickSwitcherModel switcherModel_;
|
||||
|
||||
Window *window{};
|
||||
|
||||
void initWidgets();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue