Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
actionprovider_p.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
ACTIONPROVIDER_H
6
#
define
ACTIONPROVIDER_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtDesigner
/
extension
.
h
>
20
#
include
<
QtCore
/
qpoint
.
h
>
21
#
include
<
QtCore
/
qrect
.
h
>
22
#
include
<
QtWidgets
/
qapplication
.
h
>
23
24
QT_BEGIN_NAMESPACE
25
26
class
QAction;
27
28
class
QDesignerActionProviderExtension
29
{
30
public
:
31
virtual
~
QDesignerActionProviderExtension
() =
default
;
32
33
virtual
QRect
actionGeometry
(QAction *action)
const
= 0;
34
virtual
QAction *
actionAt
(
const
QPoint &pos)
const
= 0;
35
36
virtual
void
adjustIndicator
(
const
QPoint &pos) = 0;
37
};
38
39
// Find action at the given position for a widget that has actionGeometry() (QToolBar,
40
// QMenuBar, QMenu). They usually have actionAt(), but that fails since Designer usually sets
41
// WA_TransparentForMouseEvents on the widgets.
42
template
<
class
Widget>
43
int
actionIndexAt
(
const
Widget *w,
const
QPoint &pos, Qt::Orientation orientation)
44
{
45
const
auto
actions = w->actions();
46
if
(actions.isEmpty())
47
return
-1;
48
// actionGeometry() can be wrong sometimes; it returns a geometry that
49
// stretches to the end of the toolbar/menu bar. So, check from the beginning
50
// in the case of a horizontal right-to-left orientation.
51
const
bool
checkTopRight = orientation == Qt::Horizontal && w->layoutDirection() == Qt::RightToLeft;
52
const
QPoint topRight = QPoint(w->rect().width(), 0);
53
for
(qsizetype index = 0, actionCount = actions.size(); index < actionCount; ++index) {
54
QRect g = w->actionGeometry(actions.at(index));
55
if
(checkTopRight)
56
g.setTopRight(topRight);
57
else
58
g.setTopLeft(QPoint(0, 0));
59
60
if
(g.contains(pos))
61
return
int
(index);
62
}
63
return
-1;
64
}
65
66
Q_DECLARE_EXTENSION_INTERFACE(QDesignerActionProviderExtension,
"org.qt-project.Qt.Designer.ActionProvider"
)
67
68
QT_END_NAMESPACE
69
70
#
endif
// ACTIONPROVIDER_H
actionIndexAt
int actionIndexAt(const Widget *w, const QPoint &pos, Qt::Orientation orientation)
Definition
actionprovider_p.h:43
QDesignerActionProviderExtension
Definition
actionprovider_p.h:29
QDesignerActionProviderExtension::~QDesignerActionProviderExtension
virtual ~QDesignerActionProviderExtension()=default
QDesignerActionProviderExtension::actionGeometry
virtual QRect actionGeometry(QAction *action) const =0
QDesignerActionProviderExtension::actionAt
virtual QAction * actionAt(const QPoint &pos) const =0
QDesignerActionProviderExtension::adjustIndicator
virtual void adjustIndicator(const QPoint &pos)=0
QT_FORMEDITOR_EXPORT
#define QT_FORMEDITOR_EXPORT
Definition
formeditor_global.h:17
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qdesigner_internal
Auxiliary methods to store/retrieve settings.
Definition
buddyeditor.cpp:67
qdesigner_internal::verticalIndicatorRect
static QRect verticalIndicatorRect(const QRect &rect)
Definition
default_actionprovider.cpp:51
qdesigner_internal::horizontalIndicatorRect
static QRect horizontalIndicatorRect(const QRect &rect, Qt::LayoutDirection layoutDirection)
Definition
default_actionprovider.cpp:41
qdesigner_internal::indicatorSize
@ indicatorSize
Definition
default_actionprovider.cpp:37
qttools
src
designer
src
lib
shared
actionprovider_p.h
Generated on
for Qt by
1.18.0