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
3dd07bb4
Commit
3dd07bb4
authored
Jan 20, 2012
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backup while reworking the teacher bar
parent
15f89fc7
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1464 additions
and
1192 deletions
+1464
-1192
UBTBDocumentEditWidget.cpp
src/gui/UBTBDocumentEditWidget.cpp
+88
-0
UBTBDocumentEditWidget.h
src/gui/UBTBDocumentEditWidget.h
+45
-0
UBTBDocumentPreviewWidget.cpp
src/gui/UBTBDocumentPreviewWidget.cpp
+48
-0
UBTBDocumentPreviewWidget.h
src/gui/UBTBDocumentPreviewWidget.h
+33
-0
UBTBPageEditWidget.cpp
src/gui/UBTBPageEditWidget.cpp
+417
-0
UBTBPageEditWidget.h
src/gui/UBTBPageEditWidget.h
+92
-0
UBTeacherBarDataMgr.cpp
src/gui/UBTeacherBarDataMgr.cpp
+97
-0
UBTeacherBarDataMgr.h
src/gui/UBTeacherBarDataMgr.h
+109
-0
UBTeacherBarPreviewWidget.cpp
src/gui/UBTeacherBarPreviewWidget.cpp
+314
-0
UBTeacherBarPreviewWidget.h
src/gui/UBTeacherBarPreviewWidget.h
+96
-0
UBTeacherBarWidget.cpp
src/gui/UBTeacherBarWidget.cpp
+102
-948
UBTeacherBarWidget.h
src/gui/UBTeacherBarWidget.h
+11
-240
gui.pri
src/gui/gui.pri
+12
-4
No files found.
src/gui/UBTBDocumentEditWidget.cpp
0 → 100644
View file @
3dd07bb4
#include "UBTBDocumentEditWidget.h"
#include "customWidgets/UBGlobals.h"
UBTBDocumentEditWidget
::
UBTBDocumentEditWidget
(
UBTeacherBarDataMgr
*
pDataMgr
,
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpPageViewButton
(
NULL
)
,
mpPreviewButton
(
NULL
)
,
mpTitleLabel
(
NULL
)
,
mpTitle
(
NULL
)
,
mpTargetLabel
(
NULL
)
,
mpTarget
(
NULL
)
,
mpMetadataLabel
(
NULL
)
,
mpLicenseLabel
(
NULL
)
{
setObjectName
(
name
);
mpDataMgr
=
pDataMgr
;
setLayout
(
&
mLayout
);
mLayout
.
setContentsMargins
(
0
,
0
,
0
,
0
);
mpContainer
=
new
QWidget
(
this
);
mpContainer
->
setObjectName
(
"DockPaletteWidgetBox"
);
mLayout
.
addWidget
(
mpContainer
,
1
);
mpContainer
->
setLayout
(
&
mContainerLayout
);
// Title
mpTitleLabel
=
new
QLabel
(
tr
(
"Session Title"
),
mpContainer
);
mpTitleLabel
->
setAlignment
(
Qt
::
AlignLeft
);
//mpTitleLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mContainerLayout
.
addWidget
(
mpTitleLabel
,
0
);
mpTitle
=
new
QLineEdit
(
mpContainer
);
mpTitle
->
setObjectName
(
"DockPaletteWidgetLineEdit"
);
mContainerLayout
.
addWidget
(
mpTitle
,
0
);
// Target
mpTargetLabel
=
new
QLabel
(
tr
(
"Session Target"
),
mpContainer
);
//mpTargetLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mContainerLayout
.
addWidget
(
mpTargetLabel
,
0
);
mpTarget
=
new
QTextEdit
(
mpContainer
);
mpTarget
->
setObjectName
(
"UBTeacherBarTargetBox"
);
mContainerLayout
.
addWidget
(
mpTarget
,
1
);
// Metadata
mpMetadataLabel
=
new
QLabel
(
tr
(
"Metadata"
),
mpContainer
);
mpMetadataLabel
->
setAlignment
(
Qt
::
AlignLeft
);
//mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mContainerLayout
.
addWidget
(
mpMetadataLabel
,
0
);
// License
mpLicenseLabel
=
new
QLabel
(
tr
(
"License"
),
mpContainer
);
mpLicenseLabel
->
setAlignment
(
Qt
::
AlignLeft
);
//mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle");
mContainerLayout
.
addWidget
(
mpLicenseLabel
,
0
);
mpPageViewButton
=
new
QPushButton
(
tr
(
"Page View"
),
this
);
mpPageViewButton
->
setObjectName
(
"DockPaletteWidgetButton"
);
mPreviewLayout
.
addWidget
(
mpPageViewButton
,
0
);
mpPreviewButton
=
new
QPushButton
(
tr
(
"Preview"
),
this
);
mpPreviewButton
->
setObjectName
(
"DockPaletteWidgetButton"
);
mPreviewLayout
.
addWidget
(
mpPreviewButton
,
0
);
mPreviewLayout
.
addStretch
(
1
);
mLayout
.
addLayout
(
&
mPreviewLayout
,
0
);
connect
(
mpPageViewButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onPageView
()));
connect
(
mpPreviewButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onPreview
()));
}
UBTBDocumentEditWidget
::~
UBTBDocumentEditWidget
()
{
DELETEPTR
(
mpTitleLabel
);
DELETEPTR
(
mpTitle
);
DELETEPTR
(
mpTargetLabel
);
DELETEPTR
(
mpTarget
);
DELETEPTR
(
mpMetadataLabel
);
DELETEPTR
(
mpLicenseLabel
);
DELETEPTR
(
mpPageViewButton
);
DELETEPTR
(
mpPreviewButton
);
}
void
UBTBDocumentEditWidget
::
onPageView
()
{
emit
changeTBState
(
eTeacherBarState_PageEdit
);
}
void
UBTBDocumentEditWidget
::
onPreview
()
{
emit
changeTBState
(
eTeacherBarState_DocumentPreview
);
}
src/gui/UBTBDocumentEditWidget.h
0 → 100644
View file @
3dd07bb4
#ifndef UBTBDOCUMENTEDITWIDGET_H
#define UBTBDOCUMENTEDITWIDGET_H
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QTextEdit>
#include "UBTeacherBarDataMgr.h"
class
UBTBDocumentEditWidget
:
public
QWidget
{
Q_OBJECT
public
:
UBTBDocumentEditWidget
(
UBTeacherBarDataMgr
*
pDataMgr
,
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTBDocumentEditWidget"
);
~
UBTBDocumentEditWidget
();
signals
:
void
changeTBState
(
eTeacherBarState
state
);
private
slots
:
void
onPageView
();
void
onPreview
();
private
:
QVBoxLayout
mLayout
;
QHBoxLayout
mPageLayout
;
QHBoxLayout
mPreviewLayout
;
QVBoxLayout
mContainerLayout
;
QPushButton
*
mpPageViewButton
;
QPushButton
*
mpPreviewButton
;
QWidget
*
mpContainer
;
QLabel
*
mpTitleLabel
;
QLineEdit
*
mpTitle
;
QLabel
*
mpTargetLabel
;
QTextEdit
*
mpTarget
;
QLabel
*
mpMetadataLabel
;
QLabel
*
mpLicenseLabel
;
UBTeacherBarDataMgr
*
mpDataMgr
;
};
#endif // UBTBDOCUMENTEDITWIDGET_H
src/gui/UBTBDocumentPreviewWidget.cpp
0 → 100644
View file @
3dd07bb4
#include "customWidgets/UBGlobals.h"
#include "UBTBDocumentPreviewWidget.h"
UBTBDocumentPreviewWidget
::
UBTBDocumentPreviewWidget
(
UBTeacherBarDataMgr
*
pDataMgr
,
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpPageViewButton
(
NULL
)
,
mpEditButton
(
NULL
)
{
setObjectName
(
name
);
mpDataMgr
=
pDataMgr
;
setLayout
(
&
mLayout
);
mpPageViewButton
=
new
QPushButton
(
tr
(
"Page View"
),
this
);
mpPageViewButton
->
setObjectName
(
"DockPaletteWidgetButton"
);
mPageLayout
.
addStretch
(
1
);
mPageLayout
.
addWidget
(
mpPageViewButton
,
0
);
mPageLayout
.
addStretch
(
1
);
mLayout
.
addLayout
(
&
mPageLayout
);
// TODO : Add the elements here
mpEditButton
=
new
QPushButton
(
tr
(
"Edit"
),
this
);
mpEditButton
->
setObjectName
(
"DockPaletteWidgetButton"
);
mPreviewLayout
.
addStretch
(
1
);
mPreviewLayout
.
addWidget
(
mpEditButton
,
0
);
mPreviewLayout
.
addStretch
(
1
);
mLayout
.
addLayout
(
&
mPreviewLayout
);
connect
(
mpPageViewButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onPageView
()));
connect
(
mpEditButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onEdit
()));
}
UBTBDocumentPreviewWidget
::~
UBTBDocumentPreviewWidget
()
{
DELETEPTR
(
mpPageViewButton
);
DELETEPTR
(
mpEditButton
);
}
void
UBTBDocumentPreviewWidget
::
onEdit
()
{
emit
changeTBState
(
eTeacherBarState_DocumentEdit
);
}
void
UBTBDocumentPreviewWidget
::
onPageView
()
{
emit
changeTBState
(
eTeacherBarState_PagePreview
);
}
src/gui/UBTBDocumentPreviewWidget.h
0 → 100644
View file @
3dd07bb4
#ifndef UBTBDOCUMENTPREVIEWWIDGET_H
#define UBTBDOCUMENTPREVIEWWIDGET_H
#include <QVBoxLayout>
#include <QPushButton>
#include "UBTeacherBarDataMgr.h"
class
UBTBDocumentPreviewWidget
:
public
QWidget
{
Q_OBJECT
public
:
UBTBDocumentPreviewWidget
(
UBTeacherBarDataMgr
*
pDataMgr
,
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTBDocumentPreviewWidget"
);
~
UBTBDocumentPreviewWidget
();
signals
:
void
changeTBState
(
eTeacherBarState
state
);
private
slots
:
void
onPageView
();
void
onEdit
();
private
:
QVBoxLayout
mLayout
;
QHBoxLayout
mPageLayout
;
QHBoxLayout
mPreviewLayout
;
QPushButton
*
mpPageViewButton
;
QPushButton
*
mpEditButton
;
UBTeacherBarDataMgr
*
mpDataMgr
;
};
#endif // UBTBDOCUMENTPREVIEWWIDGET_H
src/gui/UBTBPageEditWidget.cpp
0 → 100644
View file @
3dd07bb4
#include "customWidgets/UBGlobals.h"
#include "core/UBApplication.h"
#include "frameworks/UBFileSystemUtils.h"
#include "gui/UBMediaPlayer.h"
#include "customWidgets/UBMediaWidget.h"
#include "UBTBPageEditWidget.h"
UBTBPageEditWidget
::
UBTBPageEditWidget
(
UBTeacherBarDataMgr
*
pDataMgr
,
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpDataMgr
(
NULL
)
,
mpTitleLabel
(
NULL
)
,
mpTitle
(
NULL
)
,
mpMediaLabel
(
NULL
)
,
mpActionLabel
(
NULL
)
,
mpActions
(
NULL
)
,
mpActionButton
(
NULL
)
,
mpLinkLabel
(
NULL
)
,
mpLinks
(
NULL
)
,
mpLinkButton
(
NULL
)
,
mpCommentLabel
(
NULL
)
,
mpComments
(
NULL
)
,
mpDocumentEditbutton
(
NULL
)
,
mpPagePreviewButton
(
NULL
)
,
mpContainer
(
NULL
)
{
Q_UNUSED
(
name
);
mpDataMgr
=
pDataMgr
;
setAttribute
(
Qt
::
WA_StyledBackground
,
true
);
setStyleSheet
(
UBApplication
::
globalStyleSheet
());
mLayout
.
setContentsMargins
(
0
,
0
,
0
,
0
);
setLayout
(
&
mLayout
);
mpContainer
=
new
QWidget
(
this
);
mpContainer
->
setObjectName
(
"DockPaletteWidgetBox"
);
mpContainer
->
setLayout
(
&
mContainerLayout
);
mLayout
.
addWidget
(
mpContainer
,
1
);
// Title
mpTitleLabel
=
new
QLabel
(
tr
(
"Title"
),
mpContainer
);
mpTitle
=
new
QLineEdit
(
mpContainer
);
mpTitle
->
setObjectName
(
"DockPaletteWidgetLineEdit"
);
connect
(
mpTitle
,
SIGNAL
(
textChanged
(
const
QString
&
)),
this
,
SLOT
(
onTitleTextChanged
(
const
QString
&
)));
mContainerLayout
.
addWidget
(
mpTitleLabel
,
0
);
mContainerLayout
.
addWidget
(
mpTitle
,
0
);
// Actions
mpActionLabel
=
new
QLabel
(
tr
(
"Actions"
),
mpContainer
);
mContainerLayout
.
addWidget
(
mpActionLabel
,
0
);
mpActions
=
new
UBWidgetList
(
mpContainer
);
mpActions
->
setEmptyText
(
tr
(
"Add actions"
));
mContainerLayout
.
addWidget
(
mpActions
,
1
);
mpActionButton
=
new
QPushButton
(
mpContainer
);
mpActionButton
->
setObjectName
(
"DockPaletteWidgetButton"
);
mpActionButton
->
setText
(
tr
(
"Add action"
));
mActionLayout
.
addWidget
(
mpActionButton
,
0
);
mActionLayout
.
addStretch
(
1
);
mContainerLayout
.
addLayout
(
&
mActionLayout
,
0
);
// Media
mpMediaLabel
=
new
QLabel
(
tr
(
"Medias"
),
mpContainer
);
mContainerLayout
.
addWidget
(
mpMediaLabel
,
0
);
mpMediaContainer
=
new
UBTBMediaContainer
(
mpContainer
);
mpMediaContainer
->
setEmptyText
(
tr
(
"Drop media here"
));
mContainerLayout
.
addWidget
(
mpMediaContainer
,
1
);
// Links
mpLinkLabel
=
new
QLabel
(
tr
(
"Links"
),
mpContainer
);
mContainerLayout
.
addWidget
(
mpLinkLabel
,
0
);
mpLinks
=
new
UBWidgetList
(
mpContainer
);
mContainerLayout
.
addWidget
(
mpLinks
,
1
);
mpLinkButton
=
new
QPushButton
(
tr
(
"Add link"
),
mpContainer
);
mpLinkButton
->
setObjectName
(
"DockPaletteWidgetButton"
);
mLinkLayout
.
addWidget
(
mpLinkButton
,
0
);
mLinkLayout
.
addStretch
(
1
);
mContainerLayout
.
addLayout
(
&
mLinkLayout
,
0
);
// Comments
mpCommentLabel
=
new
QLabel
(
tr
(
"Comments"
),
mpContainer
);
mContainerLayout
.
addWidget
(
mpCommentLabel
,
0
);
mpComments
=
new
QTextEdit
(
mpContainer
);
mpComments
->
setObjectName
(
"DockPaletteWidgetBox"
);
mpComments
->
setStyleSheet
(
"background:white;"
);
mContainerLayout
.
addWidget
(
mpComments
,
1
);
mpPagePreviewButton
=
new
QPushButton
(
tr
(
"Preview"
),
this
);
mpPagePreviewButton
->
setObjectName
(
"DockPaletteWidgetButton"
);
mpDocumentEditbutton
=
new
QPushButton
(
tr
(
"Document View"
),
this
);
mpDocumentEditbutton
->
setObjectName
(
"DockPaletteWidgetButton"
);
mPagePreviewLayout
.
addWidget
(
mpDocumentEditbutton
,
0
);
mPagePreviewLayout
.
addWidget
(
mpPagePreviewButton
,
0
);
mPagePreviewLayout
.
addStretch
(
1
);
mLayout
.
addLayout
(
&
mPagePreviewLayout
,
0
);
connect
(
mpTitle
,
SIGNAL
(
textChanged
(
QString
)),
this
,
SLOT
(
onValueChanged
()));
connect
(
mpActionButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onActionButton
()));
connect
(
mpLinkButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onLinkButton
()));
connect
(
mpDocumentEditbutton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onDocumentEditClicked
()));
connect
(
mpPagePreviewButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onPagePreviewClicked
()));
connect
(
mpMediaContainer
,
SIGNAL
(
mediaDropped
(
QString
)),
this
,
SLOT
(
onMediaDropped
(
QString
)));
}
UBTBPageEditWidget
::~
UBTBPageEditWidget
()
{
DELETEPTR
(
mpDocumentEditbutton
);
DELETEPTR
(
mpPagePreviewButton
);
DELETEPTR
(
mpComments
);
DELETEPTR
(
mpCommentLabel
);
DELETEPTR
(
mpLinks
);
DELETEPTR
(
mpLinkLabel
);
DELETEPTR
(
mpLinkButton
);
DELETEPTR
(
mpMediaLabel
);
DELETEPTR
(
mpActionButton
);
DELETEPTR
(
mpActionLabel
);
DELETEPTR
(
mpTitleLabel
);
DELETEPTR
(
mpTitle
);
}
void
UBTBPageEditWidget
::
onValueChanged
()
{
mpDataMgr
->
setPageTitle
(
mpTitle
->
text
());
mpDataMgr
->
setComments
(
mpComments
->
document
()
->
toPlainText
());
emit
valueChanged
();
}
void
UBTBPageEditWidget
::
onActionButton
()
{
UBTeacherStudentAction
*
pAction
=
new
UBTeacherStudentAction
(
this
);
mpDataMgr
->
actions
()
<<
pAction
;
mpActions
->
addWidget
(
pAction
);
}
void
UBTBPageEditWidget
::
onLinkButton
()
{
UBUrlWidget
*
pUrl
=
new
UBUrlWidget
(
this
);
mpDataMgr
->
urls
()
<<
pUrl
;
mpLinks
->
addWidget
(
pUrl
);
}
void
UBTBPageEditWidget
::
onMediaDropped
(
const
QString
&
url
)
{
if
(
""
!=
url
){
QWidget
*
pMedia
=
mpMediaContainer
->
generateMediaWidget
(
url
);
if
(
NULL
!=
pMedia
){
mpDataMgr
->
medias
()
<<
pMedia
;
mpMediaContainer
->
addWidget
(
pMedia
);
}
}
}
void
UBTBPageEditWidget
::
saveInfos
(
sTeacherBarInfos
*
infos
)
{
if
(
NULL
!=
infos
){
infos
->
title
=
mpTitle
->
text
();
// Actions
for
(
int
i
=
0
;
i
<
mpDataMgr
->
actions
().
size
();
i
++
){
infos
->
actions
<<
QString
(
"%0;%1"
).
arg
(
mpDataMgr
->
actions
().
at
(
i
)
->
comboValue
()).
arg
(
mpDataMgr
->
actions
().
at
(
i
)
->
text
());
}
// Media
foreach
(
QString
media
,
mpMediaContainer
->
mediaUrls
()){
infos
->
medias
<<
media
;
}
// Links
for
(
int
j
=
0
;
j
<
mpDataMgr
->
urls
().
size
();
j
++
){
if
(
""
!=
mpDataMgr
->
urls
().
at
(
j
)
->
url
()){
infos
->
urls
<<
mpDataMgr
->
urls
().
at
(
j
)
->
url
();
}
}
// Comments
infos
->
comments
=
mpComments
->
document
()
->
toPlainText
();
}
}
void
UBTBPageEditWidget
::
loadInfos
(
sTeacherBarInfos
*
infos
)
{
if
(
NULL
!=
infos
){
// Title
mpTitle
->
setText
(
infos
->
title
);
mpDataMgr
->
setPageTitle
(
infos
->
title
);
// Actions
for
(
int
i
=
0
;
i
<
infos
->
actions
.
size
();
i
++
){
QStringList
qslAction
=
infos
->
actions
.
at
(
i
).
split
(
";"
);
if
(
qslAction
.
size
()
>=
2
){
UBTeacherStudentAction
*
pAction
=
new
UBTeacherStudentAction
(
this
);
pAction
->
setComboValue
(
qslAction
.
at
(
0
).
toInt
());
pAction
->
setText
(
qslAction
.
at
(
1
));
mpDataMgr
->
actions
()
<<
pAction
;
mpActions
->
addWidget
(
pAction
);
}
}
// Media
foreach
(
QString
url
,
infos
->
medias
){
if
(
""
!=
url
){
QWidget
*
pMedia
=
mpMediaContainer
->
generateMediaWidget
(
url
);
if
(
NULL
!=
pMedia
){
mpDataMgr
->
medias
()
<<
pMedia
;
mpMediaContainer
->
addWidget
(
pMedia
);
}
}
}
// Links
for
(
int
j
=
0
;
j
<
infos
->
urls
.
size
();
j
++
){
QString
qsUrl
=
infos
->
urls
.
at
(
j
);
if
(
""
!=
qsUrl
){
UBUrlWidget
*
pLink
=
new
UBUrlWidget
(
this
);
pLink
->
setUrl
(
qsUrl
);
mpDataMgr
->
urls
()
<<
pLink
;
mpLinks
->
addWidget
(
pLink
);
}
}
// Comments
if
(
NULL
!=
mpComments
){
mpComments
->
document
()
->
setPlainText
(
infos
->
comments
);
}
}
}
void
UBTBPageEditWidget
::
onDocumentEditClicked
()
{
emit
changeTBState
(
eTeacherBarState_DocumentEdit
);
}
void
UBTBPageEditWidget
::
onPagePreviewClicked
()
{
emit
changeTBState
(
eTeacherBarState_PagePreview
);
}
// ---------------------------------------------------------------------------------------------
UBUrlWidget
::
UBUrlWidget
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpLayout
(
NULL
)
,
mpUrlLabel
(
NULL
)
,
mpUrl
(
NULL
)
{
setObjectName
(
name
);
setAttribute
(
Qt
::
WA_StyledBackground
,
true
);
setStyleSheet
(
UBApplication
::
globalStyleSheet
());
mpLayout
=
new
QVBoxLayout
(
this
);
setLayout
(
mpLayout
);
mpLabelLayout
=
new
QHBoxLayout
(
this
);
mpUrlLabel
=
new
QLabel
(
tr
(
"Url"
),
this
);
mpLabelLayout
->
addWidget
(
mpUrlLabel
,
0
);
mpUrl
=
new
QLineEdit
(
this
);
mpUrl
->
setObjectName
(
"DockPaletteWidgetLineEdit"
);
mpUrl
->
setMinimumHeight
(
20
);
mpLabelLayout
->
addWidget
(
mpUrl
,
1
);
mpTitleLayout
=
new
QHBoxLayout
(
this
);
mpTitleLabel
=
new
QLabel
(
tr
(
"Title"
),
this
);
mpTitleLayout
->
addWidget
(
mpTitleLabel
,
0
);
mpTitle
=
new
QLineEdit
(
this
);
mpTitle
->
setObjectName
(
"DockPaletteWidgetLineEdit"
);
mpTitle
->
setMinimumHeight
(
20
);
mpTitleLayout
->
addWidget
(
mpTitle
,
1
);
mpLayout
->
addLayout
(
mpTitleLayout
);
mpLayout
->
addLayout
(
mpLabelLayout
);
}
UBUrlWidget
::~
UBUrlWidget
()
{
DELETEPTR
(
mpTitle
);
DELETEPTR
(
mpTitleLabel
);
DELETEPTR
(
mpUrlLabel
);
DELETEPTR
(
mpUrl
);
DELETEPTR
(
mpTitleLayout
);
DELETEPTR
(
mpLabelLayout
);
DELETEPTR
(
mpLayout
);
}
QString
UBUrlWidget
::
url
()
{
QString
str
;
if
(
NULL
!=
mpUrl
){
str
=
mpUrl
->
text
()
+
";"
+
mpTitle
->
text
();
}
return
str
;
}
void
UBUrlWidget
::
setUrl
(
const
QString
&
url
)
{
QStringList
list
=
url
.
split
(
";"
);
if
(
NULL
!=
mpUrl
){
mpUrl
->
setText
(
list
.
at
(
0
));
mpTitle
->
setText
(
list
.
at
(
1
));
}
}
// ------------------------------------------------------------------------------------------------------------------------------------
UBTBMediaContainer
::
UBTBMediaContainer
(
QWidget
*
parent
,
const
char
*
name
)
:
UBWidgetList
(
parent
)
{
setObjectName
(
name
);
setAcceptDrops
(
true
);
}
UBTBMediaContainer
::~
UBTBMediaContainer
()
{
}
void
UBTBMediaContainer
::
dropEvent
(
QDropEvent
*
pEvent
)
{
QPixmap
pixFromDropEvent
;
QString
mimeType
;
QString
resourcePath
;
if
(
pEvent
->
mimeData
()
->
hasText
()){
resourcePath
=
pEvent
->
mimeData
()
->
text
();
}
else
if
(
pEvent
->
mimeData
()
->
hasUrls
()){
resourcePath
=
pEvent
->
mimeData
()
->
urls
().
at
(
0
).
toLocalFile
();
}
else
if
(
pEvent
->
mimeData
()
->
hasImage
()){
pixFromDropEvent
.
loadFromData
(
pEvent
->
mimeData
()
->
imageData
().
toByteArray
());
if
(
!
pixFromDropEvent
.
isNull
())
mimeType
=
"image"
;
}
if
(
mimeType
.
isEmpty
()
&&
resourcePath
.
isEmpty
()){
pEvent
->
acceptProposedAction
();
return
;
}
if
(
!
resourcePath
.
isEmpty
()){
emit
mediaDropped
(
resourcePath
);
pEvent
->
acceptProposedAction
();
}
}
void
UBTBMediaContainer
::
dragEnterEvent
(
QDragEnterEvent
*
pEvent
)
{
pEvent
->
acceptProposedAction
();
}
void
UBTBMediaContainer
::
dragMoveEvent
(
QDragMoveEvent
*
pEvent
)
{
pEvent
->
acceptProposedAction
();
}
void
UBTBMediaContainer
::
dragLeaveEvent
(
QDragLeaveEvent
*
pEvent
)
{
pEvent
->
accept
();
}
void
UBTBMediaContainer
::
addMedia
(
const
QString
&
mediaPath
)
{
if
(
!
mediaPath
.
isEmpty
())
mMediaList
.
append
(
mediaPath
);
else
qWarning
()
<<
__FUNCTION__
<<
"empty path"
;
QString
mimeType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
mediaPath
);
if
(
mimeType
.
contains
(
"image"
)){
QPixmap
pix
=
QPixmap
(
mediaPath
);
QLabel
*
label
=
new
QLabel
();
label
->
setPixmap
(
pix
);
label
->
setScaledContents
(
true
);
addWidget
(
label
);
}
else
if
(
mimeType
.
contains
(
"video"
)
||
mimeType
.
contains
(
"audio"
)){
UBMediaPlayer
*
mediaPlayer
=
new
UBMediaPlayer
();
mediaPlayer
->
setFile
(
mediaPath
);
addWidget
(
mediaPlayer
);
}
else
{
qWarning
()
<<
"pMediaPath"
<<
mediaPath
;
qWarning
()
<<
"bad idea to come here"
;
}
}
QStringList
UBTBMediaContainer
::
mediaUrls
()
{
return
mMediaList
;
}
void
UBTBMediaContainer
::
cleanMedias
()
{
mMediaList
.
clear
();
}
QWidget
*
UBTBMediaContainer
::
generateMediaWidget
(
const
QString
&
url
)
{
QWidget
*
pW
=
NULL
;
if
(
!
url
.
isEmpty
())
mMediaList
.
append
(
url
);
else
qWarning
()
<<
__FUNCTION__
<<
"empty path"
;
QString
mimeType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
url
);
if
(
mimeType
.
contains
(
"image"
)){
QPixmap
pix
=
QPixmap
(
url
);
QLabel
*
label
=
new
QLabel
();
pix
.
scaledToWidth
(
label
->
width
());
label
->
resize
(
pix
.
width
(),
pix
.
height
());
label
->
setPixmap
(
pix
);
label
->
setScaledContents
(
true
);
pW
=
label
;
}
else
if
(
mimeType
.
contains
(
"video"
)
||
mimeType
.
contains
(
"audio"
)){
UBMediaWidget
*
mediaPlayer
=
new
UBMediaWidget
(
mimeType
.
contains
(
"audio"
)
?
eMediaType_Audio
:
eMediaType_Video
);
mediaPlayer
->
setFile
(
url
);
pW
=
mediaPlayer
;
}
else
{
qWarning
()
<<
"pMediaPath"
<<
url
;
qWarning
()
<<
"bad idea to come here"
;
}
return
pW
;
}
src/gui/UBTBPageEditWidget.h
0 → 100644
View file @
3dd07bb4
#ifndef UBTBPAGEEDITWIDGET_H
#define UBTBPAGEEDITWIDGET_H
#include <QString>
#include <QTextEdit>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QComboBox>
#include <QLabel>
#include <QPushButton>
#include "core/UBPersistenceManager.h"
#include "customWidgets/UBWidgetList.h"
#include "interfaces/IDropable.h"
#include "UBTeacherBarDataMgr.h"
class
UBTBMediaContainer
:
public
UBWidgetList
,
public
IDropable
{
Q_OBJECT
public
:
UBTBMediaContainer
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTBMediaContainer"
);
~
UBTBMediaContainer
();
QStringList
mediaUrls
();
QWidget
*
generateMediaWidget
(
const
QString
&
url
);
void
cleanMedias
();
signals
:
void
mediaDropped
(
const
QString
&
url
);
protected
:
void
dropEvent
(
QDropEvent
*
pEvent
);
void
dragEnterEvent
(
QDragEnterEvent
*
pEvent
);
void
dragMoveEvent
(
QDragMoveEvent
*
pEvent
);
void
dragLeaveEvent
(
QDragLeaveEvent
*
pEvent
);
private
:
void
addMedia
(
const
QString
&
mediaPath
);
QStringList
mMediaList
;
};
class
UBTBPageEditWidget
:
public
QWidget
{
Q_OBJECT
public
:
UBTBPageEditWidget
(
UBTeacherBarDataMgr
*
pDataMgr
,
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTBPageEditWidget"
);
~
UBTBPageEditWidget
();
void
saveInfos
(
sTeacherBarInfos
*
infos
);
void
loadInfos
(
sTeacherBarInfos
*
infos
);
signals
:
void
valueChanged
();
void
changeTBState
(
eTeacherBarState
state
);
private
slots
:
void
onValueChanged
();
void
onActionButton
();
void
onLinkButton
();
void
onMediaDropped
(
const
QString
&
url
);
void
onDocumentEditClicked
();
void
onPagePreviewClicked
();
private
:
QVBoxLayout
mLayout
;
QHBoxLayout
mTitleLayout
;
QVBoxLayout
mContainerLayout
;
QHBoxLayout
mActionLayout
;
QHBoxLayout
mLinkLayout
;
QHBoxLayout
mDocumentViewLayout
;
QHBoxLayout
mPagePreviewLayout
;
UBTeacherBarDataMgr
*
mpDataMgr
;
QLabel
*
mpTitleLabel
;
QLineEdit
*
mpTitle
;
QLabel
*
mpMediaLabel
;
UBTBMediaContainer
*
mpMediaContainer
;
QLabel
*
mpActionLabel
;
UBWidgetList
*
mpActions
;
QPushButton
*
mpActionButton
;
QLabel
*
mpLinkLabel
;
UBWidgetList
*
mpLinks
;
QPushButton
*
mpLinkButton
;
QLabel
*
mpCommentLabel
;
QTextEdit
*
mpComments
;
QPushButton
*
mpDocumentEditbutton
;
QPushButton
*
mpPagePreviewButton
;
QWidget
*
mpContainer
;
};
#endif // UBTBPAGEEDITWIDGET_H
src/gui/UBTeacherBarDataMgr.cpp
0 → 100644
View file @
3dd07bb4
#include "core/UBApplication.h"
#include "customWidgets/UBGlobals.h"
#include "UBTeacherBarDataMgr.h"
UBTeacherBarDataMgr
::
UBTeacherBarDataMgr
()
{
}
UBTeacherBarDataMgr
::~
UBTeacherBarDataMgr
()
{
}
void
UBTeacherBarDataMgr
::
clearLists
()
{
mActionList
.
clear
();
mUrlList
.
clear
();
mMediaList
.
clear
();
}
UBTeacherStudentAction
::
UBTeacherStudentAction
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpText
(
NULL
)
,
mpLayout
(
NULL
)
,
mpComboLayout
(
NULL
)
,
mpCombo
(
NULL
)
{
setObjectName
(
name
);
setAttribute
(
Qt
::
WA_StyledBackground
,
true
);
setStyleSheet
(
UBApplication
::
globalStyleSheet
());
// Create the GUI
mpLayout
=
new
QHBoxLayout
(
this
);
setLayout
(
mpLayout
);
mpComboLayout
=
new
QVBoxLayout
();
mpCombo
=
new
QComboBox
(
this
);
mpCombo
->
setObjectName
(
"DockPaletteWidgetComboBox"
);
mpCombo
->
setMinimumWidth
(
80
);
mpCombo
->
addItem
(
tr
(
"Teacher"
));
mpCombo
->
addItem
(
tr
(
"Student"
));
mpComboLayout
->
addWidget
(
mpCombo
,
0
);
mpComboLayout
->
addStretch
(
1
);
mpLayout
->
addLayout
(
mpComboLayout
,
0
);
mpText
=
new
QTextEdit
(
this
);
mpText
->
setObjectName
(
"DockPaletteWidgetBox"
);
mpText
->
setStyleSheet
(
"background:white;"
);
mpLayout
->
addWidget
(
mpText
,
1
);
}
UBTeacherStudentAction
::~
UBTeacherStudentAction
()
{
DELETEPTR
(
mpCombo
);
DELETEPTR
(
mpText
);
DELETEPTR
(
mpComboLayout
);
DELETEPTR
(
mpLayout
);
}
QString
UBTeacherStudentAction
::
text
()
{
QString
str
;
if
(
NULL
!=
mpText
){
str
=
mpText
->
document
()
->
toPlainText
();
}
return
str
;
}
QString
UBTeacherStudentAction
::
comboValue
()
{
QString
str
;
if
(
NULL
!=
mpCombo
){
str
=
QString
(
"%0"
).
arg
(
mpCombo
->
currentIndex
());
}
return
str
;
}
void
UBTeacherStudentAction
::
setComboValue
(
int
value
)
{
if
(
NULL
!=
mpCombo
){
mpCombo
->
setCurrentIndex
(
value
);
}
}
void
UBTeacherStudentAction
::
setText
(
const
QString
&
text
)
{
if
(
NULL
!=
mpText
){
mpText
->
document
()
->
setPlainText
(
text
);
}
}
src/gui/UBTeacherBarDataMgr.h
0 → 100644
View file @
3dd07bb4
#ifndef UBTEACHERBARDATAMGR_H
#define UBTEACHERBARDATAMGR_H
#include <QString>
#include <QWidget>
#include <QTextEdit>
#include <QLineEdit>
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QComboBox>
typedef
enum
{
eTeacherBarState_DocumentEdit
,
eTeacherBarState_DocumentPreview
,
eTeacherBarState_PageEdit
,
eTeacherBarState_PagePreview
}
eTeacherBarState
;
typedef
enum
{
eActionOwner_Teacher
,
eActionOwner_Student
}
eActionOwner
;
class
UBTeacherStudentAction
:
public
QWidget
{
Q_OBJECT
public
:
UBTeacherStudentAction
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTeacherStudentAction"
);
~
UBTeacherStudentAction
();
QString
text
();
QString
comboValue
();
void
setComboValue
(
int
value
);
void
setText
(
const
QString
&
text
);
private
:
QTextEdit
*
mpText
;
QHBoxLayout
*
mpLayout
;
QVBoxLayout
*
mpComboLayout
;
QComboBox
*
mpCombo
;
};
class
UBUrlWidget
:
public
QWidget
{
public
:
UBUrlWidget
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBUrlWidget"
);
~
UBUrlWidget
();
QString
url
();
void
setUrl
(
const
QString
&
url
);
private
:
QVBoxLayout
*
mpLayout
;
QHBoxLayout
*
mpLabelLayout
;
QHBoxLayout
*
mpTitleLayout
;
QLabel
*
mpUrlLabel
;
QLineEdit
*
mpUrl
;
QLabel
*
mpTitleLabel
;
QLineEdit
*
mpTitle
;
};
class
UBTeacherBarDataMgr
{
public
:
UBTeacherBarDataMgr
();
~
UBTeacherBarDataMgr
();
// Session Title
void
setSessionTitle
(
const
QString
&
title
){
mSessionTitle
=
title
;}
QString
sessionTitle
(){
return
mSessionTitle
;}
// Session Target
void
setSessionTarget
(
const
QString
&
target
){
mSessionTarget
=
target
;}
QString
sessionTarget
(){
return
mSessionTarget
;}
// Page Title
void
setPageTitle
(
const
QString
&
title
){
mPageTitle
=
title
;}
QString
pageTitle
(){
return
mPageTitle
;}
// Actions
QVector
<
UBTeacherStudentAction
*>
actions
(){
return
mActionList
;}
// Medias
QVector
<
QWidget
*>
medias
(){
return
mMediaList
;}
// Urls
QVector
<
UBUrlWidget
*>
urls
(){
return
mUrlList
;}
// Comments
void
setComments
(
const
QString
&
c
){
mComments
=
c
;}
QString
comments
(){
return
mComments
;}
// Others
void
clearLists
();
private
:
QString
mSessionTitle
;
QString
mSessionTarget
;
QString
mPageTitle
;
QString
mComments
;
QVector
<
UBTeacherStudentAction
*>
mActionList
;
QVector
<
UBUrlWidget
*>
mUrlList
;
QVector
<
QWidget
*>
mMediaList
;
};
#endif // UBTEACHERBARDATAMGR_H
src/gui/UBTeacherBarPreviewWidget.cpp
0 → 100644
View file @
3dd07bb4
#include "core/UBApplication.h"
#include "customWidgets/UBGlobals.h"
#include "frameworks/UBFileSystemUtils.h"
#include "UBTeacherBarPreviewWidget.h"
UBTeacherBarPreviewMedia
::
UBTeacherBarPreviewMedia
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
{
setObjectName
(
name
);
mWidget
=
new
UBWidgetList
(
parent
);
mLayout
.
addWidget
(
mWidget
);
setLayout
(
&
mLayout
);
mWidgetList
.
clear
();
}
UBTeacherBarPreviewMedia
::~
UBTeacherBarPreviewMedia
()
{
DELETEPTR
(
mWidget
);
}
void
UBTeacherBarPreviewMedia
::
cleanMedia
()
{
foreach
(
QWidget
*
eachWidget
,
mWidgetList
.
keys
()){
if
(
QString
(
eachWidget
->
metaObject
()
->
className
()).
contains
(
"UBDraggable"
)){
mWidget
->
removeWidget
(
eachWidget
);
delete
eachWidget
;
eachWidget
=
NULL
;
}
else
{
mWidget
->
removeWidget
(
eachWidget
);
}
}
mWidgetList
.
clear
();
}
void
UBTeacherBarPreviewMedia
::
loadWidgets
(
QList
<
QWidget
*>
pWidgetsList
,
bool
isResizable
)
{
foreach
(
QWidget
*
eachWidget
,
pWidgetsList
){
mWidget
->
addWidget
(
eachWidget
);
mWidgetList
[
eachWidget
]
=
"DRAG UNAVAILABLE"
;
}
}
int
UBTeacherBarPreviewMedia
::
loadMedia
(
QStringList
pMedias
)
{
int
addedMedia
=
0
;
// foreach(QString eachString, pMedias){
// if(!eachString.isEmpty()){
// QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString);
// if(mimeType.contains("image")){
// UBDraggableLabel* label = new UBDraggableLabel();
// label->loadImage(eachString);
// mWidget->addWidget(label);
// mWidgetList[label]=eachString;
// addedMedia += 1;
// }
// else if(mimeType.contains("video") || mimeType.contains("audio")){
// UBDraggableMediaPlayer* mediaPlayer = new UBDraggableMediaPlayer();
// mediaPlayer->setFile(eachString);
// mWidget->addWidget(mediaPlayer);
// mWidgetList[mediaPlayer] = eachString;
// addedMedia += 1;
// }
// else{
// qWarning() << "pMediaPath" << eachString;
// qWarning() << "bad idea to come here";
// }
// }
// }
return
addedMedia
;
}
// -----------------------------------------------------------------------------------------------
UBActionPreview
::
UBActionPreview
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpOwner
(
NULL
)
,
mpContent
(
NULL
)
{
setObjectName
(
name
);
setLayout
(
&
mLayout
);
mpOwner
=
new
QLabel
(
this
);
mpOwner
->
setObjectName
(
"UBActionPreviewOwner"
);
mOwnerLayout
.
addWidget
(
mpOwner
,
0
);
mOwnerLayout
.
addStretch
(
1
);
mLayout
.
addLayout
(
&
mOwnerLayout
);
mpContent
=
new
QLabel
(
this
);
mpContent
->
setObjectName
(
"UBActionPreviewContent"
);
mpContent
->
setWordWrap
(
true
);
mLayout
.
addWidget
(
mpContent
);
setContentsMargins
(
-
9
,
-
9
,
-
9
,
-
9
);
}
UBActionPreview
::~
UBActionPreview
()
{
if
(
NULL
!=
mpOwner
){
delete
mpOwner
;
mpOwner
=
NULL
;
}
if
(
NULL
!=
mpContent
){
delete
mpContent
;
mpContent
=
NULL
;
}
}
void
UBActionPreview
::
setOwner
(
const
QString
&
owner
)
{
if
(
NULL
!=
mpOwner
&&
NULL
!=
mpContent
){
switch
(
owner
.
toInt
()){
case
eActionOwner_Teacher
:
mpOwner
->
setText
(
tr
(
"Teacher"
));
mpContent
->
setStyleSheet
(
"background:lightblue; border:lightblue;"
);
break
;
case
eActionOwner_Student
:
mpOwner
->
setText
(
tr
(
"Student"
));
mpContent
->
setStyleSheet
(
"background:lightgreen; border:lightgreen;"
);
break
;
}
}
}
void
UBActionPreview
::
setContent
(
const
QString
&
content
)
{
if
(
NULL
!=
mpContent
){
mpContent
->
setText
(
content
);
}
}
// -------------------------------------------------------------------------------------------------------------------
UBTBPreviewContainer
::
UBTBPreviewContainer
(
QWidget
*
parent
,
const
char
*
name
)
:
UBWidgetList
(
parent
)
{
setObjectName
(
name
);
}
UBTBPreviewContainer
::~
UBTBPreviewContainer
()
{
}
// ------------------------------------------------------------------------------------
UBTeacherBarPreviewWidget
::
UBTeacherBarPreviewWidget
(
UBTeacherBarDataMgr
*
pDataMgr
,
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpEditButton
(
NULL
)
,
mpTitle
(
NULL
)
,
mpDuration
(
NULL
)
,
mpActionsLabel
(
NULL
)
,
mpMediaLabel
(
NULL
)
,
mpCommentsLabel
(
NULL
)
,
mpComments
(
NULL
)
,
mpLinksLabel
(
NULL
)
,
mpContentContainer
(
NULL
)
{
setObjectName
(
name
);
mpDataMgr
=
pDataMgr
;
setLayout
(
&
mLayout
);
setAttribute
(
Qt
::
WA_StyledBackground
,
true
);
setStyleSheet
(
UBApplication
::
globalStyleSheet
());
// Build the Preview widget
// Title + duration
mpTitle
=
new
QLabel
(
this
);
mpTitle
->
setObjectName
(
"UBTeacherBarPreviewTitle"
);
mpTitle
->
setWordWrap
(
true
);
mpTitle
->
setAlignment
(
Qt
::
AlignCenter
);
mpDuration
=
new
QLabel
(
this
);
mTitleDurationLayout
.
addWidget
(
mpTitle
,
0
);
mTitleDurationLayout
.
addWidget
(
mpDuration
,
1
);
mLayout
.
addLayout
(
&
mTitleDurationLayout
,
0
);
mpContentContainer
=
new
UBTBPreviewContainer
(
this
);
mLayout
.
addWidget
(
mpContentContainer
,
1
);
//mLayout.addWidget(&mMediaViewer, 1);
// The next line is disgusting. This is a quickfix that must be reworked later
mMediaViewer
.
setContentsMargins
(
-
9
,
-
9
,
-
9
,
-
9
);
hideElements
();
// Edit button
mpEditButton
=
new
QPushButton
(
tr
(
"Edit infos"
),
this
);
mpEditButton
->
setObjectName
(
"DockPaletteWidgetButton"
);
mEditLayout
.
addStretch
(
1
);
mEditLayout
.
addWidget
(
mpEditButton
,
0
);
mEditLayout
.
addStretch
(
1
);
mLayout
.
addLayout
(
&
mEditLayout
,
0
);
connect
(
mpEditButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onEdit
()));
}
UBTeacherBarPreviewWidget
::~
UBTeacherBarPreviewWidget
()
{
DELETEPTR
(
mpLinksLabel
);
DELETEPTR
(
mpComments
);
DELETEPTR
(
mpTitle
);
DELETEPTR
(
mpDuration
);
DELETEPTR
(
mpActionsLabel
);
DELETEPTR
(
mpMediaLabel
);
DELETEPTR
(
mpCommentsLabel
);
DELETEPTR
(
mpContentContainer
);
DELETEPTR
(
mpEditButton
);
}
void
UBTeacherBarPreviewWidget
::
onEdit
()
{
emit
showEditMode
();
}
void
UBTeacherBarPreviewWidget
::
setTitle
(
const
QString
&
title
)
{
if
(
NULL
!=
mpTitle
){
mpTitle
->
setText
(
title
);
}
}
void
UBTeacherBarPreviewWidget
::
setComments
(
const
QString
&
comments
)
{
if
(
""
!=
comments
){
mWidgets
.
clear
();
mpComments
->
setText
(
comments
);
mpComments
->
setVisible
(
true
);
mpCommentsLabel
->
setVisible
(
true
);
mWidgets
<<
mpCommentsLabel
;
mMediaViewer
.
loadWidgets
(
mWidgets
,
false
);
mWidgets
.
clear
();
mWidgets
<<
mpComments
;
mMediaViewer
.
loadWidgets
(
mWidgets
,
true
);
}
}
void
UBTeacherBarPreviewWidget
::
clean
()
{
mMediaViewer
.
cleanMedia
();
foreach
(
QWidget
*
eachWidget
,
mStoredWidgets
){
delete
eachWidget
;
eachWidget
=
NULL
;
}
mStoredWidgets
.
clear
();
hideElements
();
}
void
UBTeacherBarPreviewWidget
::
hideElements
()
{
mpActionsLabel
=
new
QLabel
(
tr
(
"Actions"
),
this
);
mpActionsLabel
->
setObjectName
(
"UBTeacherBarPreviewSubtitle"
);
mpMediaLabel
=
new
QLabel
(
tr
(
"Medias"
),
this
);
mpMediaLabel
->
setObjectName
(
"UBTeacherBarPreviewSubtitle"
);
mpCommentsLabel
=
new
QLabel
(
tr
(
"Comments"
),
this
);
mpCommentsLabel
->
setObjectName
(
"UBTeacherBarPreviewSubtitle"
);
mpComments
=
new
QLabel
(
this
);
mpComments
->
setWordWrap
(
true
);
mpComments
->
setObjectName
(
"UBTeacherBarPreviewComments"
);
mpLinksLabel
=
new
QLabel
(
tr
(
"Links"
),
this
);
mpLinksLabel
->
setObjectName
(
"UBTeacherBarPreviewSubtitle"
);
mpActionsLabel
->
setVisible
(
false
);
mpMediaLabel
->
setVisible
(
false
);
mpCommentsLabel
->
setVisible
(
false
);
mpComments
->
setVisible
(
false
);
mpLinksLabel
->
setVisible
(
false
);
}
void
UBTeacherBarPreviewWidget
::
setActions
(
QStringList
actions
)
{
if
(
!
actions
.
empty
()){
mWidgets
.
clear
();
mpActionsLabel
->
setVisible
(
true
);
mWidgets
<<
mpActionsLabel
;
mediaViewer
()
->
loadWidgets
(
mWidgets
,
false
);
mWidgets
.
clear
();
foreach
(
QString
action
,
actions
){
QStringList
desc
=
action
.
split
(
';'
);
if
(
2
<=
desc
.
size
()){
QString
owner
=
desc
.
at
(
0
);
QString
act
=
desc
.
at
(
1
);
mpTmpAction
=
new
UBActionPreview
(
this
);
mpTmpAction
->
setOwner
(
owner
);
mpTmpAction
->
setContent
(
act
);
mWidgets
<<
mpTmpAction
;
}
}
mMediaViewer
.
loadWidgets
(
mWidgets
,
true
);
}
}
void
UBTeacherBarPreviewWidget
::
setLinks
(
QStringList
links
)
{
if
(
!
links
.
empty
()){
mWidgets
.
clear
();
mpLinksLabel
->
setVisible
(
true
);
mWidgets
<<
mpLinksLabel
;
mMediaViewer
.
loadWidgets
(
mWidgets
,
false
);
mWidgets
.
clear
();
foreach
(
QString
link
,
links
){
mpTmpLink
=
new
QLabel
(
link
,
this
);
mpTmpLink
->
setOpenExternalLinks
(
true
);
mWidgets
<<
mpTmpLink
;
}
mMediaViewer
.
loadWidgets
(
mWidgets
,
true
);
}
}
void
UBTeacherBarPreviewWidget
::
loadInfos
(
sTeacherBarInfos
*
infos
)
{
if
(
NULL
!=
infos
){
setTitle
(
infos
->
title
);
mediaViewer
()
->
loadMedia
(
infos
->
medias
);
// Add the comments
//setComments();
}
}
src/gui/UBTeacherBarPreviewWidget.h
0 → 100644
View file @
3dd07bb4
#ifndef UBTEACHERBARPREVIEWWIDGET_H
#define UBTEACHERBARPREVIEWWIDGET_H
#include <QLabel>
#include <QVBoxLayout>
#include <QPushButton>
#include "core/UBPersistenceManager.h"
#include "customWidgets/UBWidgetList.h"
#include "UBTeacherBarDataMgr.h"
class
UBTeacherBarPreviewMedia
:
public
QWidget
{
Q_OBJECT
public
:
UBTeacherBarPreviewMedia
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTeacherBarPreviewMedia"
);
~
UBTeacherBarPreviewMedia
();
int
loadMedia
(
QStringList
pMedias
);
void
loadWidgets
(
QList
<
QWidget
*>
pWidgetList
,
bool
isResizable
=
true
);
void
cleanMedia
();
private
:
UBWidgetList
*
mWidget
;
QVBoxLayout
mLayout
;
QMap
<
QWidget
*
,
QString
>
mWidgetList
;
};
class
UBActionPreview
:
public
QWidget
{
public
:
UBActionPreview
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBActionPreview"
);
~
UBActionPreview
();
void
setOwner
(
const
QString
&
owner
);
void
setContent
(
const
QString
&
content
);
private
:
QLabel
*
mpOwner
;
QLabel
*
mpContent
;
QVBoxLayout
mLayout
;
QHBoxLayout
mOwnerLayout
;
};
class
UBTBPreviewContainer
:
public
UBWidgetList
{
public
:
UBTBPreviewContainer
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTBPreviewContainer"
);
~
UBTBPreviewContainer
();
};
class
UBTeacherBarPreviewWidget
:
public
QWidget
{
Q_OBJECT
public
:
UBTeacherBarPreviewWidget
(
UBTeacherBarDataMgr
*
pDataMgr
,
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTeacherBarPreviewWidget"
);
~
UBTeacherBarPreviewWidget
();
UBTeacherBarPreviewMedia
*
mediaViewer
()
{
return
&
mMediaViewer
;}
void
setTitle
(
const
QString
&
title
);
void
setComments
(
const
QString
&
comments
);
void
setActions
(
QStringList
actions
);
void
setLinks
(
QStringList
links
);
void
clean
();
QLabel
*
mediaLabel
()
{
return
mpMediaLabel
;}
void
loadInfos
(
sTeacherBarInfos
*
infos
);
signals
:
void
showEditMode
();
private
slots
:
void
onEdit
();
private
:
void
hideElements
();
QVBoxLayout
mLayout
;
QHBoxLayout
mEditLayout
;
QHBoxLayout
mTitleDurationLayout
;
UBTeacherBarPreviewMedia
mMediaViewer
;
QList
<
QWidget
*>
mWidgets
;
QList
<
QWidget
*>
mStoredWidgets
;
QPushButton
*
mpEditButton
;
QLabel
*
mpTitle
;
QLabel
*
mpDuration
;
QLabel
*
mpActionsLabel
;
QLabel
*
mpMediaLabel
;
QLabel
*
mpCommentsLabel
;
QLabel
*
mpComments
;
QLabel
*
mpLinksLabel
;
QLabel
*
mpTmpLink
;
UBActionPreview
*
mpTmpAction
;
UBTBPreviewContainer
*
mpContentContainer
;
UBTeacherBarDataMgr
*
mpDataMgr
;
};
#endif // UBTEACHERBARPREVIEWWIDGET_H
src/gui/UBTeacherBarWidget.cpp
View file @
3dd07bb4
...
...
@@ -13,8 +13,6 @@
#include "gui/UBMediaPlayer.h"
#include "frameworks/UBFileSystemUtils.h"
#include "customWidgets/UBDraggableLabel.h"
#include "customWidgets/UBMediaWidget.h"
#include "customWidgets/UBGlobals.h"
...
...
@@ -22,34 +20,15 @@
#include "core/memcheck.h"
UBTeacherBarWidget
::
UBTeacherBarWidget
(
QWidget
*
parent
,
const
char
*
name
)
:
UBDockPaletteWidget
(
parent
)
,
mpLayout
(
NULL
)
,
mpTitleLayout
(
NULL
)
,
mpTitleLabel
(
NULL
)
,
mpTitle
(
NULL
)
,
mpMediaLabel
(
NULL
)
,
mpContainer
(
NULL
)
,
mpContainerLayout
(
NULL
)
,
mpActionLabel
(
NULL
)
,
mpActions
(
NULL
)
,
mpActionButton
(
NULL
)
,
mpActionLayout
(
NULL
)
,
mpCommentLabel
(
NULL
)
,
mpComments
(
NULL
)
,
mpLinkLabel
(
NULL
)
,
mpLinks
(
NULL
)
,
mpLinkButton
(
NULL
)
,
mpLinkLayout
(
NULL
)
,
mpStackWidget
(
NULL
)
,
mpPreview
(
NULL
)
,
mpMediaContainer
(
NULL
)
,
mpDocPreviewWidget
(
NULL
)
,
mpDocEditWidget
(
NULL
)
{
{
setObjectName
(
name
);
mName
=
"TeacherBarWidget"
;
mVisibleState
=
true
;
mActionList
.
clear
();
mUrlList
.
clear
();
mData
.
clearLists
();
setAttribute
(
Qt
::
WA_StyledBackground
,
true
);
setStyleSheet
(
UBApplication
::
globalStyleSheet
());
...
...
@@ -58,110 +37,35 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
mIconToRight
=
QPixmap
(
":images/teacher_close.png"
);
// Create the GUI
mpContainerLayout
=
new
QVBoxLayout
(
this
);
setLayout
(
mpContainerLayout
);
mpContainer
=
new
QWidget
(
this
);
mpContainer
->
setObjectName
(
"DockPaletteWidgetBox"
);
setLayout
(
&
mLayout
);
mpPreview
=
new
UBTeacherBarPreviewWidget
(
this
);
mpDocPreviewWidget
=
new
UBTBDocumentPreviewWidget
(
this
);
mpDocEditWidget
=
new
UBTBDocumentEditWidget
(
this
);
mpPageEditWidget
=
new
UBTBPageEditWidget
(
&
mData
,
this
);
mpPreview
=
new
UBTeacherBarPreviewWidget
(
&
mData
,
this
);
mpDocPreviewWidget
=
new
UBTBDocumentPreviewWidget
(
&
mData
,
this
);
mpDocEditWidget
=
new
UBTBDocumentEditWidget
(
&
mData
,
this
);
mpStackWidget
=
new
QStackedWidget
(
this
);
m
pContainerLayout
->
addWidget
(
mpStackWidget
);
mpStackWidget
->
addWidget
(
mp
Container
);
m
Layout
.
addWidget
(
mpStackWidget
);
mpStackWidget
->
addWidget
(
mp
PageEditWidget
);
mpStackWidget
->
addWidget
(
mpPreview
);
mpStackWidget
->
addWidget
(
mpDocPreviewWidget
);
mpStackWidget
->
addWidget
(
mpDocEditWidget
);
mpLayout
=
new
QVBoxLayout
(
mpContainer
);
mpContainer
->
setLayout
(
mpLayout
);
// Title
mpTitleLabel
=
new
QLabel
(
tr
(
"Title"
),
mpContainer
);
mpTitle
=
new
QLineEdit
(
mpContainer
);
mpTitle
->
setObjectName
(
"DockPaletteWidgetLineEdit"
);
connect
(
mpTitle
,
SIGNAL
(
textChanged
(
const
QString
&
)),
this
,
SLOT
(
onTitleTextChanged
(
const
QString
&
)));
mpLayout
->
addWidget
(
mpTitleLabel
,
0
);
mpLayout
->
addWidget
(
mpTitle
,
0
);
// Actions
mpActionLabel
=
new
QLabel
(
tr
(
"Actions"
),
mpContainer
);
mpLayout
->
addWidget
(
mpActionLabel
,
0
);
mpActions
=
new
UBWidgetList
(
mpContainer
);
mpActions
->
setEmptyText
(
tr
(
"Add actions"
));
mpLayout
->
addWidget
(
mpActions
,
1
);
mpActionButton
=
new
QPushButton
(
mpContainer
);
mpActionButton
->
setObjectName
(
"DockPaletteWidgetButton"
);
mpActionButton
->
setText
(
tr
(
"Add action"
));
mpActionLayout
=
new
QHBoxLayout
();
mpActionLayout
->
addWidget
(
mpActionButton
,
0
);
mpActionLayout
->
addStretch
(
1
);
mpLayout
->
addLayout
(
mpActionLayout
,
0
);
// Media
mpMediaLabel
=
new
QLabel
(
tr
(
"Medias"
),
mpContainer
);
mpLayout
->
addWidget
(
mpMediaLabel
,
0
);
mpMediaContainer
=
new
UBTBMediaContainer
(
this
);
mpMediaContainer
->
setEmptyText
(
tr
(
"Drop media here"
));
mpLayout
->
addWidget
(
mpMediaContainer
,
1
);
// Links
mpLinkLabel
=
new
QLabel
(
tr
(
"Links"
),
mpContainer
);
mpLayout
->
addWidget
(
mpLinkLabel
,
0
);
mpLinks
=
new
UBWidgetList
(
mpContainer
);
mpLayout
->
addWidget
(
mpLinks
,
1
);
mpLinkButton
=
new
QPushButton
(
tr
(
"Add link"
),
mpContainer
);
mpLinkButton
->
setObjectName
(
"DockPaletteWidgetButton"
);
mpLinkLayout
=
new
QHBoxLayout
();
mpLinkLayout
->
addWidget
(
mpLinkButton
,
0
);
mpLinkLayout
->
addStretch
(
1
);
mpLayout
->
addLayout
(
mpLinkLayout
,
0
);
// Comments
mpCommentLabel
=
new
QLabel
(
tr
(
"Comments"
),
mpContainer
);
mpLayout
->
addWidget
(
mpCommentLabel
,
0
);
mpComments
=
new
QTextEdit
(
this
);
mpComments
->
setObjectName
(
"DockPaletteWidgetBox"
);
mpComments
->
setStyleSheet
(
"background:white;"
);
mpLayout
->
addWidget
(
mpComments
,
1
);
connect
(
UBApplication
::
boardController
,
SIGNAL
(
activeSceneWillChange
()),
this
,
SLOT
(
saveContent
()));
connect
(
UBApplication
::
boardController
,
SIGNAL
(
activeSceneChanged
()),
this
,
SLOT
(
loadContent
()));
connect
(
UBApplication
::
mainWindow
->
actionQuit
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
saveContent
()));
connect
(
mpTitle
,
SIGNAL
(
textChanged
(
QString
)),
this
,
SLOT
(
onValueChanged
()));
connect
(
mpActionButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onActionButton
()));
connect
(
mpLinkButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onLinkButton
()));
connect
(
mpPreview
,
SIGNAL
(
showEditMode
()),
this
,
SLOT
(
onShowEditMode
()));
connect
(
mpMediaContainer
,
SIGNAL
(
mediaDropped
(
QString
)),
this
,
SLOT
(
onMediaDropped
(
QString
)));
connect
(
mpDocPreviewWidget
,
SIGNAL
(
onEditClicked
()),
this
,
SLOT
(
onTBStateChanged
(
eTeacherBarState
)));
connect
(
mpDocPreviewWidget
,
SIGNAL
(
onPageViewClicked
()),
this
,
SLOT
(
onTBStateChanged
(
eTeacherBarState
)));
connect
(
mpDocEditWidget
,
SIGNAL
(
onPageViewClicked
()),
this
,
SLOT
(
onTBStateChanged
(
eTeacherBarState
)));
connect
(
mpDocEditWidget
,
SIGNAL
(
onPreviewClicked
()),
this
,
SLOT
(
onTBStateChanged
(
eTeacherBarState
)));
connect
(
mpDocPreviewWidget
,
SIGNAL
(
changeTBState
(
eTeacherBarState
)),
this
,
SLOT
(
onTBStateChanged
(
eTeacherBarState
)));
connect
(
mpDocEditWidget
,
SIGNAL
(
changeTBState
(
eTeacherBarState
)),
this
,
SLOT
(
onTBStateChanged
(
eTeacherBarState
)));
connect
(
mpPageEditWidget
,
SIGNAL
(
changeTBState
(
eTeacherBarState
)),
this
,
SLOT
(
onTBStateChanged
(
eTeacherBarState
)));
}
UBTeacherBarWidget
::~
UBTeacherBarWidget
()
{
DELETEPTR
(
mpDocPreviewWidget
);
DELETEPTR
(
mpDocEditWidget
);
DELETEPTR
(
mpMediaContainer
);
DELETEPTR
(
mpComments
);
DELETEPTR
(
mpCommentLabel
);
DELETEPTR
(
mpLinks
);
DELETEPTR
(
mpLinkLabel
);
DELETEPTR
(
mpLinkButton
);
DELETEPTR
(
mpLinkLayout
);
DELETEPTR
(
mpMediaLabel
);
DELETEPTR
(
mpActionButton
);
DELETEPTR
(
mpActionLayout
);
DELETEPTR
(
mpActionLabel
);
DELETEPTR
(
mpTitleLabel
);
DELETEPTR
(
mpTitle
);
DELETEPTR
(
mpTitleLayout
);
DELETEPTR
(
mpLayout
);
DELETEPTR
(
mpContainer
);
DELETEPTR
(
mpContainerLayout
);
DELETEPTR
(
mpPageEditWidget
);
DELETEPTR
(
mpPreview
);
DELETEPTR
(
mpStackWidget
);
}
...
...
@@ -185,199 +89,114 @@ void UBTeacherBarWidget::onValueChanged()
void
UBTeacherBarWidget
::
saveContent
()
{
sTeacherBarInfos
infos
;
// Title
infos
.
title
=
mpTitle
->
text
();
// Actions
for
(
int
i
=
0
;
i
<
mActionList
.
size
();
i
++
){
infos
.
actions
<<
QString
(
"%0;%1"
).
arg
(
mActionList
.
at
(
i
)
->
comboValue
()).
arg
(
mActionList
.
at
(
i
)
->
text
());
}
// Media
foreach
(
QString
media
,
mpMediaContainer
->
mediaUrls
()){
infos
.
medias
<<
media
;
}
// Links
for
(
int
j
=
0
;
j
<
mUrlList
.
size
();
j
++
){
if
(
""
!=
mUrlList
.
at
(
j
)
->
url
()){
infos
.
urls
<<
mUrlList
.
at
(
j
)
->
url
();
}
}
// Comments
infos
.
comments
=
mpComments
->
document
()
->
toPlainText
();
mpPageEditWidget
->
saveInfos
(
&
infos
);
UBPersistenceManager
::
persistenceManager
()
->
persistTeacherBar
(
UBApplication
::
boardController
->
activeDocument
(),
UBApplication
::
boardController
->
activeSceneIndex
(),
infos
);
}
void
UBTeacherBarWidget
::
loadContent
()
{
clearWidgetLists
();
sTeacherBarInfos
nextInfos
=
UBPersistenceManager
::
persistenceManager
()
->
getTeacherBarInfos
(
UBApplication
::
boardController
->
activeDocument
(),
UBApplication
::
boardController
->
activeSceneIndex
());
// Title
mpTitle
->
setText
(
nextInfos
.
title
);
// Actions
for
(
int
i
=
0
;
i
<
nextInfos
.
actions
.
size
();
i
++
){
QStringList
qslAction
=
nextInfos
.
actions
.
at
(
i
).
split
(
";"
);
if
(
qslAction
.
size
()
>=
2
){
UBTeacherStudentAction
*
pAction
=
new
UBTeacherStudentAction
(
mpContainer
);
pAction
->
setComboValue
(
qslAction
.
at
(
0
).
toInt
());
pAction
->
setText
(
qslAction
.
at
(
1
));
mActionList
<<
pAction
;
mpActions
->
addWidget
(
pAction
);
}
}
// Media
foreach
(
QString
url
,
nextInfos
.
medias
){
if
(
""
!=
url
){
QWidget
*
pMedia
=
mpMediaContainer
->
generateMediaWidget
(
url
);
if
(
NULL
!=
pMedia
){
mMediaList
<<
pMedia
;
mpMediaContainer
->
addWidget
(
pMedia
);
}
}
}
// Links
for
(
int
j
=
0
;
j
<
nextInfos
.
urls
.
size
();
j
++
){
QString
qsUrl
=
nextInfos
.
urls
.
at
(
j
);
if
(
""
!=
qsUrl
){
UBUrlWidget
*
pLink
=
new
UBUrlWidget
(
mpContainer
);
pLink
->
setUrl
(
qsUrl
);
mUrlList
<<
pLink
;
mpLinks
->
addWidget
(
pLink
);
}
}
// Comments
if
(
NULL
!=
mpComments
){
mpComments
->
document
()
->
setPlainText
(
nextInfos
.
comments
);
}
mpPreview
->
mediaViewer
()
->
cleanMedia
();
if
(
!
isEmpty
()){
// Update the fields of the preview widget
mpPreview
->
setTitle
(
mpTitle
->
text
());
mpPreview
->
mediaViewer
()
->
loadMedia
(
nextInfos
.
medias
);
mpStackWidget
->
setCurrentWidget
(
mpPreview
);
mpPreview
->
clean
();
// Add the actions
if
(
!
mActionList
.
empty
()){
QStringList
actions
;
foreach
(
UBTeacherStudentAction
*
action
,
mActionList
){
QString
desc
=
QString
(
"%0;%1"
).
arg
(
action
->
comboValue
()).
arg
(
action
->
text
());
actions
<<
desc
;
}
mpPreview
->
setActions
(
actions
);
}
// Add the media
if
(
nextInfos
.
medias
.
count
()
>
0
){
QList
<
QWidget
*>
widgetList
;
widgetList
.
append
(
mpPreview
->
mediaLabel
());
mpPreview
->
mediaViewer
()
->
loadWidgets
(
widgetList
,
false
);
int
loadedMedia
=
mpPreview
->
mediaViewer
()
->
loadMedia
(
nextInfos
.
medias
);
if
(
loadedMedia
)
mpPreview
->
mediaLabel
()
->
setVisible
(
true
);
}
// Add the links
if
(
!
mUrlList
.
empty
()){
QStringList
links
;
foreach
(
UBUrlWidget
*
url
,
mUrlList
){
QStringList
list
=
url
->
url
().
split
(
";"
);
QString
formedlink
=
"<a href="
;
if
(
!
list
.
at
(
0
).
startsWith
(
"http://"
))
formedlink
+=
"http://"
;
formedlink
+=
list
.
at
(
0
)
+
">"
+
list
.
at
(
1
)
+
"</a>"
;
links
<<
formedlink
;
}
mpPreview
->
setLinks
(
links
);
}
// Add the comments
mpPreview
->
setComments
(
mpComments
->
document
()
->
toPlainText
());
}
else
{
mpStackWidget
->
setCurrentWidget
(
mpContainer
);
}
// clearWidgetLists();
// sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex());
// mpPageEditWidget->loadInfos(&nextInfos);
// mpPreview->mediaViewer()->cleanMedia();
// if(!isEmpty()){
// // Update the fields of the preview widget
// onTBStateChanged(eTeacherBarState_PagePreview);
// mpPreview->clean();
// mpPreview->loadInfos(&nextInfos);
// // Add the actions
// if(!mActionList.empty()){
// QStringList actions;
// foreach(UBTeacherStudentAction* action, mActionList){
// QString desc = QString("%0;%1").arg(action->comboValue()).arg(action->text());
// actions << desc;
// }
// mpPreview->setActions(actions);
// }
// // Add the media
// if(nextInfos.medias.count() > 0){
// QList<QWidget*> widgetList;
// widgetList.append(mpPreview->mediaLabel());
// mpPreview->mediaViewer()->loadWidgets(widgetList,false);
// int loadedMedia = mpPreview->mediaViewer()->loadMedia(nextInfos.medias);
// if(loadedMedia)
// mpPreview->mediaLabel()->setVisible(true);
// }
// // Add the links
// if(!mUrlList.empty()){
// QStringList links;
// foreach(UBUrlWidget* url, mUrlList){
// QStringList list = url->url().split(";");
// QString formedlink = "<a href=";
// if(!list.at(0).startsWith("http://"))
// formedlink += "http://";
// formedlink += list.at(0) + ">" + list.at(1) + "</a>";
// links << formedlink;
// }
// mpPreview->setLinks(links);
// }
// }
// else{
// // If the document has only one page, show the document edit page
// if(1 == UBApplication::boardController->activeDocument()->pageCount()){
// onTBStateChanged(eTeacherBarState_DocumentEdit);
// }else{
// onTBStateChanged(eTeacherBarState_PageEdit);
// }
// }
}
bool
UBTeacherBarWidget
::
isEmpty
()
{
return
m
pTitle
->
text
()
==
""
&&
m
pLinks
->
empty
()
&&
m
pActions
->
empty
()
&&
m
pMediaContainer
->
empty
()
&&
m
pComments
->
document
()
->
toPlainText
()
==
""
;
return
m
Data
.
pageTitle
()
==
""
&&
m
Data
.
urls
().
empty
()
&&
m
Data
.
actions
().
empty
()
&&
m
Data
.
medias
().
empty
()
&&
m
Data
.
comments
()
==
""
;
}
void
UBTeacherBarWidget
::
onTitleTextChanged
(
const
QString
&
text
)
{
mpTitle
->
setToolTip
(
text
);
}
void
UBTeacherBarWidget
::
onActionButton
()
{
UBTeacherStudentAction
*
pAction
=
new
UBTeacherStudentAction
(
mpContainer
);
mActionList
<<
pAction
;
mpActions
->
addWidget
(
pAction
);
}
void
UBTeacherBarWidget
::
onLinkButton
()
{
UBUrlWidget
*
pUrl
=
new
UBUrlWidget
(
mpContainer
);
mUrlList
<<
pUrl
;
mpLinks
->
addWidget
(
pUrl
);
//mpTitle->setToolTip(text);
}
void
UBTeacherBarWidget
::
clearWidgetLists
()
{
if
(
NULL
!=
mpMediaContainer
){
for
(
int
i
=
0
;
i
<
mMediaList
.
size
();
i
++
){
mpMediaContainer
->
removeWidget
(
mMediaList
.
at
(
i
));
delete
mMediaList
.
at
(
i
);
}
mMediaList
.
clear
();
mpMediaContainer
->
cleanMedias
();
}
if
(
NULL
!=
mpActions
){
for
(
int
i
=
0
;
i
<
mActionList
.
size
();
i
++
){
mpActions
->
removeWidget
(
mActionList
.
at
(
i
));
delete
mActionList
.
at
(
i
);
}
mActionList
.
clear
();
}
if
(
NULL
!=
mpLinks
){
for
(
int
i
=
0
;
i
<
mUrlList
.
size
();
i
++
){
mpLinks
->
removeWidget
(
mUrlList
.
at
(
i
));
delete
mUrlList
.
at
(
i
);
}
mUrlList
.
clear
();
}
//
if(NULL != mpMediaContainer){
//
for(int i=0; i<mMediaList.size(); i++){
//
mpMediaContainer->removeWidget(mMediaList.at(i));
//
delete mMediaList.at(i);
//
}
//
mMediaList.clear();
//
mpMediaContainer->cleanMedias();
//
}
//
if(NULL != mpActions){
//
for(int i=0; i<mActionList.size(); i++){
//
mpActions->removeWidget(mActionList.at(i));
//
delete mActionList.at(i);
//
}
//
mActionList.clear();
//
}
//
if(NULL != mpLinks){
//
for(int i=0; i<mUrlList.size(); i++){
//
mpLinks->removeWidget(mUrlList.at(i));
//
delete mUrlList.at(i);
//
}
//
mUrlList.clear();
//
}
}
void
UBTeacherBarWidget
::
onShowEditMode
()
{
mpStackWidget
->
setCurrentWidget
(
mpContainer
);
}
void
UBTeacherBarWidget
::
onMediaDropped
(
const
QString
&
url
)
{
if
(
""
!=
url
){
QWidget
*
pMedia
=
mpMediaContainer
->
generateMediaWidget
(
url
);
if
(
NULL
!=
pMedia
){
mMediaList
<<
pMedia
;
mpMediaContainer
->
addWidget
(
pMedia
);
}
}
mpStackWidget
->
setCurrentWidget
(
mpPageEditWidget
);
}
void
UBTeacherBarWidget
::
onTBStateChanged
(
eTeacherBarState
state
)
...
...
@@ -390,7 +209,7 @@ void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state)
mpStackWidget
->
setCurrentWidget
(
mpDocPreviewWidget
);
break
;
case
eTeacherBarState_PageEdit
:
mpStackWidget
->
setCurrentWidget
(
mp
Container
);
mpStackWidget
->
setCurrentWidget
(
mp
PageEditWidget
);
break
;
case
eTeacherBarState_PagePreview
:
mpStackWidget
->
setCurrentWidget
(
mpPreview
);
...
...
@@ -398,668 +217,3 @@ void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state)
}
}
// ---------------------------------------------------------------------------------------------
UBTeacherStudentAction
::
UBTeacherStudentAction
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpText
(
NULL
)
,
mpLayout
(
NULL
)
,
mpComboLayout
(
NULL
)
,
mpCombo
(
NULL
)
{
setObjectName
(
name
);
setAttribute
(
Qt
::
WA_StyledBackground
,
true
);
setStyleSheet
(
UBApplication
::
globalStyleSheet
());
// Create the GUI
mpLayout
=
new
QHBoxLayout
(
this
);
setLayout
(
mpLayout
);
mpComboLayout
=
new
QVBoxLayout
();
mpCombo
=
new
QComboBox
(
this
);
mpCombo
->
setObjectName
(
"DockPaletteWidgetComboBox"
);
mpCombo
->
setMinimumWidth
(
80
);
mpCombo
->
addItem
(
tr
(
"Teacher"
));
mpCombo
->
addItem
(
tr
(
"Student"
));
mpComboLayout
->
addWidget
(
mpCombo
,
0
);
mpComboLayout
->
addStretch
(
1
);
mpLayout
->
addLayout
(
mpComboLayout
,
0
);
mpText
=
new
QTextEdit
(
this
);
mpText
->
setObjectName
(
"DockPaletteWidgetBox"
);
mpText
->
setStyleSheet
(
"background:white;"
);
mpLayout
->
addWidget
(
mpText
,
1
);
}
UBTeacherStudentAction
::~
UBTeacherStudentAction
()
{
DELETEPTR
(
mpCombo
);
DELETEPTR
(
mpText
);
DELETEPTR
(
mpComboLayout
);
DELETEPTR
(
mpLayout
);
}
QString
UBTeacherStudentAction
::
text
()
{
QString
str
;
if
(
NULL
!=
mpText
){
str
=
mpText
->
document
()
->
toPlainText
();
}
return
str
;
}
QString
UBTeacherStudentAction
::
comboValue
()
{
QString
str
;
if
(
NULL
!=
mpCombo
){
str
=
QString
(
"%0"
).
arg
(
mpCombo
->
currentIndex
());
}
return
str
;
}
void
UBTeacherStudentAction
::
setComboValue
(
int
value
)
{
if
(
NULL
!=
mpCombo
){
mpCombo
->
setCurrentIndex
(
value
);
}
}
void
UBTeacherStudentAction
::
setText
(
const
QString
&
text
)
{
if
(
NULL
!=
mpText
){
mpText
->
document
()
->
setPlainText
(
text
);
}
}
// ---------------------------------------------------------------------------------------------
UBUrlWidget
::
UBUrlWidget
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpLayout
(
NULL
)
,
mpUrlLabel
(
NULL
)
,
mpUrl
(
NULL
)
{
setObjectName
(
name
);
setAttribute
(
Qt
::
WA_StyledBackground
,
true
);
setStyleSheet
(
UBApplication
::
globalStyleSheet
());
mpLayout
=
new
QVBoxLayout
(
this
);
setLayout
(
mpLayout
);
mpLabelLayout
=
new
QHBoxLayout
(
this
);
mpUrlLabel
=
new
QLabel
(
tr
(
"Url"
),
this
);
mpLabelLayout
->
addWidget
(
mpUrlLabel
,
0
);
mpUrl
=
new
QLineEdit
(
this
);
mpUrl
->
setObjectName
(
"DockPaletteWidgetLineEdit"
);
mpUrl
->
setMinimumHeight
(
20
);
mpLabelLayout
->
addWidget
(
mpUrl
,
1
);
mpTitleLayout
=
new
QHBoxLayout
(
this
);
mpTitleLabel
=
new
QLabel
(
tr
(
"Title"
),
this
);
mpTitleLayout
->
addWidget
(
mpTitleLabel
,
0
);
mpTitle
=
new
QLineEdit
(
this
);
mpTitle
->
setObjectName
(
"DockPaletteWidgetLineEdit"
);
mpTitle
->
setMinimumHeight
(
20
);
mpTitleLayout
->
addWidget
(
mpTitle
,
1
);
mpLayout
->
addLayout
(
mpTitleLayout
);
mpLayout
->
addLayout
(
mpLabelLayout
);
}
UBUrlWidget
::~
UBUrlWidget
()
{
DELETEPTR
(
mpTitle
);
DELETEPTR
(
mpTitleLabel
);
DELETEPTR
(
mpUrlLabel
);
DELETEPTR
(
mpUrl
);
DELETEPTR
(
mpTitleLayout
);
DELETEPTR
(
mpLabelLayout
);
DELETEPTR
(
mpLayout
);
}
QString
UBUrlWidget
::
url
()
{
QString
str
;
if
(
NULL
!=
mpUrl
){
str
=
mpUrl
->
text
()
+
";"
+
mpTitle
->
text
();
}
return
str
;
}
void
UBUrlWidget
::
setUrl
(
const
QString
&
url
)
{
QStringList
list
=
url
.
split
(
";"
);
if
(
NULL
!=
mpUrl
){
mpUrl
->
setText
(
list
.
at
(
0
));
mpTitle
->
setText
(
list
.
at
(
1
));
}
}
// ------------------------------------------------------------------------------------
UBTeacherBarPreviewWidget
::
UBTeacherBarPreviewWidget
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpEditButton
(
NULL
)
,
mpTitle
(
NULL
)
,
mpDuration
(
NULL
)
,
mpActionsLabel
(
NULL
)
,
mpMediaLabel
(
NULL
)
,
mpCommentsLabel
(
NULL
)
,
mpComments
(
NULL
)
,
mpLinksLabel
(
NULL
)
,
mpContentContainer
(
NULL
)
{
setObjectName
(
name
);
setLayout
(
&
mLayout
);
setAttribute
(
Qt
::
WA_StyledBackground
,
true
);
setStyleSheet
(
UBApplication
::
globalStyleSheet
());
// Build the Preview widget
// Title + duration
mpTitle
=
new
QLabel
(
this
);
mpTitle
->
setObjectName
(
"UBTeacherBarPreviewTitle"
);
mpTitle
->
setWordWrap
(
true
);
mpTitle
->
setAlignment
(
Qt
::
AlignCenter
);
mpDuration
=
new
QLabel
(
this
);
mTitleDurationLayout
.
addWidget
(
mpTitle
,
0
);
mTitleDurationLayout
.
addWidget
(
mpDuration
,
1
);
mLayout
.
addLayout
(
&
mTitleDurationLayout
,
0
);
mpContentContainer
=
new
UBTBPreviewContainer
(
this
);
mLayout
.
addWidget
(
mpContentContainer
,
1
);
//mLayout.addWidget(&mMediaViewer, 1);
// The next line is disgusting. This is a quickfix that must be reworked later
mMediaViewer
.
setContentsMargins
(
-
9
,
-
9
,
-
9
,
-
9
);
hideElements
();
// Edit button
mpEditButton
=
new
QPushButton
(
tr
(
"Edit infos"
),
this
);
mpEditButton
->
setObjectName
(
"DockPaletteWidgetButton"
);
mEditLayout
.
addStretch
(
1
);
mEditLayout
.
addWidget
(
mpEditButton
,
0
);
mEditLayout
.
addStretch
(
1
);
mLayout
.
addLayout
(
&
mEditLayout
,
0
);
connect
(
mpEditButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
onEdit
()));
}
UBTeacherBarPreviewWidget
::~
UBTeacherBarPreviewWidget
()
{
DELETEPTR
(
mpLinksLabel
);
DELETEPTR
(
mpComments
);
DELETEPTR
(
mpTitle
);
DELETEPTR
(
mpDuration
);
DELETEPTR
(
mpActionsLabel
);
DELETEPTR
(
mpMediaLabel
);
DELETEPTR
(
mpCommentsLabel
);
DELETEPTR
(
mpContentContainer
);
DELETEPTR
(
mpEditButton
);
}
void
UBTeacherBarPreviewWidget
::
onEdit
()
{
emit
showEditMode
();
}
void
UBTeacherBarPreviewWidget
::
setTitle
(
const
QString
&
title
)
{
if
(
NULL
!=
mpTitle
){
mpTitle
->
setText
(
title
);
}
}
void
UBTeacherBarPreviewWidget
::
setDuration
(
eDuration
duration
)
{
if
(
NULL
!=
mpDuration
){
QPixmap
p
;
switch
(
duration
){
case
eDuration_Quarter
:
p
=
QPixmap
(
":images/duration1.png"
);
break
;
case
eDuration_Half
:
p
=
QPixmap
(
":images/duration2.png"
);
break
;
case
eDuration_ThreeQuarter
:
p
=
QPixmap
(
":images/duration3.png"
);
break
;
default
:
break
;
}
mpDuration
->
setPixmap
(
p
.
scaledToHeight
(
16
,
Qt
::
SmoothTransformation
));
}
}
void
UBTeacherBarPreviewWidget
::
setComments
(
const
QString
&
comments
)
{
if
(
""
!=
comments
){
mWidgets
.
clear
();
mpComments
->
setText
(
comments
);
mpComments
->
setVisible
(
true
);
mpCommentsLabel
->
setVisible
(
true
);
mWidgets
<<
mpCommentsLabel
;
mMediaViewer
.
loadWidgets
(
mWidgets
,
false
);
mWidgets
.
clear
();
mWidgets
<<
mpComments
;
mMediaViewer
.
loadWidgets
(
mWidgets
,
true
);
}
}
void
UBTeacherBarPreviewWidget
::
clean
()
{
mMediaViewer
.
cleanMedia
();
foreach
(
QWidget
*
eachWidget
,
mStoredWidgets
){
delete
eachWidget
;
eachWidget
=
NULL
;
}
mStoredWidgets
.
clear
();
hideElements
();
}
void
UBTeacherBarPreviewWidget
::
hideElements
()
{
mpActionsLabel
=
new
QLabel
(
tr
(
"Actions"
),
this
);
mpActionsLabel
->
setObjectName
(
"UBTeacherBarPreviewSubtitle"
);
mpMediaLabel
=
new
QLabel
(
tr
(
"Medias"
),
this
);
mpMediaLabel
->
setObjectName
(
"UBTeacherBarPreviewSubtitle"
);
mpCommentsLabel
=
new
QLabel
(
tr
(
"Comments"
),
this
);
mpCommentsLabel
->
setObjectName
(
"UBTeacherBarPreviewSubtitle"
);
mpComments
=
new
QLabel
(
this
);
mpComments
->
setWordWrap
(
true
);
mpComments
->
setObjectName
(
"UBTeacherBarPreviewComments"
);
mpLinksLabel
=
new
QLabel
(
tr
(
"Links"
),
this
);
mpLinksLabel
->
setObjectName
(
"UBTeacherBarPreviewSubtitle"
);
mpActionsLabel
->
setVisible
(
false
);
mpMediaLabel
->
setVisible
(
false
);
mpCommentsLabel
->
setVisible
(
false
);
mpComments
->
setVisible
(
false
);
mpLinksLabel
->
setVisible
(
false
);
}
void
UBTeacherBarPreviewWidget
::
setActions
(
QStringList
actions
)
{
if
(
!
actions
.
empty
()){
mWidgets
.
clear
();
mpActionsLabel
->
setVisible
(
true
);
mWidgets
<<
mpActionsLabel
;
mediaViewer
()
->
loadWidgets
(
mWidgets
,
false
);
mWidgets
.
clear
();
foreach
(
QString
action
,
actions
){
QStringList
desc
=
action
.
split
(
';'
);
if
(
2
<=
desc
.
size
()){
QString
owner
=
desc
.
at
(
0
);
QString
act
=
desc
.
at
(
1
);
mpTmpAction
=
new
UBActionPreview
(
this
);
mpTmpAction
->
setOwner
(
owner
);
mpTmpAction
->
setContent
(
act
);
mWidgets
<<
mpTmpAction
;
}
}
mMediaViewer
.
loadWidgets
(
mWidgets
,
true
);
}
}
void
UBTeacherBarPreviewWidget
::
setLinks
(
QStringList
links
)
{
if
(
!
links
.
empty
()){
mWidgets
.
clear
();
mpLinksLabel
->
setVisible
(
true
);
mWidgets
<<
mpLinksLabel
;
mMediaViewer
.
loadWidgets
(
mWidgets
,
false
);
mWidgets
.
clear
();
foreach
(
QString
link
,
links
){
mpTmpLink
=
new
QLabel
(
link
,
this
);
mpTmpLink
->
setOpenExternalLinks
(
true
);
mWidgets
<<
mpTmpLink
;
}
mMediaViewer
.
loadWidgets
(
mWidgets
,
true
);
}
}
// ------------------------------------------------------------------------------------
UBTeacherBarPreviewMedia
::
UBTeacherBarPreviewMedia
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
{
setObjectName
(
name
);
mWidget
=
new
UBWidgetList
(
parent
);
mLayout
.
addWidget
(
mWidget
);
setLayout
(
&
mLayout
);
mWidgetList
.
clear
();
}
UBTeacherBarPreviewMedia
::~
UBTeacherBarPreviewMedia
()
{
DELETEPTR
(
mWidget
);
}
void
UBTeacherBarPreviewMedia
::
cleanMedia
()
{
foreach
(
QWidget
*
eachWidget
,
mWidgetList
.
keys
()){
if
(
QString
(
eachWidget
->
metaObject
()
->
className
()).
contains
(
"UBDraggable"
)){
mWidget
->
removeWidget
(
eachWidget
);
delete
eachWidget
;
eachWidget
=
NULL
;
}
else
{
mWidget
->
removeWidget
(
eachWidget
);
}
}
mWidgetList
.
clear
();
}
void
UBTeacherBarPreviewMedia
::
loadWidgets
(
QList
<
QWidget
*>
pWidgetsList
,
bool
isResizable
)
{
foreach
(
QWidget
*
eachWidget
,
pWidgetsList
){
mWidget
->
addWidget
(
eachWidget
);
mWidgetList
[
eachWidget
]
=
"DRAG UNAVAILABLE"
;
}
}
int
UBTeacherBarPreviewMedia
::
loadMedia
(
QStringList
pMedias
)
{
int
addedMedia
=
0
;
foreach
(
QString
eachString
,
pMedias
){
if
(
!
eachString
.
isEmpty
()){
QString
mimeType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
eachString
);
if
(
mimeType
.
contains
(
"image"
)){
UBDraggableLabel
*
label
=
new
UBDraggableLabel
();
label
->
loadImage
(
eachString
);
mWidget
->
addWidget
(
label
);
mWidgetList
[
label
]
=
eachString
;
addedMedia
+=
1
;
}
else
if
(
mimeType
.
contains
(
"video"
)
||
mimeType
.
contains
(
"audio"
)){
UBDraggableMediaPlayer
*
mediaPlayer
=
new
UBDraggableMediaPlayer
();
mediaPlayer
->
setFile
(
eachString
);
mWidget
->
addWidget
(
mediaPlayer
);
mWidgetList
[
mediaPlayer
]
=
eachString
;
addedMedia
+=
1
;
}
else
{
qWarning
()
<<
"pMediaPath"
<<
eachString
;
qWarning
()
<<
"bad idea to come here"
;
}
}
}
return
addedMedia
;
}
// -----------------------------------------------------------------------------------------------
UBActionPreview
::
UBActionPreview
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpOwner
(
NULL
)
,
mpContent
(
NULL
)
{
setObjectName
(
name
);
setLayout
(
&
mLayout
);
mpOwner
=
new
QLabel
(
this
);
mpOwner
->
setObjectName
(
"UBActionPreviewOwner"
);
mOwnerLayout
.
addWidget
(
mpOwner
,
0
);
mOwnerLayout
.
addStretch
(
1
);
mLayout
.
addLayout
(
&
mOwnerLayout
);
mpContent
=
new
QLabel
(
this
);
mpContent
->
setObjectName
(
"UBActionPreviewContent"
);
mpContent
->
setWordWrap
(
true
);
mLayout
.
addWidget
(
mpContent
);
setContentsMargins
(
-
9
,
-
9
,
-
9
,
-
9
);
}
UBActionPreview
::~
UBActionPreview
()
{
if
(
NULL
!=
mpOwner
){
delete
mpOwner
;
mpOwner
=
NULL
;
}
if
(
NULL
!=
mpContent
){
delete
mpContent
;
mpContent
=
NULL
;
}
}
void
UBActionPreview
::
setOwner
(
const
QString
&
owner
)
{
if
(
NULL
!=
mpOwner
&&
NULL
!=
mpContent
){
switch
(
owner
.
toInt
()){
case
eActionOwner_Teacher
:
mpOwner
->
setText
(
tr
(
"Teacher"
));
mpContent
->
setStyleSheet
(
"background:lightblue; border:lightblue;"
);
break
;
case
eActionOwner_Student
:
mpOwner
->
setText
(
tr
(
"Student"
));
mpContent
->
setStyleSheet
(
"background:lightgreen; border:lightgreen;"
);
break
;
}
}
}
void
UBActionPreview
::
setContent
(
const
QString
&
content
)
{
if
(
NULL
!=
mpContent
){
mpContent
->
setText
(
content
);
}
}
// ------------------------------------------------------------------------------------------------------------------------------------
UBTBMediaContainer
::
UBTBMediaContainer
(
QWidget
*
parent
,
const
char
*
name
)
:
UBWidgetList
(
parent
)
{
setObjectName
(
name
);
setAcceptDrops
(
true
);
}
UBTBMediaContainer
::~
UBTBMediaContainer
()
{
}
void
UBTBMediaContainer
::
dropEvent
(
QDropEvent
*
pEvent
)
{
QPixmap
pixFromDropEvent
;
QString
mimeType
;
QString
resourcePath
;
if
(
pEvent
->
mimeData
()
->
hasText
()){
resourcePath
=
pEvent
->
mimeData
()
->
text
();
}
else
if
(
pEvent
->
mimeData
()
->
hasUrls
()){
resourcePath
=
pEvent
->
mimeData
()
->
urls
().
at
(
0
).
toLocalFile
();
}
else
if
(
pEvent
->
mimeData
()
->
hasImage
()){
pixFromDropEvent
.
loadFromData
(
pEvent
->
mimeData
()
->
imageData
().
toByteArray
());
if
(
!
pixFromDropEvent
.
isNull
())
mimeType
=
"image"
;
}
if
(
mimeType
.
isEmpty
()
&&
resourcePath
.
isEmpty
()){
pEvent
->
acceptProposedAction
();
return
;
}
if
(
!
resourcePath
.
isEmpty
()){
emit
mediaDropped
(
resourcePath
);
pEvent
->
acceptProposedAction
();
}
}
void
UBTBMediaContainer
::
dragEnterEvent
(
QDragEnterEvent
*
pEvent
)
{
pEvent
->
acceptProposedAction
();
}
void
UBTBMediaContainer
::
dragMoveEvent
(
QDragMoveEvent
*
pEvent
)
{
pEvent
->
acceptProposedAction
();
}
void
UBTBMediaContainer
::
dragLeaveEvent
(
QDragLeaveEvent
*
pEvent
)
{
pEvent
->
accept
();
}
void
UBTBMediaContainer
::
addMedia
(
const
QString
&
mediaPath
)
{
if
(
!
mediaPath
.
isEmpty
())
mMediaList
.
append
(
mediaPath
);
else
qWarning
()
<<
__FUNCTION__
<<
"empty path"
;
QString
mimeType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
mediaPath
);
if
(
mimeType
.
contains
(
"image"
)){
QPixmap
pix
=
QPixmap
(
mediaPath
);
QLabel
*
label
=
new
QLabel
();
label
->
setPixmap
(
pix
);
label
->
setScaledContents
(
true
);
addWidget
(
label
);
}
else
if
(
mimeType
.
contains
(
"video"
)
||
mimeType
.
contains
(
"audio"
)){
UBMediaPlayer
*
mediaPlayer
=
new
UBMediaPlayer
();
mediaPlayer
->
setFile
(
mediaPath
);
addWidget
(
mediaPlayer
);
}
else
{
qWarning
()
<<
"pMediaPath"
<<
mediaPath
;
qWarning
()
<<
"bad idea to come here"
;
}
}
QStringList
UBTBMediaContainer
::
mediaUrls
()
{
return
mMediaList
;
}
void
UBTBMediaContainer
::
cleanMedias
()
{
mMediaList
.
clear
();
}
QWidget
*
UBTBMediaContainer
::
generateMediaWidget
(
const
QString
&
url
)
{
QWidget
*
pW
=
NULL
;
if
(
!
url
.
isEmpty
())
mMediaList
.
append
(
url
);
else
qWarning
()
<<
__FUNCTION__
<<
"empty path"
;
QString
mimeType
=
UBFileSystemUtils
::
mimeTypeFromFileName
(
url
);
if
(
mimeType
.
contains
(
"image"
)){
QPixmap
pix
=
QPixmap
(
url
);
QLabel
*
label
=
new
QLabel
();
pix
.
scaledToWidth
(
label
->
width
());
label
->
resize
(
pix
.
width
(),
pix
.
height
());
label
->
setPixmap
(
pix
);
label
->
setScaledContents
(
true
);
pW
=
label
;
}
else
if
(
mimeType
.
contains
(
"video"
)
||
mimeType
.
contains
(
"audio"
)){
UBMediaWidget
*
mediaPlayer
=
new
UBMediaWidget
(
mimeType
.
contains
(
"audio"
)
?
eMediaType_Audio
:
eMediaType_Video
);
mediaPlayer
->
setFile
(
url
);
pW
=
mediaPlayer
;
}
else
{
qWarning
()
<<
"pMediaPath"
<<
url
;
qWarning
()
<<
"bad idea to come here"
;
}
return
pW
;
}
// -------------------------------------------------------------------------------------------------------------------
UBTBPreviewContainer
::
UBTBPreviewContainer
(
QWidget
*
parent
,
const
char
*
name
)
:
UBWidgetList
(
parent
)
{
setObjectName
(
name
);
}
UBTBPreviewContainer
::~
UBTBPreviewContainer
()
{
}
// -------------------------------------------------------------------------------------------------------------------
UBTBDocumentEditWidget
::
UBTBDocumentEditWidget
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpPageViewButton
(
NULL
)
,
mpPreviewButton
(
NULL
)
,
mpTitleLabel
(
NULL
)
,
mpTitle
(
NULL
)
,
mpTargetLabel
(
NULL
)
,
mpTarget
(
NULL
)
,
mpMetadataLabel
(
NULL
)
,
mpLicenseLabel
(
NULL
)
{
setObjectName
(
name
);
setLayout
(
&
mLayout
);
mpPageViewButton
=
new
QPushButton
(
tr
(
"Page View"
),
this
);
mPageLayout
.
addStretch
(
1
);
mPageLayout
.
addWidget
(
mpPageViewButton
,
0
);
mPageLayout
.
addStretch
(
1
);
mLayout
.
addLayout
(
&
mPageLayout
);
mpTitleLabel
=
new
QLabel
(
tr
(
"Session Title:"
),
this
);
mpTitleLabel
->
setAlignment
(
Qt
::
AlignLeft
);
mLayout
.
addWidget
(
mpTitleLabel
);
mpTitle
=
new
QLineEdit
(
this
);
mLayout
.
addWidget
(
mpTitle
);
mpPreviewButton
=
new
QPushButton
(
tr
(
"Preview"
),
this
);
mPreviewLayout
.
addStretch
(
1
);
mPreviewLayout
.
addWidget
(
mpPreviewButton
,
0
);
mPreviewLayout
.
addStretch
(
1
);
mLayout
.
addLayout
(
&
mPreviewLayout
);
connect
(
mpPageViewButton
,
SIGNAL
(
clicked
()),
this
,
SIGNAL
(
onPageViewClicked
()));
connect
(
mpPreviewButton
,
SIGNAL
(
clicked
()),
this
,
SIGNAL
(
onPreviewClicked
()));
}
UBTBDocumentEditWidget
::~
UBTBDocumentEditWidget
()
{
DELETEPTR
(
mpTitleLabel
);
DELETEPTR
(
mpTitle
);
DELETEPTR
(
mpTargetLabel
);
DELETEPTR
(
mpTarget
);
DELETEPTR
(
mpMetadataLabel
);
DELETEPTR
(
mpLicenseLabel
);
DELETEPTR
(
mpPageViewButton
);
DELETEPTR
(
mpPreviewButton
);
}
// -------------------------------------------------------------------------------------------------------------------
UBTBDocumentPreviewWidget
::
UBTBDocumentPreviewWidget
(
QWidget
*
parent
,
const
char
*
name
)
:
QWidget
(
parent
)
,
mpPageViewButton
(
NULL
)
,
mpEditButton
(
NULL
)
{
setObjectName
(
name
);
setLayout
(
&
mLayout
);
mpPageViewButton
=
new
QPushButton
(
tr
(
"Page View"
),
this
);
mPageLayout
.
addStretch
(
1
);
mPageLayout
.
addWidget
(
mpPageViewButton
,
0
);
mPageLayout
.
addStretch
(
1
);
mLayout
.
addLayout
(
&
mPageLayout
);
// TODO : Add the elements here
mpEditButton
=
new
QPushButton
(
tr
(
"Edit"
),
this
);
mPreviewLayout
.
addStretch
(
1
);
mPreviewLayout
.
addWidget
(
mpEditButton
,
0
);
mPreviewLayout
.
addStretch
(
1
);
mLayout
.
addLayout
(
&
mPreviewLayout
);
connect
(
mpPageViewButton
,
SIGNAL
(
clicked
()),
this
,
SIGNAL
(
onPageViewClicked
()));
connect
(
mpEditButton
,
SIGNAL
(
clicked
()),
this
,
SIGNAL
(
onEditClicked
()));
}
UBTBDocumentPreviewWidget
::~
UBTBDocumentPreviewWidget
()
{
DELETEPTR
(
mpPageViewButton
);
DELETEPTR
(
mpEditButton
);
}
src/gui/UBTeacherBarWidget.h
View file @
3dd07bb4
#ifndef UBTEACHERBARWIDGET_H
#define UBTEACHERBARWIDGET_H
class
UBMediaPlayer
;
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
...
...
@@ -19,220 +17,14 @@ class UBMediaPlayer;
#include "UBDockPaletteWidget.h"
#include "customWidgets/UBWidgetList.h"
#include "interfaces/IDropable.h"
#include "UBTeacherBarDataMgr.h"
#include "UBTBDocumentPreviewWidget.h"
#include "UBTBPageEditWidget.h"
#include "UBTeacherBarPreviewWidget.h"
#include "UBTBDocumentEditWidget.h"
#define LABEL_MINWIDHT 80
typedef
enum
{
eTeacherBarState_DocumentEdit
,
eTeacherBarState_DocumentPreview
,
eTeacherBarState_PageEdit
,
eTeacherBarState_PagePreview
}
eTeacherBarState
;
typedef
enum
{
eDuration_Quarter
,
eDuration_Half
,
eDuration_ThreeQuarter
}
eDuration
;
typedef
enum
{
eActionOwner_Teacher
,
eActionOwner_Student
}
eActionOwner
;
class
UBTeacherStudentAction
:
public
QWidget
{
Q_OBJECT
public
:
UBTeacherStudentAction
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTeacherStudentAction"
);
~
UBTeacherStudentAction
();
QString
comboValue
();
QString
text
();
void
setComboValue
(
int
value
);
void
setText
(
const
QString
&
text
);
private
:
QTextEdit
*
mpText
;
QHBoxLayout
*
mpLayout
;
QVBoxLayout
*
mpComboLayout
;
QComboBox
*
mpCombo
;
};
class
UBTeacherBarPreviewMedia
:
public
QWidget
{
Q_OBJECT
public
:
UBTeacherBarPreviewMedia
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTeacherBarPreviewMedia"
);
~
UBTeacherBarPreviewMedia
();
int
loadMedia
(
QStringList
pMedias
);
void
loadWidgets
(
QList
<
QWidget
*>
pWidgetList
,
bool
isResizable
=
true
);
void
cleanMedia
();
private
:
UBWidgetList
*
mWidget
;
QVBoxLayout
mLayout
;
QMap
<
QWidget
*
,
QString
>
mWidgetList
;
};
class
UBUrlWidget
:
public
QWidget
{
public
:
UBUrlWidget
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBUrlWidget"
);
~
UBUrlWidget
();
QString
url
();
void
setUrl
(
const
QString
&
url
);
private
:
QVBoxLayout
*
mpLayout
;
QHBoxLayout
*
mpLabelLayout
;
QHBoxLayout
*
mpTitleLayout
;
QLabel
*
mpUrlLabel
;
QLineEdit
*
mpUrl
;
QLabel
*
mpTitleLabel
;
QLineEdit
*
mpTitle
;
};
class
UBActionPreview
:
public
QWidget
{
public
:
UBActionPreview
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBActionPreview"
);
~
UBActionPreview
();
void
setOwner
(
const
QString
&
owner
);
void
setContent
(
const
QString
&
content
);
private
:
QLabel
*
mpOwner
;
QLabel
*
mpContent
;
QVBoxLayout
mLayout
;
QHBoxLayout
mOwnerLayout
;
};
class
UBTBPreviewContainer
:
public
UBWidgetList
{
public
:
UBTBPreviewContainer
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTBPreviewContainer"
);
~
UBTBPreviewContainer
();
};
class
UBTeacherBarPreviewWidget
:
public
QWidget
{
Q_OBJECT
public
:
UBTeacherBarPreviewWidget
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTeacherBarPreviewWidget"
);
~
UBTeacherBarPreviewWidget
();
UBTeacherBarPreviewMedia
*
mediaViewer
()
{
return
&
mMediaViewer
;}
void
setTitle
(
const
QString
&
title
);
void
setDuration
(
eDuration
duration
);
void
setComments
(
const
QString
&
comments
);
void
setActions
(
QStringList
actions
);
void
setLinks
(
QStringList
links
);
void
clean
();
QLabel
*
mediaLabel
()
{
return
mpMediaLabel
;}
signals
:
void
showEditMode
();
private
slots
:
void
onEdit
();
private
:
void
hideElements
();
QVBoxLayout
mLayout
;
QHBoxLayout
mEditLayout
;
QHBoxLayout
mTitleDurationLayout
;
UBTeacherBarPreviewMedia
mMediaViewer
;
QList
<
QWidget
*>
mWidgets
;
QList
<
QWidget
*>
mStoredWidgets
;
QPushButton
*
mpEditButton
;
QLabel
*
mpTitle
;
QLabel
*
mpDuration
;
QLabel
*
mpActionsLabel
;
QLabel
*
mpMediaLabel
;
QLabel
*
mpCommentsLabel
;
QLabel
*
mpComments
;
QLabel
*
mpLinksLabel
;
QLabel
*
mpTmpLink
;
UBActionPreview
*
mpTmpAction
;
UBTBPreviewContainer
*
mpContentContainer
;
};
class
UBTBMediaContainer
:
public
UBWidgetList
,
public
IDropable
{
Q_OBJECT
public
:
UBTBMediaContainer
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTBMediaContainer"
);
~
UBTBMediaContainer
();
QStringList
mediaUrls
();
QWidget
*
generateMediaWidget
(
const
QString
&
url
);
void
cleanMedias
();
signals
:
void
mediaDropped
(
const
QString
&
url
);
protected
:
void
dropEvent
(
QDropEvent
*
pEvent
);
void
dragEnterEvent
(
QDragEnterEvent
*
pEvent
);
void
dragMoveEvent
(
QDragMoveEvent
*
pEvent
);
void
dragLeaveEvent
(
QDragLeaveEvent
*
pEvent
);
private
:
void
addMedia
(
const
QString
&
mediaPath
);
QStringList
mMediaList
;
};
class
UBTBDocumentEditWidget
:
public
QWidget
{
Q_OBJECT
public
:
UBTBDocumentEditWidget
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTBDocumentEditWidget"
);
~
UBTBDocumentEditWidget
();
signals
:
void
onPreviewClicked
();
void
onPageViewClicked
();
private
:
QVBoxLayout
mLayout
;
QHBoxLayout
mPageLayout
;
QHBoxLayout
mPreviewLayout
;
QPushButton
*
mpPageViewButton
;
QPushButton
*
mpPreviewButton
;
QLabel
*
mpTitleLabel
;
QLineEdit
*
mpTitle
;
QLabel
*
mpTargetLabel
;
QTextEdit
*
mpTarget
;
QLabel
*
mpMetadataLabel
;
QLabel
*
mpLicenseLabel
;
};
class
UBTBDocumentPreviewWidget
:
public
QWidget
{
Q_OBJECT
public
:
UBTBDocumentPreviewWidget
(
QWidget
*
parent
=
0
,
const
char
*
name
=
"UBTBDocumentPreviewWidget"
);
~
UBTBDocumentPreviewWidget
();
signals
:
void
onEditClicked
();
void
onPageViewClicked
();
private
:
QVBoxLayout
mLayout
;
QHBoxLayout
mPageLayout
;
QHBoxLayout
mPreviewLayout
;
QPushButton
*
mpPageViewButton
;
QPushButton
*
mpEditButton
;
};
class
UBTeacherBarWidget
:
public
UBDockPaletteWidget
{
Q_OBJECT
...
...
@@ -245,44 +37,23 @@ private slots:
void
loadContent
();
void
onValueChanged
();
void
onTitleTextChanged
(
const
QString
&
text
);
void
onActionButton
();
void
onLinkButton
();
void
onShowEditMode
();
void
onMediaDropped
(
const
QString
&
url
);
void
onTBStateChanged
(
eTeacherBarState
state
);
private
:
void
clearWidgetLists
();
bool
isEmpty
();
QVBoxLayout
*
mpLayout
;
QHBoxLayout
*
mpTitleLayout
;
QLabel
*
mpTitleLabel
;
QLineEdit
*
mpTitle
;
QLabel
*
mpMediaLabel
;
QWidget
*
mpContainer
;
QVBoxLayout
*
mpContainerLayout
;
QLabel
*
mpActionLabel
;
UBWidgetList
*
mpActions
;
QPushButton
*
mpActionButton
;
QHBoxLayout
*
mpActionLayout
;
QLabel
*
mpLinkLabel
;
UBWidgetList
*
mpLinks
;
QPushButton
*
mpLinkButton
;
QHBoxLayout
*
mpLinkLayout
;
QLabel
*
mpCommentLabel
;
QTextEdit
*
mpComments
;
QStackedWidget
*
mpStackWidget
;
UBTeacherBarPreviewWidget
*
mpPreview
;
QVector
<
UBTeacherStudentAction
*>
mActionList
;
QVector
<
UBUrlWidget
*>
mUrlList
;
QVector
<
QWidget
*>
mMediaList
;
UBTBMediaContainer
*
mpMediaContainer
;
QVBoxLayout
mLayout
;
QStackedWidget
*
mpStackWidget
;
eTeacherBarState
mState
;
UBTBPageEditWidget
*
mpPageEditWidget
;
UBTeacherBarPreviewWidget
*
mpPreview
;
UBTBDocumentPreviewWidget
*
mpDocPreviewWidget
;
UBTBDocumentEditWidget
*
mpDocEditWidget
;
UBTeacherBarDataMgr
mData
;
};
#endif // UBTEACHERBARWIDGET_H
src/gui/gui.pri
View file @
3dd07bb4
...
...
@@ -47,7 +47,12 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBLibWebView.h \
src/gui/UBDownloadWidget.h \
src/gui/UBDockDownloadWidget.h \
src/gui/UBMediaPlayer.h
src/gui/UBMediaPlayer.h \
src/gui/UBTeacherBarDataMgr.h \
src/gui/UBTBDocumentEditWidget.h \
src/gui/UBTBDocumentPreviewWidget.h \
src/gui/UBTeacherBarPreviewWidget.h \
src/gui/UBTBPageEditWidget.h
SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFloatingPalette.cpp \
...
...
@@ -97,7 +102,12 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBLibWebView.cpp \
src/gui/UBDownloadWidget.cpp \
src/gui/UBDockDownloadWidget.cpp \
src/gui/UBMediaPlayer.cpp
src/gui/UBMediaPlayer.cpp \
src/gui/UBTeacherBarDataMgr.cpp \
src/gui/UBTBDocumentEditWidget.cpp \
src/gui/UBTBDocumentPreviewWidget.cpp \
src/gui/UBTeacherBarPreviewWidget.cpp \
src/gui/UBTBPageEditWidget.cpp
win32 {
...
...
@@ -125,5 +135,3 @@ linux-g++-64 {
SOURCES += src/gui/UBKeyboardPalette_linux.cpp
}
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