changed to have a correct the wrong resize behaviour

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent 5c0d14b7de
commit 453debb2a3
  1. 15
      src/customWidgets/UBWidgetList.cpp
  2. 44
      src/gui/UBTeacherBarWidget.cpp
  3. 5
      src/gui/UBTeacherBarWidget.h

@ -76,16 +76,23 @@ void UBWidgetList::updateSize(bool widgetAdded, QWidget *widget)
int newWidgetHeight;
if(eWidgetListOrientation_Vertical == mOrientation){
scaleFactor = (float)widget->width() / (float)mpContainer->width();
scaleFactor = (float)mpContainer->width() / (float)widget->width();
}else{
scaleFactor = (float)widget->height() / (float)mpContainer->height();
scaleFactor = (float)mpContainer->height() / (float)widget->height();
}
newWidgetWidth = widget->width()*scaleFactor;
newWidgetHeight = widget->height()*scaleFactor;
newWidgetWidth = (int)((float)widget->width()*scaleFactor);
newWidgetHeight = (int)((float)widget->height()*scaleFactor);
qDebug() << "container size " << mpContainer->size();
qDebug() << "widget size " << widget->size();
qDebug() << "scale factor " << scaleFactor;
widget->resize(newWidgetWidth, newWidgetHeight);
qDebug() << "widget new value " << newWidgetWidth << "x" << newWidgetHeight;
// Now we have to update the container
if(eWidgetListOrientation_Vertical == mOrientation){
if(widgetAdded){

@ -322,12 +322,16 @@ QTextEdit* UBTeacherStudentAction::student()
}
UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):UBWidgetList(parent)
UBTeacherBarDropMediaZone::UBTeacherBarDropMediaZone(QWidget *parent, const char *name):QWidget(parent)
{
setObjectName(name);
setAcceptDrops(true);
setEmptyText(tr("Drag media here ..."));
mWidget.setEmptyText(tr("Drag media here ..."));
mLayout.addWidget(&mWidget);
setLayout(&mLayout);
}
UBTeacherBarDropMediaZone::~UBTeacherBarDropMediaZone()
@ -348,20 +352,46 @@ void UBTeacherBarDropMediaZone::dragLeaveEvent(QDragLeaveEvent *pEvent)
void UBTeacherBarDropMediaZone::dropEvent(QDropEvent *pEvent)
{
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(pEvent->mimeData()->urls().at(0).toLocalFile());
QPixmap pixFromDropEvent;
QString mimeType;
QString resourcePath;
if(pEvent->mimeData()->hasText()){
qDebug() << "pEvent->mimeData()->hasText()" << pEvent->mimeData()->text();
resourcePath = pEvent->mimeData()->text();
}
else if(pEvent->mimeData()->hasUrls()){
qDebug() << "pEvent->mimeData()->hasUrls()" << pEvent->mimeData()->urls().at(0);
resourcePath = pEvent->mimeData()->urls().at(0).toLocalFile();
}
else if(pEvent->mimeData()->hasImage()){
qDebug() << "pEvent->mimeData()->hasImage()";
pixFromDropEvent.loadFromData(pEvent->mimeData()->imageData().toByteArray());
if(!pixFromDropEvent.isNull())
mimeType = "image";
}
if (mimeType.isEmpty() && resourcePath.isEmpty()){
pEvent->acceptProposedAction();
return;
}
mimeType = mimeType.isEmpty() ? UBFileSystemUtils::mimeTypeFromFileName(resourcePath) : mimeType;
if(mimeType.contains("image")){
QPixmap pix = QPixmap(pEvent->mimeData()->urls().at(0).toLocalFile());
qDebug() << pixFromDropEvent.size();
QPixmap pix = pixFromDropEvent.height() ? pixFromDropEvent : QPixmap(resourcePath);
QLabel* label = new QLabel();
label->setPixmap(pix);
//label->resize(size());
label->setScaledContents(true);
addWidget(label);
mWidget.addWidget(label);
mWidgetList << label;
}
else if(mimeType.contains("video") || mimeType.contains("audio")){
UBMediaPlayer* mediaPlayer = new UBMediaPlayer();
mediaPlayer->setFile(pEvent->mimeData()->urls().at(0).toLocalFile());
mediaPlayer->setFile(resourcePath);
//mediaPlayer->resize(size());
mediaPlayer->playPause();
addWidget(mediaPlayer);
mWidget.addWidget(mediaPlayer);
mWidgetList << mediaPlayer;
}
else{

@ -47,7 +47,7 @@ private:
};
class UBTeacherBarDropMediaZone : public UBWidgetList
class UBTeacherBarDropMediaZone : public QWidget
{
Q_OBJECT
@ -57,6 +57,9 @@ public:
private:
QList<QWidget*>mWidgetList;
UBWidgetList mWidget;
QVBoxLayout mLayout;
protected:
void dragEnterEvent(QDragEnterEvent* pEvent);

Loading…
Cancel
Save