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->commands->load();
|
||||
this->logging->initialize();
|
||||
this->windows->initialize();
|
||||
|
||||
this->resources->initialize();
|
||||
|
@ -105,7 +106,6 @@ void Application::initialize()
|
|||
this->accounts->load();
|
||||
|
||||
this->twitch.server->initialize();
|
||||
this->logging->initialize();
|
||||
|
||||
// XXX
|
||||
this->settings->updateWordTypeMask();
|
||||
|
|
|
@ -228,8 +228,10 @@ void TwitchChannel::addJoinedUser(const QString &user)
|
|||
QTimer::singleShot(500, &this->object, [this] {
|
||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex);
|
||||
|
||||
this->addMessage(messages::Message::createSystemMessage("Users joined: " +
|
||||
this->joinedUsers.join(", ")));
|
||||
auto message = messages::Message::createSystemMessage("Users joined: " +
|
||||
this->joinedUsers.join(", "));
|
||||
message->flags |= messages::Message::Collapsed;
|
||||
this->addMessage(message);
|
||||
this->joinedUsers.clear();
|
||||
this->joinedUsersMergeQueued = false;
|
||||
});
|
||||
|
@ -255,8 +257,10 @@ void TwitchChannel::addPartedUser(const QString &user)
|
|||
QTimer::singleShot(500, &this->object, [this] {
|
||||
std::lock_guard<std::mutex> guard(this->partedUserMutex);
|
||||
|
||||
this->addMessage(messages::Message::createSystemMessage("Users parted: " +
|
||||
this->partedUsers.join(", ")));
|
||||
auto message = messages::Message::createSystemMessage("Users parted: " +
|
||||
this->partedUsers.join(", "));
|
||||
message->flags |= messages::Message::Collapsed;
|
||||
this->addMessage(message);
|
||||
this->partedUsers.clear();
|
||||
|
||||
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.width(), this->height());
|
||||
});
|
||||
|
|
|
@ -120,20 +120,35 @@ void Notebook::select(QWidget *page)
|
|||
if (page != nullptr) {
|
||||
page->setHidden(false);
|
||||
|
||||
NotebookTab *tab = this->getTabFromPage(page);
|
||||
tab->setSelected(true);
|
||||
tab->raise();
|
||||
assert(this->containsPage(page));
|
||||
Item &item = this->findItem(page);
|
||||
|
||||
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) {
|
||||
this->selectedPage->setHidden(true);
|
||||
|
||||
NotebookTab *tab = this->getTabFromPage(selectedPage);
|
||||
tab->setSelected(false);
|
||||
Item &item = this->findItem(selectedPage);
|
||||
item.tab->setSelected(false);
|
||||
|
||||
// for (auto split : this->selectedPage->getSplits()) {
|
||||
// split->updateLastReadMessage();
|
||||
// }
|
||||
|
||||
item.selectedWidget = this->selectedPage->focusWidget();
|
||||
}
|
||||
|
||||
this->selectedPage = page;
|
||||
|
@ -141,6 +156,31 @@ void Notebook::select(QWidget *page)
|
|||
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)
|
||||
{
|
||||
if (index < 0 || this->items.count() <= index) {
|
||||
|
|
|
@ -59,11 +59,17 @@ private:
|
|||
struct Item {
|
||||
NotebookTab *tab;
|
||||
QWidget *page;
|
||||
QWidget *selectedWidget = nullptr;
|
||||
};
|
||||
|
||||
QList<Item> items;
|
||||
QWidget *selectedPage = nullptr;
|
||||
|
||||
bool containsPage(QWidget *page);
|
||||
Item &findItem(QWidget *page);
|
||||
|
||||
static bool containsChild(const QObject *obj, const QObject *child);
|
||||
|
||||
NotebookButton addButton;
|
||||
std::vector<NotebookButton *> customButtons;
|
||||
|
||||
|
|
|
@ -279,19 +279,19 @@ void Split::paintEvent(QPaintEvent *)
|
|||
|
||||
void Split::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers());
|
||||
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||
}
|
||||
|
||||
void Split::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
this->view.unsetCursor();
|
||||
this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers());
|
||||
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||
}
|
||||
|
||||
void Split::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
this->view.unsetCursor();
|
||||
this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers());
|
||||
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||
}
|
||||
|
||||
void Split::resizeEvent(QResizeEvent *event)
|
||||
|
@ -305,7 +305,7 @@ void Split::enterEvent(QEvent *event)
|
|||
{
|
||||
this->isMouseOver = true;
|
||||
|
||||
this->handleModifiers(event, QGuiApplication::queryKeyboardModifiers());
|
||||
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||
|
||||
if (modifierStatus == Qt::AltModifier ||
|
||||
modifierStatus == (Qt::AltModifier | Qt::ControlModifier)) {
|
||||
|
@ -319,10 +319,15 @@ void Split::leaveEvent(QEvent *event)
|
|||
|
||||
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) {
|
||||
modifierStatus = modifiers;
|
||||
|
|
|
@ -83,6 +83,7 @@ protected:
|
|||
void resizeEvent(QResizeEvent *event) override;
|
||||
void enterEvent(QEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
void focusInEvent(QFocusEvent *event) override;
|
||||
|
||||
private:
|
||||
SplitContainer *container;
|
||||
|
@ -109,7 +110,7 @@ private:
|
|||
|
||||
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
||||
void channelNameUpdated(const QString &newChannelName);
|
||||
void handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers);
|
||||
void handleModifiers(Qt::KeyboardModifiers modifiers);
|
||||
|
||||
public slots:
|
||||
// Add new split to the notebook page that this chat widget is in
|
||||
|
|
|
@ -459,6 +459,18 @@ void SplitContainer::leaveEvent(QEvent *)
|
|||
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()
|
||||
{
|
||||
if (this->tab == nullptr) {
|
||||
|
|
|
@ -195,6 +195,7 @@ public:
|
|||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
void focusInEvent(QFocusEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
|
Loading…
Reference in a new issue