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

preferencesAboutTextFull
Aleksei Kanash 13 years ago
commit 32cd8b9a85
  1. 1
      Sankore_3.1.pro
  2. 6
      release.linux.sh
  3. 1
      resources/library/interactivities/associer_images.wgt/js/script.js
  4. 3
      resources/library/interactivities/associer_sounds.wgt/js/script.js
  5. 3
      resources/library/interactivities/categoriser_images.wgt/js/script.js
  6. 3
      resources/library/interactivities/etudier.wgt/js/script.js
  7. 1
      resources/library/interactivities/ordonner_des_images.wgt/js/script.js
  8. 3
      resources/library/interactivities/ordonner_des_letters.wgt/js/script.js
  9. 3
      resources/library/interactivities/ordonner_des_lettres.wgt/js/script.js
  10. 1
      resources/library/interactivities/selectionner.wgt/js/script.js
  11. 32
      src/adaptors/UBSvgSubsetAdaptor.cpp
  12. 5
      src/api/UBWidgetUniboardAPI.cpp
  13. 10
      src/board/UBBoardController.cpp
  14. 10
      src/board/UBBoardView.cpp
  15. 13
      src/core/UBSettings.cpp
  16. 13
      src/core/UBSettings.h
  17. 65
      src/customWidgets/UBActionableWidget.cpp
  18. 45
      src/customWidgets/UBActionableWidget.h
  19. 39
      src/customWidgets/UBDraggableLabel.cpp
  20. 23
      src/customWidgets/UBDraggableLabel.h
  21. 42
      src/customWidgets/UBDraggableMedia.cpp
  22. 19
      src/customWidgets/UBDraggableMedia.h
  23. 335
      src/customWidgets/UBMediaWidget.cpp
  24. 127
      src/customWidgets/UBMediaWidget.h
  25. 229
      src/customWidgets/UBWidgetList.cpp
  26. 69
      src/customWidgets/UBWidgetList.h
  27. 13
      src/customWidgets/customWidgets.pri
  28. 30
      src/domain/UBGraphicsItemDelegate.cpp
  29. 1
      src/gui/UBDockPalette.cpp
  30. 2
      src/gui/UBDockPalette.h
  31. 47
      src/gui/UBLeftPalette.cpp
  32. 2
      src/gui/UBLeftPalette.h
  33. 1
      src/gui/UBNavigatorPalette.cpp
  34. 47
      src/gui/UBRightPalette.cpp
  35. 2
      src/gui/UBRightPalette.h

@ -52,7 +52,6 @@ include(src/tools/tools.pri)
include(src/desktop/desktop.pri)
include(src/web/web.pri)
include(src/transition/transition.pri)
include(src/customWidgets/customWidgets.pri)
include(src/interfaces/interfaces.pri)
DEPENDPATH += src/pdf-merger

@ -52,7 +52,7 @@ if [ ! -f $QT_GUI_TRANSLATIONS ]; then
exit 1
else
$LRELEASES $QT_GUI_TRANSLATIONS_PRO_FILE
elif
fi
VERSION=`cat build/linux/release/version`
if [ ! -f build/linux/release/version ]; then
@ -62,8 +62,8 @@ else
LAST_COMMITED_VERSION="`git describe $(git rev-list --tags --max-count=1)`"
if [ "v$VERSION" != "$LAST_COMMITED_VERSION" ]; then
echo creating a tag with the version $VERSION
git tag -a "v$VERSION" -m "Generating setup for v$VERSION"
git push origin --tags
# git tag -a "v$VERSION" -m "Generating setup for v$VERSION"
# git push origin --tags
fi
fi

@ -705,7 +705,6 @@ function onDropTarget(obj, event) {
}
textData = stringToXML(textData);
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent;
tmp = tmp.substr(1, tmp.length);
var tmp_img = $("<img/>").attr("src", tmp);
$(obj).append(tmp_img);
setTimeout(function(){

@ -811,7 +811,6 @@ function onDropAudio(obj, event) {
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
if(tmp_type.substr(0, 5) == "audio"){
var audio_block = $(obj).find(".audio_block");
tmp = tmp.substr(1, tmp.length);
$(obj).find("audio").remove();
audio_block.find(":first-child").removeClass("stop").addClass("play");
var source = $("<source/>").attr("src", tmp);
@ -839,4 +838,4 @@ if (window.widget) {
$(this).parent().find(":first-child").removeClass("stop").addClass("play");
});
}
}
}

@ -698,7 +698,6 @@ function onDropTarget(obj, event) {
textData = stringToXML(textData);
if(textData.getElementsByTagName("ready")[0].firstChild.textContent == "true"){
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent;
tmp = tmp.substr(1, tmp.length);
var img_block = $("<div class='img_block' style='text-align: center;'>");
$("<div class='close_img'>").appendTo(img_block);
$("<input type='hidden' value='" + $(obj).find("input[name='mask']").val() + "'/>").appendTo(img_block);
@ -743,4 +742,4 @@ function onDropTarget(obj, event) {
event.cancelBubble = true;
}
return false;
}
}

@ -529,7 +529,6 @@ function onDropTarget(obj, event) {
textData = stringToXML(textData);
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent;
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
tmp = tmp.substr(1, tmp.length);
if(tmp_type.substr(0, 5) == "audio"){
var audio_block = $("<div class='audio_block'>").draggable().appendTo($(obj));
audio_block.css("position","absolute").css("top",event.clientY).css("left",event.clientX);
@ -587,4 +586,4 @@ $(window).resize(function(){
$(this).width(slider.width()).height(slider.height());
});
slider.setSize(slider.width(), slider.height());
})
})

@ -444,7 +444,6 @@ function onDropTarget(obj, event) {
}
textData = stringToXML(textData);
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent;
tmp = tmp.substr(1, tmp.length);
var tmp_img = $("<img/>").attr("src", tmp);
$(obj).append(tmp_img);
setTimeout(function(){

@ -438,7 +438,6 @@ function onDropAudio(obj, event) {
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
if(tmp_type.substr(0, 5) == "audio"){
var audio_block = $(obj).find(".audio_block");
tmp = tmp.substr(1, tmp.length);
$(obj).find("audio").remove();
audio_block.find(":first-child").removeClass("stop").addClass("play");
var source = $("<source/>").attr("src", tmp);
@ -466,4 +465,4 @@ if (window.widget) {
$(this).parent().find(":first-child").removeClass("stop").addClass("play");
});
}
}
}

@ -438,7 +438,6 @@ function onDropAudio(obj, event) {
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
if(tmp_type.substr(0, 5) == "audio"){
var audio_block = $(obj).find(".audio_block");
tmp = tmp.substr(1, tmp.length);
$(obj).find("audio").remove();
audio_block.find(":first-child").removeClass("stop").addClass("play");
var source = $("<source/>").attr("src", tmp);
@ -466,4 +465,4 @@ if (window.widget) {
$(this).parent().find(":first-child").removeClass("stop").addClass("play");
});
}
}
}

@ -415,7 +415,6 @@ function onDropTarget(obj, event) {
textData = stringToXML(textData);
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent;
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
tmp = tmp.substr(1, tmp.length);
if(tmp_type.substr(0, 5) == "audio"){
var img_tmp = $("<div class='img_block'>").insertBefore($(obj).find(".add_img"));
var audio_block = $("<div class='audio_block'>").appendTo(img_tmp)

@ -2314,6 +2314,22 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
QStringRef ubFillOnDarkBackground = mXmlReader.attributes().value(mNamespaceUri, "fill-on-dark-background");
QStringRef ubFillOnLightBackground = mXmlReader.attributes().value(mNamespaceUri, "fill-on-light-background");
if (!ubFillOnDarkBackground.isNull()) {
QColor color;
color.setNamedColor(ubFillOnDarkBackground.toString());
if (!color.isValid())
color = Qt::white;
textItem->setColorOnDarkBackground(color);
}
if (!ubFillOnLightBackground.isNull()) {
QColor color;
color.setNamedColor(ubFillOnLightBackground.toString());
if (!color.isValid())
color = Qt::black;
textItem->setColorOnLightBackground(color);
}
QString text;
while (!(mXmlReader.isEndElement() && (mXmlReader.name() == "font" || mXmlReader.name() == "foreignObject")))
@ -2382,22 +2398,6 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
textItem->setDefaultTextColor(textColor);
}
if (!ubFillOnDarkBackground.isNull()) {
QColor color;
color.setNamedColor(ubFillOnDarkBackground.toString());
if (!color.isValid())
color = Qt::white;
textItem->setColorOnDarkBackground(color);
}
if (!ubFillOnLightBackground.isNull()) {
QColor color;
color.setNamedColor(ubFillOnLightBackground.toString());
if (!color.isValid())
color = Qt::black;
textItem->setColorOnLightBackground(color);
}
while (!(mXmlReader.isEndElement() && mXmlReader.name() == "font")) {
if (mXmlReader.hasError()) {
break;

@ -467,7 +467,10 @@ void UBWidgetUniboardAPI::sendFileMetadata(QString metaData)
void UBWidgetUniboardAPI::enableDropOnWidget(bool enable)
{
mGraphicsWidget->setAcceptDrops(enable);
if (mGraphicsWidget)
{
mGraphicsWidget->setAcceptDrops(enable);
}
}
void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)

@ -1959,8 +1959,12 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
if("" != url)
{
downloadURL(url, pPos);
return;
}
else
{
mActiveScene->addTextHtml(qsHtml, pPos);
}
return;
}
if (pMimeData->hasUrls())
@ -1996,11 +2000,11 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
if("" != pMimeData->text()){
// Sometimes, it is possible to have an URL as text. we check here if it is the case
QString qsTmp = pMimeData->text().remove(QRegExp("[\\0]"));
if(qsTmp.startsWith("http")){
if(qsTmp.startsWith("http://") || qsTmp.startsWith("https://")){
downloadURL(QUrl(qsTmp), pPos);
}
else{
mActiveScene->addTextHtml(pMimeData->html(), pPos);
mActiveScene->addTextHtml(pMimeData->text(), pPos);
}
}
else{

@ -49,9 +49,6 @@
#include "document/UBDocumentProxy.h"
#include "customWidgets/UBDraggableLabel.h"
#include "customWidgets/UBDraggableMedia.h"
#include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsCache.h"
#include "tools/UBGraphicsTriangle.h"
@ -813,14 +810,11 @@ void UBBoardView::dropEvent (QDropEvent *event)
UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos);
if (graphicsWidget && graphicsWidget->acceptDrops()) {
graphicsWidget->processDropEvent(event);
event->acceptProposedAction();
} else if (!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source())
|| dynamic_cast<QWebView*>(event->source()) || dynamic_cast<UBDraggableMediaPlayer *>(event->source())
|| dynamic_cast<UBDraggableLabel *>(event->source()) || dynamic_cast<UBDraggableMedia *>(event->source())) {
}
else if (!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source()) || dynamic_cast<QWebView*>(event->source())){
mController->processMimeData (event->mimeData (), mapToScene (event->pos ()));
event->acceptProposedAction();
}

@ -204,11 +204,14 @@ void UBSettings::init()
appEnableAutomaticSoftwareUpdates = new UBSetting(this, "App", "EnableAutomaticSoftwareUpdates", true);
appEnableSoftwareUpdates = new UBSetting(this, "App", "EnableSoftwareUpdates", true);
appToolBarOrientationVertical = new UBSetting(this, "App", "ToolBarOrientationVertical", false);
navigPaletteWidth = new UBSetting(this, "Board", "NavigPaletteWidth", 270);
rightLibPaletteWidth = new UBSetting(this, "Board", "RightLibPaletteWidth", 270);
rightLibPaletteIsCollapsed = new UBSetting(this,"Board", "RightLibPaletteIsCollapsed",false);
leftLibPaletteWidth = new UBSetting(this, "Board", "LeftLibPaletteWidth",270);
leftLibPaletteIsCollapsed = new UBSetting(this,"Board","LeftLibPaletteIsCollapsed",false);
rightLibPaletteBoardModeWidth = new UBSetting(this, "Board", "RightLibPaletteBoardModeWidth", 270);
rightLibPaletteBoardModeIsCollapsed = new UBSetting(this,"Board", "RightLibPaletteBoardModeIsCollapsed",false);
rightLibPaletteDesktopModeWidth = new UBSetting(this, "Board", "RightLibPaletteDesktopModeWidth", 270);
rightLibPaletteDesktopModeIsCollapsed = new UBSetting(this,"Board", "RightLibPaletteDesktopModeIsCollapsed",false);
leftLibPaletteBoardModeWidth = new UBSetting(this, "Board", "LeftLibPaletteBoardModeWidth",270);
leftLibPaletteBoardModeIsCollapsed = new UBSetting(this,"Board","LeftLibPaletteBoardModeIsCollapsed",false);
leftLibPaletteDesktopModeWidth = new UBSetting(this, "Board", "LeftLibPaletteDesktopModeWidth",270);
leftLibPaletteDesktopModeIsCollapsed = new UBSetting(this,"Board","LeftLibPaletteDesktopModeIsCollapsed",false);
appIsInSoftwareUpdateProcess = new UBSetting(this, "App", "IsInSoftwareUpdateProcess", false);
appLastSessionDocumentUUID = new UBSetting(this, "App", "LastSessionDocumentUUID", "");

@ -314,11 +314,14 @@ class UBSettings : public QObject
UBSetting* gipThumbnailWidth;
UBSetting* soundThumbnailWidth;
UBSetting* navigPaletteWidth;
UBSetting* rightLibPaletteWidth;
UBSetting* rightLibPaletteIsCollapsed;
UBSetting* leftLibPaletteWidth;
UBSetting* leftLibPaletteIsCollapsed;
UBSetting* rightLibPaletteBoardModeWidth;
UBSetting* rightLibPaletteBoardModeIsCollapsed;
UBSetting* rightLibPaletteDesktopModeWidth;
UBSetting* rightLibPaletteDesktopModeIsCollapsed;
UBSetting* leftLibPaletteBoardModeWidth;
UBSetting* leftLibPaletteBoardModeIsCollapsed;
UBSetting* leftLibPaletteDesktopModeWidth;
UBSetting* leftLibPaletteDesktopModeIsCollapsed;
UBSetting* communityUser;
UBSetting* communityPsw;

@ -1,65 +0,0 @@
#include <QPainter>
#include <QDebug>
#include "UBActionableWidget.h"
UBActionableWidget::UBActionableWidget(QWidget *parent, const char *name):QWidget(parent)
, mShowActions(false)
{
setObjectName(name);
mActions.clear();
mCloseButtons.setIcon(QIcon(QPixmap(":images/close.svg")));
mCloseButtons.setGeometry(0, 0, 2*ACTIONSIZE, ACTIONSIZE);
mCloseButtons.setVisible(false);
connect(&mCloseButtons, SIGNAL(clicked()), this, SLOT(onCloseClicked()));
}
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)
{
if(!mActions.empty() && mActions.contains(eAction_Close)){
mCloseButtons.setVisible(bVisible);
}
}
void UBActionableWidget::onCloseClicked()
{
emit close(this);
}
void UBActionableWidget::setActionsParent(QWidget *parent)
{
if(mActions.contains(eAction_Close)){
mCloseButtons.setParent(parent);
}
}
void UBActionableWidget::unsetActionsParent()
{
if(mActions.contains(eAction_Close)){
mCloseButtons.setParent(this);
}
}

@ -1,45 +0,0 @@
#ifndef UBACTIONABLEWIDGET_H
#define UBACTIONABLEWIDGET_H
#include <QWidget>
#include <QPaintEvent>
#include <QToolButton>
#include <QPushButton>
#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);
signals:
void close(QWidget* w);
protected:
void setActionsParent(QWidget* parent);
void unsetActionsParent();
QVector<eAction> mActions;
QPushButton mCloseButtons;
private slots:
void onCloseClicked();
private:
bool mShowActions;
};
#endif // UBACTIONABLEWIDGET_H

@ -1,39 +0,0 @@
#include <QMimeData>
#include <QDrag>
#include <QUrl>
#include "UBDraggableLabel.h"
UBDraggableLabel::UBDraggableLabel(QWidget *parent) :
QLabel(parent)
{
}
UBDraggableLabel::~UBDraggableLabel()
{
//NOOP
}
void UBDraggableLabel::loadImage(QString imagePath)
{
mSourcePath = imagePath;
QPixmap pix = QPixmap(mSourcePath);
setPixmap(pix);
setScaledContents(true);
}
void UBDraggableLabel::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event);
QMimeData *mimeData = new QMimeData;
QList<QUrl> urls;
urls << QUrl::fromLocalFile(mSourcePath);
mimeData->setUrls(urls);
mimeData->setText(mSourcePath);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->start();
}

@ -1,23 +0,0 @@
#ifndef UBDRAGGABLELABEL_H
#define UBDRAGGABLELABEL_H
#include <QLabel>
class UBDraggableLabel : public QLabel
{
Q_OBJECT
public:
UBDraggableLabel(QWidget *parent = 0);
~UBDraggableLabel();
void loadImage(QString imagePath);
signals:
public slots:
protected:
QString mSourcePath;
void mousePressEvent(QMouseEvent *event);
};
#endif // UBDRAGGABLELABEL_H

@ -1,42 +0,0 @@
#include <QApplication>
#include <QUrl>
#include "UBDraggableMedia.h"
UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name)
{
removeAllActions();
}
UBDraggableMedia::~UBDraggableMedia()
{
}
void UBDraggableMedia::mousePressEvent(QMouseEvent* ev)
{
if(Qt::LeftButton == ev->button()){
mDragStartPos = ev->pos();
}
}
void UBDraggableMedia::mouseMoveEvent(QMouseEvent* ev)
{
if(!(ev->buttons() & Qt::LeftButton)){
return;
}
if((ev->pos() - mDragStartPos).manhattanLength() < QApplication::startDragDistance()){
return;
}
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
QList<QUrl> urls;
urls << QUrl(mFilePath);
mimeData->setText(mFilePath);
mimeData->setUrls(urls);
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction | Qt::MoveAction);
}

@ -1,19 +0,0 @@
#ifndef UBDRAGGABLEMEDIA_H
#define UBDRAGGABLEMEDIA_H
#include "UBMediaWidget.h"
class UBDraggableMedia : public UBMediaWidget
{
public:
UBDraggableMedia(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBDraggableMedia");
~UBDraggableMedia();
protected:
void mousePressEvent(QMouseEvent* ev);
void mouseMoveEvent(QMouseEvent* ev);
private:
QPoint mDragStartPos;
};
#endif // UBDRAGGABLEMEDIA_H

@ -1,335 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "core/UBApplication.h"
#include "globals/UBGlobals.h"
#include "UBMediaWidget.h"
/**
* \brief Constructor
* @param type as the media type
* @param parent as the parent widget
* @param name as the object name
*/
UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):UBActionableWidget(parent, name)
, mpMediaObject(NULL)
, mpVideoWidget(NULL)
, mpAudioOutput(NULL)
, mpPlayStopButton(NULL)
, mpPauseButton(NULL)
, mpSlider(NULL)
, mAutoUpdate(false)
, mGeneratingThumbnail(false)
, mBorder(5)
, mpMediaContainer(NULL)
, mpCover(NULL)
{
setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet());
addAction(eAction_Close);
mType = type;
setLayout(&mLayout);
mpPlayStopButton = new UBMediaButton(this);
mpPlayStopButton->setPixmap(QPixmap(":images/play.svg"));
mpPauseButton = new UBMediaButton(this);
mpPauseButton->setPixmap(QPixmap(":images/pause.svg"));
mpPauseButton->setEnabled(false);
mpSlider = new QSlider(this);
mpSlider->setOrientation(Qt::Horizontal);
mpSlider->setMinimum(0);
mpSlider->setMaximum(0);
mSeekerLayout.addWidget(mpPlayStopButton, 0);
mSeekerLayout.addWidget(mpPauseButton, 0);
mSeekerLayout.addWidget(mpSlider, 1);
mSeekerLayout.setContentsMargins(0, 0, 0, 0);
connect(mpPlayStopButton, SIGNAL(clicked()), this, SLOT(onPlayStopClicked()));
connect(mpPauseButton, SIGNAL(clicked()), this, SLOT(onPauseClicked()));
connect(mpSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderChanged(int)));
}
/**
* \brief Destructor
*/
UBMediaWidget::~UBMediaWidget()
{
unsetActionsParent();
DELETEPTR(mpSlider);
DELETEPTR(mpPauseButton);
DELETEPTR(mpPlayStopButton);
DELETEPTR(mpAudioOutput);
DELETEPTR(mpVideoWidget);
DELETEPTR(mpMediaObject);
DELETEPTR(mpCover);
}
/**
* \brief Set the media file
* @param filePath as the media file path
*/
void UBMediaWidget::setFile(const QString &filePath)
{
Q_ASSERT("" != filePath);
mFilePath = filePath;
mpMediaObject = new Phonon::MediaObject(this);
mpMediaObject->setTickInterval(TICK_INTERVAL);
connect(mpMediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(onStateChanged(Phonon::State,Phonon::State)));
connect(mpMediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(onTotalTimeChanged(qint64)));
connect(mpMediaObject, SIGNAL(tick(qint64)), this, SLOT(onTick(qint64)));
mpMediaObject->setCurrentSource(Phonon::MediaSource(filePath));
createMediaPlayer();
}
/**
* \brief Get the media type
* @returns the media type
*/
eMediaType UBMediaWidget::mediaType()
{
return mType;
}
void UBMediaWidget::showEvent(QShowEvent* event)
{
if(!mpVideoWidget){
mpVideoWidget = new Phonon::VideoWidget(this);
mMediaLayout.addStretch(1);
mMediaLayout.addWidget(mpVideoWidget, 0);
mMediaLayout.addStretch(1);
Phonon::createPath(mpMediaObject, mpVideoWidget);
adaptSizeToVideo();
mpMediaObject->play();
mpMediaObject->stop();
}
QWidget::showEvent(event);
}
/**
* \brief Create the media player
*/
void UBMediaWidget::createMediaPlayer()
{
mpMediaContainer = new QWidget(this);
mpMediaContainer->setObjectName("UBMediaVideoContainer");
mpMediaContainer->setLayout(&mMediaLayout);
if(eMediaType_Video == mType){
mMediaLayout.setContentsMargins(10, 10, 25, 10);
if(isVisible()){
mpVideoWidget = new Phonon::VideoWidget(this);
mMediaLayout.addStretch(1);
mMediaLayout.addWidget(mpVideoWidget, 0);
mMediaLayout.addStretch(1);
Phonon::createPath(mpMediaObject, mpVideoWidget);
adaptSizeToVideo();
}
mpAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this);
Phonon::createPath(mpMediaObject, mpAudioOutput);
}else if(eMediaType_Audio == mType){
mMediaLayout.setContentsMargins(10, 10, 10, 10);
mpCover = new QLabel(mpMediaContainer);
mpMediaContainer->setStyleSheet(QString("background: none;"));
setAudioCover(":images/libpalette/soundIcon.svg");
mpCover->setScaledContents(true);
mMediaLayout.addStretch(1);
mMediaLayout.addWidget(mpCover, 0);
mMediaLayout.addStretch(1);
mpAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
Phonon::createPath(mpMediaObject, mpAudioOutput);
}
mLayout.addWidget(mpMediaContainer, 1);
mLayout.addLayout(&mSeekerLayout, 0);
setActionsParent(mpMediaContainer);
}
/**
* \brief Adapt the widget size to the video in order to keep the good aspect ratio
*/
void UBMediaWidget::adaptSizeToVideo()
{
if(NULL != mpMediaContainer){
int origW = mpMediaContainer->width();
int origH = mpMediaContainer->height();
int newW = width();
float scaleFactor = (float)origW/(float)newW;
int newH = origH/scaleFactor;
resize(newW, height() + newH);
}
}
/**
* \brief Handle the media state change notification
* @param newState as the new state
* @param oldState as the old state
*/
void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldState)
{
if(!mGeneratingThumbnail){
if(Phonon::LoadingState == oldState && Phonon::StoppedState == newState){
if(eMediaType_Video == mType){
// We do that here to generate the thumbnail of the video
mGeneratingThumbnail = true;
mpMediaObject->play();
mpMediaObject->pause();
mGeneratingThumbnail = false;
}
}else if(Phonon::PlayingState == oldState && Phonon::PausedState == newState){
mpPlayStopButton->setPixmap(QPixmap(":images/play.svg"));
mpPauseButton->setEnabled(false);
}else if((Phonon::PausedState == oldState && Phonon::PlayingState == newState) ||
(Phonon::StoppedState == oldState && Phonon::PlayingState == newState)){
mpPlayStopButton->setPixmap(QPixmap(":images/stop.svg"));
mpPauseButton->setEnabled(true);
}else if(Phonon::PlayingState == oldState && Phonon::StoppedState == newState){
mpPlayStopButton->setPixmap(QPixmap(":images/play.svg"));
mpPauseButton->setEnabled(false);
mpSlider->setValue(0);
}
}
}
/**
* \brief Handles the total time change notification
* @param total as the new total time
*/
void UBMediaWidget::onTotalTimeChanged(qint64 total)
{
mpSlider->setMaximum(total);
}
/**
* \brief Handles the tick notification
* @param currentTime as the current time
*/
void UBMediaWidget::onTick(qint64 currentTime)
{
mAutoUpdate = true;
mpSlider->setValue((int)currentTime);
mAutoUpdate = false;
}
/**
* \brief Handles the seeker value change notification
* @param value as the new seeker value
*/
void UBMediaWidget::onSliderChanged(int value)
{
if(!mAutoUpdate){
mpMediaObject->seek(value);
}
}
/**
* \brief Toggle Play-Stop
*/
void UBMediaWidget::onPlayStopClicked()
{
switch(mpMediaObject->state()){
case Phonon::PlayingState:
mpMediaObject->stop();
break;
case Phonon::StoppedState:
case Phonon::PausedState:
mpMediaObject->play();
break;
default:
break;
}
}
/**
* \brief Pause the media
*/
void UBMediaWidget::onPauseClicked()
{
mpMediaObject->pause();
}
/**
* Get the border
* @returns the actual border
*/
int UBMediaWidget::border()
{
return mBorder;
}
/**
* \brief Handles the resize event
* @param ev as the resize event
*/
void UBMediaWidget::resizeEvent(QResizeEvent* ev)
{
Q_UNUSED(ev);
}
/**
* \brief Set the audio cover
* @param coverPath as the cover image file path
*/
void UBMediaWidget::setAudioCover(const QString &coverPath)
{
if(NULL != mpCover){
mpCover->setPixmap(QPixmap(coverPath));
}
}
// -----------------------------------------------------------------------------------------------------------
/**
* \brief Constructor
* @param parent as the parent widget
* @param name as the object name
*/
UBMediaButton::UBMediaButton(QWidget *parent, const char *name):QLabel(parent)
, mPressed(false)
{
setObjectName(name);
resize(UBMEDIABUTTON_SIZE, UBMEDIABUTTON_SIZE);
setStyleSheet(QString("padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;"));
}
/**
* \brief Destructor
*/
UBMediaButton::~UBMediaButton()
{
}
/**
* \brief Handles the mouse press notification
* @param ev as the mouse press event
*/
void UBMediaButton::mousePressEvent(QMouseEvent* ev)
{
Q_UNUSED(ev);
mPressed = true;
}
/**
* \brief Handles the mouse release notification
* @param ev as the mouse release event
*/
void UBMediaButton::mouseReleaseEvent(QMouseEvent* ev)
{
Q_UNUSED(ev);
if(mPressed){
mPressed = false;
emit clicked();
}
}

@ -1,127 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBMEDIAWIDGET_H
#define UBMEDIAWIDGET_H
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QSlider>
#include <QMouseEvent>
#include <phonon/MediaObject>
#include <phonon/VideoWidget>
#include <phonon/AudioOutput>
#include "interfaces/IResizeable.h"
#include "UBActionableWidget.h"
#define UBMEDIABUTTON_SIZE 32
#define TICK_INTERVAL 1000
/**
* \brief The media type
*/
typedef enum{
eMediaType_Video,
eMediaType_Audio
}eMediaType;
class UBMediaButton : public QLabel
{
Q_OBJECT
public:
UBMediaButton(QWidget* parent=0, const char* name="UBMediaButton");
~UBMediaButton();
signals:
void clicked();
protected:
void mousePressEvent(QMouseEvent* ev);
void mouseReleaseEvent(QMouseEvent* ev);
private:
/** And indicator of the press event in progress */
bool mPressed;
};
class UBMediaWidget : public UBActionableWidget
{
Q_OBJECT
public:
UBMediaWidget(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBMediaWidget");
~UBMediaWidget();
void setFile(const QString& filePath);
eMediaType mediaType();
int border();
void setAudioCover(const QString& coverPath);
void setUrl(const QString& url){mUrl = url;}
QString url(){return mUrl;}
protected:
void resizeEvent(QResizeEvent* ev);
void showEvent(QShowEvent* event);
/** The current media file path */
QString mFilePath;
private slots:
void onPlayStopClicked();
void onPauseClicked();
void onStateChanged(Phonon::State newState, Phonon::State oldState);
void onTotalTimeChanged(qint64 total);
void onTick(qint64 currentTime);
void onSliderChanged(int value);
private:
void createMediaPlayer();
void adaptSizeToVideo();
/** The current media type */
eMediaType mType;
/** The media object */
Phonon::MediaObject* mpMediaObject;
/** The video renderer */
Phonon::VideoWidget* mpVideoWidget;
/** The audio renderer */
Phonon::AudioOutput* mpAudioOutput;
/** The principal layout of this widget */
QVBoxLayout mLayout;
/** The seeker layout */
QHBoxLayout mSeekerLayout;
/** The play-stop button */
UBMediaButton* mpPlayStopButton;
/** The pause button */
UBMediaButton* mpPauseButton;
/** The seeker slider */
QSlider* mpSlider;
/** An indicator of the seeker auto update in progress */
bool mAutoUpdate;
/** An indicator of the thumbnail generation in progress */
bool mGeneratingThumbnail;
/** The border */
int mBorder;
/** A widget that will contain the media */
QWidget* mpMediaContainer;
/** The media layout */
QHBoxLayout mMediaLayout;
/** The audio cover */
QLabel* mpCover;
/** The media url */
QString mUrl;
};
#endif // UBMEDIAWIDGET_H

@ -1,229 +0,0 @@
#include <QDebug>
#include <QScrollBar>
#include <QApplication>
#include <QPainter>
#include "globals/UBGlobals.h"
#include "UBWidgetList.h"
UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, const char* name):QScrollArea(parent)
, mCanRemove(true)
, mpLayout(NULL)
, mpContainer(NULL)
, mMargin(10)
, mListElementsSpacing(10)
, mpEmptyLabel(NULL)
, mpCurrentWidget(NULL)
{
setObjectName(name);
mOrientation = orientation;
mpContainer = new QWidget(this);
mpEmptyLabel = new QLabel(this);
mpEmptyLabel->setObjectName("emptyString");
mpEmptyLabel->setWordWrap(true);
mpEmptyLabel->setAlignment(Qt::AlignCenter);
if(eWidgetListOrientation_Vertical == orientation){
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mpLayout = new QVBoxLayout(mpContainer);
}
else{
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mpLayout = new QHBoxLayout(mpContainer);
}
mpLayout->setContentsMargins(margin(), margin(), margin(), margin());
mpContainer->setLayout(mpLayout);
setWidget(mpContainer);
}
UBWidgetList::~UBWidgetList()
{
DELETEPTR(mpEmptyLabel);
DELETEPTR(mpLayout);
DELETEPTR(mpContainer);
}
void UBWidgetList::addWidget(QWidget *widget)
{
if(NULL != mpLayout && NULL != widget){
widget->setParent(mpContainer);
mpEmptyLabel->setVisible(false);
mWidgetInfo[widget] = widget->size();
updateView(size());
mpLayout->addWidget(widget);
// This call is used only to refresh the size of the widgets
updateSizes();
}
}
void UBWidgetList::removeWidget(QWidget *widget)
{
if(NULL != mpLayout && NULL != widget){
mpLayout->removeWidget(widget);
mWidgetInfo.remove(widget);
widget->setVisible(false);
updateView(size());
if(0 == mpLayout->count()){
mpEmptyLabel->setVisible(true);
}
if(mpCurrentWidget == widget){
mpCurrentWidget = NULL;
}
}
}
int UBWidgetList::scaleWidgets(QSize pSize)
{
// to remove the first spacing that shouldn't be there.
int result = -mListElementsSpacing;
foreach(QWidget* eachWidget, mWidgetInfo.keys()){
qreal scaleFactor = 0;
int newWidgetWidth = pSize.width();
int newWidgetHeight = pSize.height();
if(eWidgetListOrientation_Vertical == mOrientation){
scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width();
newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor;
result += newWidgetHeight;
eachWidget->setMinimumHeight(newWidgetHeight- 1);
eachWidget->setMaximumHeight(newWidgetHeight);
}
else{
scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height();
newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor;
result += newWidgetWidth;
eachWidget->setMinimumWidth(newWidgetWidth - 1);
eachWidget->setMaximumWidth(newWidgetWidth);
}
//Adding a vertical/horizontal space between each element of the list
result += mListElementsSpacing;
}
return result;
}
void UBWidgetList::scaleContainer(QSize pSize, int updateValue)
{
if(eWidgetListOrientation_Vertical == mOrientation)
mpContainer->resize(pSize.width(), updateValue);
else
mpContainer->resize(updateValue, pSize.height());
}
void UBWidgetList::updateView(QSize pSize)
{
// Widgets on list are resized automatically to fit the mpcontainer.
// so if you want to keep the aspect ratio you have to calculate
// the sum of the new widget height and give it to the mpContainer.
// The container resize will trig the widgets resize and the good
// height permits to respect the aspect ratio.
int updatedValue = scaleWidgets(pSize);
scaleContainer(pSize,updatedValue);
}
void UBWidgetList::resizeEvent(QResizeEvent *ev)
{
Q_UNUSED(ev);
mpEmptyLabel->setGeometry((width() - mpEmptyLabel->width()) / 2,
(height() - mpEmptyLabel->height()) /2,
mpEmptyLabel->width(),
mpEmptyLabel->height());
updateView(size());
updateSizes();
}
void UBWidgetList::mousePressEvent(QMouseEvent *ev)
{
Q_UNUSED(ev);
if(mCanRemove){
QWidget* pWAt = widgetAt(ev->pos());
if(NULL != mpCurrentWidget){
if(pWAt != mpCurrentWidget){
mpCurrentWidget->setActionsVisible(false);
update();
}
}
mpCurrentWidget = dynamic_cast<UBActionableWidget*>(pWAt);
if(NULL != mpCurrentWidget){
mpCurrentWidget->setActionsVisible(true);
update();
}
}
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()
{
// Resize all the widgets
foreach(QWidget* eachWidget, mWidgetInfo.keys()){
if(NULL != eachWidget){
QSize originalSize = mWidgetInfo[eachWidget];
int currentWidth = mpContainer->width();
int currentHeight = mpContainer->height();
if(eWidgetListOrientation_Vertical == mOrientation){
if(verticalScrollBar()->isVisible()){
currentWidth -= verticalScrollBar()->width();
eachWidget->setStyleSheet(QString("margin-right:%0;").arg(verticalScrollBar()->width()));
}
float scaleFactor = (float)currentWidth/(float)originalSize.width();
currentHeight = originalSize.height()*scaleFactor;
}else{
if(horizontalScrollBar()->isVisible()){
currentHeight -= horizontalScrollBar()->height();
eachWidget->setStyleSheet(QString("padding-bottom:%0;").arg(horizontalScrollBar()->height()));
}
float scaleFactor = (float)currentHeight/(float)originalSize.height();
currentWidth = originalSize.width()*scaleFactor;
}
eachWidget->resize(currentWidth, currentHeight);
}
}
}
void UBWidgetList::setMargin(int margin)
{
mMargin = margin;
}
int UBWidgetList::margin()
{
return mMargin;
}
void UBWidgetList::setEmptyText(const QString &text)
{
if(NULL != mpEmptyLabel){
mpEmptyLabel->setText(text);
}
}
bool UBWidgetList::empty()
{
return mWidgetInfo.empty();
}

@ -1,69 +0,0 @@
#ifndef UBWIDGETLIST_H
#define UBWIDGETLIST_H
#include <QWidget>
#include <QScrollArea>
#include <QBoxLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QResizeEvent>
#include <QVector>
#include <QLabel>
#include "interfaces/IResizeable.h"
#include "customWidgets/UBActionableWidget.h"
typedef enum{
eWidgetListOrientation_Vertical,
eWidgetListOrientation_Horizontal
}eWidgetListOrientation;
class UBWidgetList : public QScrollArea
{
Q_OBJECT
typedef struct
{
QSize size;
bool isResizable;
} sWidgetProperties;
public:
UBWidgetList(QWidget* parent=0, eWidgetListOrientation orientation = eWidgetListOrientation_Vertical, const char* name = "UBWidgetList");
~UBWidgetList();
void addWidget(QWidget* widget);
void removeWidget(QWidget* widget);
void setMargin(int margin);
void setEmptyText(const QString& text);
int margin();
bool empty();
void setListElementSpacing(int margin) { mListElementsSpacing = margin; }
int listElementsSpacing() {return mListElementsSpacing; }
signals:
void closeWidget(QWidget* w);
protected:
bool mCanRemove;
void resizeEvent(QResizeEvent* ev);
void mousePressEvent(QMouseEvent* ev);
private:
QWidget* widgetAt(QPoint p);
int scaleWidgets(QSize pSize);
void scaleContainer(QSize pSize, int updateValue);
void updateView(QSize pSize);
void updateSizes();
QBoxLayout* mpLayout;
QWidget* mpContainer;
eWidgetListOrientation mOrientation;
int mMargin;
int mListElementsSpacing;
QMap<QWidget*, QSize> mWidgetInfo;
QLabel* mpEmptyLabel;
UBActionableWidget* mpCurrentWidget;
};
#endif // UBWIDGETLIST_H

@ -1,13 +0,0 @@
HEADERS += src/customWidgets/UBWidgetList.h \
src/customWidgets/UBDraggableLabel.h \
src/customWidgets/UBMediaWidget.h \
src/globals/UBGlobals.h \
src/customWidgets/UBDraggableMedia.h \
src/customWidgets/UBActionableWidget.h
SOURCES += src/customWidgets/UBWidgetList.cpp \
src/customWidgets/UBDraggableLabel.cpp \
src/customWidgets/UBMediaWidget.cpp \
src/customWidgets/UBDraggableMedia.cpp \
src/customWidgets/UBActionableWidget.cpp

@ -181,27 +181,31 @@ void UBGraphicsItemDelegate::setMimeData(QMimeData *mimeData)
bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if((NULL != mMimeData) && ((event->pos() - mDragStartPosition).manhattanLength() < QApplication::startDragDistance()))
{
QDrag* mDrag = new QDrag(event->widget());
mDrag->setMimeData(mMimeData);
if (!mDragPixmap.isNull()) {
mDrag->setPixmap(mDragPixmap);
mDrag->setHotSpot(mDragPixmap.rect().center());
}
mDrag->exec();
mDragPixmap = QPixmap();
return true;
if(mMimeData)
{
QDrag* mDrag = new QDrag(event->widget());
mDrag->setMimeData(mMimeData);
if (!mDragPixmap.isNull()) {
mDrag->setPixmap(mDragPixmap);
mDrag->setHotSpot(mDragPixmap.rect().center());
}
mDrag->exec();
mDragPixmap = QPixmap();
return true;
}
if(isLocked())
{
event->accept();
return true;
}
else
{
return false;
}
return true;
}
bool UBGraphicsItemDelegate::weelEvent(QGraphicsSceneWheelEvent *event)

@ -531,6 +531,7 @@ void UBDockPalette::setVisible(bool visible)
bool UBDockPalette::switchMode(eUBDockPaletteWidgetMode mode)
{
mCurrentMode = mode;
bool hasVisibleElements = false;
//-------------------------------//
// get full palette widgets list, parse it, show all widgets for BOARD mode, and hide all other

@ -115,6 +115,8 @@ public:
bool switchMode(eUBDockPaletteWidgetMode mode);
eUBDockPaletteWidgetMode mCurrentMode;
QVector<UBDockPaletteWidget*> GetWidgetsList() { return mRegisteredWidgets; }
public:

@ -25,11 +25,19 @@ UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name):
{
setObjectName(name);
setOrientation(eUBDockOrientation_Left);
mLastWidth = UBSettings::settings()->leftLibPaletteWidth->get().toInt();
mCollapseWidth = 150;
if(UBSettings::settings()->leftLibPaletteIsCollapsed->get().toBool())
bool isCollapsed = false;
if(mCurrentMode == eUBDockPaletteWidget_BOARD){
mLastWidth = UBSettings::settings()->leftLibPaletteBoardModeWidth->get().toInt();
isCollapsed = UBSettings::settings()->leftLibPaletteBoardModeIsCollapsed->get().toBool();
}
else{
mLastWidth = UBSettings::settings()->leftLibPaletteDesktopModeWidth->get().toInt();
isCollapsed = UBSettings::settings()->leftLibPaletteDesktopModeIsCollapsed->get().toBool();
}
if(isCollapsed)
resize(0,parentWidget()->height());
else
resize(mLastWidth, parentWidget()->height());
@ -58,8 +66,35 @@ void UBLeftPalette::updateMaxWidth()
void UBLeftPalette::resizeEvent(QResizeEvent *event)
{
int newWidth = width();
if(newWidth > mCollapseWidth)
UBSettings::settings()->leftLibPaletteWidth->set(newWidth);
UBSettings::settings()->leftLibPaletteIsCollapsed->set(newWidth == 0);
if(mCurrentMode == eUBDockPaletteWidget_BOARD){
if(newWidth > mCollapseWidth)
UBSettings::settings()->leftLibPaletteBoardModeWidth->set(newWidth);
UBSettings::settings()->leftLibPaletteBoardModeIsCollapsed->set(newWidth == 0);
}
else{
if(newWidth > mCollapseWidth)
UBSettings::settings()->leftLibPaletteDesktopModeWidth->set(newWidth);
UBSettings::settings()->leftLibPaletteDesktopModeIsCollapsed->set(newWidth == 0);
}
UBDockPalette::resizeEvent(event);
}
bool UBLeftPalette::switchMode(eUBDockPaletteWidgetMode mode)
{
int newModeWidth;
if(mode == eUBDockPaletteWidget_BOARD){
mLastWidth = UBSettings::settings()->leftLibPaletteBoardModeWidth->get().toInt();
newModeWidth = mLastWidth;
if(UBSettings::settings()->leftLibPaletteBoardModeIsCollapsed->get().toBool())
newModeWidth = 0;
}
else{
mLastWidth = UBSettings::settings()->leftLibPaletteDesktopModeWidth->get().toInt();
newModeWidth = mLastWidth;
if(UBSettings::settings()->leftLibPaletteDesktopModeIsCollapsed->get().toBool())
newModeWidth = 0;
}
resize(newModeWidth,height());
return UBDockPalette::switchMode(mode);
}

@ -23,6 +23,8 @@ public:
UBLeftPalette(QWidget* parent=0, const char* name="UBLeftPalette");
~UBLeftPalette();
bool switchMode(eUBDockPaletteWidgetMode mode);
protected:
void updateMaxWidth();
void resizeEvent(QResizeEvent *event);

@ -145,7 +145,6 @@ void UBNavigatorPalette::resizeEvent(QResizeEvent *event)
{
mNavigator->setMinimumHeight(height() - 2*border());
}
UBSettings::settings()->navigPaletteWidth->set(width());
}
void UBNavigatorPalette::timerEvent(QTimerEvent *event)

@ -28,9 +28,16 @@ UBRightPalette::UBRightPalette(QWidget *parent, const char *name):
setObjectName(name);
setOrientation(eUBDockOrientation_Right);
mCollapseWidth = 150;
mLastWidth = UBSettings::settings()->rightLibPaletteWidth->get().toInt();
if(UBSettings::settings()->rightLibPaletteIsCollapsed->get().toBool())
bool isCollapsed = false;
if(mCurrentMode == eUBDockPaletteWidget_BOARD){
mLastWidth = UBSettings::settings()->rightLibPaletteBoardModeWidth->get().toInt();
isCollapsed = UBSettings::settings()->rightLibPaletteBoardModeIsCollapsed->get().toBool();
}
else{
mLastWidth = UBSettings::settings()->rightLibPaletteDesktopModeWidth->get().toInt();
isCollapsed = UBSettings::settings()->rightLibPaletteDesktopModeIsCollapsed->get().toBool();
}
if(isCollapsed)
resize(0,parentWidget()->height());
else
resize(mLastWidth, parentWidget()->height());
@ -62,10 +69,17 @@ void UBRightPalette::mouseMoveEvent(QMouseEvent *event)
void UBRightPalette::resizeEvent(QResizeEvent *event)
{
int newWidth = width();
if(newWidth > mCollapseWidth)
UBSettings::settings()->rightLibPaletteWidth->set(newWidth);
UBSettings::settings()->rightLibPaletteIsCollapsed->set(newWidth == 0);
UBDockPalette::resizeEvent(event);
if(mCurrentMode == eUBDockPaletteWidget_BOARD){
if(newWidth > mCollapseWidth)
UBSettings::settings()->rightLibPaletteBoardModeWidth->set(newWidth);
UBSettings::settings()->rightLibPaletteBoardModeIsCollapsed->set(newWidth == 0);
}
else{
if(newWidth > mCollapseWidth)
UBSettings::settings()->rightLibPaletteDesktopModeWidth->set(newWidth);
UBSettings::settings()->rightLibPaletteDesktopModeIsCollapsed->set(newWidth == 0);
}
UBDockPalette::resizeEvent(event);
emit resized();
}
@ -78,3 +92,22 @@ void UBRightPalette::updateMaxWidth()
setMaximumHeight(parentWidget()->height());
setMinimumHeight(parentWidget()->height());
}
bool UBRightPalette::switchMode(eUBDockPaletteWidgetMode mode)
{
int newModeWidth;
if(mode == eUBDockPaletteWidget_BOARD){
mLastWidth = UBSettings::settings()->rightLibPaletteBoardModeWidth->get().toInt();
newModeWidth = mLastWidth;
if(UBSettings::settings()->rightLibPaletteBoardModeIsCollapsed->get().toBool())
newModeWidth = 0;
}
else{
mLastWidth = UBSettings::settings()->rightLibPaletteDesktopModeWidth->get().toInt();
newModeWidth = mLastWidth;
if(UBSettings::settings()->rightLibPaletteDesktopModeIsCollapsed->get().toBool())
newModeWidth = 0;
}
resize(newModeWidth,height());
return UBDockPalette::switchMode(mode);
}

@ -23,6 +23,7 @@ class UBRightPalette : public UBDockPalette
public:
UBRightPalette(QWidget* parent=0, const char* name="UBRightPalette");
~UBRightPalette();
bool switchMode(eUBDockPaletteWidgetMode mode);
signals:
void resized();
@ -31,6 +32,7 @@ protected:
void updateMaxWidth();
void mouseMoveEvent(QMouseEvent *event);
void resizeEvent(QResizeEvent *event);
};
#endif // UBRIGHTPALETTE_H

Loading…
Cancel
Save