From f627e52cd6a6e035d64c1e56ddd2030d0ad3ea98 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 14 Oct 2011 09:35:12 +0200 Subject: [PATCH 1/5] changed sankore version --- Sankore_3.1.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro index 1c7b4ae7..63a3ae83 100644 --- a/Sankore_3.1.pro +++ b/Sankore_3.1.pro @@ -7,7 +7,7 @@ CONFIG += debug_and_release \ no_include_pwd VERSION_MAJ = 1 -VERSION_MIN = 28 +VERSION_MIN = 30 VERSION_TYPE = b # a = alpha, b = beta, r = release, other => error VERSION_PATCH = 00 From 8bb8616e1218da701121b65928dd22043ddc22d7 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 14 Oct 2011 09:52:50 +0200 Subject: [PATCH 2/5] fixed qt path --- release.linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.linux.sh b/release.linux.sh index 51742ee3..fffc2450 100644 --- a/release.linux.sh +++ b/release.linux.sh @@ -19,7 +19,7 @@ make clean rm -rf build/linux/release/ rm -rf install -QT_PATH="/usr/local/Trolltech/Qt-4.7.3" +QT_PATH="../Qt-sankore3.1" PLUGINS_PATH="$QT_PATH/plugins" QMAKE_PATH="$QT_PATH/bin/qmake" From 387f754092fbf0942b24b93942582f8cf8857751 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Wed, 19 Oct 2011 14:36:25 +0200 Subject: [PATCH 3/5] fixed translation on dialog --- src/core/UBApplicationController.cpp | 4 +-- src/core/UBPersistenceManager.cpp | 7 ++--- src/gui/UBMainWindow.cpp | 24 ++++++++++++++- src/gui/UBMainWindow.h | 5 ++++ src/gui/UBUpdateDlg.cpp | 41 +++++++++++++------------- src/network/UBNetworkAccessManager.cpp | 20 ++++++++----- src/web/browser/WBWebView.cpp | 3 +- 7 files changed, 64 insertions(+), 40 deletions(-) diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index 4fad106a..2ac37db1 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -563,9 +563,7 @@ void UBApplicationController::downloadJsonFinished(QString currentJson) } else { if (isNoUpdateDisplayed) { - QMessageBox msgBox; - msgBox.setText (tr ("No update available")); - msgBox.exec(); + mMainWindow->information(tr("Update"), tr("No update available")); } } } diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 3987f615..bdb0a11b 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -14,6 +14,7 @@ */ #include "UBPersistenceManager.h" +#include "gui/UBMainWindow.h" #include @@ -1005,11 +1006,7 @@ void UBPersistenceManager::checkIfDocumentRepositoryExists() QString humanPath = QDir::cleanPath(mDocumentRepositoryPath); humanPath = QDir::toNativeSeparators(humanPath); - QMessageBox::question( - QApplication::activeWindow(), - tr("Document Repository Loss"), - tr("Sankore has lost access to the document repository '%1'. Unfortunately the application must shut down to avoid data corruption. Latest changes may be lost as well.").arg(humanPath), - QMessageBox::Yes); + UBApplication::mainWindow->warning(tr("Document Repository Loss"),tr("Sankore has lost access to the document repository '%1'. Unfortunately the application must shut down to avoid data corruption. Latest changes may be lost as well.").arg(humanPath)); UBApplication::quit(); } diff --git a/src/gui/UBMainWindow.cpp b/src/gui/UBMainWindow.cpp index 11d8b41c..1bc2cab5 100644 --- a/src/gui/UBMainWindow.cpp +++ b/src/gui/UBMainWindow.cpp @@ -16,7 +16,6 @@ #include #include "UBMainWindow.h" - #include "core/UBApplication.h" #include "core/UBApplicationController.h" #include "board/UBBoardController.h" @@ -160,3 +159,26 @@ bool UBMainWindow::yesNoQuestion(QString windowTitle, QString text) return messageBox.clickedButton() == yesButton; } + +void UBMainWindow::oneButtonMessageBox(QString windowTitle, QString text, QMessageBox::Icon type) +{ + QMessageBox messageBox; + messageBox.setParent(this); + messageBox.setWindowFlags(Qt::Dialog); + messageBox.setWindowTitle(windowTitle); + messageBox.setText(text); + messageBox.addButton(tr("Ok"),QMessageBox::YesRole); + messageBox.setIcon(type); + messageBox.exec(); +} + +void UBMainWindow::warning(QString windowTitle, QString text) +{ + oneButtonMessageBox(windowTitle,text, QMessageBox::Warning); +} + +void UBMainWindow::information(QString windowTitle, QString text) +{ + oneButtonMessageBox(windowTitle, text, QMessageBox::Information); +} + diff --git a/src/gui/UBMainWindow.h b/src/gui/UBMainWindow.h index 2bd6fc25..4150bbec 100644 --- a/src/gui/UBMainWindow.h +++ b/src/gui/UBMainWindow.h @@ -20,6 +20,7 @@ #include #include #include +#include class QStackedLayout; @@ -41,7 +42,10 @@ class UBMainWindow : public QMainWindow, public Ui::MainWindow void addDocumentsWidget(QWidget *pWidget); void switchToDocumentsWidget(); + bool yesNoQuestion(QString windowTitle, QString text); + void warning(QString windowTitle, QString text); + void information(QString windowTitle, QString text); signals: void closeEvent_Signal( QCloseEvent *event ); @@ -50,6 +54,7 @@ class UBMainWindow : public QMainWindow, public Ui::MainWindow void onExportDone(); protected: + void oneButtonMessageBox(QString windowTitle, QString text, QMessageBox::Icon type); virtual void keyPressEvent(QKeyEvent *event); virtual void closeEvent (QCloseEvent *event); diff --git a/src/gui/UBUpdateDlg.cpp b/src/gui/UBUpdateDlg.cpp index 2c2ba56b..c0651258 100644 --- a/src/gui/UBUpdateDlg.cpp +++ b/src/gui/UBUpdateDlg.cpp @@ -12,28 +12,29 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include #include #include "UBUpdateDlg.h" +#include "core/UBApplication.h" +#include "UBMainWindow.h" #include "core/memcheck.h" UBUpdateDlg::UBUpdateDlg(QWidget *parent, int nbFiles, const QString& bkpPath) - : QDialog(parent) - , mMainLayout(NULL) - , mNbFilesLabel(NULL) - , mBkpLabel(NULL) - , mBkpPath(NULL) - , mBrowseBttn(NULL) - , mpDlgBttn(NULL) - , mLayout(NULL) - , mHLayout(NULL) - , mStackedWidget(NULL) - , mDialogWidget(NULL) - , mProgressWidget(NULL) - , mProgressLayout(NULL) - , mProgressLabel(NULL) + : QDialog(parent) + , mMainLayout(NULL) + , mNbFilesLabel(NULL) + , mBkpLabel(NULL) + , mBkpPath(NULL) + , mBrowseBttn(NULL) + , mpDlgBttn(NULL) + , mLayout(NULL) + , mHLayout(NULL) + , mStackedWidget(NULL) + , mDialogWidget(NULL) + , mProgressWidget(NULL) + , mProgressLayout(NULL) + , mProgressLabel(NULL) { mDialogWidget = new QWidget(this); @@ -178,18 +179,16 @@ void UBUpdateDlg::onUpdate() void UBUpdateDlg::onFilesUpdated(bool bResult) { - this->hide(); + this->hide(); QString qsMsg; - if (bResult) - { + if (bResult) { qsMsg = tr("Files update successful!\nPlease reboot the application to access the updated documents."); } - else - { + else { qsMsg = tr("An error occured during the update. The files have not been affected."); } - QMessageBox::information(this, tr("Files update results"), qsMsg, QMessageBox::Ok); + UBApplication::mainWindow->information(tr("Files update results"), qsMsg); } QString UBUpdateDlg::backupPath() diff --git a/src/network/UBNetworkAccessManager.cpp b/src/network/UBNetworkAccessManager.cpp index 6529c388..c2b7aa10 100644 --- a/src/network/UBNetworkAccessManager.cpp +++ b/src/network/UBNetworkAccessManager.cpp @@ -160,14 +160,18 @@ void UBNetworkAccessManager::sslErrors(QNetworkReply *reply, const QListurl().toString()).arg(errors), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No); - - if (ret == QMessageBox::Yes) - { + QMessageBox messageBox; + messageBox.setParent(mainWindow); + messageBox.setWindowFlags(Qt::Dialog); + messageBox.setWindowTitle(QCoreApplication::applicationName()); + messageBox.setText(tr("SSL Errors:\n\n%1\n\n%2\n\n" + "Do you want to ignore these errors for this host?").arg(reply->url().toString()).arg(errors)); + QPushButton* yesButton = messageBox.addButton(tr("Yes"),QMessageBox::YesRole); + messageBox.addButton(tr("No"),QMessageBox::NoRole); + messageBox.setIcon(QMessageBox::Question); + messageBox.exec(); + + if(messageBox.clickedButton() == yesButton) { reply->ignoreSslErrors(); sslTrustedHostList.append(replyHost); } diff --git a/src/web/browser/WBWebView.cpp b/src/web/browser/WBWebView.cpp index 23fb6cb5..eb0be66f 100644 --- a/src/web/browser/WBWebView.cpp +++ b/src/web/browser/WBWebView.cpp @@ -168,8 +168,7 @@ void WBWebPage::handleUnsupportedContent(QNetworkReply *reply) messageBox.setText(tr("Download PDF Document: would you prefer to download the PDF file or add it to the current Sankore document?")); messageBox.addButton(tr("Download"), QMessageBox::AcceptRole); - QAbstractButton *addButton = - messageBox.addButton(tr("Add to Current Document"), QMessageBox::AcceptRole); + QAbstractButton *addButton = messageBox.addButton(tr("Add to Current Document"), QMessageBox::AcceptRole); messageBox.exec(); if (messageBox.clickedButton() == addButton) From 6e181605d7ae8f598ce4986c75e4b4dc5cc5718d Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Thu, 20 Oct 2011 16:03:29 +0200 Subject: [PATCH 4/5] Added the teacherbar --- resources/images/teacher_close.png | Bin 0 -> 1043 bytes resources/images/teacher_close_disabled.png | Bin 0 -> 1043 bytes resources/images/teacher_open.png | Bin 0 -> 1034 bytes resources/images/teacher_open_disabled.png | Bin 0 -> 1030 bytes resources/sankore.qrc | 6 +- resources/style.qss | 44 +- src/board/UBBoardPaletteManager.cpp | 18 + src/board/UBBoardPaletteManager.h | 4 + src/core/UBPersistenceManager.cpp | 86 ++++ src/core/UBPersistenceManager.h | 18 + src/gui/UBDocumentNavigator.cpp | 5 +- src/gui/UBTeacherBarWidget.cpp | 431 ++++++++++++++++++++ src/gui/UBTeacherBarWidget.h | 78 ++++ src/gui/gui.pri | 6 +- 14 files changed, 691 insertions(+), 5 deletions(-) create mode 100644 resources/images/teacher_close.png create mode 100644 resources/images/teacher_close_disabled.png create mode 100644 resources/images/teacher_open.png create mode 100644 resources/images/teacher_open_disabled.png create mode 100644 src/gui/UBTeacherBarWidget.cpp create mode 100644 src/gui/UBTeacherBarWidget.h diff --git a/resources/images/teacher_close.png b/resources/images/teacher_close.png new file mode 100644 index 0000000000000000000000000000000000000000..bee2ea0d948eb65c3d538ec6f28c3c00ea3f82d5 GIT binary patch literal 1043 zcmV+u1nm2XP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipo0 z4G$4n!3pvJ00WarL_t(Y$F-MBPa9Vh$A9hJ!cxG-FCXTFPFovG((fsxMpL@A8+5Pc0!~kTqT6y4ky*X|vq-E8< zzbN52&SZk4tk!BZwzi&NS=RLgMerKDUg6NyCF-u`85T6tMA z5{XbQm&xUFW7EoUY~*se0qybe$)yLT$E{5&m11*qliAtNX*3!bVDS0Uu6I+1q=;`*-hgyEalvv{oo3ab1^#g9DC_ zKQJ>h!{Xu+>2z|4QUe6Q{@cHK{(O(a!$Vx#Mr(=I8jvUnxpY9i)Bmv7^Ef*ChqJRf z`Fx&I>E3`?1MEI~!S2p3t;QKb2$WL&q=MDCfSD}x0>SII!}fgN=j5b+onRp63&dhCdN5EtDwUo1s#v z^5#v2a`p%D!QE26SQ7_B2r2c3WbTq;zXlS!r?GlhsF?$E0U2W*<_fz=?q=h#rOU5 ze$*(XkWyldL5D+E&vLOK$)+W_q>GdRLI{KqgE|>waC;t+NR(o+I8?t23De;kQbH-; zWnsR+q1DE*+ZY2a3rO6j2ok}(&rgUiIURs=!NKa@gY`nyj(=p)4SD23?HG#G>cxwyFW z`$hdU@d}8=Vuz0&ZG541=r_Q-sh~Ljtq`_te^aei@|IQm;U*9Ge*r+ni?u^g;tv1- N002ovPDHLkV1iXi@X`PP literal 0 HcmV?d00001 diff --git a/resources/images/teacher_close_disabled.png b/resources/images/teacher_close_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..8f3c988c8e240c89fd40ad271e04765365931c10 GIT binary patch literal 1043 zcmV+u1nm2XP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipo0 z4H6vK92rvp00WarL_t(Y$F-JAPa9VlhM#ls%-HynVsmR^2LlQuQPoxoS<|S?N_4}o zBmba(p)0zBh+Nbx8hNUOgwk=KU}Jm68jAFqeMY@0>^PcRfb{7-N+0`&rkm zjd@=Erzq-iT@%Kb?D26kv$?tT^G!fsO!~fWZ*Fe=cpESP>AJOI6!o&)l1b02ubk%y zg5Y|Eb8yhzVN-3#UtJt>9#>Q_WtCbfyZQG_= ztx_tLMpi3F38Pdh4b<-MA6!^4J!)?9`8=zutK7Z&HO*!dW6bq{LI@TYAMoVKGQD0% zqtUqV{Dr`DI?c0ZKakJo2?BqlNQMFng#v49YxsVLUT^fV916^2GIToat4|8IYy*Yo z6-|iIL0|6c>jEwf`8HtxZw`l9CkUw3{v--R9z0keo6QaxfPNl_0vpF|-n{vpo%inv z0w1L$uIo~%RCxGsk$gUXxxyq#_4ZZ?6AN8nVFdx z=I0kE6mn-&YJdcI|KTrQzT9SacbCxj(OROl1|&*CsgTg<^e^^$5qo=ob9B^Ta&nSN z<=#NC2H1M>imlBpTFoPb5GbYkP6bQ%6K0CgO9XE}oDDCIV-61b>uh}dE9T~^ePD5X zoQa7df`qW!Ma!6P76cP_`s)AqC^>9tbP6nWb`ynRNEF35j&-VVVXi{?-VC*x%e!|q zs>MCDjCt)Enr(s7f>i3iucDApDc@&ywlb*xpeVML;_;&;ob(v7amb6eEsp&ZIwj92 z>UO(yIvt`YCY#Ok=+P2V%HfTjBoU6S2*ZG8^OztA0YMzcv|24%trkgQ$mMcmGS20V zowwV3TMjvDWNE!VRiu<8m9j{uGdPZeWm#yQ8UdJ5XT)YpBF<@en*kEbR@^_1TuP2G3s2}1<$XD1l0=K<_ z%gVqb0n4&3-PTH}ey)|$XFf>Aoc|nL1k+lPBuQVu^z_uPr#%=W#MQR95dE13gAgF+ z=NJAtub-~{1fKiOnAGI3H};rsrK>((64tKaAY|1a&vh8YRAXy^a{ N002ovPDHLkV1g&Y>iPfx literal 0 HcmV?d00001 diff --git a/resources/images/teacher_open.png b/resources/images/teacher_open.png new file mode 100644 index 0000000000000000000000000000000000000000..17469cc79ec9e6aa7f694d92459b597e2e45ecd5 GIT binary patch literal 1034 zcmV+l1oiugP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipo0 z4G=Y`nB%}=nc6>_{$8t%i1PFmhg;cSobVWD( z1p1?jSi`pLks3C*u&4?Pgq_4~Q^!t8Y{&78?U^|&9Ovd#PU7%MXESHcqxZX>8DWeO zK)|-`#Y&|-U#~ZQaoqt|H4QB6@3%9h(zD;D0gX)BwjD2(p8a$kFaTMpls|FZL7ry-?YBo_D0SP$*0fJgFAIb=|AGeCb|3PQvss zV@?2tm>wv^|LO8|*~BalT$e^;2ha7$WKvhJL#Nm0<;&M>ZfvlqD5X&nk~e)?UGROMot?L|T5TGQw`8*!lF7u8Vhymd`HHo*U#V@q zMhJmY3Q%YTALM8ZOcB_S!9v|Hn%*}ug z{QXL@*U@MT0_tSl2|UlE+qLQU`^O6BlC#{q_XR5}?^CI45cOZ6rN{G%p?x4wT5xt) zJB~vl8E0`JPa-i(Fc>_Y6s;85Od72%I$ITf|Fg}$ZJ{lBN>Q)ZqucG`x*o-1k!&`N zIMHTfh3)wsp@5{{cWAfwahyIdbgk3r(CKvWeM2l3Lu);`4#V1Ex!9xGiqd(0tVk(| zWd#U_BZNXB0)fC`@+JX;7O|j1A|{x*8K>9p<9QxZ%EK~JNGUPKV4c%7V=m9$kj&iB zBx3`#9>z@wft2#7TnxjmNu^V#;&-mXh;E|gfNVO-XPPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipo0 z4HFF9usC)A00V|eL_t(Y$F-I_a~o9{hM#j;-6AEnB}-a4iLFtvNdW~6&M=dLf`SkV z$e$oTD)|MJp`?nb6q*cBFlcQnH(9c=C0W+4q}@Ff@?AEvE%VKsX3sg#yx;Y#05HZV z*L9PQQ@K&EH@@@z0arC)j7je9wiD&@tM4ZP9hh`oH(D;g`uaLx0Mc&>}9DJ9$6+ZR%G;@){1(P)&XPk-dmqi={rB9jA+F*KV^78jRz z^5h3>+nx+~V6NN67{lYo-}2zW@>sPODw`k(4%HTm#mRxk)dKjwe|48H-OEQwm>g!z zF`y8W1BLiMUA`_Go8^J;(`alG_yPHR_Ud)$_4>Sd^N#hkH8wVC2qBo8E3mMzK%rn0 zi^awRjWKlgx~#6Qv%0#*M(xA!kXBfhMXk2M&Q6nBt;X%!bL4V)VzKBb&;Z*zEh?1? ze^(spA8IHi&|0IEMoGxr3TbsA3_~_Iw`jH6G#XpjcAiWoeW+LitgXLgW#w0D@82PW zKq&<%w1SW4L+msRLcyQa(c$5`?*8zdC6mbvfvIGY`MY=U2YuSD7Fq^;a!)Wj1tIX) zTggsGqb-Q2<8>zpf`D$P6;dZ-8=K7)6+zw(UVEhN@3@7Xl>DX@9^6nZFXG?ZOIdgdc7XqZWrGVD3wasb`Ei@ z%|;442m@jfNx$#WZtvoGePHNXr_-U+=@5p7R4RqmdVC$mwZ~$qN3)fr^ZH1UQWDFG z5RWH_#bQJvk^SV214b=UQIB*=Fm-E&UcXNe1V}0O%Sa)m#2ABhM%RqEJbhC#byJf` z4bXZRHz5R4%ENLo47(+%E^4VHh9;BWv8)4}t(N!zZ9ry0@*hb$w4jJRa{Z zFMsiq*47roSuoi{wVz$#x~}awl~}#rnCJ)oU#csMpJ+*`8~^|S07*qoM6N<$f?F)w A_y7O^ literal 0 HcmV?d00001 diff --git a/resources/sankore.qrc b/resources/sankore.qrc index 501755ef..88354189 100644 --- a/resources/sankore.qrc +++ b/resources/sankore.qrc @@ -319,12 +319,16 @@ images/pages_open.png images/cache_close.png images/cache_open.png - style.qss images/cache_circle.png images/cache_square.png images/down_arrow.png images/up_arrow.png images/left_arrow.png images/right_arrow.png + style.qss + images/teacher_close.png + images/teacher_close_disabled.png + images/teacher_open.png + images/teacher_open_disabled.png diff --git a/resources/style.qss b/resources/style.qss index 9f79a645..1c0ab3a3 100644 --- a/resources/style.qss +++ b/resources/style.qss @@ -1,7 +1,8 @@ QWidget#DockPaletteWidgetBox, QWidget#documentNavigator, QWidget#UBLibraryWidget, -QWidget#UBLibPathViewer +QWidget#UBLibPathViewer, +QWidget#UBTeacherStudentAction { background: #EEEEEE; border-radius: 10px; @@ -21,6 +22,40 @@ QLabel#DockPaletteWidgetTitle font-weight:bold; } +QLineEdit#DockPaletteWidgetLineEdit +{ + background: white; + border-radius : 10px; + padding: 2px; +} + +QComboBox#DockPaletteWidgetComboBox +{ + background: white; + border-radius : 10px; + padding: 2px; +} + +QComboBox#DockPaletteWidgetComboBox:drop-down +{ + background: white; + width:1px; + height:1px; + margin: 9px 5px 0px 0px; +} + +QComboBox#DockPaletteWidgetComboBox::down-arrow +{ + image:url(:/images/down_arrow.png); + background:#BBBBBB; + border: 2px solid #999999; + height:16px; + width:16px; + padding: 0px 0px 0px 0px; + margin: 5px 10px 0px 0px; + border-radius: 10px; +} + QPushButton#DockPaletteWidgetButton { background-color : #DDDDDD; @@ -31,6 +66,13 @@ QPushButton#DockPaletteWidgetButton font-size : 12px; } +QTextEdit#TeacherStudentBox +{ + background: white; + border: 2px solid #999999; + border-radius: 10px; +} + QPushButton#DockPaletteWidgetButton::checked { background-color: #BBBBBB; diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 08d609bf..a6461bc5 100755 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -76,6 +76,7 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll , mpPageNavigWidget(NULL) , mpLibWidget(NULL) , mpCachePropWidget(NULL) + , mpTeacherBarWidget(NULL) , mDesktopRightPalette(NULL) , mpDesktopLibWidget(NULL) { @@ -96,6 +97,11 @@ UBBoardPaletteManager::~UBBoardPaletteManager() delete mpLibWidget; mpLibWidget = NULL; } + if(NULL != mpTeacherBarWidget) + { + delete mpTeacherBarWidget; + mpTeacherBarWidget = NULL; + } if(NULL != mpCachePropWidget) { delete mpCachePropWidget; @@ -155,8 +161,13 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() // RIGHT palette widgets mRightPalette->registerWidget(mpLibWidget); mRightPalette->registerWidget(mpCachePropWidget); + mRightPalette->registerWidget(mpTeacherBarWidget); mRightPalette->addTabWidget(mpLibWidget); + mRightPalette->addTabWidget(mpTeacherBarWidget); mRightPalette->connectSignals(); + + mLeftPalette->showTabWidget(0); + mRightPalette->showTabWidget(0); } void UBBoardPaletteManager::setupPalettes() @@ -169,6 +180,7 @@ void UBBoardPaletteManager::setupPalettes() mpPageNavigWidget = new UBPageNavigationWidget(); mpLibWidget = new UBLibWidget(); mpCachePropWidget = new UBCachePropertiesWidget(); + mpTeacherBarWidget = new UBTeacherBarWidget(); setupDockPaletteWidgets(); @@ -717,3 +729,9 @@ UBRightPalette* UBBoardPaletteManager::createDesktopRightPalette(QWidget* parent return mDesktopRightPalette; } + +void UBBoardPaletteManager::refreshPalettes() +{ + mRightPalette->update(); + mLeftPalette->update(); +} diff --git a/src/board/UBBoardPaletteManager.h b/src/board/UBBoardPaletteManager.h index 4ca00fd7..dc81dd17 100644 --- a/src/board/UBBoardPaletteManager.h +++ b/src/board/UBBoardPaletteManager.h @@ -25,6 +25,7 @@ #include "gui/UBPageNavigationWidget.h" #include "gui/UBLibWidget.h" #include "gui/UBCachePropertiesWidget.h" +#include "gui/UBTeacherBarWidget.h" class UBStylusPalette; class UBClockPalette; @@ -49,6 +50,7 @@ class UBBoardPaletteManager : public QObject UBLeftPalette* leftPalette(){return mLeftPalette;} void showVirtualKeyboard(bool show = true); void initPalettesPosAtStartup(); + void refreshPalettes(); UBKeyboardPalette *mKeyboardPalette; UBRightPalette* createDesktopRightPalette(QWidget* parent); @@ -113,6 +115,8 @@ class UBBoardPaletteManager : public QObject UBLibWidget* mpLibWidget; /** The cache properties widget */ UBCachePropertiesWidget* mpCachePropWidget; + /** The teacherbar widget */ + UBTeacherBarWidget* mpTeacherBarWidget; // HACK: here we duplicate the lib widget for the desktop mode // we MUST refactor the architecture in order to use only one diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index bdb0a11b..8c2f3f95 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -1056,3 +1056,89 @@ bool UBPersistenceManager::mayHaveWidget(UBDocumentProxy* pDocumentProxy) return widgetDir.exists() && widgetDir.entryInfoList(QDir::Dirs).length() > 0; } +void UBPersistenceManager::persistTeacherBar(UBDocumentProxy* pDocumentProxy, int page, sTeacherBarInfos infos) +{ + if(NULL != pDocumentProxy) + { + QFile f(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", page + 1)); + if(f.exists()) + { + if(f.open(QIODevice::ReadOnly)) + { + QDomDocument domDoc; + if(domDoc.setContent(f.readAll())) + { + f.close(); + if(f.open(QIODevice::WriteOnly)) + { + QDomElement rootElem = domDoc.documentElement(); + QDomNode teacherBarNode = domDoc.namedItem("teacherBar"); + if(teacherBarNode.isNull()) + { + // Create the element + QDomElement teacherElem = domDoc.createElement("teacherBar"); + rootElem.appendChild(teacherElem); + teacherBarNode = teacherElem; + } + + // Set the element values + QDomElement teacherBarElem = teacherBarNode.toElement(); + teacherBarElem.setAttribute("title", infos.title); + teacherBarElem.setAttribute("phasis", infos.phasis); + teacherBarElem.setAttribute("duration", infos.Duration); + teacherBarElem.setAttribute("equipment", infos.material); + teacherBarElem.setAttribute("activity", infos.activity); + teacherBarElem.setAttribute("action1Teacher", infos.action1Master); + teacherBarElem.setAttribute("action1Student", infos.action1Student); + teacherBarElem.setAttribute("action2Teacher", infos.action2Master); + teacherBarElem.setAttribute("action2Student", infos.action2Student); + teacherBarElem.setAttribute("action3Teacher", infos.action3Master); + teacherBarElem.setAttribute("action3Student", infos.action3Student); + + // Save the file + f.write(domDoc.toString().toAscii()); + f.close(); + } + } + f.close(); + } + } + } +} + +sTeacherBarInfos UBPersistenceManager::getTeacherBarInfos(UBDocumentProxy* pDocumentProxy, int page) +{ + sTeacherBarInfos infos; + + if(NULL != pDocumentProxy) + { + QFile f(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", page + 1)); + if(f.exists()) + { + if(f.open(QIODevice::ReadWrite)) + { + QDomDocument domDoc; + if(domDoc.setContent(f.readAll())) + { + QDomElement rootElem = domDoc.documentElement(); + QDomNode teacherBarNode = rootElem.namedItem("teacherBar"); + + infos.title = teacherBarNode.toElement().attributeNode("title").value(); + infos.phasis = teacherBarNode.toElement().attributeNode("phasis").value().toInt(); + infos.Duration = teacherBarNode.toElement().attributeNode("duration").value().toInt(); + infos.material = teacherBarNode.toElement().attributeNode("equipment").value(); + infos.activity = teacherBarNode.toElement().attributeNode("activity").value().toInt(); + infos.action1Master = teacherBarNode.toElement().attributeNode("action1Teacher").value(); + infos.action1Student = teacherBarNode.toElement().attributeNode("action1Student").value(); + infos.action2Master = teacherBarNode.toElement().attributeNode("action2Teacher").value(); + infos.action2Student = teacherBarNode.toElement().attributeNode("action2Student").value(); + infos.action3Master = teacherBarNode.toElement().attributeNode("action3Teacher").value(); + infos.action3Student = teacherBarNode.toElement().attributeNode("action3Student").value(); + } + f.close(); + } + } + } + + return infos; +} diff --git a/src/core/UBPersistenceManager.h b/src/core/UBPersistenceManager.h index 9189e38f..98a296f6 100644 --- a/src/core/UBPersistenceManager.h +++ b/src/core/UBPersistenceManager.h @@ -20,6 +20,21 @@ #include "UBSceneCache.h" +struct sTeacherBarInfos +{ + QString title; + int phasis; + int Duration; + QString material; + int activity; + QString action1Master; + QString action1Student; + QString action2Master; + QString action2Student; + QString action3Master; + QString action3Student; +}; + class UBDocument; class UBDocumentProxy; class UBGraphicsScene; @@ -59,6 +74,9 @@ class UBPersistenceManager : public QObject virtual void persistDocumentScene(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* pScene, const int pSceneIndex); + virtual void persistTeacherBar(UBDocumentProxy* pDocumentProxy, int page, sTeacherBarInfos infos); + + sTeacherBarInfos getTeacherBarInfos(UBDocumentProxy* pDocumentProxy, int page); virtual UBGraphicsScene* createDocumentSceneAt(UBDocumentProxy* pDocumentProxy, int index); diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index afd62d79..4d3ee9a0 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -138,7 +138,10 @@ void UBDocumentNavigator::updateSpecificThumbnail(int iPage) { // Save the current state of the scene pScene->setModified(true); - UBSvgSubsetAdaptor::persistScene(mCrntDoc,pScene, iPage); + if(UBApplication::boardController) + { + UBApplication::boardController->persistCurrentScene(); + } UBThumbnailAdaptor::persistScene(mCrntDoc->persistencePath(), pScene, iPage); diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp new file mode 100644 index 00000000..513cd246 --- /dev/null +++ b/src/gui/UBTeacherBarWidget.cpp @@ -0,0 +1,431 @@ +#include "UBTeacherBarWidget.h" + +#include "core/UBApplication.h" +#include "core/UBPersistenceManager.h" + +#include "document/UBDocumentController.h" +#include "document/UBDocumentProxy.h" + +#include "board/UBBoardController.h" +#include "board/UBBoardPaletteManager.h" + +UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) + , mpLayout(NULL) + , mpTitleLayout(NULL) + , mpPhasisLayout(NULL) + , mpDurationLayout(NULL) + , mpEquipmentLayout(NULL) + , mpActivityLayout(NULL) + , mpTitleLabel(NULL) + , mpPhasisLabel(NULL) + , mpDurationLabel(NULL) + , mpEquipmentLabel(NULL) + , mpActivityLabel(NULL) + , mpTitle(NULL) + , mpEquipment(NULL) + , mpPhasis(NULL) + , mpDuration(NULL) + , mpActivity(NULL) + , mpAction1(NULL) + , mpAction2(NULL) + , mpAction3(NULL) + , mpContainer(NULL) + , mpContainerLayout(NULL) +{ + setObjectName(name); + mName = "TeacherBarWidget"; + + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + + mIconToLeft = QPixmap(":images/teacher_open.png"); + mIconToRight = QPixmap(":images/teacher_close.png"); + + // Create the GUI + mpContainerLayout = new QVBoxLayout(this); + setLayout(mpContainerLayout); + + mpContainer = new QWidget(this); + mpContainer->setObjectName("DockPaletteWidgetBox"); + mpContainerLayout->addWidget(mpContainer); + + mpLayout = new QVBoxLayout(mpContainer); + mpContainer->setLayout(mpLayout); + + // Title + mpTitleLabel = new QLabel(tr("Title"), mpContainer); + mpTitleLabel->setMinimumWidth(LABEL_MINWIDHT); + mpTitleLabel->setAlignment(Qt::AlignRight); + mpTitle = new QLineEdit(mpContainer); + mpTitle->setObjectName("DockPaletteWidgetLineEdit"); + mpTitleLayout = new QHBoxLayout(); + mpTitleLayout->addWidget(mpTitleLabel, 0); + mpTitleLayout->addWidget(mpTitle, 1); + mpLayout->addLayout(mpTitleLayout); + + // Phasis + mpPhasisLabel = new QLabel(tr("Phasis"), mpContainer); + mpPhasisLabel->setMinimumWidth(LABEL_MINWIDHT); + mpPhasisLabel->setAlignment(Qt::AlignRight); + mpPhasis = new QComboBox(mpContainer); + mpPhasis->setObjectName("DockPaletteWidgetComboBox"); + mpPhasisLayout = new QHBoxLayout(); + mpPhasisLayout->addWidget(mpPhasisLabel, 0); + mpPhasisLayout->addWidget(mpPhasis, 1); + mpLayout->addLayout(mpPhasisLayout); + + // Duration + mpDurationLabel = new QLabel(tr("Duration"), mpContainer); + mpDurationLabel->setMinimumWidth(LABEL_MINWIDHT); + mpDurationLabel->setAlignment(Qt::AlignRight); + mpDuration = new QComboBox(mpContainer); + mpDuration->setObjectName("DockPaletteWidgetComboBox"); + mpDurationLayout = new QHBoxLayout(); + mpDurationLayout->addWidget(mpDurationLabel, 0); + mpDurationLayout->addWidget(mpDuration, 1); + mpLayout->addLayout(mpDurationLayout); + + // Equipment + mpEquipmentLabel = new QLabel(tr("Equipment"), mpContainer); + mpEquipmentLabel->setMinimumWidth(LABEL_MINWIDHT); + mpEquipmentLabel->setAlignment(Qt::AlignRight); + mpEquipment = new QLineEdit(mpContainer); + mpEquipment->setObjectName("DockPaletteWidgetLineEdit"); + mpEquipmentLayout = new QHBoxLayout(); + mpEquipmentLayout->addWidget(mpEquipmentLabel, 0); + mpEquipmentLayout->addWidget(mpEquipment, 1); + mpLayout->addLayout(mpEquipmentLayout); + + // Activity + mpActivityLabel = new QLabel(tr("Activity"), mpContainer); + mpActivityLabel->setMinimumWidth(LABEL_MINWIDHT); + mpActivityLabel->setAlignment(Qt::AlignRight); + mpActivity = new QComboBox(mpContainer); + mpActivity->setObjectName("DockPaletteWidgetComboBox"); + mpActivityLayout = new QHBoxLayout(); + mpActivityLayout->addWidget(mpActivityLabel, 0); + mpActivityLayout->addWidget(mpActivity, 1); + mpLayout->addLayout(mpActivityLayout); + + // Actions + mpAction1 = new UBTeacherStudentAction(1, mpContainer); + mpAction2 = new UBTeacherStudentAction(2, mpContainer); + mpAction3 = new UBTeacherStudentAction(3, mpContainer); + + mpLayout->addWidget(mpAction1); + mpLayout->addWidget(mpAction2); + mpLayout->addWidget(mpAction3); + + populateCombos(); + + connect(UBApplication::boardController, SIGNAL(activeSceneWillChange()), this, SLOT(saveContent())); + connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContent())); + connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); + connect(mpPhasis, SIGNAL(currentIndexChanged(int)), this, SLOT(onValueChanged())); + connect(mpDuration, SIGNAL(currentIndexChanged(int)), this, SLOT(onValueChanged())); + connect(mpEquipment, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); + connect(mpActivity, SIGNAL(currentIndexChanged(int)), this, SLOT(onValueChanged())); + connect(mpAction1->teacher(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); + connect(mpAction1->student(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); + connect(mpAction2->teacher(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); + connect(mpAction2->student(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); + connect(mpAction3->teacher(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); + connect(mpAction3->student(), SIGNAL(textChanged()), this, SLOT(onValueChanged())); +} + +UBTeacherBarWidget::~UBTeacherBarWidget() +{ + if(NULL != mpAction3) + { + delete mpAction3; + mpAction3 = NULL; + } + if(NULL != mpAction2) + { + delete mpAction2; + mpAction2 = NULL; + } + if(NULL != mpAction1) + { + delete mpAction1; + mpAction1 = NULL; + } + if(NULL != mpActivityLabel) + { + delete mpActivityLabel; + mpActivityLabel = NULL; + } + if(NULL != mpActivity) + { + delete mpActivity; + mpActivity = NULL; + } + if(NULL != mpActivityLayout) + { + delete mpActivityLayout; + mpActivityLayout = NULL; + } + if(NULL != mpEquipmentLabel) + { + delete mpEquipmentLabel; + mpEquipmentLabel = NULL; + } + if(NULL != mpEquipment) + { + delete mpEquipment; + mpEquipment = NULL; + } + if(NULL != mpEquipmentLayout) + { + delete mpEquipmentLayout; + mpEquipmentLayout = NULL; + } + if(NULL != mpDurationLabel) + { + delete mpDurationLabel; + mpDurationLabel = NULL; + } + if(NULL != mpDuration) + { + delete mpDuration; + mpDuration = NULL; + } + if(NULL != mpDurationLayout) + { + delete mpDurationLayout; + mpDurationLayout = NULL; + } + if(NULL != mpPhasisLabel) + { + delete mpPhasisLabel; + mpPhasisLabel = NULL; + } + if(NULL != mpPhasisLayout) + { + delete mpPhasisLayout; + mpPhasisLayout = NULL; + } + if(NULL != mpTitleLabel) + { + delete mpTitleLabel; + mpTitleLabel = NULL; + } + if(NULL != mpTitle) + { + delete mpTitle; + mpTitle = NULL; + } + if(NULL != mpTitleLayout) + { + delete mpTitleLayout; + mpTitleLayout = NULL; + } + if(NULL != mpLayout) + { + delete mpLayout; + mpLayout = NULL; + } + if(NULL != mpContainer) + { + delete mpContainer; + mpContainer = NULL; + } + if(NULL != mpContainerLayout) + { + delete mpContainerLayout; + mpContainerLayout = NULL; + } +} + +void UBTeacherBarWidget::populateCombos() +{ + QStringList qslPhasis; + qslPhasis << tr("") << tr("I discover") << tr("I experiment") << tr("I train myself") << tr("I play") << tr("I memorize"); + mpPhasis->insertItems(0, qslPhasis); + mpPhasis->setCurrentIndex(0); + + QStringList qslDuration; + qslDuration << tr("") << tr("Short") << tr("Middle") << tr("Long"); + mpDuration->insertItems(0, qslDuration); + mpDuration->setCurrentIndex(0); + + QStringList qslActivity; + qslActivity << tr("") << tr("Alone") << tr("By Group") << tr("All together"); + mpActivity->insertItems(0, qslActivity); + mpActivity->setCurrentIndex(0); +} + +void UBTeacherBarWidget::saveContent() +{ + sTeacherBarInfos infos; + infos.title = mpTitle->text(); + infos.phasis = mpPhasis->currentIndex(); + infos.Duration = mpDuration->currentIndex(); + infos.material = mpEquipment->text(); + infos.activity = mpActivity->currentIndex(); + infos.action1Master = mpAction1->teacherText(); + infos.action1Student = mpAction1->studentText(); + infos.action2Master = mpAction2->teacherText(); + infos.action2Student = mpAction2->studentText(); + infos.action3Master = mpAction3->teacherText(); + infos.action3Student = mpAction3->studentText(); + UBPersistenceManager::persistenceManager()->persistTeacherBar(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex(), infos); +} + +void UBTeacherBarWidget::loadContent() +{ + sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(UBApplication::boardController->activeDocument(), UBApplication::boardController->activeSceneIndex()); + mpTitle->setText(nextInfos.title); + mpPhasis->setCurrentIndex(nextInfos.phasis); + mpDuration->setCurrentIndex(nextInfos.Duration); + mpEquipment->setText(nextInfos.material); + mpActivity->setCurrentIndex(nextInfos.activity); + mpAction1->setTeacherText(nextInfos.action1Master); + mpAction1->setStudentText(nextInfos.action1Student); + mpAction2->setTeacherText(nextInfos.action2Master); + mpAction2->setStudentText(nextInfos.action2Student); + mpAction3->setTeacherText(nextInfos.action3Master); + mpAction3->setStudentText(nextInfos.action3Student); +} + +void UBTeacherBarWidget::onValueChanged() +{ + if( mpTitle->text() == "" + && mpDuration->currentIndex() == 0 + && mpPhasis->currentIndex() == 0 + && mpEquipment->text() == "" + && mpActivity->currentIndex() == 0 + && mpAction1->teacherText() == "" + && mpAction1->studentText() == "" + && mpAction2->teacherText() == "" + && mpAction2->studentText() == "" + && mpAction3->teacherText() == "" + && mpAction3->studentText() == "") + { + mIconToLeft = QPixmap(":images/teacher_open_disabled.png"); + mIconToRight = QPixmap(":images/teacher_close_disabled.png"); + } + else + { + mIconToLeft = QPixmap(":images/teacher_open.png"); + mIconToRight = QPixmap(":images/teacher_close.png"); + } + + UBApplication::boardController->paletteManager()->refreshPalettes(); +} + +UBTeacherStudentAction::UBTeacherStudentAction(int actionNumber, QWidget *parent, const char *name):QWidget(parent) + , mpActionLabel(NULL) + , mpTeacherLabel(NULL) + , mpStudentLabel(NULL) + , mpTeacher(NULL) + , mpStudent(NULL) + , mpLayout(NULL) + , mpTeacherLayout(NULL) + , mpStudentLayout(NULL) +{ + setObjectName(name); + mActionNumber = actionNumber; + + setAttribute(Qt::WA_StyledBackground, true); + setStyleSheet(UBApplication::globalStyleSheet()); + + // Create the GUI + mpLayout = new QVBoxLayout(this); + setLayout(mpLayout); + + mpActionLabel = new QLabel(tr("Action %0").arg(mActionNumber), this); + mpLayout->addWidget(mpActionLabel, 0); + + mpTeacherLayout = new QHBoxLayout(); + mpTeacherLabel = new QLabel(tr("Teacher"), this); + mpTeacherLabel->setAlignment(Qt::AlignTop); + mpTeacher = new QTextEdit(this); + mpTeacher->setObjectName("TeacherStudentBox"); + mpTeacherLayout->addWidget(mpTeacherLabel, 0); + mpTeacherLayout->addWidget(mpTeacher, 1); + mpLayout->addLayout(mpTeacherLayout, 1); + + mpStudentLayout = new QHBoxLayout(); + mpStudentLabel = new QLabel(tr("Student"), this); + mpStudentLabel->setAlignment(Qt::AlignTop); + mpStudent = new QTextEdit(this); + mpStudent->setObjectName("TeacherStudentBox"); + mpStudentLayout->addWidget(mpStudentLabel, 0); + mpStudentLayout->addWidget(mpStudent, 1); + mpLayout->addLayout(mpStudentLayout, 1); +} + +UBTeacherStudentAction::~UBTeacherStudentAction() +{ + if(NULL != mpActionLabel) + { + delete mpActionLabel; + mpActionLabel = NULL; + } + if(NULL != mpTeacherLabel) + { + delete mpTeacherLabel; + mpTeacherLabel = NULL; + } + if(NULL != mpTeacher) + { + delete mpTeacher; + mpTeacher = NULL; + } + if(NULL != mpTeacherLayout) + { + delete mpTeacherLayout; + mpTeacherLayout = NULL; + } + if(NULL != mpStudentLabel) + { + delete mpStudentLabel; + mpStudentLabel = NULL; + } + if(NULL != mpStudent) + { + delete mpStudent; + mpStudent = NULL; + } + if(NULL != mpStudentLayout) + { + delete mpStudentLayout; + mpStudentLayout = NULL; + } + if(NULL != mpLayout) + { + delete mpLayout; + mpLayout = NULL; + } +} + +QString UBTeacherStudentAction::teacherText() +{ + return mpTeacher->document()->toPlainText(); +} + +QString UBTeacherStudentAction::studentText() +{ + return mpStudent->document()->toPlainText(); +} + +void UBTeacherStudentAction::setTeacherText(QString text) +{ + mpTeacher->setText(text); +} + +void UBTeacherStudentAction::setStudentText(QString text) +{ + mpStudent->setText(text); +} + +QTextEdit* UBTeacherStudentAction::teacher() +{ + return mpTeacher; +} + +QTextEdit* UBTeacherStudentAction::student() +{ + return mpStudent; +} diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h new file mode 100644 index 00000000..555b6ef6 --- /dev/null +++ b/src/gui/UBTeacherBarWidget.h @@ -0,0 +1,78 @@ +#ifndef UBTEACHERBARWIDGET_H +#define UBTEACHERBARWIDGET_H + +#include +#include +#include +#include +#include +#include +#include + +#include "UBDockPaletteWidget.h" + +#define LABEL_MINWIDHT 80 + +class UBTeacherStudentAction : public QWidget +{ +public: + UBTeacherStudentAction(int actionNumber, QWidget* parent=0, const char* name="UBTeacherStudentAction"); + ~UBTeacherStudentAction(); + QString teacherText(); + QString studentText(); + void setTeacherText(QString text); + void setStudentText(QString text); + QTextEdit* teacher(); + QTextEdit* student(); + +private: + int mActionNumber; + QLabel* mpActionLabel; + QLabel* mpTeacherLabel; + QLabel* mpStudentLabel; + QTextEdit* mpTeacher; + QTextEdit* mpStudent; + QVBoxLayout* mpLayout; + QHBoxLayout* mpTeacherLayout; + QHBoxLayout* mpStudentLayout; +}; + +class UBTeacherBarWidget : public UBDockPaletteWidget +{ + Q_OBJECT +public: + UBTeacherBarWidget(QWidget* parent=0, const char* name="UBTeacherBarWidget"); + ~UBTeacherBarWidget(); + +private slots: + void saveContent(); + void loadContent(); + void onValueChanged(); + +private: + void populateCombos(); + + QVBoxLayout* mpLayout; + QHBoxLayout* mpTitleLayout; + QHBoxLayout* mpPhasisLayout; + QHBoxLayout* mpDurationLayout; + QHBoxLayout* mpEquipmentLayout; + QHBoxLayout* mpActivityLayout; + QLabel* mpTitleLabel; + QLabel* mpPhasisLabel; + QLabel* mpDurationLabel; + QLabel* mpEquipmentLabel; + QLabel* mpActivityLabel; + QLineEdit* mpTitle; + QLineEdit* mpEquipment; + QComboBox* mpPhasis; + QComboBox* mpDuration; + QComboBox* mpActivity; + UBTeacherStudentAction* mpAction1; + UBTeacherStudentAction* mpAction2; + UBTeacherStudentAction* mpAction3; + QWidget* mpContainer; + QVBoxLayout* mpContainerLayout; +}; + +#endif // UBTEACHERBARWIDGET_H diff --git a/src/gui/gui.pri b/src/gui/gui.pri index 3dae376c..d7ad9d1e 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -42,7 +42,8 @@ HEADERS += src/gui/UBThumbnailView.h \ src/gui/UBPageNavigationWidget.h \ src/gui/UBLibWidget.h \ src/gui/UBMagnifer.h \ - src/gui/UBCachePropertiesWidget.h + src/gui/UBCachePropertiesWidget.h \ + src/gui/UBTeacherBarWidget.h SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBFloatingPalette.cpp \ @@ -87,7 +88,8 @@ SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBPageNavigationWidget.cpp \ src/gui/UBLibWidget.cpp \ src/gui/UBMagnifer.cpp \ - src/gui/UBCachePropertiesWidget.cpp + src/gui/UBCachePropertiesWidget.cpp \ + src/gui/UBTeacherBarWidget.cpp win32 { From 757e74d1270efc43ebed4af3ee60af809a62fa19 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 21 Oct 2011 10:21:38 +0200 Subject: [PATCH 5/5] imported Maxim changes to persist changes --- .../template/scripts/template2.js | 219 ++++++++------ .../template/scripts/template2.js | 257 +++++++++-------- .../spl-phrase.wgt/scripts/app.js | 260 +++++++++-------- .../spl-text.wgt/scripts/app2.js | 270 +++++++++--------- .../spl-word.wgt/scripts/spl-word.js | 170 ++++++----- 5 files changed, 640 insertions(+), 536 deletions(-) diff --git a/resources/library/sankoreInteractivities/ord-phrases.wgt/template/scripts/template2.js b/resources/library/sankoreInteractivities/ord-phrases.wgt/template/scripts/template2.js index 2ad61229..7e6e14a9 100644 --- a/resources/library/sankoreInteractivities/ord-phrases.wgt/template/scripts/template2.js +++ b/resources/library/sankoreInteractivities/ord-phrases.wgt/template/scripts/template2.js @@ -5,12 +5,12 @@ function startEditing() { - modeEdit(); + modeEdit(); } function stopEditing() { - modeView(); + modeView(); } function initialize() @@ -20,7 +20,7 @@ function initialize() function checkResponse() { - checkWord(); + checkWord(); } /* / END sankore api @@ -28,7 +28,16 @@ function checkResponse() -var sentence = "this is\nan example\nsentence"; +var sentence = ""; +var curSentence = ""; + +if(window.sankore){ + sentence = (sankore.preference("rightOrdPhrases", ""))?sankore.preference("rightOrdPhrases", ""):"this is\nan example\nsentence"; + curSentence = (sankore.preference("currentOrdPhrases", ""))?sankore.preference("currentOrdPhrases", ""):""; +} else { + sentence = "this is\nan example\nsentence"; +} + var doCheck = true; // array of dom elements @@ -47,10 +56,10 @@ var widget_padding = 100; function str_replace( w, b, s ){ - while( s.indexOf( w ) != -1 ){ - s = s.replace( w, b ); - } - return s; + while( s.indexOf( w ) != -1 ){ + s = s.replace( w, b ); + } + return s; } /* @@ -61,16 +70,16 @@ shuffles an array */ function shuffle( arr ) { - var pos, tmp; + var pos, tmp; - for( var i = 0; i < arr.length; i++ ) - { - pos = Math.round( Math.random() * ( arr.length - 1 ) ); - tmp = arr[pos]; - arr[pos] = arr[i]; - arr[i] = tmp; - } - return arr; + for( var i = 0; i < arr.length; i++ ) + { + pos = Math.round( Math.random() * ( arr.length - 1 ) ); + tmp = arr[pos]; + arr[pos] = arr[i]; + arr[i] = tmp; + } + return arr; } /* @@ -81,34 +90,34 @@ returns array of dom elements */ function createElements( sentence ) { - var el; - var elements = []; - var phrases = sentence.split( "\n" ); + var el; + var elements = []; + var phrases = sentence.split( "\n" ); - for( i in phrases ) - { - el = document.createElement( "div" ); - $( el ).addClass( "phrase" ).text( phrases[i] ); - elements.push( el ); - } - return elements; + for( i in phrases ) + { + el = document.createElement( "div" ); + $( el ).addClass( "phrase" ).text( phrases[i] ); + elements.push( el ); + } + return elements; } function checkSentence() { - if( !doCheck ) - return; + if( !doCheck ) + return; - var ph = []; - $( "#mp_word .phrase" ).each( function() - { - ph.push( $( this ).text() ); - }); + var ph = []; + $( "#mp_word .phrase" ).each( function() + { + ph.push( $( this ).text() ); + }); - if( ph.join( "\n" ) == str_replace( "\r", "", sentence ) ){ - $( "#mp_word .phrase" ).addClass( "right" ); - } + if( ph.join( "\n" ) == str_replace( "\r", "", sentence ) ){ + $( "#mp_word .phrase" ).addClass( "right" ); + } } /* @@ -119,49 +128,56 @@ turns the widget into the view mode */ function modeView() { - if( editMode ){ - sentence = str_replace( "\r", "", $( "#mp_word textarea" ).attr( "value" ) ); - var p = sentence.split( "\n" ); - var p2 = []; - var t; - for( var i in p ) - { - t = jQuery.trim( p[i] ); - if( t ) p2.push( t ); - } - sentence = p2.join( "\n" ); - } + if( editMode ){ + sentence = str_replace( "\r", "", $( "#mp_word textarea" ).attr( "value" ) ); + var p = sentence.split( "\n" ); + var p2 = []; + var t; + for( var i in p ) + { + t = jQuery.trim( p[i] ); + if( t ) p2.push( t ); + } + sentence = p2.join( "\n" ); + } - // if no sankore api, insert edit button - if( !isSankore ){ - $( "#mp_setup" ).empty().append( '' ); - $( "#mp_setup input:button" ).click( function(){ - modeEdit(); - }); - } + // if no sankore api, insert edit button + if( !isSankore ){ + $( "#mp_setup" ).empty().append( '' ); + $( "#mp_setup input:button" ).click( function(){ + modeEdit(); + }); + } - // clean the previous word - $( "#mp_word" ).empty(); + // clean the previous word + $( "#mp_word" ).empty(); - // create new set of elements - var phrases = shuffle( createElements( sentence ) ); - for( i in phrases ){ - $("#mp_word").append( phrases[i] ); - } + var phrases; + // create new set of elements + if(window.sankore && curSentence && !editMode) + phrases = createElements( curSentence ); + else + phrases = shuffle( createElements( sentence ) ); + + for( i in phrases ){ + $("#mp_word").append( phrases[i] ); + } - // in sankore api there would be a function to check - // the answer, so no update parameter would be needed - $( "#mp_word" ).sortable(); - if( !isSankore ){ - $( "#mp_word" ).sortable( { update: checkSentence } ); - } else - $( "#mp_word" ).sortable(); - - // adjustHeight - var aHeight = $( phrases[0] ).outerHeight( true ); + // in sankore api there would be a function to check + // the answer, so no update parameter would be needed + $( "#mp_word" ).sortable(); + if( !isSankore ){ + $( "#mp_word" ).sortable( { + update: checkSentence + } ); + } else + $( "#mp_word" ).sortable(); + + // adjustHeight + var aHeight = $( phrases[0] ).outerHeight( true ); - // apply new width - adjust( aHeight * phrases.length ); + // apply new width + adjust( aHeight * phrases.length ); } @@ -172,11 +188,13 @@ adjust width or height */ function adjust( height ) { - $( "#mp_word" ).animate( {height: height } ); - // if viewed as a widget, resize the window - if( !isBrowser ){ - window.resizeTo( widget.width, height + widget_padding ); - } + $( "#mp_word" ).animate( { + height: height + } ); + // if viewed as a widget, resize the window + if( !isBrowser ){ + window.resizeTo( widget.width, height + widget_padding ); + } } /* @@ -186,26 +204,39 @@ modeEdit */ function modeEdit() { - editMode = true; - // if no sankore api, insert ok button - if( !isSankore ) - { - $( "#mp_setup" ).empty().append( '' ); - $( "#mp_setup input:button" ).click( function(){ - modeView(); - }); - } - $( "#mp_word").css( "margin-left", 0 ).empty() - .append(''); - adjust( $( "#mp_word textarea" ).outerHeight() ); + editMode = true; + // if no sankore api, insert ok button + if( !isSankore ) + { + $( "#mp_setup" ).empty().append( '' ); + $( "#mp_setup input:button" ).click( function(){ + modeView(); + }); + } + $( "#mp_word").css( "margin-left", 0 ).empty() + .append(''); + adjust( $( "#mp_word textarea" ).outerHeight() ); } +$(window).mouseout(function(){ + if(window.sankore){ + var ph = []; + $( "#mp_word .phrase" ).each( function() + { + ph.push( $( this ).text() ); + }); + + sankore.setPreference("currentOrdPhrases", ph.join( "\n" )); + sankore.setPreference("rightOrdPhrases", sentence); + + } +}); $(document).ready(function() { - $("#ub-widget").append( '\ + $("#ub-widget").append( '\
\
\ '); - modeView(); + modeView(); }); \ No newline at end of file diff --git a/resources/library/sankoreInteractivities/ord-words.wgt/template/scripts/template2.js b/resources/library/sankoreInteractivities/ord-words.wgt/template/scripts/template2.js index 3ae3790e..bb06994c 100644 --- a/resources/library/sankoreInteractivities/ord-words.wgt/template/scripts/template2.js +++ b/resources/library/sankoreInteractivities/ord-words.wgt/template/scripts/template2.js @@ -5,12 +5,12 @@ function startEditing() { - modeEdit(); + modeEdit(); } function stopEditing() { - modeView(); + modeView(); } function initialize() @@ -20,7 +20,7 @@ function initialize() function checkResponse() { - checkWord(); + checkWord(); } /* / END sankore api @@ -28,7 +28,16 @@ function checkResponse() -var word = "a*long*,*long*time*ago*..."; +var word = ""; +var curWord = ""; + +if(window.sankore){ + word = (sankore.preference("rightOrdWords", ""))?sankore.preference("rightOrdWords", ""):"a*long*,*long*time*ago*..."; + curWord = (sankore.preference("currentOrdWords", ""))?sankore.preference("currentOrdWords", ""):""; +} else { + word = "a*long*,*long*time*ago*..."; +} + var img = "template/images/horse.png"; var doCheckWord = true; @@ -55,31 +64,31 @@ returns array of dom elements */ function createWordLetters( word ) { - var ch, el; - var letters = []; + var ch, el; + var letters = []; - if( word.indexOf( '*' ) != -1 ) - { - var tmp = word.split( '*' ); - for( i in tmp ) - { - ch = tmp[i]; - el = document.createElement( "div" ); - $(el).addClass( "letter" ).text( ch ); - letters.push( el ); - } - } - else - { - for( var i = 0; i < word.length; i++ ) - { - ch = word.charAt( i ); - el = document.createElement( "div" ); - $(el).addClass( "letter" ).text( ch ); - letters.push( el ); - } - } - return letters; + if( word.indexOf( '*' ) != -1 ) + { + var tmp = word.split( '*' ); + for( i in tmp ) + { + ch = tmp[i]; + el = document.createElement( "div" ); + $(el).addClass( "letter" ).text( ch ); + letters.push( el ); + } + } + else + { + for( var i = 0; i < word.length; i++ ) + { + ch = word.charAt( i ); + el = document.createElement( "div" ); + $(el).addClass( "letter" ).text( ch ); + letters.push( el ); + } + } + return letters; } @@ -92,22 +101,22 @@ if they are in the right order */ function checkWord() { - if( !doCheckWord ) - return; + if( !doCheckWord ) + return; - var str = ""; - $( "#mp_word .letter" ).each( function(){ - str += $(this).text(); - }); - var w = word; - while( w.indexOf( '*' ) != -1 ) - { - w = w.replace( '*', '' ); - } - if( str == w ){ - $( "#mp_word .letter" ).addClass( "right" ); - //message( "Right!" ); - } + var str = ""; + $( "#mp_word .letter" ).each( function(){ + str += $(this).text(); + }); + var w = word; + while( w.indexOf( '*' ) != -1 ) + { + w = w.replace( '*', '' ); + } + if( str == w ){ + $( "#mp_word .letter" ).addClass( "right" ); + //message( "Right!" ); + } } /* @@ -118,16 +127,16 @@ shuffles an array */ function shuffle( arr ) { - var pos, tmp; + var pos, tmp; - for( var i = 0; i < arr.length; i++ ) - { - pos = Math.round( Math.random() * ( arr.length - 1 ) ); - tmp = arr[pos]; - arr[pos] = arr[i]; - arr[i] = tmp; - } - return arr; + for( var i = 0; i < arr.length; i++ ) + { + pos = Math.round( Math.random() * ( arr.length - 1 ) ); + tmp = arr[pos]; + arr[pos] = arr[i]; + arr[i] = tmp; + } + return arr; } @@ -140,56 +149,63 @@ turns the widget into the view mode */ function modeView() { - if( editMode ){ - word = $( "#mp_word input:text" ).attr( "value" ); - } + if( editMode ){ + word = $( "#mp_word input:text" ).attr( "value" ); + } - // if no sankore api, insert edit button - if( !isSankore ){ - $( "#mp_setup" ).empty().append( '' ); - $( "#mp_setup input:button" ).click( function(){ - modeEdit(); - }); - } + // if no sankore api, insert edit button + if( !isSankore ){ + $( "#mp_setup" ).empty().append( '' ); + $( "#mp_setup input:button" ).click( function(){ + modeEdit(); + }); + } - // clean the previous word - $( "#mp_word" ).empty(); + // clean the previous word + $( "#mp_word" ).empty(); - // create new set of letters - var letters = shuffle( createWordLetters( word ) ); - for( i in letters ){ - $("#mp_word").append( letters[i] ); - } + // create new set of letters + var letters; + if(window.sankore && curWord && !editMode) + letters = createWordLetters( curWord ); + else + letters = shuffle( createWordLetters( word ) ); + + for( i in letters ){ + $("#mp_word").append( letters[i] ); + } - // in sankore api there would be a function to check - // the answer, so no update parameter would be needed - if( !isSankore ){ - $( "#mp_word" ).sortable( { update: checkWord } ); - } else $( "#mp_word" ).sortable(); - - // adjustWidth - var totalLettersWidth = 0; - for( i in letters ){ - var currentWidth = $( letters[i] ).outerWidth( true ); - totalLettersWidth += currentWidth; - } - totalLettersWidth += 1; - - var width = Math.max( - totalLettersWidth, - min_view_width - ); + // in sankore api there would be a function to check + // the answer, so no update parameter would be needed + if( !isSankore ){ + $( "#mp_word" ).sortable( { + update: checkWord + } ); + } else $( "#mp_word" ).sortable(); + + // adjustWidth + var totalLettersWidth = 0; + for( i in letters ){ + var currentWidth = $( letters[i] ).outerWidth( true ); + totalLettersWidth += currentWidth; + } + totalLettersWidth += 1; + + var width = Math.max( + totalLettersWidth, + min_view_width + ); - // shift the words to the right to center them - if( width > totalLettersWidth ){ - $( "#mp_word" ).css( "margin-left", Math.round( (width - totalLettersWidth)/2 ) ); - } - else{ - $( "#mp_word" ).css( "margin-left", 0 ); - } + // shift the words to the right to center them + if( width > totalLettersWidth ){ + $( "#mp_word" ).css( "margin-left", Math.round( (width - totalLettersWidth)/2 ) ); + } + else{ + $( "#mp_word" ).css( "margin-left", 0 ); + } - // apply new width - adjustWidth( width ); + // apply new width + adjustWidth( width ); } @@ -200,11 +216,13 @@ adjustWidth */ function adjustWidth( width ) { - $( "#ub-widget" ).animate( {width: width } ); - // if viewed as a widget, resize the window - if( !isBrowser ){ - window.resizeTo( width + widget_padding, widget.height ); - } + $( "#ub-widget" ).animate( { + width: width + } ); + // if viewed as a widget, resize the window + if( !isBrowser ){ + window.resizeTo( width + widget_padding, widget.height ); + } } /* @@ -214,25 +232,36 @@ modeEdit */ function modeEdit() { - editMode = true; - // if no sankore api, insert ok button - if( !isSankore ) - { - $( "#mp_setup" ).empty().append( '' ); - $( "#mp_setup input:button" ).click( function(){ - modeView(); - }); - } - $( "#mp_word").css( "margin-left", 0 ).empty().append(''); - adjustWidth( input_width ); + editMode = true; + // if no sankore api, insert ok button + if( !isSankore ) + { + $( "#mp_setup" ).empty().append( '' ); + $( "#mp_setup input:button" ).click( function(){ + modeView(); + }); + } + $( "#mp_word").css( "margin-left", 0 ).empty().append(''); + adjustWidth( input_width ); } +$(window).mouseout(function(){ + if(window.sankore){ + var str = ""; + $( "#mp_word .letter" ).each( function(){ + str += $(this).text(); + }); + + sankore.setPreference("currentOrdWords", str); + sankore.setPreference("rightOrdWords", word); + } +}); $(document).ready(function() { - $("#ub-widget").append( '\ + $("#ub-widget").append( '\
\
\ '); - modeView(); + modeView(); }); \ No newline at end of file diff --git a/resources/library/sankoreInteractivities/spl-phrase.wgt/scripts/app.js b/resources/library/sankoreInteractivities/spl-phrase.wgt/scripts/app.js index 871d5816..0bf5cbba 100644 --- a/resources/library/sankoreInteractivities/spl-phrase.wgt/scripts/app.js +++ b/resources/library/sankoreInteractivities/spl-phrase.wgt/scripts/app.js @@ -3,162 +3,178 @@ function createElements( phrase ) { - var s = ''; - for( var i = 0; i < phrase.length; i++ ) - { - ch = phrase.charAt( i ); - if( ch == " " ){ - ch = " "; - } + var s = ''; + for( var i = 0; i < phrase.length; i++ ) + { + ch = phrase.charAt( i ); + if( ch == " " ){ + ch = " "; + } - s += '
' + ch + '
' + - '
 
'; - } - return s; + s += '
' + ch + '
' + + '
 
'; + } + return s; } $(document).ready(function() { - var w = new wcontainer( "#ub-widget" ); + var w = new wcontainer( "#ub-widget" ); + var sentence = ""; + + if(window.sankore) + sentence = (sankore.preference("ordSplPhrases", ""))?sankore.preference("ordSplPhrases", ""):"this is a bunch of words which should be split apart"; + else + sentence = "this is a bunch of words which should be split apart"; + - w.maxWidth = 600; + w.maxWidth = 600; - w.setEditContent( '
' ); - w.setViewContent( '
.
' ); - w.setData( "dashWidth", w.elements.container.find( ".dash" ).outerWidth() ); - w.setViewContent( '
M
' ); - w.setData( "lineHeight", w.elements.container.find( ".dash" ).outerHeight() ); - w.setViewContent( "" ); + w.setEditContent( '
' ); + w.setViewContent( '
.
' ); + w.setData( "dashWidth", w.elements.container.find( ".dash" ).outerWidth() ); + w.setViewContent( '
M
' ); + w.setData( "lineHeight", w.elements.container.find( ".dash" ).outerHeight() ); + w.setViewContent( "" ); - // onViewMode - w.onViewMode = function() - { - // clean up the text - var phrase = w.elements.container.find( "textarea" ).val() - .replace( /\r/g, '' ).replace( /\n/g, ' ' ).replace( / /g, ' ' ).trim(); + // onViewMode + w.onViewMode = function() + { + // clean up the text + var phrase = w.elements.container.find( "textarea" ).val() + .replace( /\r/g, '' ).replace( /\n/g, ' ' ).replace( / /g, ' ' ).trim(); - // store the text - w.setData( "phrase", phrase ); + // store the text + w.setData( "phrase", phrase ); - // remove all dots (they are to be set during the exercise) - phrase = phrase.replace( / /g, '' ); + // remove all dots (they are to be set during the exercise) + phrase = phrase.replace( / /g, '' ); - // create the html - w.setViewContent( createElements( phrase ) ); + // create the html + w.setViewContent( createElements( phrase ) ); - // the behaviour - w.elements.containerView.find( ".letter" ) - .mouseover( function() - { - var el = $( this ).next(); + // the behaviour + w.elements.containerView.find( ".letter" ) + .mouseover( function() + { + var el = $( this ).next(); - // determine new hover class - var is_fixed = ( el.get( 0 ).className.indexOf( "fixed" ) != -1 ); - var hover_class = is_fixed? - "dash_hover_fixed" : "dash_hover"; + // determine new hover class + var is_fixed = ( el.get( 0 ).className.indexOf( "fixed" ) != -1 ); + var hover_class = is_fixed? + "dash_hover_fixed" : "dash_hover"; - // assign new hover class - el.addClass( hover_class ) - .data( "hc", hover_class ); - }) - .mouseout( function() - { - var el = $( this ).next(); - // remove current hover class - var hc = el.data( "hc" ); - el.removeClass( hc ); - }) - .click( function() - { - var el = $( this ).next(); + // assign new hover class + el.addClass( hover_class ) + .data( "hc", hover_class ); + }) + .mouseout( function() + { + var el = $( this ).next(); + // remove current hover class + var hc = el.data( "hc" ); + el.removeClass( hc ); + }) + .click( function() + { + var el = $( this ).next(); - // remove current hover class - $( this ).trigger( "mouseout" ); + // remove current hover class + $( this ).trigger( "mouseout" ); - // toggle fixed class - el.toggleClass( "fixed" ); + // toggle fixed class + el.toggleClass( "fixed" ); - // determine new hover class - // assign new hover class - $( this ).trigger( "mouseover" ); + // determine new hover class + // assign new hover class + $( this ).trigger( "mouseover" ); - w.checkAnswer(); - w.adjustSize(); - }); + w.checkAnswer(); + w.adjustSize(); + }); - w.checkAnswer(); - }; + w.checkAnswer(); + }; - // viewSize - w.viewSize = function() - { - var w = 0; - var h = 0; + // viewSize + w.viewSize = function() + { + var w = 0; + var h = 0; - var dh = winstance.getData( "lineHeight" ); - var dw = winstance.getData( "dashWidth" ); + var dh = winstance.getData( "lineHeight" ); + var dw = winstance.getData( "dashWidth" ); - winstance.elements.containerView.find( "div:visible" ).each( function() - { - w += $( this ).outerWidth(); - h = Math.max( h, $( this ).outerHeight( true ) ); - }); + winstance.elements.containerView.find( "div:visible" ).each( function() + { + w += $( this ).outerWidth(); + h = Math.max( h, $( this ).outerHeight( true ) ); + }); - var square = w*h; - h = Math.max( h, $( winstance.elements.containerView ).height() ); + var square = w*h; + h = Math.max( h, $( winstance.elements.containerView ).height() ); - if( winstance.maxWidth ) - { - w = Math.min( w, winstance.maxWidth ); - h = parseInt( square / w ); - } + if( winstance.maxWidth ) + { + w = Math.min( w, winstance.maxWidth ); + h = parseInt( square / w ); + } - return { w: w, h: h+dh }; - }; + return { + w: w, + h: h+dh + }; + }; - // editSize - w.editSize = function() - { - return { - w: winstance.elements.containerEdit.find( "textarea" ).parent().outerWidth( true ), - h: winstance.elements.containerEdit.find( "textarea" ).parent().outerHeight( true ), - }; - }; + // editSize + w.editSize = function() + { + return { + w: winstance.elements.containerEdit.find( "textarea" ).parent().outerWidth( true ), + h: winstance.elements.containerEdit.find( "textarea" ).parent().outerHeight( true ), + }; + }; - w.checkAnswer = function() - { - var phrase = ""; - var ch = ""; - this.elements.containerView.find( "div:visible" ).each( function() - { - if( this.className.indexOf( "fixed" ) != -1 ){ - phrase += ' '; - } - else if( this.className.indexOf( "dash" ) != -1 ){ - return; - } - else{ - ch = $( this ).html(); - phrase += ch; - } - }); + w.checkAnswer = function() + { + var phrase = ""; + var ch = ""; + this.elements.containerView.find( "div:visible" ).each( function() + { + if( this.className.indexOf( "fixed" ) != -1 ){ + phrase += ' '; + } + else if( this.className.indexOf( "dash" ) != -1 ){ + return; + } + else{ + ch = $( this ).html(); + phrase += ch; + } + }); - if( phrase == this.getData( "phrase" ) ){ - this.elements.containerView.addClass( "answerRight" ); - } - else{ - this.elements.containerView.removeClass( "answerRight" ); - } - }; + if( phrase == this.getData( "phrase" ) ){ + this.elements.containerView.addClass( "answerRight" ); + } + else{ + this.elements.containerView.removeClass( "answerRight" ); + } + }; - window.w = w; - window.winstance = w; + window.w = w; + window.winstance = w; - w.modeView(); + w.modeView(); + + $(window).mouseout(function(){ + if(window.sankore){ + sankore.setPreference("ordSplPhrases", w.getData("phrase")); + } + }); }); \ No newline at end of file diff --git a/resources/library/sankoreInteractivities/spl-text.wgt/scripts/app2.js b/resources/library/sankoreInteractivities/spl-text.wgt/scripts/app2.js index d1a40ae6..d357e7bc 100644 --- a/resources/library/sankoreInteractivities/spl-text.wgt/scripts/app2.js +++ b/resources/library/sankoreInteractivities/spl-text.wgt/scripts/app2.js @@ -3,168 +3,182 @@ function createElements( text ) { - var s = ''; + var s = ''; - var words = text.split( " " ); + var words = text.split( " " ); - for( var i = 0; i < words.length; i++ ) - { - if( i ){ - s += '
 
'; - } - s += '
' + words[i] + '
' + - '
.
'; - } + for( var i = 0; i < words.length; i++ ) + { + if( i ){ + s += '
 
'; + } + s += '
' + words[i] + '
' + + '
.
'; + } - return s; + return s; } $(document).ready(function() { - var w = new wcontainer( "#ub-widget" ); + var w = new wcontainer( "#ub-widget" ); + + var sentences = ""; + + if(window.sankore) + sentences = (sankore.preference("ordSplText", ""))?sankore.preference("ordSplText", ""):"hello, this is the first sentence. hi, this is the second sentence. hello again, this is the third sentence. good morning, this is the fifth sentence. hi, sorry, i\'m late, i\'m the fourth sentence."; + else + sentences = "hello, this is the first sentence. hi, this is the second sentence. hello again, this is the third sentence. good morning, this is the fifth sentence. hi, sorry, i\'m late, i\'m the fourth sentence."; + + w.maxWidth = 600; - w.maxWidth = 600; + w.setEditContent( '
' ); + w.setViewContent( '
.
' ); + w.setData( "dashWidth", w.elements.container.find( ".dash" ).outerWidth() ); + w.setViewContent( '
M
' ); + w.setData( "lineHeight", w.elements.container.find( ".dash" ).outerHeight() ); + w.setViewContent( "" ); - w.setEditContent( '
' ); - w.setViewContent( '
.
' ); - w.setData( "dashWidth", w.elements.container.find( ".dash" ).outerWidth() ); - w.setViewContent( '
M
' ); - w.setData( "lineHeight", w.elements.container.find( ".dash" ).outerHeight() ); - w.setViewContent( "" ); - - // onViewMode - w.onViewMode = function() - { - // clean up the text - var text = w.elements.container.find( "textarea" ).val() - .replace( /\r/g, '' ).replace( /\n/g, ' ' ).replace( / /g, ' ' ); + // onViewMode + w.onViewMode = function() + { + // clean up the text + var text = w.elements.container.find( "textarea" ).val() + .replace( /\r/g, '' ).replace( /\n/g, ' ' ).replace( / /g, ' ' ); - // store the text - w.setData( "text", text ); + // store the text + w.setData( "text", text ); - // remove all dots (they are to be set during the exercise) - text = text.replace( /\. /g, ' ' ).trim( ["."] ); + // remove all dots (they are to be set during the exercise) + text = text.replace( /\. /g, ' ' ).trim( ["."] ); - // create the html - w.setViewContent( createElements( text ) ); + // create the html + w.setViewContent( createElements( text ) ); - // the behaviour - w.elements.containerView.find( ".letter" ) - .mouseover( function() - { - var el = $( this ).next(); + // the behaviour + w.elements.containerView.find( ".letter" ) + .mouseover( function() + { + var el = $( this ).next(); - // determine new hover class - var is_fixed = ( el.get( 0 ).className.indexOf( "fixed" ) != -1 ); - var hover_class = is_fixed? - "dash_hover_fixed" : "dash_hover"; + // determine new hover class + var is_fixed = ( el.get( 0 ).className.indexOf( "fixed" ) != -1 ); + var hover_class = is_fixed? + "dash_hover_fixed" : "dash_hover"; - // assign new hover class - el.addClass( hover_class ) - .data( "hc", hover_class ); - }) - .mouseout( function() - { - var el = $( this ).next(); - // remove current hover class - var hc = el.data( "hc" ); - el.removeClass( hc ); - }) - .click( function() - { - var el = $( this ).next(); + // assign new hover class + el.addClass( hover_class ) + .data( "hc", hover_class ); + }) + .mouseout( function() + { + var el = $( this ).next(); + // remove current hover class + var hc = el.data( "hc" ); + el.removeClass( hc ); + }) + .click( function() + { + var el = $( this ).next(); - // remove current hover class - $( this ).trigger( "mouseout" ); + // remove current hover class + $( this ).trigger( "mouseout" ); - // toggle fixed class - el.toggleClass( "fixed" ); + // toggle fixed class + el.toggleClass( "fixed" ); - // determine new hover class - // assign new hover class - $( this ).trigger( "mouseover" ); + // determine new hover class + // assign new hover class + $( this ).trigger( "mouseover" ); - w.checkAnswer(); - w.adjustSize(); - }); + w.checkAnswer(); + w.adjustSize(); + }); - w.checkAnswer(); - }; + w.checkAnswer(); + }; - // viewSize - w.viewSize = function() - { - var w = 0; - var h = 0; + // viewSize + w.viewSize = function() + { + var w = 0; + var h = 0; - var dh = winstance.getData( "lineHeight" ); - var dw = winstance.getData( "dashWidth" ); + var dh = winstance.getData( "lineHeight" ); + var dw = winstance.getData( "dashWidth" ); - winstance.elements.containerView.find( "div:visible" ).each( function() - { - w += $( this ).outerWidth(); - h = Math.max( h, $( this ).outerHeight( true ) ); - }); + winstance.elements.containerView.find( "div:visible" ).each( function() + { + w += $( this ).outerWidth(); + h = Math.max( h, $( this ).outerHeight( true ) ); + }); - var square = w*h; - h = Math.max( h, $( winstance.elements.containerView ).height() ); + var square = w*h; + h = Math.max( h, $( winstance.elements.containerView ).height() ); - if( winstance.maxWidth ) - { - w = Math.min( w, winstance.maxWidth ); - h = parseInt( square / w ); - } + if( winstance.maxWidth ) + { + w = Math.min( w, winstance.maxWidth ); + h = parseInt( square / w ); + } - return { w: w, h: h+dh }; - }; + return { + w: w, + h: h+dh + }; + }; - // editSize - w.editSize = function() - { - return { - w: winstance.elements.containerEdit.find( "textarea" ).parent().outerWidth( true ), - h: winstance.elements.containerEdit.find( "textarea" ).parent().outerHeight( true ), - }; - }; + // editSize + w.editSize = function() + { + return { + w: winstance.elements.containerEdit.find( "textarea" ).parent().outerWidth( true ), + h: winstance.elements.containerEdit.find( "textarea" ).parent().outerHeight( true ), + }; + }; - w.checkAnswer = function() - { - var text = ""; - var ch = ""; - this.elements.containerView.find( "div:visible" ).each( function() - { - if( this.className.indexOf( "fixed" ) != -1 ){ - text += '.'; - } - else if( this.className.indexOf( "dash" ) != -1 ){ - return; - } - else{ - ch = $( this ).html(); - if( ch == " " ){ - ch = " "; - } - text += ch; - } - }); - - console.log( text ); + w.checkAnswer = function() + { + var text = ""; + var ch = ""; + this.elements.containerView.find( "div:visible" ).each( function() + { + if( this.className.indexOf( "fixed" ) != -1 ){ + text += '.'; + } + else if( this.className.indexOf( "dash" ) != -1 ){ + return; + } + else{ + ch = $( this ).html(); + if( ch == " " ){ + ch = " "; + } + text += ch; + } + }); - if( text == this.getData( "text" ) ){ - this.elements.containerView.addClass( "answerRight" ); - } - else{ - this.elements.containerView.removeClass( "answerRight" ); - } - }; + if( text == this.getData( "text" ) ){ + this.elements.containerView.addClass( "answerRight" ); + } + else{ + this.elements.containerView.removeClass( "answerRight" ); + } + }; - window.w = w; - window.winstance = w; + window.w = w; + window.winstance = w; - w.modeView(); + w.modeView(); + + $(window).mouseout(function(){ + if(window.sankore){ + sankore.setPreference("ordSplText", w.getData( "text" )); + } + }); }); \ No newline at end of file diff --git a/resources/library/sankoreInteractivities/spl-word.wgt/scripts/spl-word.js b/resources/library/sankoreInteractivities/spl-word.wgt/scripts/spl-word.js index b62ea90c..b4f49cd8 100644 --- a/resources/library/sankoreInteractivities/spl-word.wgt/scripts/spl-word.js +++ b/resources/library/sankoreInteractivities/spl-word.wgt/scripts/spl-word.js @@ -1,99 +1,113 @@ function createWord( word ) { - var s = ''; - for( var i = 0; i < word.length; i++ ) - { - ch = word.charAt( i ); - s += - '' + - '' + ch + '' + - (( i < word.length - 1 ) ? - '' : '' ) + - ''; - } - return s; + var s = ''; + for( var i = 0; i < word.length; i++ ) + { + ch = word.charAt( i ); + s += + '' + + '' + ch + '' + + (( i < word.length - 1 ) ? + '' : '' ) + + ''; + } + return s; } $(document).ready(function() { - var w = new wcontainer( "#ub-widget" ); + var w = new wcontainer( "#ub-widget" ); + var words = ""; + + if(window.sankore) + words = (sankore.preference("ordSplWords", ""))?sankore.preference("ordSplWords", ""):"so*phis*ti*ca*ted"; + else + words = "so*phis*ti*ca*ted"; + w.setEditContent( '
' ); + w.setViewContent( '' ); + w.setData( "dashWidth", w.elements.container.find( "span.dash" ).outerWidth() ); + w.setViewContent( "" ); - w.setEditContent( '
' ); - w.setViewContent( '' ); - w.setData( "dashWidth", w.elements.container.find( "span.dash" ).outerWidth() ); - w.setViewContent( "" ); - - // onViewMode - w.onViewMode = function() - { - var word = w.elements.container.find( "input" ).val().trim( ['*'] ); + // onViewMode + w.onViewMode = function() + { + var word = w.elements.container.find( "input" ).val().trim( ['*'] ); - w.setData( "word", word ); - word = word.replace( /\*/g, '' ); - w.setViewContent( createWord( word ) ); - w.elements.container.find( "span.upper" ).click( function(){ - $( this ).find( "span.dash" ).toggleClass( "fixed" ); - w.adjustSize(); - w.checkAnswer(); - }); - w.checkAnswer(); - }; + w.setData( "word", word ); + word = word.replace( /\*/g, '' ); + w.setViewContent( createWord( word ) ); + w.elements.container.find( "span.upper" ).click( function(){ + $( this ).find( "span.dash" ).toggleClass( "fixed" ); + w.adjustSize(); + w.checkAnswer(); + }); + w.checkAnswer(); + }; - // viewSize - w.viewSize = function() - { - var w = 0; - var h = 0; + // viewSize + w.viewSize = function() + { + var w = 0; + var h = 0; - winstance.elements.containerView.find( "span.upper span:visible" ).each( function() - { - w += $( this ).outerWidth(); - h = Math.max( h, $( this ).outerHeight() ); - }); - var dw = winstance.getData( "dashWidth" ); + winstance.elements.containerView.find( "span.upper span:visible" ).each( function() + { + w += $( this ).outerWidth(); + h = Math.max( h, $( this ).outerHeight() ); + }); + var dw = winstance.getData( "dashWidth" ); - return { w: w+dw, h: h }; - }; + return { + w: w+dw, + h: h + }; + }; - // editSize - w.editSize = function() - { - return { - w: winstance.elements.containerEdit.find( "input" ).outerWidth( true ), - h: winstance.elements.containerEdit.find( "input" ).outerHeight( true ), - }; - }; + // editSize + w.editSize = function() + { + return { + w: winstance.elements.containerEdit.find( "input" ).outerWidth( true ), + h: winstance.elements.containerEdit.find( "input" ).outerHeight( true ), + }; + }; - w.checkAnswer = function() - { - var word = ""; - this.elements.container.find( "span.upper span:visible" ).each( function() - { - if( this.className.indexOf( "fixed" ) != -1 ){ - word += '*'; - } - else if( this.className.indexOf( "dash" ) != -1 ){ - return; - } - else{ - word += $( this ).text(); - } - }); + w.checkAnswer = function() + { + var word = ""; + this.elements.container.find( "span.upper span:visible" ).each( function() + { + if( this.className.indexOf( "fixed" ) != -1 ){ + word += '*'; + } + else if( this.className.indexOf( "dash" ) != -1 ){ + return; + } + else{ + word += $( this ).text(); + } + }); - if( word == this.getData( "word" ) ){ - this.elements.container.addClass( "answerRight" ); - } - else{ - this.elements.container.removeClass( "answerRight" ); - } - }; + if( word == this.getData( "word" ) ){ + this.elements.container.addClass( "answerRight" ); + } + else{ + this.elements.container.removeClass( "answerRight" ); + } + }; - window.w = w; - window.winstance = w; + window.w = w; + window.winstance = w; - w.modeView(); + w.modeView(); + + $(window).mouseout(function(){ + if(window.sankore){ + sankore.setPreference("ordSplWords", w.getData("word")); + } + }); }); \ No newline at end of file