From 59b3ecd2315f16ebf733696a3f8e26873e41cd9f Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Mon, 16 May 2011 09:58:54 +0200 Subject: [PATCH] Fixed issue Sankore-16 --- src/board/UBBoardPaletteManager.cpp | 14 +++++- src/desktop/UBDesktopAnnotationController.cpp | 10 ++-- src/gui/UBActionPalette.cpp | 7 ++- src/gui/UBActionPalette.h | 3 +- src/gui/UBFloatingPalette.h | 2 +- src/gui/UBKeyboardPalette_linux.cpp | 2 +- src/gui/UBLibNavigatorWidget.cpp | 6 +++ src/gui/UBLibNavigatorWidget.h | 1 + src/gui/UBLibPalette.cpp | 47 +++++++++++++++++++ src/gui/UBLibPalette.h | 18 +++++++ src/gui/UBLibraryWidget.cpp | 5 ++ src/gui/UBLibraryWidget.h | 2 +- src/gui/UBStylusPalette.cpp | 2 +- src/gui/UBStylusPalette.h | 2 +- 14 files changed, 105 insertions(+), 16 deletions(-) diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 24ac7868..2c20151b 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -90,6 +90,12 @@ UBBoardPaletteManager::~UBBoardPaletteManager() delete mLibPalette; mLibPalette = NULL; } + + if(NULL != mStylusPalette) + { + delete mStylusPalette; + mStylusPalette = NULL; + } } void UBBoardPaletteManager::initPalettesPosAtStartup() @@ -641,9 +647,13 @@ void UBBoardPaletteManager::changeStylusPaletteOrientation(QVariant var) bool bVertical = var.toBool(); bool bVisible = mStylusPalette->isVisible(); + UBStylusPalette* mOldPalette; // Clean the old palette - disconnect(mStylusPalette, SIGNAL(stylusToolDoubleClicked(int)), UBApplication::boardController, SLOT(stylusToolDoubleClicked(int))); - delete mStylusPalette; + if(NULL != mStylusPalette) + { + // TODO : check why this line creates a crash in the application. + delete mStylusPalette; + } // Create the new palette if(bVertical) diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp index 2cd607ac..1073e431 100644 --- a/src/desktop/UBDesktopAnnotationController.cpp +++ b/src/desktop/UBDesktopAnnotationController.cpp @@ -111,12 +111,12 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) UBPlatformUtils::disableShadow(mDesktopMarkerPalette); mDesktopEraserPalette = new UBDesktopEraserPalette(mTransparentDrawingView); UBPlatformUtils::disableShadow(mDesktopEraserPalette); - if (UBPlatformUtils::hasVirtualKeyboard()) - { - mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView); + if (UBPlatformUtils::hasVirtualKeyboard()) + { + mKeyboardPalette = UBKeyboardPalette::create(mTransparentDrawingView); - connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool))); - } + connect(mKeyboardPalette, SIGNAL(keyboardActivated(bool)), mTransparentDrawingView, SLOT(virtualKeyboardActivated(bool))); + } mDesktopPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopToolsPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); diff --git a/src/gui/UBActionPalette.cpp b/src/gui/UBActionPalette.cpp index d7f3bff3..bc93294a 100644 --- a/src/gui/UBActionPalette.cpp +++ b/src/gui/UBActionPalette.cpp @@ -43,6 +43,7 @@ void UBActionPalette::init(Qt::Orientation orientation) mAutoClose = false; mButtonGroup = 0; mToolButtonStyle = Qt::ToolButtonIconOnly; + mButtons.clear(); QBoxLayout *layout = 0; @@ -111,7 +112,8 @@ QList UBActionPalette::actions() UBActionPalette::~UBActionPalette() { - + qDeleteAll(mButtons.begin(), mButtons.end()); + mButtons.clear(); } @@ -160,6 +162,7 @@ void UBActionPalette::updateLayout() { layout()->setContentsMargins (sLayoutContentMargin + border(), sLayoutContentMargin + border() , sLayoutContentMargin + border(), sLayoutContentMargin + border()); + } update(); } @@ -256,7 +259,7 @@ UBActionPaletteButton::UBActionPaletteButton(QAction* action, QWidget * parent) UBActionPaletteButton::~UBActionPaletteButton() { - // NOOP + } diff --git a/src/gui/UBActionPalette.h b/src/gui/UBActionPalette.h index 6ea9949b..5d20bcaa 100644 --- a/src/gui/UBActionPalette.h +++ b/src/gui/UBActionPalette.h @@ -73,7 +73,6 @@ class UBActionPalette : public UBFloatingPalette QPoint mMousePos; UBActionPaletteButton *createPaletteButton(QAction* action, QWidget *parent); - private slots: void buttonClicked(); void actionChanged(); @@ -82,7 +81,7 @@ class UBActionPalette : public UBFloatingPalette class UBActionPaletteButton : public QToolButton { - Q_OBJECT; + Q_OBJECT public: UBActionPaletteButton(QAction* action, QWidget * parent = 0); diff --git a/src/gui/UBFloatingPalette.h b/src/gui/UBFloatingPalette.h index a4b37bfb..ba0dbb84 100644 --- a/src/gui/UBFloatingPalette.h +++ b/src/gui/UBFloatingPalette.h @@ -17,7 +17,7 @@ typedef enum class UBFloatingPalette : public QWidget { - Q_OBJECT; + Q_OBJECT public: diff --git a/src/gui/UBKeyboardPalette_linux.cpp b/src/gui/UBKeyboardPalette_linux.cpp index 54a9b5ee..0e5a0c40 100644 --- a/src/gui/UBKeyboardPalette_linux.cpp +++ b/src/gui/UBKeyboardPalette_linux.cpp @@ -95,7 +95,7 @@ void UBKeyboardButton::sendControlSymbol(int nSymbol) void UBKeyboardPalette::createCtrlButtons() { - ctrlButtons = new UBKeyboardButton*[7]; + ctrlButtons = new UBKeyboardButton*[8]; ctrlButtons[0] = new UBCntrlButton(this, "<-", XK_BackSpace); ctrlButtons[1] = new UBCntrlButton(this, "<->", XK_Tab); diff --git a/src/gui/UBLibNavigatorWidget.cpp b/src/gui/UBLibNavigatorWidget.cpp index 97b193c4..a1c11941 100644 --- a/src/gui/UBLibNavigatorWidget.cpp +++ b/src/gui/UBLibNavigatorWidget.cpp @@ -94,6 +94,12 @@ UBLibNavigatorWidget::~UBLibNavigatorWidget() } } +void UBLibNavigatorWidget::dropMe(const QMimeData *_data) +{ + // Forward the mime data to the library widget + +} + /** * \brief Update the navigation bar * @param pElem as the current element diff --git a/src/gui/UBLibNavigatorWidget.h b/src/gui/UBLibNavigatorWidget.h index d661e66c..a7e6fae8 100644 --- a/src/gui/UBLibNavigatorWidget.h +++ b/src/gui/UBLibNavigatorWidget.h @@ -16,6 +16,7 @@ class UBLibNavigatorWidget : public QWidget public: UBLibNavigatorWidget(QWidget* parent=0, const char* name="UBLibNavigatorWidget"); ~UBLibNavigatorWidget(); + void dropMe(const QMimeData* _data); signals: void propertiesRequested(UBLibElement* elem); diff --git a/src/gui/UBLibPalette.cpp b/src/gui/UBLibPalette.cpp index d64827b6..87485db5 100644 --- a/src/gui/UBLibPalette.cpp +++ b/src/gui/UBLibPalette.cpp @@ -12,6 +12,7 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare , mNavigator(NULL) , mProperties(NULL) , mActionBar(NULL) + , mDropWidget(NULL) { setOrientation(eUBDockOrientation_Right); mIcon = QPixmap(":images/paletteLibrary.png"); @@ -31,14 +32,17 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare mActionBar = new UBLibActionBar(this); mNavigator = new UBLibNavigatorWidget(this); mProperties = new UBLibItemProperties(this); + //mDropWidget = new UBDropMeWidget(this); mLayout->addWidget(mStackedWidget, 1); mLayout->addWidget(mActionBar, 0); mStackedWidget->addWidget(mNavigator); mStackedWidget->addWidget(mProperties); + //mStackedWidget->addWidget(mDropWidget); mStackedWidget->setCurrentIndex(ID_NAVIGATOR); + miCrntStackWidget = ID_NAVIGATOR; connect(mNavigator, SIGNAL(propertiesRequested(UBLibElement*)), this, SLOT(showProperties(UBLibElement*))); connect(mProperties, SIGNAL(showFolderContent()), this, SLOT(showFolder())); @@ -69,6 +73,11 @@ UBLibPalette::~UBLibPalette() delete mActionBar; mActionBar = NULL; } + if(NULL != mDropWidget) + { + delete mDropWidget; + mDropWidget = NULL; + } if(NULL != mLayout) { delete mLayout; @@ -93,9 +102,16 @@ void UBLibPalette::updateMaxWidth() void UBLibPalette::dragEnterEvent(QDragEnterEvent *pEvent) { setBackgroundRole(QPalette::Highlight); + //mStackedWidget->setCurrentIndex(ID_DROPME); pEvent->acceptProposedAction(); } +void UBLibPalette::dragLeaveEvent(QDragLeaveEvent *pEvent) +{ + //mStackedWidget->setCurrentIndex(miCrntStackWidget); + pEvent->accept(); +} + /** * \brief Handles the drop event * @param pEvent as the drop event @@ -104,6 +120,7 @@ void UBLibPalette::dropEvent(QDropEvent *pEvent) { processMimeData(pEvent->mimeData()); setBackgroundRole(QPalette::Dark); + mStackedWidget->setCurrentIndex(miCrntStackWidget); pEvent->acceptProposedAction(); } @@ -128,6 +145,7 @@ void UBLibPalette::processMimeData(const QMimeData *pData) { qDebug() << "Dropped element format " << i << " = "<< qslFormats.at(i); } + // mNavigator->dropMe(pData); } @@ -151,6 +169,7 @@ void UBLibPalette::showProperties(UBLibElement *elem) // Show the properties of this object mProperties->showElement(elem); mStackedWidget->setCurrentIndex(ID_PROPERTIES); + miCrntStackWidget = ID_PROPERTIES; } } @@ -158,6 +177,7 @@ void UBLibPalette::showFolder() { mActionBar->setButtons(mActionBar->previousButtonSet()); mStackedWidget->setCurrentIndex(ID_NAVIGATOR); + miCrntStackWidget = ID_NAVIGATOR; } void UBLibPalette::resizeEvent(QResizeEvent *event) @@ -165,3 +185,30 @@ void UBLibPalette::resizeEvent(QResizeEvent *event) UBDockPalette::resizeEvent(event); UBSettings::settings()->libPaletteWidth->set(width()); } + +// -------------------------------------------------------------------------- +UBDropMeWidget::UBDropMeWidget(QWidget *parent, const char *name):QWidget(parent) + , mpLabel(NULL) + , mpLayout(NULL) +{ + setObjectName(name); + mpLayout = new QVBoxLayout(this); + setLayout(mpLayout); + + mpLabel = new QLabel(tr("Drop here"), this); + mpLayout->addWidget(mpLabel); +} + +UBDropMeWidget::~UBDropMeWidget() +{ + if(NULL != mpLabel) + { + delete mpLabel; + mpLabel = NULL; + } + if(NULL != mpLayout) + { + delete mpLayout; + mpLayout = NULL; + } +} diff --git a/src/gui/UBLibPalette.h b/src/gui/UBLibPalette.h index 7dc6c6f8..28e87e98 100644 --- a/src/gui/UBLibPalette.h +++ b/src/gui/UBLibPalette.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "UBDockPalette.h" #include "UBLibNavigatorWidget.h" @@ -18,6 +19,18 @@ #define ID_NAVIGATOR 0 #define ID_PROPERTIES 1 +#define ID_DROPME 2 + +class UBDropMeWidget : public QWidget +{ +public: + UBDropMeWidget(QWidget* parent=0, const char* name="dropMeWidget"); + ~UBDropMeWidget(); + +private: + QLabel* mpLabel; + QVBoxLayout* mpLayout; +}; class UBLibPalette : public UBDockPalette { @@ -33,6 +46,7 @@ protected: void dragEnterEvent(QDragEnterEvent* pEvent); void dropEvent(QDropEvent *pEvent); void dragMoveEvent(QDragMoveEvent* pEvent); + void dragLeaveEvent(QDragLeaveEvent* pEvent); void mouseMoveEvent(QMouseEvent *event); void resizeEvent(QResizeEvent *event); @@ -53,6 +67,10 @@ private: UBLibItemProperties* mProperties; /** UBLibActionBar */ UBLibActionBar* mActionBar; + /** The 'drop here' indicator */ + UBDropMeWidget* mDropWidget; + /** The current stack widget index*/ + int miCrntStackWidget; }; #endif // UBLIBPALETTE_H diff --git a/src/gui/UBLibraryWidget.cpp b/src/gui/UBLibraryWidget.cpp index f28239e2..fd5da1e2 100644 --- a/src/gui/UBLibraryWidget.cpp +++ b/src/gui/UBLibraryWidget.cpp @@ -283,6 +283,11 @@ void UBLibraryWidget::dragMoveEvent(QDragMoveEvent *event) } } +void UBLibraryWidget::onDropMe(const QMimeData *_data) +{ + +} + /** * \brief Handles the drop event * @param event as the drop event diff --git a/src/gui/UBLibraryWidget.h b/src/gui/UBLibraryWidget.h index 7d8b2405..741d357a 100644 --- a/src/gui/UBLibraryWidget.h +++ b/src/gui/UBLibraryWidget.h @@ -35,7 +35,7 @@ public slots: void onElementsDropped(QList elements, UBLibElement* target); void onSearchElement(QString elem); void onNewFolderToCreate(); - + void onDropMe(const QMimeData* _data); signals: void navigBarUpdate(UBLibElement* pElem); void itemsSelected(QList elemList, bool inTrash); diff --git a/src/gui/UBStylusPalette.cpp b/src/gui/UBStylusPalette.cpp index 3db3c0b8..a837f081 100644 --- a/src/gui/UBStylusPalette.cpp +++ b/src/gui/UBStylusPalette.cpp @@ -89,7 +89,7 @@ void UBStylusPalette::initPosition() UBStylusPalette::~UBStylusPalette() { - // NOOP + } void UBStylusPalette::stylusToolDoubleClicked() diff --git a/src/gui/UBStylusPalette.h b/src/gui/UBStylusPalette.h index 7faceb4c..d9f8d0ef 100644 --- a/src/gui/UBStylusPalette.h +++ b/src/gui/UBStylusPalette.h @@ -9,7 +9,7 @@ class UBStylusPalette : public UBActionPalette { - Q_OBJECT; + Q_OBJECT public: UBStylusPalette(QWidget *parent = 0, Qt::Orientation orient = Qt::Vertical);