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
47dd119c
Commit
47dd119c
authored
Sep 10, 2012
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified placeholder management in teacherguide
parent
62e5308f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
25 deletions
+32
-25
UBTeacherGuideWidgetsTools.cpp
src/gui/UBTeacherGuideWidgetsTools.cpp
+26
-24
UBTeacherGuideWidgetsTools.h
src/gui/UBTeacherGuideWidgetsTools.h
+6
-1
No files found.
src/gui/UBTeacherGuideWidgetsTools.cpp
View file @
47dd119c
...
...
@@ -148,30 +148,10 @@ void UBTGAdaptableText::setPlaceHolderText(QString text)
setPlainText
(
mPlaceHolderText
);
}
void
UBTGAdaptableText
::
keyPressEvent
(
QKeyEvent
*
e
)
{
if
(
isReadOnly
()){
// this is important if you set a placeholder. In this case even if the text field is readonly the
// keypressed event came here. So if you don't ignore it you'll have a flick on the text zone
e
->
ignore
();
return
;
}
if
(
toPlainText
()
==
mPlaceHolderText
){
setPlainText
(
""
);
}
setTextColor
(
QColor
(
Qt
::
black
));
QTextEdit
::
keyPressEvent
(
e
);
}
void
UBTGAdaptableText
::
keyReleaseEvent
(
QKeyEvent
*
e
)
{
QTextEdit
::
keyReleaseEvent
(
e
);
if
(
toPlainText
().
isEmpty
()){
setTextColor
(
QColor
(
Qt
::
lightGray
));
setPlainText
(
mPlaceHolderText
);
}
if
(
mMaximumLength
&&
toPlainText
().
length
()
>
mMaximumLength
){
setPlainText
(
toPlainText
().
left
(
mMaximumLength
));
QTextCursor
tc
(
document
());
...
...
@@ -183,8 +163,10 @@ void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e)
void
UBTGAdaptableText
::
showEvent
(
QShowEvent
*
e
)
{
Q_UNUSED
(
e
);
if
(
!
mIsUpdatingSize
&&
mHasPlaceHolder
&&
toPlainText
().
isEmpty
())
setPlainText
(
mPlaceHolderText
);
if
(
!
mIsUpdatingSize
&&
mHasPlaceHolder
&&
toPlainText
().
isEmpty
()){
setTextColor
(
QColor
(
Qt
::
lightGray
));
setPlainText
(
mPlaceHolderText
);
}
else
// If the teacherguide is collapsed, don't updated the size. Or set the size as the expanded size
onTextChanged
();
...
...
@@ -201,9 +183,7 @@ QString UBTGAdaptableText::text()
void
UBTGAdaptableText
::
onTextChanged
()
{
//qDebug() << ">> onTextChanged CALLED!";
qreal
documentSize
=
document
()
->
size
().
height
();
//qDebug() << ">> documentSize: " << documentSize << ", height: " << height();
if
(
height
()
==
documentSize
+
mBottomMargin
){
return
;
}
...
...
@@ -248,6 +228,28 @@ void UBTGAdaptableText::bottomMargin(int newValue)
onTextChanged
();
}
void
UBTGAdaptableText
::
focusInEvent
(
QFocusEvent
*
e
){
if
(
isReadOnly
()){
e
->
ignore
();
}
managePlaceholder
();
QTextEdit
::
focusInEvent
(
e
);
}
void
UBTGAdaptableText
::
focusOutEvent
(
QFocusEvent
*
e
){
if
(
toPlainText
().
isEmpty
()){
setTextColor
(
QColor
(
Qt
::
lightGray
));
setPlainText
(
mPlaceHolderText
);
}
QTextEdit
::
focusOutEvent
(
e
);
}
void
UBTGAdaptableText
::
managePlaceholder
(){
if
(
toPlainText
()
==
mPlaceHolderText
){
setTextColor
(
QColor
(
Qt
::
black
));
setPlainText
(
""
);
}
}
/***************************************************************************
* class UBTGDraggableWeb *
...
...
src/gui/UBTeacherGuideWidgetsTools.h
View file @
47dd119c
...
...
@@ -26,6 +26,8 @@
#include <QMimeData>
#include <QStackedWidget>
#include <QWebView>
#include <QFocusEvent>
#include <QMouseEvent>
#include "customWidgets/UBMediaWidget.h"
...
...
@@ -103,11 +105,14 @@ public slots:
void
onTextChanged
();
protected
:
void
keyPressEvent
(
QKeyEvent
*
e
);
void
keyReleaseEvent
(
QKeyEvent
*
e
);
void
showEvent
(
QShowEvent
*
e
);
void
focusInEvent
(
QFocusEvent
*
e
);
void
focusOutEvent
(
QFocusEvent
*
e
);
private
:
void
managePlaceholder
();
int
mBottomMargin
;
QTreeWidgetItem
*
mpTreeWidgetItem
;
int
mMinimumHeight
;
...
...
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