Debian Codegraph @

src/librssguard/gui/tabbar.cpp

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/gui/tabbar.cpp`/
2
3 #include "gui/tabbar.h"cxx . . $ `<file>/src/librssguard/gui/tabbar.h`/
4
5 #include "definitions/definitions.h"cxx . . $ `<file>/src/librssguard/definitions/definitions.h`/
6 #include "definitions/globals.h"cxx . . $ `<file>/src/librssguard/definitions/globals.h`/
7 #include "gui/reusable/plaintoolbutton.h"cxx . . $ `<file>/src/librssguard/gui/reusable/plaintoolbutton.h`/
8 #include "miscellaneous/settings.h"cxx . . $ `<file>/src/librssguard/miscellaneous/settings.h`/
9
10 #include <QMouseEvent>
11 #include <QStyle>
12
13 TabBarcxx . . $ TabBar#::TabBarcxx . . $ TabBar#TabBar(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent) : QTabBarcxx . . $ QTabBar#(parent) {
14 setDocumentModecxx . . $ QTabBar#setDocumentMode(b45ddcbc8423892c).(false);
15 setUsesScrollButtonscxx . . $ QTabBar#setUsesScrollButtons(b45ddcbc8423892c).(true);
16 setContextMenuPolicycxx . . $ QWidget#setContextMenuPolicy(de0fa9f0eb4c7210).(Qtcxx . . $ Qt/::ContextMenuPolicycxx . . $ Qt/ContextMenuPolicy#::CustomContextMenucxx . . $ Qt/CustomContextMenu.);
17 }
18
19 TabBarcxx . . $ TabBar#::~cxx . . $ TabBar#`~TabBar`(ced63f7c635d850d).TabBarcxx . . $ TabBar#() {
20 qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_GUIcxx . . $ `src/librssguard/definitions/definitions.h:174:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Destroying TabBar instance.";
21 }
22
23 void TabBarcxx . . $ TabBar#::setTabTypecxx . . $ TabBar#setTabType(ba48fa34e6ec9a2).(int index, TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType# type) {
24 const auto button_position =
25 static_cast<ButtonPositioncxx . . $ QTabBar#ButtonPosition#>(stylecxx . . $ QWidget#style(5bbb00d3017c281f).()->styleHintcxx . . $ QStyle#styleHint(671b55e70cc3dc02).(QStylecxx . . $ QStyle#::StyleHintcxx . . $ QStyle#StyleHint#::SH_TabBar_CloseButtonPositioncxx . . $ QStyle#SH_TabBar_CloseButtonPosition., nullptr, this));
26
27 switch (type) {
28 case TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#::DownloadManagercxx . . $ TabBar#TabType#DownloadManager.:
29 case TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#::Closablecxx . . $ TabBar#TabType#Closable.: {
30 auto* close_button = new PlainToolButtoncxx . . $ PlainToolButton#(this);
31
32 close_button->setIconcxx . . $ QAbstractButton#setIcon(71dcdac178620ed6).(qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->iconscxx . . $ Application#icons(d976db2a0d825b70).()->fromThemecxx . . $ IconFactory#fromTheme(e457fbbee8993f3).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("application-exit")));
33 close_button->setToolTipcxx . . $ QWidget#setToolTip(3520e46b33348bf6).(trcxx . . $ TabBar#tr(75d9f1c324b4579d).("Close this tab."));
34 close_button->setTextcxx . . $ QAbstractButton#setText(3520e46b33348bf6).(trcxx . . $ TabBar#tr(75d9f1c324b4579d).("Close tab"));
35 close_button->setFixedSizecxx . . $ QWidget#setFixedSize(1c5f201b4c2f0aba).(iconSizecxx . . $ QTabBar#iconSize(4b3b776e5ee2b367).());
36
37 // Close underlying tab when button is clicked.
38 connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(close_button, &PlainToolButtoncxx . . $ PlainToolButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &TabBarcxx . . $ TabBar#::closeTabViaButtoncxx . . $ TabBar#closeTabViaButton(49f6e7a06ebc5aa8).);
39 setTabButtoncxx . . $ QTabBar#setTabButton(acba17f530ea825a).(index, button_position, close_button);
40 break;
41 }
42
43 default:
44 setTabButtoncxx . . $ QTabBar#setTabButton(acba17f530ea825a).(index, button_position, nullptr);
45 break;
46 }
47
48 setTabDatacxx . . $ QTabBar#setTabData(e71f85060bf8a055).(index, QVariantcxx . . $ QVariant#QVariant(f349c77f591a7878).(int(type)));
49 }
50
51 void TabBarcxx . . $ TabBar#::closeTabViaButtoncxx . . $ TabBar#closeTabViaButton(49f6e7a06ebc5aa8).() {
52 const auto* close_button = qobject_castcxx . . $ qobject_cast(c988cfc0ca08742e).<QAbstractButtoncxx . . $ QAbstractButton#*>(sendercxx . . $ QObject#sender(2dbb680a34285c44).());
53 const auto button_position =
54 static_cast<ButtonPositioncxx . . $ QTabBar#ButtonPosition#>(stylecxx . . $ QWidget#style(5bbb00d3017c281f).()->styleHintcxx . . $ QStyle#styleHint(671b55e70cc3dc02).(QStylecxx . . $ QStyle#::StyleHintcxx . . $ QStyle#StyleHint#::SH_TabBar_CloseButtonPositioncxx . . $ QStyle#SH_TabBar_CloseButtonPosition., nullptr, this));
55
56 if (close_button != nullptr) {
57 // Find index of tab for this close button.
58 for (int i = 0; i < countcxx . . $ QTabBar#count(455f465bc33b4cdf).(); i++) {
59 if (tabButtoncxx . . $ QTabBar#tabButton(4bfcf27a0463ab61).(i, button_position) == close_button) {
60 emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! tabCloseRequestedcxx . . $ QTabBar#tabCloseRequested(d4f767463ce0a6b3).(i);
61
62 return;
63 }
64 }
65 }
66 }
67
68 void TabBarcxx . . $ TabBar#::wheelEventcxx . . $ TabBar#wheelEvent(92d40974398e4832).(QWheelEventcxx . . $ QWheelEvent#* event) {
69 const int current_index = currentIndexcxx . . $ QTabBar#currentIndex(455f465bc33b4cdf).();
70 const int number_of_tabs = countcxx . . $ QTabBar#count(455f465bc33b4cdf).();
71
72 // Make sure rotating works.
73 if (number_of_tabs > 1) {
74 if (event->angleDeltacxx . . $ QWheelEvent#angleDelta(75d69cfbd3c4b2dd).().ycxx . . $ QPoint#y(ea6fe5115c70a13f).() > 0) {
75 // Scroll to the LEFT tab.
76 setCurrentIndexcxx . . $ QTabBar#setCurrentIndex(d4f767463ce0a6b3).(current_index == 0 ? number_of_tabs - 1 : current_index - 1);
77 }
78 else if (event->angleDeltacxx . . $ QWheelEvent#angleDelta(75d69cfbd3c4b2dd).().ycxx . . $ QPoint#y(ea6fe5115c70a13f).() < 0) {
79 // Scroll to the RIGHT tab.
80 setCurrentIndexcxx . . $ QTabBar#setCurrentIndex(d4f767463ce0a6b3).(current_index == number_of_tabs - 1 ? 0 : current_index + 1);
81 }
82 }
83 }
84
85 void TabBarcxx . . $ TabBar#::mousePressEventcxx . . $ TabBar#mousePressEvent(702858a82d06265c).(QMouseEventcxx . . $ QMouseEvent#* event) {
86 QTabBarcxx . . $ QTabBar#::mousePressEventcxx . . $ QTabBar#mousePressEvent(702858a82d06265c).(event);
87
88 const int tab_index = tabAtcxx . . $ QTabBar#tabAt(708179cdcbf2817c).(event->poscxx . . $ QMouseEvent#pos(75d69cfbd3c4b2dd).());
89
90 // Check if user clicked on some tab or on empty space.
91 if (tab_index >= 0) {
92 // Check if user clicked tab with middle button.
93 // NOTE: This needs to be done here because
94 // destination does not know the original event.
95 if (Globalscxx . . $ Globals#::hasFlagcxx . . $ Globals#hasFlag(e81494ae8084f6ba).(event->buttoncxx . . $ QSinglePointEvent#button(4a2598559eeedfc9).(), Qtcxx . . $ Qt/::MouseButtoncxx . . $ Qt/MouseButton#::MiddleButtoncxx . . $ Qt/MiddleButton.) &&
96 qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(GUI), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(GUI::TabCloseMiddleClick)).toBoolcxx . . $ QVariant#toBool(50ce9a9e25b4a850).()) {
97 if (tabTypecxx . . $ TabBar#tabType(b6eec15960406bc2).(tab_index) == TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#::Closablecxx . . $ TabBar#TabType#Closable. || tabTypecxx . . $ TabBar#tabType(b6eec15960406bc2).(tab_index) == TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#::DownloadManagercxx . . $ TabBar#TabType#DownloadManager.) {
98 // This tab is closable, so we can close it.
99 emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! tabCloseRequestedcxx . . $ QTabBar#tabCloseRequested(d4f767463ce0a6b3).(tab_index);
100 }
101 }
102 }
103 }
104
105 void TabBarcxx . . $ TabBar#::mouseDoubleClickEventcxx . . $ TabBar#mouseDoubleClickEvent(702858a82d06265c).(QMouseEventcxx . . $ QMouseEvent#* event) {
106 QTabBarcxx . . $ QTabBar#::mouseDoubleClickEventcxx . . $ QTabBar#mouseDoubleClickEvent(702858a82d06265c).(event);
107 const int tab_index = tabAtcxx . . $ QTabBar#tabAt(708179cdcbf2817c).(event->poscxx . . $ QMouseEvent#pos(75d69cfbd3c4b2dd).());
108
109 // Check if user clicked on some tab or on empty space.
110 if (tab_index >= 0) {
111 // Check if user clicked tab with middle button.
112 // NOTE: This needs to be done here because
113 // destination does not know the original event.
114 if (Globalscxx . . $ Globals#::hasFlagcxx . . $ Globals#hasFlag(e81494ae8084f6ba).(event->buttoncxx . . $ QSinglePointEvent#button(4a2598559eeedfc9).(), Qtcxx . . $ Qt/::MouseButtoncxx . . $ Qt/MouseButton#::LeftButtoncxx . . $ Qt/LeftButton.) &&
115 qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->valuecxx . . $ Settings#value(8f1f29a69568d71a).(GROUPcxx . . $ `src/librssguard/miscellaneous/settings.h:32:9`!(GUI), SETTINGcxx . . $ `src/librssguard/miscellaneous/settings.h:30:9`!(GUI::TabCloseDoubleClick)).toBoolcxx . . $ QVariant#toBool(50ce9a9e25b4a850).()) {
116 if (int(tabTypecxx . . $ TabBar#tabType(b6eec15960406bc2).(tab_index) &cxx . . $ `operator&`(b0f6f68325c241cc). (TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#::Closablecxx . . $ TabBar#TabType#Closable. |cxx . . $ `operator|`(b0f6f68325c241cc). TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#::DownloadManagercxx . . $ TabBar#TabType#DownloadManager.)) > 0) {
117 // This tab is closable, so we can close it.
118 emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! tabCloseRequestedcxx . . $ QTabBar#tabCloseRequested(d4f767463ce0a6b3).(tab_index);
119 }
120 }
121 }
122 else {
123 emitcxx . . $ `<external>/4830994369567095248/qtmetamacros.h:51:10`! emptySpaceDoubleClickedcxx . . $ TabBar#emptySpaceDoubleClicked(49f6e7a06ebc5aa8).();
124 }
125 }
126
127 TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#& operatorcxx . . $ `operator&=`(9b21e1ab6104a6b2).&=(TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#& a, TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType# b) {
128 return (TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#&)((int&)a &= (int)b);
129 }
130
131 TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#& operatorcxx . . $ `operator|=`(9b21e1ab6104a6b2).|=(TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#& a, TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType# b) {
132 return (TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#&)((int&)a |= (int)b);
133 }
134
135 TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType# operatorcxx . . $ `operator&`(b0f6f68325c241cc).&(TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType# a, TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType# b) {
136 return (TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#)((int)a & (int)b);
137 }
138
139 TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType# operatorcxx . . $ `operator|`(b0f6f68325c241cc).|(TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType# a, TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType# b) {
140 return (TabBarcxx . . $ TabBar#::TabTypecxx . . $ TabBar#TabType#)((int)a | (int)b);
141 }