GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
tab-bar.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2018-2022 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26// This file implements a tab bar derived from QTabBar with a contextmenu
27// and possibility to close a tab via double-left or middle mouse click.
28
29#if ! defined (octave_tab_bar_h)
30#define octave_tab_bar_h 1
31
32#include <QMenu>
33#include <QMouseEvent>
34#include <QSize>
35#include <QStyleOptionTab>
36#include <QStylePainter>
37#include <QTabBar>
38
39namespace octave
40{
41 // Subclassed QTabBar for usable tab-bar, rotated tabs and
42 // reimplemented mouse event
43
44 class tab_bar : public QTabBar
45 {
46 Q_OBJECT
47
48 public:
49
50 tab_bar (QWidget *p);
51
52 ~tab_bar (void) = default;
53
54 void set_rotated (int rotated);
56 QSize tabSizeHint (int idx) const;
57
58 signals:
59
61
62 public slots:
63
64 void switch_left_tab (void);
65 void switch_right_tab (void);
66 void move_tab_left (void);
67 void move_tab_right (void);
68 void sort_tabs_alph (void);
69
70 private slots:
71
72 void ctx_menu_activated (QAction *a);
73
74 protected:
75
76 void paintEvent(QPaintEvent *e);
77 void mousePressEvent(QMouseEvent *event);
78
79 private:
80
81 void switch_tab (int direction, bool movetab = false);
82
86 };
87}
88
89#endif
void paintEvent(QPaintEvent *e)
Definition: tab-bar.cc:146
void close_current_tab_signal(bool)
void mousePressEvent(QMouseEvent *event)
Definition: tab-bar.cc:178
void switch_left_tab(void)
Definition: tab-bar.cc:51
void move_tab_left(void)
Definition: tab-bar.cc:61
void set_rotated(int rotated)
Definition: tab-bar.cc:45
void switch_tab(int direction, bool movetab=false)
Definition: tab-bar.cc:71
QMenu * m_context_menu
Definition: tab-bar.h:83
~tab_bar(void)=default
tab_bar(QWidget *p)
Definition: tab-bar.cc:41
void sort_tabs_alph(void)
Definition: tab-bar.cc:94
void ctx_menu_activated(QAction *a)
Definition: tab-bar.cc:276
void switch_right_tab(void)
Definition: tab-bar.cc:56
QSize tabSizeHint(int idx) const
Definition: tab-bar.cc:136
void move_tab_right(void)
Definition: tab-bar.cc:66
QList< QAction * > m_ctx_actions
Definition: tab-bar.h:84
QMenu * get_context_menu(void)
Definition: tab-bar.h:55