Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
83212cc4
Commit
83212cc4
authored
May 03, 2012
by
Anatoly Mihalchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SANKORE-613
Frame buttons Part 1: changes in toolbars
parent
62a82e1d
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1389 additions
and
1252 deletions
+1389
-1252
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+802
-794
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+77
-3
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+34
-0
UBGraphicsTextItemDelegate.cpp
src/domain/UBGraphicsTextItemDelegate.cpp
+9
-5
UBGraphicsVideoItemDelegate.cpp
src/domain/UBGraphicsVideoItemDelegate.cpp
+351
-336
UBGraphicsVideoItemDelegate.h
src/domain/UBGraphicsVideoItemDelegate.h
+116
-114
No files found.
src/domain/UBGraphicsDelegateFrame.cpp
View file @
83212cc4
This diff is collapsed.
Click to expand it.
src/domain/UBGraphicsItemDelegate.cpp
View file @
83212cc4
...
...
@@ -37,6 +37,9 @@
#include "UBGraphicsWidgetItem.h"
#include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "web/UBWebController.h"
...
...
@@ -93,6 +96,8 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
void
UBGraphicsItemDelegate
::
init
()
{
mToolBarItem
=
new
UBGraphicsToolBarItem
(
delegated
());
mFrame
=
new
UBGraphicsDelegateFrame
(
this
,
QRectF
(
0
,
0
,
0
,
0
),
mFrameWidth
,
mRespectRatio
);
mFrame
->
hide
();
mFrame
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
...
...
@@ -123,10 +128,13 @@ void UBGraphicsItemDelegate::init()
foreach
(
DelegateButton
*
button
,
mButtons
)
{
if
(
button
->
getSection
()
!=
Qt
::
TitleBarArea
)
{
button
->
hide
();
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
}
}
}
UBGraphicsItemDelegate
::~
UBGraphicsItemDelegate
()
...
...
@@ -292,13 +300,20 @@ void UBGraphicsItemDelegate::positionHandles()
updateButtons
(
true
);
if
(
mToolBarItem
->
isVisibleOnBoard
())
{
updateToolBar
();
mToolBarItem
->
show
();
}
}
else
{
foreach
(
DelegateButton
*
button
,
mButtons
)
button
->
hide
();
mFrame
->
hide
();
mToolBarItem
->
hide
();
}
}
void
UBGraphicsItemDelegate
::
setZOrderButtonsVisible
(
bool
visible
)
{
if
(
visible
)
{
...
...
@@ -335,6 +350,7 @@ void UBGraphicsItemDelegate::remove(bool canUndo)
scene
->
removeItem
(
mFrame
);
scene
->
removeItem
(
mDelegated
);
scene
->
removeItem
(
mToolBarItem
);
if
(
canUndo
)
{
...
...
@@ -577,14 +593,16 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
int
i
=
1
,
j
=
0
,
k
=
0
;
while
((
i
+
j
+
k
)
<
mButtons
.
size
())
{
DelegateButton
*
button
=
mButtons
[
i
+
j
];
button
->
setParentItem
(
mFrame
);
button
->
setTransform
(
tr
);
if
(
button
->
getSection
()
==
Qt
::
TopLeftSection
)
{
button
->
setParentItem
(
mFrame
);
button
->
setPos
(
topX
+
(
i
++
*
1.6
*
mFrameWidth
*
mAntiScaleRatio
),
topY
);
button
->
setTransform
(
tr
);
}
else
if
(
button
->
getSection
()
==
Qt
::
BottomLeftSection
)
{
button
->
setParentItem
(
mFrame
);
button
->
setPos
(
bottomX
+
(
++
j
*
1.6
*
mFrameWidth
*
mAntiScaleRatio
),
bottomY
);
}
else
if
(
button
->
getSection
()
==
Qt
::
NoSection
)
{
button
->
setTransform
(
tr
);
}
else
if
(
button
->
getSection
()
==
Qt
::
TitleBarArea
||
button
->
getSection
()
==
Qt
::
NoSection
){
++
k
;
}
if
(
!
button
->
scene
())
...
...
@@ -599,9 +617,65 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
}
}
void
UBGraphicsItemDelegate
::
updateToolBar
()
{
QTransform
transformForToolbarButtons
;
transformForToolbarButtons
.
scale
(
mAntiScaleRatio
,
1
);
QRectF
toolBarRect
=
mToolBarItem
->
rect
();
toolBarRect
.
setWidth
(
delegated
()
->
boundingRect
().
width
()
-
10
);
mToolBarItem
->
setRect
(
toolBarRect
);
if
(
mToolBarItem
->
isShifting
())
mToolBarItem
->
setPos
(
delegated
()
->
boundingRect
().
bottomLeft
()
+
QPointF
(
5
*
mAntiScaleRatio
,
0
));
else
mToolBarItem
->
setPos
(
delegated
()
->
boundingRect
().
bottomLeft
()
-
QPointF
(
-
5
*
mAntiScaleRatio
,
mToolBarItem
->
rect
().
height
()
*
1.1
*
mAntiScaleRatio
));
int
offsetOnToolBar
=
5
*
mAntiScaleRatio
;
QList
<
QGraphicsItem
*>
itemList
=
mToolBarItem
->
itemsOnToolBar
();
foreach
(
QGraphicsItem
*
item
,
itemList
)
{
item
->
setPos
(
offsetOnToolBar
,
0
);
offsetOnToolBar
+=
(
item
->
boundingRect
().
width
()
+
5
)
*
mAntiScaleRatio
;
item
->
setTransform
(
transformForToolbarButtons
);
item
->
show
();
}
mToolBarItem
->
setOffsetOnToolBar
(
offsetOnToolBar
);
QTransform
tr
;
tr
.
scale
(
1
,
mAntiScaleRatio
);
mToolBarItem
->
setTransform
(
tr
);
}
void
UBGraphicsItemDelegate
::
setButtonsVisible
(
bool
visible
)
{
foreach
(
DelegateButton
*
pButton
,
mButtons
){
pButton
->
setVisible
(
visible
);
}
}
UBGraphicsToolBarItem
::
UBGraphicsToolBarItem
(
QGraphicsItem
*
parent
)
:
QGraphicsRectItem
(
parent
),
mShifting
(
true
),
mVisible
(
false
),
mMinWidth
(
200
)
{
QRectF
rect
=
this
->
rect
();
rect
.
setHeight
(
26
);
this
->
setRect
(
rect
);
setBrush
(
QColor
(
UBSettings
::
paletteColor
));
setPen
(
Qt
::
NoPen
);
hide
();
}
void
UBGraphicsToolBarItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
Q_UNUSED
(
option
);
Q_UNUSED
(
widget
);
QPainterPath
path
;
path
.
addRoundedRect
(
rect
(),
10
,
10
);
painter
->
fillPath
(
path
,
brush
());
}
\ No newline at end of file
src/domain/UBGraphicsItemDelegate.h
View file @
83212cc4
...
...
@@ -84,6 +84,31 @@ class DelegateButton: public QGraphicsSvgItem
};
class
UBGraphicsToolBarItem
:
public
QGraphicsRectItem
,
public
QObject
{
public
:
UBGraphicsToolBarItem
(
QGraphicsItem
*
parent
=
0
);
virtual
~
UBGraphicsToolBarItem
()
{};
bool
isVisibleOnBoard
()
const
{
return
mVisible
;
}
void
setVisibleOnBoard
(
bool
visible
)
{
mVisible
=
visible
;
}
bool
isShifting
()
const
{
return
mShifting
;
}
void
setShifting
(
bool
shifting
)
{
mShifting
=
shifting
;
}
int
offsetOnToolBar
()
const
{
return
mOffsetOnToolBar
;
}
void
setOffsetOnToolBar
(
int
pOffset
)
{
mOffsetOnToolBar
=
pOffset
;
}
QList
<
QGraphicsItem
*>
itemsOnToolBar
()
const
{
return
mItemsOnToolBar
;
}
void
setItemsOnToolBar
(
QList
<
QGraphicsItem
*>
itemsOnToolBar
)
{
mItemsOnToolBar
=
itemsOnToolBar
;}
int
minWidth
()
{
return
mMinWidth
;
}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
private
:
bool
mShifting
;
bool
mVisible
;
int
mOffsetOnToolBar
;
int
mMinWidth
;
QList
<
QGraphicsItem
*>
mItemsOnToolBar
;
};
class
UBGraphicsItemDelegate
:
public
QObject
{
...
...
@@ -138,6 +163,10 @@ class UBGraphicsItemDelegate : public QObject
void
setButtonsVisible
(
bool
visible
);
UBGraphicsToolBarItem
*
getToolBarItem
()
const
{
return
mToolBarItem
;
}
qreal
antiScaleRatio
()
const
{
return
mAntiScaleRatio
;
}
signals
:
void
showOnDisplayChanged
(
bool
shown
);
void
lockChanged
(
bool
locked
);
...
...
@@ -183,12 +212,17 @@ class UBGraphicsItemDelegate : public QObject
QList
<
DelegateButton
*>
mButtons
;
UBGraphicsToolBarItem
*
mToolBarItem
;
protected
slots
:
virtual
void
gotoContentSource
(
bool
checked
);
private
:
void
updateFrame
();
void
updateButtons
(
bool
showUpdated
=
false
);
void
updateToolBar
();
QPointF
mOffset
;
QTransform
mPreviousTransform
;
...
...
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
83212cc4
...
...
@@ -94,17 +94,21 @@ void UBGraphicsTextItemDelegate::buildButtons()
{
UBGraphicsItemDelegate
::
buildButtons
();
mFontButton
=
new
DelegateButton
(
":/images/font.svg"
,
mDelegated
,
m
Frame
,
Qt
::
TopLeftSection
);
mColorButton
=
new
DelegateButton
(
":/images/color.svg"
,
mDelegated
,
m
Frame
,
Qt
::
TopLeftSection
);
mDecreaseSizeButton
=
new
DelegateButton
(
":/images/minus.svg"
,
mDelegated
,
m
Frame
,
Qt
::
TopLeftSection
);
mIncreaseSizeButton
=
new
DelegateButton
(
":/images/plus.svg"
,
mDelegated
,
m
Frame
,
Qt
::
TopLeftSection
);
mFontButton
=
new
DelegateButton
(
":/images/font.svg"
,
mDelegated
,
m
ToolBarItem
,
Qt
::
TitleBarArea
);
mColorButton
=
new
DelegateButton
(
":/images/color.svg"
,
mDelegated
,
m
ToolBarItem
,
Qt
::
TitleBarArea
);
mDecreaseSizeButton
=
new
DelegateButton
(
":/images/minus.svg"
,
mDelegated
,
m
ToolBarItem
,
Qt
::
TitleBarArea
);
mIncreaseSizeButton
=
new
DelegateButton
(
":/images/plus.svg"
,
mDelegated
,
m
ToolBarItem
,
Qt
::
TitleBarArea
);
connect
(
mFontButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
pickFont
()));
connect
(
mColorButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
pickColor
()));
connect
(
mDecreaseSizeButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
decreaseSize
()));
connect
(
mIncreaseSizeButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
increaseSize
()));
mButtons
<<
mFontButton
<<
mColorButton
<<
mDecreaseSizeButton
<<
mIncreaseSizeButton
;
QList
<
QGraphicsItem
*>
itemsOnToolBar
;
itemsOnToolBar
<<
mFontButton
<<
mColorButton
<<
mDecreaseSizeButton
<<
mIncreaseSizeButton
;
mToolBarItem
->
setItemsOnToolBar
(
itemsOnToolBar
);
mToolBarItem
->
setVisibleOnBoard
(
true
);
}
void
UBGraphicsTextItemDelegate
::
contentsChanged
()
...
...
src/domain/UBGraphicsVideoItemDelegate.cpp
View file @
83212cc4
This diff is collapsed.
Click to expand it.
src/domain/UBGraphicsVideoItemDelegate.h
View file @
83212cc4
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBGRAPHICSVIDEOITEMDELEGATE_H_
#define UBGRAPHICSVIDEOITEMDELEGATE_H_
#include <QtGui>
#include <phonon/MediaObject>
#include "core/UB.h"
#include "UBGraphicsItemDelegate.h"
class
QGraphicsSceneMouseEvent
;
class
QGraphicsItem
;
class
UBGraphicsVideoItem
;
class
DelegateVideoControl
:
public
QGraphicsRectItem
{
public
:
DelegateVideoControl
(
UBGraphicsVideoItem
*
pDelegated
,
QGraphicsItem
*
parent
=
0
);
virtual
~
DelegateVideoControl
()
{
// NOOP
}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
QPainterPath
shape
()
const
;
void
setAntiScale
(
qreal
antiScale
){
mAntiScale
=
antiScale
;
}
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
updateTicker
(
qint64
time
);
void
totalTimeChanged
(
qint64
newTotalTime
);
protected
:
void
seekToMousePos
(
QPointF
mousePos
);
UBGraphicsVideoItem
*
mDelegate
;
bool
mDisplayCurrentTime
;
qreal
mAntiScale
;
qint64
mCurrentTimeInMs
;
qint64
mTotalTimeInMs
;
};
class
UBGraphicsVideoItemDelegate
:
public
UBGraphicsItemDelegate
{
Q_OBJECT
public
:
UBGraphicsVideoItemDelegate
(
UBGraphicsVideoItem
*
pDelegated
,
Phonon
::
MediaObject
*
pMedia
,
QObject
*
parent
=
0
);
virtual
~
UBGraphicsVideoItemDelegate
();
virtual
void
positionHandles
();
public
slots
:
void
toggleMute
();
void
updateTicker
(
qint64
time
);
protected
slots
:
virtual
void
remove
(
bool
canUndo
=
true
);
void
togglePlayPause
();
void
mediaStateChanged
(
Phonon
::
State
newstate
,
Phonon
::
State
oldstate
);
void
updatePlayPauseState
();
void
totalTimeChanged
(
qint64
newTotalTime
);
protected
:
virtual
void
buildButtons
();
private
:
UBGraphicsVideoItem
*
delegated
();
DelegateButton
*
mPlayPauseButton
;
DelegateButton
*
mStopButton
;
DelegateButton
*
mMuteButton
;
DelegateVideoControl
*
mVideoControl
;
Phonon
::
MediaObject
*
mMedia
;
};
#endif
/* UBGRAPHICSVIDEOITEMDELEGATE_H_ */
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBGRAPHICSVIDEOITEMDELEGATE_H_
#define UBGRAPHICSVIDEOITEMDELEGATE_H_
#include <QtGui>
#include <phonon/MediaObject>
#include "core/UB.h"
#include "UBGraphicsItemDelegate.h"
class
QGraphicsSceneMouseEvent
;
class
QGraphicsItem
;
class
UBGraphicsVideoItem
;
class
DelegateVideoControl
:
public
QGraphicsRectItem
{
public
:
DelegateVideoControl
(
UBGraphicsVideoItem
*
pDelegated
,
QGraphicsItem
*
parent
=
0
);
virtual
~
DelegateVideoControl
()
{
// NOOP
}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
QPainterPath
shape
()
const
;
void
setAntiScale
(
qreal
antiScale
){
mAntiScale
=
antiScale
;
}
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
updateTicker
(
qint64
time
);
void
totalTimeChanged
(
qint64
newTotalTime
);
protected
:
void
seekToMousePos
(
QPointF
mousePos
);
UBGraphicsVideoItem
*
mDelegate
;
bool
mDisplayCurrentTime
;
qreal
mAntiScale
;
qint64
mCurrentTimeInMs
;
qint64
mTotalTimeInMs
;
private
:
int
mStartWidth
;
QRectF
mBalloon
;
};
class
UBGraphicsVideoItemDelegate
:
public
UBGraphicsItemDelegate
{
Q_OBJECT
public
:
UBGraphicsVideoItemDelegate
(
UBGraphicsVideoItem
*
pDelegated
,
Phonon
::
MediaObject
*
pMedia
,
QObject
*
parent
=
0
);
virtual
~
UBGraphicsVideoItemDelegate
();
virtual
void
positionHandles
();
public
slots
:
void
toggleMute
();
void
updateTicker
(
qint64
time
);
protected
slots
:
virtual
void
remove
(
bool
canUndo
=
true
);
void
togglePlayPause
();
void
mediaStateChanged
(
Phonon
::
State
newstate
,
Phonon
::
State
oldstate
);
void
updatePlayPauseState
();
void
totalTimeChanged
(
qint64
newTotalTime
);
protected
:
virtual
void
buildButtons
();
private
:
UBGraphicsVideoItem
*
delegated
();
DelegateButton
*
mPlayPauseButton
;
DelegateButton
*
mStopButton
;
DelegateButton
*
mMuteButton
;
DelegateVideoControl
*
mVideoControl
;
Phonon
::
MediaObject
*
mMedia
;
};
#endif
/* UBGRAPHICSVIDEOITEMDELEGATE_H_ */
Write
Preview
Markdown
is supported
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