Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
b372f9db
Commit
b372f9db
authored
Aug 13, 2010
by
Thomas Hartmann
Browse files
QuickToolBar: use absolute positioning for dragging
This resolves several usability bugs.
parent
36c40b98
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/libs/qmleditorwidgets/contextpanewidget.cpp
View file @
b372f9db
...
...
@@ -92,7 +92,7 @@ DragWidget::DragWidget(QWidget *parent) : QFrame(parent)
setFrameStyle
(
QFrame
::
NoFrame
);
setFrameShape
(
QFrame
::
StyledPanel
);
setFrameShadow
(
QFrame
::
Sunken
);
m_
old
Pos
=
QPoint
(
-
1
,
-
1
);
m_
start
Pos
=
QPoint
(
-
1
,
-
1
);
m_pos
=
QPoint
(
-
1
,
-
1
);
m_dropShadowEffect
=
new
QGraphicsDropShadowEffect
;
...
...
@@ -104,7 +104,7 @@ DragWidget::DragWidget(QWidget *parent) : QFrame(parent)
void
DragWidget
::
mousePressEvent
(
QMouseEvent
*
event
)
{
if
(
event
->
button
()
==
Qt
::
LeftButton
)
{
m_
old
Pos
=
event
->
globalPos
();
m_
start
Pos
=
event
->
globalPos
()
-
parentWidget
()
->
mapToGlobal
((
pos
()))
;
m_opacityEffect
=
new
QGraphicsOpacityEffect
;
setGraphicsEffect
(
m_opacityEffect
);
event
->
accept
();
...
...
@@ -115,7 +115,7 @@ void DragWidget::mousePressEvent(QMouseEvent * event)
void
DragWidget
::
mouseReleaseEvent
(
QMouseEvent
*
event
)
{
if
(
event
->
button
()
==
Qt
::
LeftButton
)
{
m_
old
Pos
=
QPoint
(
-
1
,
-
1
);
m_
start
Pos
=
QPoint
(
-
1
,
-
1
);
m_dropShadowEffect
=
new
QGraphicsDropShadowEffect
;
m_dropShadowEffect
->
setBlurRadius
(
6
);
m_dropShadowEffect
->
setOffset
(
2
,
2
);
...
...
@@ -124,26 +124,35 @@ void DragWidget::mouseReleaseEvent(QMouseEvent *event)
QFrame
::
mouseReleaseEvent
(
event
);
}
static
inline
int
limit
(
int
a
,
int
min
,
int
max
)
{
if
(
a
<
min
)
return
min
;
if
(
a
>
max
)
return
max
;
return
a
;
}
void
DragWidget
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
if
(
event
->
buttons
()
&&
Qt
::
LeftButton
)
{
if
(
pos
().
x
()
<
10
&&
event
->
pos
().
x
()
<
-
20
)
return
;
if
(
m_oldPos
!=
QPoint
(
-
1
,
-
1
))
{
QPoint
diff
=
event
->
globalPos
()
-
m_oldPos
;
QPoint
newPos
=
pos
()
+
diff
;
if
(
newPos
.
x
()
>
0
&&
newPos
.
y
()
>
0
&&
(
newPos
.
x
()
+
width
())
<
parentWidget
()
->
width
()
&&
(
newPos
.
y
()
+
height
())
<
parentWidget
()
->
height
())
{
if
(
m_secondaryTarget
)
m_secondaryTarget
->
move
(
m_secondaryTarget
->
pos
()
+
diff
);
move
(
newPos
);
m_pos
=
newPos
;
if
(
m_startPos
!=
QPoint
(
-
1
,
-
1
))
{
QPoint
newPos
=
parentWidget
()
->
mapFromGlobal
(
event
->
globalPos
()
-
m_startPos
);
newPos
.
setX
(
limit
(
newPos
.
x
(),
20
,
parentWidget
()
->
width
()
-
20
-
width
()));
newPos
.
setY
(
limit
(
newPos
.
y
(),
2
,
parentWidget
()
->
height
()
-
20
-
height
()));
QPoint
diff
=
pos
()
-
newPos
;
if
(
m_secondaryTarget
)
m_secondaryTarget
->
move
(
m_secondaryTarget
->
pos
()
-
diff
);
move
(
newPos
);
if
(
m_pos
!=
newPos
)
protectedMoved
();
}
m_pos
=
newPos
;
}
else
{
m_opacityEffect
=
new
QGraphicsOpacityEffect
;
setGraphicsEffect
(
m_opacityEffect
);
}
m_oldPos
=
event
->
globalPos
();
event
->
accept
();
}
}
...
...
src/libs/qmleditorwidgets/contextpanewidget.h
View file @
b372f9db
...
...
@@ -68,7 +68,7 @@ protected:
private:
QGraphicsDropShadowEffect
*
m_dropShadowEffect
;
QGraphicsOpacityEffect
*
m_opacityEffect
;
QPoint
m_
old
Pos
;
QPoint
m_
start
Pos
;
QWeakPointer
<
QWidget
>
m_secondaryTarget
;
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment