ladybird/Ladybird/Qt/TabBar.h
PiyushXCoder 9b79081a06
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
UI/Qt: Don't allow tabs to be dragged past the new tab button
Before this change, if would a tab it will pass the add new tab button
(+ button).

closes #1124
2024-09-18 17:53:09 +01:00

67 lines
1.4 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;
private:
void mousePressEvent(QMouseEvent*) override;
void mouseMoveEvent(QMouseEvent*) override;
int m_x_position_in_selected_tab_while_dragging;
};
class TabWidget : public QTabWidget {
Q_OBJECT
public:
explicit TabWidget(QWidget* parent = nullptr);
virtual void paintEvent(QPaintEvent*) override;
};
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;
};
}