Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
default_actionprovider.cpp
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
7
8#include <QtWidgets/qapplication.h>
9
10#include <QtGui/qaction.h>
11
12#include <QtCore/qrect.h>
13#include <QtCore/qdebug.h>
14
16
17namespace qdesigner_internal {
18
19// ------------ ActionProviderBase:
20// Draws the drag indicator when dragging an action over a widget
21// that receives action Dnd, such as ToolBar, Menu or MenuBar.
35
36enum { indicatorSize = 2 };
37
38// Position an indicator horizontally over the rectangle, indicating
39// 'Insert before' (left or right according to layout direction)
40static inline QRect horizontalIndicatorRect(const QRect &rect, Qt::LayoutDirection layoutDirection)
41{
42 // Position right?
43 QRect rc = QRect(rect.x(), 0, indicatorSize, rect.height() - 1);
44 if (layoutDirection == Qt::RightToLeft)
45 rc.moveLeft(rc.x() + rect.width() - indicatorSize);
46 return rc;
47}
48
49// Position an indicator vertically over the rectangle, indicating 'Insert before' (top)
50static inline QRect verticalIndicatorRect(const QRect &rect)
51{
52 return QRect(0, rect.top(), rect.width() - 1, indicatorSize);
53}
54
55// Determine the geometry of the indicator by retrieving
56// the action under mouse and positioning the bar within its geometry.
65
66// Adjust the indicator while dragging. (-1,1) is called to finish a DND operation
68{
69 if (pos == QPoint(-1, -1)) {
71 return;
72 }
74 if (ig.isValid()) {
77 if (p.color(m_indicator->backgroundRole()) != Qt::red) {
80 }
83 } else {
85 }
86}
87
88// ------------- QToolBarActionProvider
95
100
105
110
112{
114 if (actionRect.isValid())
115 return actionRect;
116 // Toolbar differs in that is has no dummy placeholder to 'insert before'
117 // when intending to append. Check the free area.
119 if (!freeArea.contains(pos))
120 return QRect();
122}
123
124// ------------- QMenuBarActionProvider
131
136
138{
139 return m_widget->actionAt(pos);
140}
141
146
147// ------------- QMenuActionProvider
154
159
161{
162 return m_widget->actionAt(pos);
163}
164
166{
167 return Qt::Vertical;
168}
169}
170
171QT_END_NAMESPACE
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static QRect verticalIndicatorRect(const QRect &rect)
static QRect horizontalIndicatorRect(const QRect &rect, Qt::LayoutDirection layoutDirection)