Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Claudio Valerio 13 years ago
commit c8a88bbb58
  1. 70
      src/customWidgets/UBActionableWidget.cpp
  2. 35
      src/customWidgets/UBActionableWidget.h
  3. 5
      src/customWidgets/UBMediaWidget.cpp
  4. 3
      src/customWidgets/UBMediaWidget.h
  5. 41
      src/customWidgets/UBWidgetList.cpp
  6. 7
      src/customWidgets/UBWidgetList.h
  7. 6
      src/customWidgets/customWidgets.pri
  8. 1
      src/globals/UBGlobals.h
  9. 70
      src/gui/UBTBPageEditWidget.cpp
  10. 22
      src/gui/UBTBPageEditWidget.h

@ -0,0 +1,70 @@
#include <QPainter>
#include <QDebug>
#include "UBActionableWidget.h"
UBActionableWidget::UBActionableWidget(QWidget *parent, const char *name):QWidget(parent)
, mShowActions(false)
{
setObjectName(name);
mActions.clear();
}
UBActionableWidget::~UBActionableWidget()
{
}
void UBActionableWidget::addAction(eAction act)
{
if(!mActions.contains(act)){
mActions << act;
}
}
void UBActionableWidget::removeAction(eAction act)
{
if(mActions.contains(act)){
mActions.remove(mActions.indexOf(act));
}
}
void UBActionableWidget::removeAllActions()
{
mActions.clear();
}
void UBActionableWidget::setActionsVisible(bool bVisible)
{
mShowActions = bVisible;
}
bool UBActionableWidget::shouldClose(QPoint p)
{
qDebug() << "Should close: " << p.x() << "," << p.y();
bool close = false;
if(mShowActions &&
p.x() >= 0 &&
p.x() <= ACTIONSIZE &&
p.y() >= 0 &&
p.y() <= ACTIONSIZE){
close = true;
}
return close;
}
void UBActionableWidget::paintEvent(QPaintEvent* ev)
{
if(mShowActions){
QPainter p(this);
if(mActions.contains(eAction_Close)){
p.drawPixmap(0, 0, 16, 16, QPixmap(":images/close.svg"));
}else if(mActions.contains(eAction_MoveUp)){
// Implement me later
}else if(mActions.contains(eAction_MoveDown)){
// Implement me later
}
}
}

@ -0,0 +1,35 @@
#ifndef UBACTIONABLEWIDGET_H
#define UBACTIONABLEWIDGET_H
#include <QWidget>
#include <QPaintEvent>
#define ACTIONSIZE 16
typedef enum{
eAction_Close,
eAction_MoveUp,
eAction_MoveDown
}eAction;
class UBActionableWidget : public QWidget
{
Q_OBJECT
public:
UBActionableWidget(QWidget* parent=0, const char* name="UBActionableWidget");
~UBActionableWidget();
void addAction(eAction act);
void removeAction(eAction act);
void removeAllActions();
void setActionsVisible(bool bVisible);
bool shouldClose(QPoint p);
protected:
void paintEvent(QPaintEvent* ev);
QVector<eAction> mActions;
private:
bool mShowActions;
};
#endif // UBACTIONABLEWIDGET_H

@ -22,7 +22,7 @@
* @param parent as the parent widget * @param parent as the parent widget
* @param name as the object name * @param name as the object name
*/ */
UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):QWidget(parent) UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):UBActionableWidget(parent, name)
, mpMediaObject(NULL) , mpMediaObject(NULL)
, mpVideoWidget(NULL) , mpVideoWidget(NULL)
, mpAudioOutput(NULL) , mpAudioOutput(NULL)
@ -35,11 +35,10 @@ UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name)
, mpMediaContainer(NULL) , mpMediaContainer(NULL)
, mpCover(NULL) , mpCover(NULL)
{ {
setObjectName(name);
setAttribute(Qt::WA_StyledBackground, true); setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet()); setStyleSheet(UBApplication::globalStyleSheet());
addAction(eAction_Close);
mType = type; mType = type;
setLayout(&mLayout); setLayout(&mLayout);

@ -27,6 +27,7 @@
#include <phonon/AudioOutput> #include <phonon/AudioOutput>
#include "interfaces/IResizeable.h" #include "interfaces/IResizeable.h"
#include "UBActionableWidget.h"
#define UBMEDIABUTTON_SIZE 32 #define UBMEDIABUTTON_SIZE 32
#define TICK_INTERVAL 1000 #define TICK_INTERVAL 1000
@ -58,7 +59,7 @@ private:
bool mPressed; bool mPressed;
}; };
class UBMediaWidget : public QWidget class UBMediaWidget : public UBActionableWidget
{ {
Q_OBJECT Q_OBJECT
public: public:

@ -1,5 +1,7 @@
#include <QDebug> #include <QDebug>
#include <QScrollBar> #include <QScrollBar>
#include <QApplication>
#include <QPainter>
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
#include "UBWidgetList.h" #include "UBWidgetList.h"
@ -136,8 +138,47 @@ void UBWidgetList::mousePressEvent(QMouseEvent *ev)
{ {
Q_UNUSED(ev); Q_UNUSED(ev);
if(mCanRemove){ if(mCanRemove){
QWidget* pWAt = widgetAt(ev->pos());
if(NULL != mpCurrentWidget){
if(pWAt == mpCurrentWidget){
QPoint p;
p.setX(ev->x());
p.setY(ev->y());
if(mpCurrentWidget->shouldClose(p)){
emit closeWidget(mpCurrentWidget);
return;
}
}else{
mpCurrentWidget->setActionsVisible(false);
}
}
mpCurrentWidget = dynamic_cast<UBActionableWidget*>(pWAt);
if(NULL != mpCurrentWidget){
mpCurrentWidget->setActionsVisible(true);
}
}
update();
}
QWidget* UBWidgetList::widgetAt(QPoint p)
{
QWidget* pW = NULL;
pW = childAt(p);
if(NULL != pW){
do{
if( "UBTeacherStudentAction" == pW->objectName() ||
"UBUrlWidget" == pW->objectName() ||
"UBTBMediaPicture" == pW->objectName() ||
"UBMediaWidget" == pW->objectName()){
return pW;
}else{
pW = pW->parentWidget();
}
}while(NULL != pW && this != pW);
} }
return pW;
} }
void UBWidgetList::updateSizes() void UBWidgetList::updateSizes()

@ -11,6 +11,7 @@
#include <QLabel> #include <QLabel>
#include "interfaces/IResizeable.h" #include "interfaces/IResizeable.h"
#include "customWidgets/UBActionableWidget.h"
typedef enum{ typedef enum{
eWidgetListOrientation_Vertical, eWidgetListOrientation_Vertical,
@ -40,6 +41,9 @@ public:
void setListElementSpacing(int margin) { mListElementsSpacing = margin; } void setListElementSpacing(int margin) { mListElementsSpacing = margin; }
int listElementsSpacing() {return mListElementsSpacing; } int listElementsSpacing() {return mListElementsSpacing; }
signals:
void closeWidget(QWidget* w);
protected: protected:
bool mCanRemove; bool mCanRemove;
@ -47,6 +51,7 @@ protected:
void mousePressEvent(QMouseEvent* ev); void mousePressEvent(QMouseEvent* ev);
private: private:
QWidget* widgetAt(QPoint p);
int scaleWidgets(QSize pSize); int scaleWidgets(QSize pSize);
void scaleContainer(QSize pSize, int updateValue); void scaleContainer(QSize pSize, int updateValue);
void updateView(QSize pSize); void updateView(QSize pSize);
@ -58,7 +63,7 @@ private:
int mListElementsSpacing; int mListElementsSpacing;
QMap<QWidget*, QSize> mWidgetInfo; QMap<QWidget*, QSize> mWidgetInfo;
QLabel* mpEmptyLabel; QLabel* mpEmptyLabel;
QWidget* mpCurrentWidget; UBActionableWidget* mpCurrentWidget;
}; };
#endif // UBWIDGETLIST_H #endif // UBWIDGETLIST_H

@ -3,9 +3,11 @@ HEADERS += src/customWidgets/UBWidgetList.h \
src/customWidgets/UBDraggableLabel.h \ src/customWidgets/UBDraggableLabel.h \
src/customWidgets/UBMediaWidget.h \ src/customWidgets/UBMediaWidget.h \
src/globals/UBGlobals.h \ src/globals/UBGlobals.h \
src/customWidgets/UBDraggableMedia.h src/customWidgets/UBDraggableMedia.h \
src/customWidgets/UBActionableWidget.h
SOURCES += src/customWidgets/UBWidgetList.cpp \ SOURCES += src/customWidgets/UBWidgetList.cpp \
src/customWidgets/UBDraggableLabel.cpp \ src/customWidgets/UBDraggableLabel.cpp \
src/customWidgets/UBMediaWidget.cpp \ src/customWidgets/UBMediaWidget.cpp \
src/customWidgets/UBDraggableMedia.cpp src/customWidgets/UBDraggableMedia.cpp \
src/customWidgets/UBActionableWidget.cpp

@ -33,6 +33,7 @@ _Pragma("GCC diagnostic ignored \"-Wsign-compare\"");
#ifdef NO_THIRD_PARTY_WARNINGS #ifdef NO_THIRD_PARTY_WARNINGS
//disabling some warnings //disabling some warnings
#define THIRD_PARTY_WARNINGS_DISABLE WARNINGS_DISABLE #define THIRD_PARTY_WARNINGS_DISABLE WARNINGS_DISABLE
#define THIRD_PARTY_WARNINGS_ENABLE WARNINGS_ENABLE #define THIRD_PARTY_WARNINGS_ENABLE WARNINGS_ENABLE
#else #else
// just save old state (needs for not empty define) // just save old state (needs for not empty define)

@ -100,6 +100,9 @@ UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *p
connect(mpDocumentEditbutton, SIGNAL(clicked()), this, SLOT(onDocumentEditClicked())); connect(mpDocumentEditbutton, SIGNAL(clicked()), this, SLOT(onDocumentEditClicked()));
connect(mpPagePreviewButton, SIGNAL(clicked()), this, SLOT(onPagePreviewClicked())); connect(mpPagePreviewButton, SIGNAL(clicked()), this, SLOT(onPagePreviewClicked()));
connect(mpMediaContainer, SIGNAL(mediaDropped(QString)), this, SLOT(onMediaDropped(QString))); connect(mpMediaContainer, SIGNAL(mediaDropped(QString)), this, SLOT(onMediaDropped(QString)));
connect(mpActions, SIGNAL(closeWidget(QWidget*)), this, SLOT(onCloseWidget(QWidget*)));
connect(mpLinks, SIGNAL(closeWidget(QWidget*)), this, SLOT(onCloseWidget(QWidget*)));
connect(mpMediaContainer, SIGNAL(closeWidget(QWidget*)), this, SLOT(onCloseWidget(QWidget*)));
} }
UBTBPageEditWidget::~UBTBPageEditWidget() UBTBPageEditWidget::~UBTBPageEditWidget()
@ -271,15 +274,36 @@ void UBTBPageEditWidget::clearFields()
mClearingFields = false; mClearingFields = false;
} }
void UBTBPageEditWidget::onCloseWidget(QWidget *w)
{
if(NULL != w){
if("UBTeacherStudentAction" == w->objectName()){
UBTeacherStudentAction* pW = dynamic_cast<UBTeacherStudentAction*>(w);
mpActions->removeWidget(pW);
mActions.remove(mActions.indexOf(pW));
DELETEPTR(w);
}else if("UBUrlWidget" == w->objectName()){
UBUrlWidget* pW = dynamic_cast<UBUrlWidget*>(w);
mpLinks->removeWidget(pW);
mUrls.remove(mUrls.indexOf(pW));
DELETEPTR(w);
}else if("UBTBMediaPicture" == w->objectName() || "UBMediaWidget" == w->objectName()){
mpMediaContainer->removeWidget(w);
mMedias.remove(mMedias.indexOf(w));
DELETEPTR(w);
}
}
}
// --------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------
UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):UBActionableWidget(parent, name)
, mpLayout(NULL) , mpLayout(NULL)
, mpUrlLabel(NULL) , mpUrlLabel(NULL)
, mpUrl(NULL) , mpUrl(NULL)
{ {
setObjectName(name);
setAttribute(Qt::WA_StyledBackground, true); setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet()); setStyleSheet(UBApplication::globalStyleSheet());
addAction(eAction_Close);
mpLayout = new QVBoxLayout(this); mpLayout = new QVBoxLayout(this);
setLayout(mpLayout); setLayout(mpLayout);
@ -435,12 +459,13 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url)
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(url); QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(url);
if(mimeType.contains("image")){ if(mimeType.contains("image")){
QPixmap pix = QPixmap(url); QPixmap pix = QPixmap(url);
QLabel* label = new QLabel(); UBPictureWidget* pic = new UBPictureWidget();
pix.scaledToWidth(label->width()); pix.scaledToWidth(pic->label()->width());
label->resize(pix.width(), pix.height()); pic->label()->resize(pix.width(), pix.height());
label->setPixmap(pix); pic->label()->setPixmap(pix);
label->setScaledContents(true); pic->label()->setScaledContents(true);
pW = label; pic->setObjectName("UBTBMediaPicture");
pW = pic;
} }
else if(mimeType.contains("video") || mimeType.contains("audio")){ else if(mimeType.contains("video") || mimeType.contains("audio")){
UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video);
@ -455,16 +480,15 @@ QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url)
return pW; return pW;
} }
UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):UBActionableWidget(parent, name)
, mpText(NULL) , mpText(NULL)
, mpLayout(NULL) , mpLayout(NULL)
, mpComboLayout(NULL) , mpComboLayout(NULL)
, mpCombo(NULL) , mpCombo(NULL)
{ {
setObjectName(name);
setAttribute(Qt::WA_StyledBackground, true); setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet()); setStyleSheet(UBApplication::globalStyleSheet());
addAction(eAction_Close);
// Create the GUI // Create the GUI
mpLayout = new QHBoxLayout(this); mpLayout = new QHBoxLayout(this);
@ -532,3 +556,27 @@ void UBTeacherStudentAction::setText(const QString& text)
} }
} }
// -------------------------------------------------------------
UBPictureWidget::UBPictureWidget(QWidget *parent, const char *name):UBActionableWidget(parent, name)
, mpLayout(NULL)
, mpLabel(NULL)
{
addAction(eAction_Close);
mpLayout = new QVBoxLayout(this);
setLayout(mpLayout);
mpLayout->setContentsMargins(10, 0, 10, 0);
mpLabel = new QLabel(this);
mpLayout->addWidget(mpLabel);
mpLabel->setGeometry( 10, 10, width()-2*10, height());
}
UBPictureWidget::~UBPictureWidget()
{
DELETEPTR(mpLabel);
DELETEPTR(mpLayout);
}
void UBPictureWidget::resizeEvent(QResizeEvent *ev)
{
mpLabel->setGeometry( 10, 10, width()-2*10, height());
}

@ -11,10 +11,11 @@
#include "core/UBPersistenceManager.h" #include "core/UBPersistenceManager.h"
#include "customWidgets/UBWidgetList.h" #include "customWidgets/UBWidgetList.h"
#include "customWidgets/UBActionableWidget.h"
#include "interfaces/IDropable.h" #include "interfaces/IDropable.h"
#include "UBTeacherBarDataMgr.h" #include "UBTeacherBarDataMgr.h"
class UBTeacherStudentAction : public QWidget class UBTeacherStudentAction : public UBActionableWidget
{ {
Q_OBJECT Q_OBJECT
@ -33,7 +34,7 @@ private:
QComboBox* mpCombo; QComboBox* mpCombo;
}; };
class UBUrlWidget : public QWidget class UBUrlWidget : public UBActionableWidget
{ {
public: public:
UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget"); UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget");
@ -56,6 +57,22 @@ private:
QLineEdit* mpTitle; QLineEdit* mpTitle;
}; };
class UBPictureWidget : public UBActionableWidget
{
public:
UBPictureWidget(QWidget* parent=0, const char* name="UBPictureWidget");
~UBPictureWidget();
QLabel* label(){return mpLabel;}
protected:
void resizeEvent(QResizeEvent* ev);
private:
QVBoxLayout* mpLayout;
QLabel* mpLabel;
};
class UBTBMediaContainer : public UBWidgetList class UBTBMediaContainer : public UBWidgetList
, public IDropable , public IDropable
{ {
@ -104,6 +121,7 @@ private slots:
void onMediaDropped(const QString& url); void onMediaDropped(const QString& url);
void onDocumentEditClicked(); void onDocumentEditClicked();
void onPagePreviewClicked(); void onPagePreviewClicked();
void onCloseWidget(QWidget* w);
private: private:
QVBoxLayout mLayout; QVBoxLayout mLayout;

Loading…
Cancel
Save