Commit a2491be4 authored by Anatoly Mihalchenko's avatar Anatoly Mihalchenko

Desktop mode: palettes layout (Windows)

parent a249bcd3
...@@ -38,9 +38,7 @@ ...@@ -38,9 +38,7 @@
#include "UBCustomCaptureWindow.h" #include "UBCustomCaptureWindow.h"
#include "UBWindowCapture.h" #include "UBWindowCapture.h"
#include "UBDesktopPalette.h" #include "UBDesktopPalette.h"
#include "UBDesktopPenPalette.h" #include "UBDesktopPropertyPalette.h"
#include "UBDesktopMarkerPalette.h"
#include "UBDesktopEraserPalette.h"
#include "gui/UBKeyboardPalette.h" #include "gui/UBKeyboardPalette.h"
#include "gui/UBResources.h" #include "gui/UBResources.h"
...@@ -55,6 +53,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent, UB ...@@ -55,6 +53,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent, UB
, mDesktopPenPalette(NULL) , mDesktopPenPalette(NULL)
, mDesktopMarkerPalette(NULL) , mDesktopMarkerPalette(NULL)
, mDesktopEraserPalette(NULL) , mDesktopEraserPalette(NULL)
, mRightPalette(rightPalette)
, mWindowPositionInitialized(0) , mWindowPositionInitialized(0)
, mIsFullyTransparent(false) , mIsFullyTransparent(false)
, mDesktopToolsPalettePositioned(false) , mDesktopToolsPalettePositioned(false)
...@@ -121,13 +120,13 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent, UB ...@@ -121,13 +120,13 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent, UB
connect(UBDrawingController::drawingController(), SIGNAL(stylusToolChanged(int)), this, SLOT(stylusToolChanged(int))); connect(UBDrawingController::drawingController(), SIGNAL(stylusToolChanged(int)), this, SLOT(stylusToolChanged(int)));
// Add the desktop associated palettes // Add the desktop associated palettes
mDesktopPenPalette = new UBDesktopPenPalette(mTransparentDrawingView); // FIX #633: The palette must be 'floating' in order to stay on top of the library palette mDesktopPenPalette = new UBDesktopPenPalette(mTransparentDrawingView, rightPalette);
connect(mDesktopPalette, SIGNAL(maximized()), mDesktopPenPalette, SLOT(onParentMaximized())); connect(mDesktopPalette, SIGNAL(maximized()), mDesktopPenPalette, SLOT(onParentMaximized()));
connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), mDesktopPenPalette, SLOT(onParentMinimized())); connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), mDesktopPenPalette, SLOT(onParentMinimized()));
mDesktopMarkerPalette = new UBDesktopMarkerPalette(mTransparentDrawingView); // FIX #633: The palette must be 'floating' in order to stay on top of the library palette mDesktopMarkerPalette = new UBDesktopMarkerPalette(mTransparentDrawingView, rightPalette);
mDesktopEraserPalette = new UBDesktopEraserPalette(mTransparentDrawingView); // FIX #633: The palette must be 'floating' in order to stay on top of the library palette mDesktopEraserPalette = new UBDesktopEraserPalette(mTransparentDrawingView, rightPalette);
mDesktopPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor);
mDesktopPenPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopPenPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor);
...@@ -161,36 +160,12 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent, UB ...@@ -161,36 +160,12 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent, UB
//mDesktopEraserPalette->raise(); //mDesktopEraserPalette->raise();
//mDesktopMarkerPalette->raise(); //mDesktopMarkerPalette->raise();
//mDesktopPenPalette->raise(); //mDesktopPenPalette->raise();
//mDesktopPalette->raise();
} }
UBDesktopAnnotationController::~UBDesktopAnnotationController() UBDesktopAnnotationController::~UBDesktopAnnotationController()
{ {
delete mTransparentDrawingScene; delete mTransparentDrawingScene;
delete mTransparentDrawingView; delete mTransparentDrawingView;
/*
if(NULL != mDesktopPenPalette)
{
delete mDesktopPalette;
mDesktopPenPalette = NULL;
}
if(NULL != mDesktopMarkerPalette)
{
delete mDesktopMarkerPalette;
mDesktopMarkerPalette = NULL;
}
if(NULL != mDesktopEraserPalette)
{
delete mDesktopEraserPalette;
mDesktopEraserPalette = NULL;
}
if(NULL != mRightPalette)
{
delete mRightPalette;
mRightPalette = NULL;
}
*/
} }
...@@ -257,7 +232,7 @@ void UBDesktopAnnotationController::setAssociatedPalettePosition(UBActionPalette ...@@ -257,7 +232,7 @@ void UBDesktopAnnotationController::setAssociatedPalettePosition(UBActionPalette
} }
// First determine if the palette must be shown on the left or on the right // First determine if the palette must be shown on the left or on the right
if(desktopPalettePos.x() <= (mTransparentDrawingView->width() - (palette->width() + mDesktopPalette->width() + 20))) // we take a small margin of 20 pixels if(desktopPalettePos.x() <= (mTransparentDrawingView->width() - (palette->width() + mDesktopPalette->width() + mRightPalette->width() + 20))) // we take a small margin of 20 pixels
{ {
// Display it on the right // Display it on the right
desktopPalettePos += QPoint(mDesktopPalette->width(), yPen); desktopPalettePos += QPoint(mDesktopPalette->width(), yPen);
......
/*
* 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 2 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 "UBDesktopEraserPalette.h"
#include "core/UBApplication.h"
#include "core/UBSettings.h"
#include "board/UBBoardController.h"
#include "board/UBDrawingController.h"
#include "gui/UBMainWindow.h"
#include "gui/UBToolbarButtonGroup.h"
#include "core/memcheck.h"
UBDesktopEraserPalette::UBDesktopEraserPalette(QWidget *parent)
: UBPropertyPalette(Qt::Horizontal, parent)
{
// Setup eraser width choice widget
QList<QAction *> eraserWidthActions;
eraserWidthActions.append(UBApplication::mainWindow->actionEraserSmall);
eraserWidthActions.append(UBApplication::mainWindow->actionEraserMedium);
eraserWidthActions.append(UBApplication::mainWindow->actionEraserLarge);
UBToolbarButtonGroup *eraserWidthChoice = new UBToolbarButtonGroup(UBApplication::mainWindow->boardToolBar, eraserWidthActions);
connect(eraserWidthChoice, SIGNAL(activated(int)), UBDrawingController::drawingController(), SLOT(setEraserWidthIndex(int)));
connect(eraserWidthChoice, SIGNAL(activated(int)), this, SLOT(close()));
connect(UBApplication::mainWindow->actionEraseDesktopAnnotations, SIGNAL(triggered()), this, SLOT(close()));
eraserWidthChoice->displayText(false);
eraserWidthChoice->setCurrentIndex(UBSettings::settings()->eraserWidthIndex());
layout()->addWidget(eraserWidthChoice);
addAction(UBApplication::mainWindow->actionEraseDesktopAnnotations);
}
/*
* 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 2 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 UBDESKTOPERASERPALETTE_H
#define UBDESKTOPERASERPALETTE_H
#include <QtGui>
#include "gui/UBPropertyPalette.h"
class UBDesktopEraserPalette : public UBPropertyPalette
{
public:
UBDesktopEraserPalette(QWidget *parent = 0);
virtual ~UBDesktopEraserPalette(){}
};
#endif // UBDESKTOPERASERPALETTE_H
/*
* 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 2 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 "UBDesktopMarkerPalette.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "board/UBDrawingController.h"
#include "gui/UBMainWindow.h"
#include "gui/UBToolbarButtonGroup.h"
#include "core/memcheck.h"
UBDesktopMarkerPalette::UBDesktopMarkerPalette(QWidget *parent)
: UBPropertyPalette(Qt::Horizontal, parent)
{
// Setup color choice widget
QList<QAction *> colorActions;
colorActions.append(UBApplication::mainWindow->actionColor0);
colorActions.append(UBApplication::mainWindow->actionColor1);
colorActions.append(UBApplication::mainWindow->actionColor2);
colorActions.append(UBApplication::mainWindow->actionColor3);
UBToolbarButtonGroup *colorChoice = new UBToolbarButtonGroup(UBApplication::mainWindow->boardToolBar, colorActions);
colorChoice->displayText(false);
//connect(colorChoice, SIGNAL(activated(int)), this, SLOT(UBApplication::boardController->setColorIndex(int)));
connect(UBDrawingController::drawingController(), SIGNAL(colorIndexChanged(int)), colorChoice, SLOT(setCurrentIndex(int)));
connect(UBDrawingController::drawingController(), SIGNAL(colorIndexChanged(int)), this, SLOT(close()));
connect(UBDrawingController::drawingController(), SIGNAL(colorPaletteChanged()), colorChoice, SLOT(colorPaletteChanged()));
connect(UBDrawingController::drawingController(), SIGNAL(colorPaletteChanged()), this, SLOT(close()));
layout()->addWidget(colorChoice);
// Setup line width choice widget
QList<QAction *> lineWidthActions;
lineWidthActions.append(UBApplication::mainWindow->actionLineSmall);
lineWidthActions.append(UBApplication::mainWindow->actionLineMedium);
lineWidthActions.append(UBApplication::mainWindow->actionLineLarge);
UBToolbarButtonGroup *lineWidthChoice = new UBToolbarButtonGroup(UBApplication::mainWindow->boardToolBar, lineWidthActions);
lineWidthChoice->displayText(false);
connect(lineWidthChoice, SIGNAL(activated(int)), UBDrawingController::drawingController(), SLOT(setLineWidthIndex(int)));
connect(lineWidthChoice, SIGNAL(activated(int)), this, SLOT(close()));
connect(UBDrawingController::drawingController(), SIGNAL(lineWidthIndexChanged(int)), lineWidthChoice, SLOT(setCurrentIndex(int)));
connect(UBDrawingController::drawingController(), SIGNAL(lineWidthIndexChanged(int)), this, SLOT(close()));
layout()->addWidget(lineWidthChoice);
}
/*
* 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 2 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 UBDESKTOPMARKERPALETTE_H
#define UBDESKTOPMARKERPALETTE_H
#include <QtGui>
#include "gui/UBPropertyPalette.h"
class UBDesktopMarkerPalette : public UBPropertyPalette
{
public:
UBDesktopMarkerPalette(QWidget *parent = 0);
virtual ~UBDesktopMarkerPalette(){}
};
#endif // UBDESKTOPMARKERPALETTE_H
...@@ -112,6 +112,9 @@ void UBDesktopPalette::updateShowHideState(bool pShowEnabled) ...@@ -112,6 +112,9 @@ void UBDesktopPalette::updateShowHideState(bool pShowEnabled)
mShowHideAction->setToolTip(tr("Show Board on Secondary Screen")); mShowHideAction->setToolTip(tr("Show Board on Secondary Screen"));
else else
mShowHideAction->setToolTip(tr("Show Desktop on Secondary Screen")); mShowHideAction->setToolTip(tr("Show Desktop on Secondary Screen"));
if (pShowEnabled)
raise();
} }
...@@ -222,12 +225,18 @@ QPoint UBDesktopPalette::buttonPos(QAction *action) ...@@ -222,12 +225,18 @@ QPoint UBDesktopPalette::buttonPos(QAction *action)
} }
int UBDesktopPalette::getParentWidth(QWidget *parent) int UBDesktopPalette::getParentRightOffset()
{ {
return parent->width() - rightPalette->width(); return rightPalette->width();
} }
void UBDesktopPalette::parentResized() void UBDesktopPalette::parentResized()
{ {
moveInsideParent(pos()); QPoint p = pos();
if (minimizedLocation() == eMinimizedLocation_Right)
{
p.setX(parentWidget()->width() - getParentRightOffset() -width());
}
moveInsideParent(p);
} }
\ No newline at end of file
...@@ -53,7 +53,7 @@ protected: ...@@ -53,7 +53,7 @@ protected:
void showEvent(QShowEvent *event); void showEvent(QShowEvent *event);
void hideEvent(QHideEvent *event); void hideEvent(QHideEvent *event);
int getParentWidth(QWidget *parent); virtual int getParentRightOffset();
private: private:
QAction *mShowHideAction; QAction *mShowHideAction;
......
...@@ -12,18 +12,30 @@ ...@@ -12,18 +12,30 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "UBDesktopPenPalette.h" #include "UBDesktopPropertyPalette.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "board/UBDrawingController.h" #include "board/UBDrawingController.h"
#include "gui/UBMainWindow.h" #include "gui/UBMainWindow.h"
#include "gui/UBToolbarButtonGroup.h" #include "gui/UBToolbarButtonGroup.h"
#include "gui/UBRightPalette.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBDesktopPenPalette::UBDesktopPenPalette(QWidget *parent) UBDesktopPropertyPalette::UBDesktopPropertyPalette(QWidget *parent, UBRightPalette* _rightPalette)
: UBPropertyPalette(Qt::Horizontal, parent) :UBPropertyPalette(Qt::Horizontal, parent)
,rightPalette(_rightPalette)
{}
int UBDesktopPropertyPalette::getParentRightOffset()
{
return rightPalette->width();
}
UBDesktopPenPalette::UBDesktopPenPalette(QWidget *parent, UBRightPalette* rightPalette)
: UBDesktopPropertyPalette(parent, rightPalette)
{ {
// Setup color choice widget // Setup color choice widget
QList<QAction *> colorActions; QList<QAction *> colorActions;
...@@ -65,13 +77,9 @@ UBDesktopPenPalette::UBDesktopPenPalette(QWidget *parent) ...@@ -65,13 +77,9 @@ UBDesktopPenPalette::UBDesktopPenPalette(QWidget *parent)
layout()->addWidget(lineWidthChoice); layout()->addWidget(lineWidthChoice);
} }
void UBDesktopPenPalette::onButtonReleased() void UBDesktopPenPalette::onButtonReleased()
{ {
qDebug() << "Pen palette released!";
// trigger the related action
// Close the palette
close(); close();
} }
...@@ -97,7 +105,66 @@ void UBDesktopPenPalette::onParentMaximized() ...@@ -97,7 +105,66 @@ void UBDesktopPenPalette::onParentMaximized()
} }
} }
void UBDesktopPenPalette::resizeEvent(QResizeEvent *)
UBDesktopEraserPalette::UBDesktopEraserPalette(QWidget *parent, UBRightPalette* rightPalette)
: UBDesktopPropertyPalette(parent, rightPalette)
{ {
qDebug("pen palette resized!"); // Setup eraser width choice widget
QList<QAction *> eraserWidthActions;
eraserWidthActions.append(UBApplication::mainWindow->actionEraserSmall);
eraserWidthActions.append(UBApplication::mainWindow->actionEraserMedium);
eraserWidthActions.append(UBApplication::mainWindow->actionEraserLarge);
UBToolbarButtonGroup *eraserWidthChoice = new UBToolbarButtonGroup(UBApplication::mainWindow->boardToolBar, eraserWidthActions);
connect(eraserWidthChoice, SIGNAL(activated(int)), UBDrawingController::drawingController(), SLOT(setEraserWidthIndex(int)));
connect(eraserWidthChoice, SIGNAL(activated(int)), this, SLOT(close()));
connect(UBApplication::mainWindow->actionEraseDesktopAnnotations, SIGNAL(triggered()), this, SLOT(close()));
eraserWidthChoice->displayText(false);
eraserWidthChoice->setCurrentIndex(UBSettings::settings()->eraserWidthIndex());
layout()->addWidget(eraserWidthChoice);
addAction(UBApplication::mainWindow->actionEraseDesktopAnnotations);
}
UBDesktopMarkerPalette::UBDesktopMarkerPalette(QWidget *parent, UBRightPalette* rightPalette)
: UBDesktopPropertyPalette(parent, rightPalette)
{
// Setup color choice widget
QList<QAction *> colorActions;
colorActions.append(UBApplication::mainWindow->actionColor0);
colorActions.append(UBApplication::mainWindow->actionColor1);
colorActions.append(UBApplication::mainWindow->actionColor2);
colorActions.append(UBApplication::mainWindow->actionColor3);
UBToolbarButtonGroup *colorChoice = new UBToolbarButtonGroup(UBApplication::mainWindow->boardToolBar, colorActions);
colorChoice->displayText(false);
//connect(colorChoice, SIGNAL(activated(int)), this, SLOT(UBApplication::boardController->setColorIndex(int)));
connect(UBDrawingController::drawingController(), SIGNAL(colorIndexChanged(int)), colorChoice, SLOT(setCurrentIndex(int)));
connect(UBDrawingController::drawingController(), SIGNAL(colorIndexChanged(int)), this, SLOT(close()));
connect(UBDrawingController::drawingController(), SIGNAL(colorPaletteChanged()), colorChoice, SLOT(colorPaletteChanged()));
connect(UBDrawingController::drawingController(), SIGNAL(colorPaletteChanged()), this, SLOT(close()));
layout()->addWidget(colorChoice);
// Setup line width choice widget
QList<QAction *> lineWidthActions;
lineWidthActions.append(UBApplication::mainWindow->actionLineSmall);
lineWidthActions.append(UBApplication::mainWindow->actionLineMedium);
lineWidthActions.append(UBApplication::mainWindow->actionLineLarge);
UBToolbarButtonGroup *lineWidthChoice = new UBToolbarButtonGroup(UBApplication::mainWindow->boardToolBar, lineWidthActions);
lineWidthChoice->displayText(false);
connect(lineWidthChoice, SIGNAL(activated(int)), UBDrawingController::drawingController(), SLOT(setLineWidthIndex(int)));
connect(lineWidthChoice, SIGNAL(activated(int)), this, SLOT(close()));
connect(UBDrawingController::drawingController(), SIGNAL(lineWidthIndexChanged(int)), lineWidthChoice, SLOT(setCurrentIndex(int)));
connect(UBDrawingController::drawingController(), SIGNAL(lineWidthIndexChanged(int)), this, SLOT(close()));
layout()->addWidget(lineWidthChoice);
} }
...@@ -20,22 +20,48 @@ ...@@ -20,22 +20,48 @@
#include "gui/UBPropertyPalette.h" #include "gui/UBPropertyPalette.h"
class UBDesktopPenPalette : public UBPropertyPalette class UBRightPalette;
class UBDesktopPropertyPalette : public UBPropertyPalette
{ {
Q_OBJECT Q_OBJECT
public: public:
UBDesktopPenPalette(QWidget *parent = 0); UBDesktopPropertyPalette(QWidget *parent, UBRightPalette* _rightPalette);
virtual ~UBDesktopPenPalette(){} private:
UBRightPalette* rightPalette;
protected:
virtual int getParentRightOffset();
};
class UBDesktopPenPalette : public UBDesktopPropertyPalette
{
Q_OBJECT
public:
UBDesktopPenPalette(QWidget *parent, UBRightPalette* rightPalette);
virtual ~UBDesktopPenPalette(){}
public slots: public slots:
void onParentMinimized(); void onParentMinimized();
void onParentMaximized(); void onParentMaximized();
protected:
void resizeEvent(QResizeEvent *);
private slots: private slots:
void onButtonReleased(); void onButtonReleased();
};
class UBDesktopEraserPalette : public UBDesktopPropertyPalette
{
public:
UBDesktopEraserPalette(QWidget *parent, UBRightPalette* rightPalette);
virtual ~UBDesktopEraserPalette(){}
}; };
class UBDesktopMarkerPalette : public UBDesktopPropertyPalette
{
public:
UBDesktopMarkerPalette(QWidget *parent, UBRightPalette* rightPalette);
virtual ~UBDesktopMarkerPalette(){}
};
#endif // UBDESKTOPPENPALETTE_H #endif // UBDESKTOPPENPALETTE_H
...@@ -2,16 +2,12 @@ HEADERS += src/desktop/UBDesktopPalette.h \ ...@@ -2,16 +2,12 @@ HEADERS += src/desktop/UBDesktopPalette.h \
src/desktop/UBDesktopAnnotationController.h \ src/desktop/UBDesktopAnnotationController.h \
src/desktop/UBCustomCaptureWindow.h \ src/desktop/UBCustomCaptureWindow.h \
src/desktop/UBWindowCapture.h \ src/desktop/UBWindowCapture.h \
src/desktop/UBDesktopPenPalette.h \ src/desktop/UBDesktopPropertyPalette.h
src/desktop/UBDesktopMarkerPalette.h \
src/desktop/UBDesktopEraserPalette.h
SOURCES += src/desktop/UBDesktopPalette.cpp \ SOURCES += src/desktop/UBDesktopPalette.cpp \
src/desktop/UBDesktopAnnotationController.cpp \ src/desktop/UBDesktopAnnotationController.cpp \
src/desktop/UBCustomCaptureWindow.cpp \ src/desktop/UBCustomCaptureWindow.cpp \
src/desktop/UBDesktopPenPalette.cpp \ src/desktop/UBDesktopPropertyPalette.cpp
src/desktop/UBDesktopMarkerPalette.cpp \
src/desktop/UBDesktopEraserPalette.cpp
win32 { win32 {
HEADERS += src/desktop/UBWindowCaptureDelegate_win.h HEADERS += src/desktop/UBWindowCaptureDelegate_win.h
......
...@@ -129,9 +129,9 @@ void UBFloatingPalette::mouseReleaseEvent(QMouseEvent *event) ...@@ -129,9 +129,9 @@ void UBFloatingPalette::mouseReleaseEvent(QMouseEvent *event)
} }
} }
int UBFloatingPalette::getParentWidth(QWidget *parent) int UBFloatingPalette::getParentRightOffset()
{ {
return parent->width(); return 0;
} }
void UBFloatingPalette::moveInsideParent(const QPoint &position) void UBFloatingPalette::moveInsideParent(const QPoint &position)
...@@ -141,7 +141,7 @@ void UBFloatingPalette::moveInsideParent(const QPoint &position) ...@@ -141,7 +141,7 @@ void UBFloatingPalette::moveInsideParent(const QPoint &position)
if (parent) if (parent)
{ {
int margin = UBSettings::boardMargin - border(); int margin = UBSettings::boardMargin - border();
qreal newX = qMax(margin, qMin(getParentWidth(parent) - width() - margin, position.x())); qreal newX = qMax(margin, qMin(parent->width() - getParentRightOffset() - width() - margin, position.x()));
qreal newY = qMax(margin, qMin(parent->height() - height() - margin, position.y())); qreal newY = qMax(margin, qMin(parent->height() - height() - margin, position.y()));
if (!mCustomPosition && !mIsMoving) if (!mCustomPosition && !mIsMoving)
...@@ -152,7 +152,7 @@ void UBFloatingPalette::moveInsideParent(const QPoint &position) ...@@ -152,7 +152,7 @@ void UBFloatingPalette::moveInsideParent(const QPoint &position)
} }
else else
{ {
newX = qMax(margin, getParentWidth(parent) - width() - margin); newX = qMax(margin, parent->width() - getParentRightOffset() - width() - margin);
} }
} }
move(newX, newY); move(newX, newY);
...@@ -265,7 +265,6 @@ void UBFloatingPalette::minimizePalette(const QPoint& pos) ...@@ -265,7 +265,6 @@ void UBFloatingPalette::minimizePalette(const QPoint& pos)
return; return;
} }
QSize parentSize = parentWidget()->size();
if(mMinimizedLocation == eMinimizedLocation_None) if(mMinimizedLocation == eMinimizedLocation_None)
{ {
// Verify if we have to minimize this palette // Verify if we have to minimize this palette
...@@ -277,7 +276,7 @@ void UBFloatingPalette::minimizePalette(const QPoint& pos) ...@@ -277,7 +276,7 @@ void UBFloatingPalette::minimizePalette(const QPoint& pos)
// { // {
// mMinimizedLocation = eMinimizedLocation_Top; // mMinimizedLocation = eMinimizedLocation_Top;
// } // }
else if(pos.x() == parentSize.width() - width() - 5) else if(pos.x() == parentWidget()->width() - getParentRightOffset() - width() - 5)
{ {
mMinimizedLocation = eMinimizedLocation_Right; mMinimizedLocation = eMinimizedLocation_Right;
} }
...@@ -297,8 +296,8 @@ void UBFloatingPalette::minimizePalette(const QPoint& pos) ...@@ -297,8 +296,8 @@ void UBFloatingPalette::minimizePalette(const QPoint& pos)
// Restore the palette // Restore the palette
if(pos.x() > 5 && if(pos.x() > 5 &&
pos.y() > 5 && pos.y() > 5 &&
pos.x() < parentSize.width() - width() - 5 && pos.x() < parentWidget()->width() - getParentRightOffset() - width() - 5 &&
pos.y() < parentSize.height() - height() - 5) pos.y() < parentWidget()->size().height() - height() - 5)
{ {
mMinimizedLocation = eMinimizedLocation_None; mMinimizedLocation = eMinimizedLocation_None;
emit maximizeStart(); emit maximizeStart();
......
...@@ -63,7 +63,9 @@ class UBFloatingPalette : public QWidget ...@@ -63,7 +63,9 @@ class UBFloatingPalette : public QWidget
bool mCustomPosition; bool mCustomPosition;
bool mIsMoving; bool mIsMoving;
virtual int getParentWidth(QWidget *parent); virtual int getParentRightOffset();
eMinimizedLocation minimizedLocation(){return mMinimizedLocation;}
private: private:
void removeAllAssociatedPalette(); void removeAllAssociatedPalette();
......
...@@ -25,7 +25,6 @@ UBPropertyPalette::UBPropertyPalette(QWidget *parent, const char *name):UBAction ...@@ -25,7 +25,6 @@ UBPropertyPalette::UBPropertyPalette(QWidget *parent, const char *name):UBAction
{ {
setObjectName(name); setObjectName(name);
mbGrip = false; mbGrip = false;
setMaximumHeight(MAX_HEIGHT);
} }
/** /**
...@@ -36,7 +35,6 @@ UBPropertyPalette::UBPropertyPalette(QWidget *parent, const char *name):UBAction ...@@ -36,7 +35,6 @@ UBPropertyPalette::UBPropertyPalette(QWidget *parent, const char *name):UBAction
UBPropertyPalette::UBPropertyPalette(Qt::Orientation orientation, QWidget *parent):UBActionPalette(orientation, parent) UBPropertyPalette::UBPropertyPalette(Qt::Orientation orientation, QWidget *parent):UBActionPalette(orientation, parent)
{ {
mbGrip = false; mbGrip = false;
setMaximumHeight(MAX_HEIGHT);
} }
/** /**
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include "UBActionPalette.h" #include "UBActionPalette.h"
#define MAX_HEIGHT 20
class UBPropertyPalette : public UBActionPalette class UBPropertyPalette : public UBActionPalette
{ {
Q_OBJECT Q_OBJECT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment