mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-10-26 14:57:54 +03:00
e17362ab79
Makes use of the fact that QTabWidget automatically reserves space for "corner widgets", and gives us the ability to override their location with a custom style. Also, determine the height of the new-tab button using the height of the tab bar, instead of a hard-coded 32px which was too tall on MacOS.
60 lines
1.2 KiB
C++
60 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
|
|
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
|
* Copyright (c) 2024, Sam Atkins <sam@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QProxyStyle>
|
|
#include <QPushButton>
|
|
#include <QTabBar>
|
|
#include <QTabWidget>
|
|
|
|
class QContextMenuEvent;
|
|
class QEvent;
|
|
class QIcon;
|
|
class QWidget;
|
|
|
|
namespace Ladybird {
|
|
|
|
class TabBar : public QTabBar {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit TabBar(QWidget* parent = nullptr);
|
|
|
|
virtual QSize tabSizeHint(int index) const override;
|
|
virtual void contextMenuEvent(QContextMenuEvent* event) override;
|
|
};
|
|
|
|
class TabWidget : public QTabWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit TabWidget(QWidget* parent = nullptr);
|
|
};
|
|
|
|
class TabBarButton : public QPushButton {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit TabBarButton(QIcon const& icon, QWidget* parent = nullptr);
|
|
|
|
protected:
|
|
virtual bool event(QEvent* event) override;
|
|
};
|
|
|
|
class TabStyle : public QProxyStyle {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit TabStyle(QObject* parent = nullptr);
|
|
|
|
virtual QRect subElementRect(QStyle::SubElement, QStyleOption const*, QWidget const*) const override;
|
|
};
|
|
|
|
}
|