mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fixed scrollbar size and split focus
This commit is contained in:
parent
783b9096c3
commit
85505a055d
|
@ -93,6 +93,7 @@ void Application::initialize()
|
||||||
|
|
||||||
this->settings->load();
|
this->settings->load();
|
||||||
this->commands->load();
|
this->commands->load();
|
||||||
|
this->logging->initialize();
|
||||||
this->windows->initialize();
|
this->windows->initialize();
|
||||||
|
|
||||||
this->resources->initialize();
|
this->resources->initialize();
|
||||||
|
@ -105,7 +106,6 @@ void Application::initialize()
|
||||||
this->accounts->load();
|
this->accounts->load();
|
||||||
|
|
||||||
this->twitch.server->initialize();
|
this->twitch.server->initialize();
|
||||||
this->logging->initialize();
|
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
this->settings->updateWordTypeMask();
|
this->settings->updateWordTypeMask();
|
||||||
|
|
|
@ -228,8 +228,10 @@ void TwitchChannel::addJoinedUser(const QString &user)
|
||||||
QTimer::singleShot(500, &this->object, [this] {
|
QTimer::singleShot(500, &this->object, [this] {
|
||||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex);
|
std::lock_guard<std::mutex> guard(this->joinedUserMutex);
|
||||||
|
|
||||||
this->addMessage(messages::Message::createSystemMessage("Users joined: " +
|
auto message = messages::Message::createSystemMessage("Users joined: " +
|
||||||
this->joinedUsers.join(", ")));
|
this->joinedUsers.join(", "));
|
||||||
|
message->flags |= messages::Message::Collapsed;
|
||||||
|
this->addMessage(message);
|
||||||
this->joinedUsers.clear();
|
this->joinedUsers.clear();
|
||||||
this->joinedUsersMergeQueued = false;
|
this->joinedUsersMergeQueued = false;
|
||||||
});
|
});
|
||||||
|
@ -255,8 +257,10 @@ void TwitchChannel::addPartedUser(const QString &user)
|
||||||
QTimer::singleShot(500, &this->object, [this] {
|
QTimer::singleShot(500, &this->object, [this] {
|
||||||
std::lock_guard<std::mutex> guard(this->partedUserMutex);
|
std::lock_guard<std::mutex> guard(this->partedUserMutex);
|
||||||
|
|
||||||
this->addMessage(messages::Message::createSystemMessage("Users parted: " +
|
auto message = messages::Message::createSystemMessage("Users parted: " +
|
||||||
this->partedUsers.join(", ")));
|
this->partedUsers.join(", "));
|
||||||
|
message->flags |= messages::Message::Collapsed;
|
||||||
|
this->addMessage(message);
|
||||||
this->partedUsers.clear();
|
this->partedUsers.clear();
|
||||||
|
|
||||||
this->partedUsersMergeQueued = false;
|
this->partedUsersMergeQueued = false;
|
||||||
|
|
|
@ -123,7 +123,7 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QTimer::singleShot(1, this, [this] {
|
QTimer::singleShot(1000, this, [this] {
|
||||||
this->scrollBar.setGeometry(this->width() - this->scrollBar.width(), 0,
|
this->scrollBar.setGeometry(this->width() - this->scrollBar.width(), 0,
|
||||||
this->scrollBar.width(), this->height());
|
this->scrollBar.width(), this->height());
|
||||||
});
|
});
|
||||||
|
|
|
@ -120,20 +120,35 @@ void Notebook::select(QWidget *page)
|
||||||
if (page != nullptr) {
|
if (page != nullptr) {
|
||||||
page->setHidden(false);
|
page->setHidden(false);
|
||||||
|
|
||||||
NotebookTab *tab = this->getTabFromPage(page);
|
assert(this->containsPage(page));
|
||||||
tab->setSelected(true);
|
Item &item = this->findItem(page);
|
||||||
tab->raise();
|
|
||||||
|
item.tab->setSelected(true);
|
||||||
|
item.tab->raise();
|
||||||
|
|
||||||
|
if (item.selectedWidget == nullptr) {
|
||||||
|
item.page->setFocus();
|
||||||
|
} else {
|
||||||
|
if (containsChild(page, item.selectedWidget)) {
|
||||||
|
qDebug() << item.selectedWidget;
|
||||||
|
item.selectedWidget->setFocus(Qt::MouseFocusReason);
|
||||||
|
} else {
|
||||||
|
qDebug() << "Notebook: selected child of page doesn't exist anymore";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->selectedPage != nullptr) {
|
if (this->selectedPage != nullptr) {
|
||||||
this->selectedPage->setHidden(true);
|
this->selectedPage->setHidden(true);
|
||||||
|
|
||||||
NotebookTab *tab = this->getTabFromPage(selectedPage);
|
Item &item = this->findItem(selectedPage);
|
||||||
tab->setSelected(false);
|
item.tab->setSelected(false);
|
||||||
|
|
||||||
// for (auto split : this->selectedPage->getSplits()) {
|
// for (auto split : this->selectedPage->getSplits()) {
|
||||||
// split->updateLastReadMessage();
|
// split->updateLastReadMessage();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
item.selectedWidget = this->selectedPage->focusWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->selectedPage = page;
|
this->selectedPage = page;
|
||||||
|
@ -141,6 +156,31 @@ void Notebook::select(QWidget *page)
|
||||||
this->performLayout();
|
this->performLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Notebook::containsPage(QWidget *page)
|
||||||
|
{
|
||||||
|
return std::any_of(this->items.begin(), this->items.end(),
|
||||||
|
[page](const auto &item) { return item.page == page; });
|
||||||
|
}
|
||||||
|
|
||||||
|
Notebook::Item &Notebook::findItem(QWidget *page)
|
||||||
|
{
|
||||||
|
auto it = std::find_if(this->items.begin(), this->items.end(),
|
||||||
|
[page](const auto &item) { return page == item.page; });
|
||||||
|
assert(it != this->items.end());
|
||||||
|
return *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Notebook::containsChild(const QObject *obj, const QObject *child)
|
||||||
|
{
|
||||||
|
return std::any_of(obj->children().begin(), obj->children().end(), [child](const QObject *o) {
|
||||||
|
if (o == child) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return containsChild(o, child);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Notebook::selectIndex(int index)
|
void Notebook::selectIndex(int index)
|
||||||
{
|
{
|
||||||
if (index < 0 || this->items.count() <= index) {
|
if (index < 0 || this->items.count() <= index) {
|
||||||
|
|
|
@ -59,11 +59,17 @@ private:
|
||||||
struct Item {
|
struct Item {
|
||||||
NotebookTab *tab;
|
NotebookTab *tab;
|
||||||
QWidget *page;
|
QWidget *page;
|
||||||
|
QWidget *selectedWidget = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<Item> items;
|
QList<Item> items;
|
||||||
QWidget *selectedPage = nullptr;
|
QWidget *selectedPage = nullptr;
|
||||||
|
|
||||||
|
bool containsPage(QWidget *page);
|
||||||
|
Item &findItem(QWidget *page);
|
||||||
|
|
||||||
|
static bool containsChild(const QObject *obj, const QObject *child);
|
||||||
|
|
||||||
NotebookButton addButton;
|
NotebookButton addButton;
|
||||||
std::vector<NotebookButton *> customButtons;
|
std::vector<NotebookButton *> customButtons;
|
||||||
|
|
||||||
|
|
|
@ -279,19 +279,19 @@ void Split::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
void Split::mouseMoveEvent(QMouseEvent *event)
|
void Split::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers());
|
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Split::keyPressEvent(QKeyEvent *event)
|
void Split::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
this->view.unsetCursor();
|
this->view.unsetCursor();
|
||||||
this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers());
|
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Split::keyReleaseEvent(QKeyEvent *event)
|
void Split::keyReleaseEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
this->view.unsetCursor();
|
this->view.unsetCursor();
|
||||||
this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers());
|
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Split::resizeEvent(QResizeEvent *event)
|
void Split::resizeEvent(QResizeEvent *event)
|
||||||
|
@ -305,7 +305,7 @@ void Split::enterEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
this->isMouseOver = true;
|
this->isMouseOver = true;
|
||||||
|
|
||||||
this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers());
|
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||||
|
|
||||||
if (modifierStatus == Qt::AltModifier ||
|
if (modifierStatus == Qt::AltModifier ||
|
||||||
modifierStatus == (Qt::AltModifier | Qt::ControlModifier)) {
|
modifierStatus == (Qt::AltModifier | Qt::ControlModifier)) {
|
||||||
|
@ -319,10 +319,15 @@ void Split::leaveEvent(QEvent *event)
|
||||||
|
|
||||||
this->overlay->hide();
|
this->overlay->hide();
|
||||||
|
|
||||||
this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers());
|
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Split::handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers)
|
void Split::focusInEvent(QFocusEvent *event)
|
||||||
|
{
|
||||||
|
this->giveFocus(event->reason());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split::handleModifiers(Qt::KeyboardModifiers modifiers)
|
||||||
{
|
{
|
||||||
if (modifierStatus != modifiers) {
|
if (modifierStatus != modifiers) {
|
||||||
modifierStatus = modifiers;
|
modifierStatus = modifiers;
|
||||||
|
|
|
@ -83,6 +83,7 @@ protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
void enterEvent(QEvent *event) override;
|
void enterEvent(QEvent *event) override;
|
||||||
void leaveEvent(QEvent *event) override;
|
void leaveEvent(QEvent *event) override;
|
||||||
|
void focusInEvent(QFocusEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SplitContainer *container;
|
SplitContainer *container;
|
||||||
|
@ -109,7 +110,7 @@ private:
|
||||||
|
|
||||||
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
||||||
void channelNameUpdated(const QString &newChannelName);
|
void channelNameUpdated(const QString &newChannelName);
|
||||||
void handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers);
|
void handleModifiers(Qt::KeyboardModifiers modifiers);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Add new split to the notebook page that this chat widget is in
|
// Add new split to the notebook page that this chat widget is in
|
||||||
|
|
|
@ -459,6 +459,18 @@ void SplitContainer::leaveEvent(QEvent *)
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SplitContainer::focusInEvent(QFocusEvent *)
|
||||||
|
{
|
||||||
|
if (this->baseNode.findNodeContainingSplit(this->selected) != nullptr) {
|
||||||
|
this->selected->setFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->splits.size() != 0) {
|
||||||
|
this->splits.front()->setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SplitContainer::refreshTabTitle()
|
void SplitContainer::refreshTabTitle()
|
||||||
{
|
{
|
||||||
if (this->tab == nullptr) {
|
if (this->tab == nullptr) {
|
||||||
|
|
|
@ -195,6 +195,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
|
void focusInEvent(QFocusEvent *event) override;
|
||||||
void leaveEvent(QEvent *event) override;
|
void leaveEvent(QEvent *event) override;
|
||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
|
|
Loading…
Reference in a new issue