Before Width: | Height: | Size: 796 B After Width: | Height: | Size: 713 B |
Before Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 676 B |
After Width: | Height: | Size: 722 B |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 476 B |
Before Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 396 B |
Before Width: | Height: | Size: 300 B |
Before Width: | Height: | Size: 272 B |
Before Width: | Height: | Size: 295 B |
@ -0,0 +1,26 @@ |
|||||||
|
#include "UBDockPaletteWidget.h" |
||||||
|
|
||||||
|
UBDockPaletteWidget::UBDockPaletteWidget(QWidget *parent, const char *name):QWidget(parent) |
||||||
|
{ |
||||||
|
setObjectName(name); |
||||||
|
} |
||||||
|
|
||||||
|
UBDockPaletteWidget::~UBDockPaletteWidget() |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
QPixmap UBDockPaletteWidget::iconToRight() |
||||||
|
{ |
||||||
|
return mIconToRight; |
||||||
|
} |
||||||
|
|
||||||
|
QPixmap UBDockPaletteWidget::iconToLeft() |
||||||
|
{ |
||||||
|
return mIconToLeft; |
||||||
|
} |
||||||
|
|
||||||
|
QString UBDockPaletteWidget::name() |
||||||
|
{ |
||||||
|
return mName; |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
#ifndef UBDOCKPALETTEWIDGET_H |
||||||
|
#define UBDOCKPALETTEWIDGET_H |
||||||
|
|
||||||
|
#include <QWidget> |
||||||
|
#include <QPixmap> |
||||||
|
#include <QString> |
||||||
|
|
||||||
|
class UBDockPaletteWidget : public QWidget |
||||||
|
{ |
||||||
|
public: |
||||||
|
UBDockPaletteWidget(QWidget* parent=0, const char* name="UBDockPaletteWidget"); |
||||||
|
~UBDockPaletteWidget(); |
||||||
|
|
||||||
|
QPixmap iconToRight(); |
||||||
|
QPixmap iconToLeft(); |
||||||
|
QString name(); |
||||||
|
|
||||||
|
protected: |
||||||
|
QPixmap mIconToRight; // arrow like this: >
|
||||||
|
QPixmap mIconToLeft; // arrow like this: <
|
||||||
|
QString mName; |
||||||
|
|
||||||
|
}; |
||||||
|
|
||||||
|
#endif // UBDOCKPALETTEWIDGET_H
|
@ -0,0 +1,44 @@ |
|||||||
|
/*
|
||||||
|
* 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 "UBLeftPalette.h" |
||||||
|
|
||||||
|
UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name):UBDockPalette(parent) |
||||||
|
, mpPageNavigator(NULL) |
||||||
|
{ |
||||||
|
setObjectName(name); |
||||||
|
setOrientation(eUBDockOrientation_Left); |
||||||
|
mLastWidth = 300; |
||||||
|
setMaximumWidth(300); |
||||||
|
resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height()); |
||||||
|
|
||||||
|
mpLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin()); |
||||||
|
|
||||||
|
mpPageNavigator = new UBPageNavigationWidget(this); |
||||||
|
addTabWidget(mpPageNavigator); |
||||||
|
} |
||||||
|
|
||||||
|
UBLeftPalette::~UBLeftPalette() |
||||||
|
{ |
||||||
|
if(NULL != mpPageNavigator) |
||||||
|
{ |
||||||
|
delete mpPageNavigator; |
||||||
|
mpPageNavigator = NULL; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
UBPageNavigationWidget* UBLeftPalette::pageNavigator() |
||||||
|
{ |
||||||
|
return mpPageNavigator; |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
/*
|
||||||
|
* 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 UBLEFTPALETTE_H |
||||||
|
#define UBLEFTPALETTE_H |
||||||
|
|
||||||
|
#include "UBDockPalette.h" |
||||||
|
#include "UBPageNavigationWidget.h" |
||||||
|
|
||||||
|
class UBLeftPalette : public UBDockPalette |
||||||
|
{ |
||||||
|
public: |
||||||
|
UBLeftPalette(QWidget* parent=0, const char* name="UBLeftPalette"); |
||||||
|
~UBLeftPalette(); |
||||||
|
|
||||||
|
UBPageNavigationWidget* pageNavigator(); |
||||||
|
|
||||||
|
private: |
||||||
|
UBPageNavigationWidget* mpPageNavigator; |
||||||
|
|
||||||
|
}; |
||||||
|
|
||||||
|
#endif // UBLEFTPALETTE_H
|
@ -1,60 +1,82 @@ |
|||||||
|
|
||||||
#ifndef UBMAGNIFER_H |
#ifndef UBMAGNIFIER_H |
||||||
#define UBMAGNIFER_H |
#define UBMAGNIFIER_H |
||||||
|
|
||||||
#include <QWidget> |
#include <QtGui> |
||||||
#include <QBitmap> |
|
||||||
#include <QPen> |
|
||||||
|
|
||||||
class QPixmap; |
class UBMagnifierParams |
||||||
class QBitmap; |
{ |
||||||
class QPen; |
public : |
||||||
class QGraphicsView; |
int x; |
||||||
|
int y; |
||||||
|
qreal zoom; |
||||||
|
qreal sizePercentFromScene; |
||||||
|
}; |
||||||
|
|
||||||
class UBMagnifer : public QWidget |
class UBMagnifier : public QWidget |
||||||
{ |
{ |
||||||
Q_OBJECT |
Q_OBJECT |
||||||
|
|
||||||
public: |
public: |
||||||
UBMagnifer(QWidget *parent = 0); |
UBMagnifier(QWidget *parent = 0, bool isInteractive = false); |
||||||
~UBMagnifer(); |
~UBMagnifier(); |
||||||
|
|
||||||
void setSize(int percentFromScene); |
void setSize(qreal percentFromScene); |
||||||
void setZoom(int z); |
void setZoom(qreal zoom); |
||||||
|
|
||||||
void setGrabView(QGraphicsView *view); |
void setGrabView(QWidget *view); |
||||||
void setMoveView(QGraphicsView *view) {mView = view;} |
void setMoveView(QWidget *view) {mView = view;} |
||||||
|
|
||||||
|
void grabPoint(); |
||||||
void grabPoint(const QPoint &point); |
void grabPoint(const QPoint &point); |
||||||
void grabPoint(const QPointF &point); |
void grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab = true, bool needMove = true); |
||||||
void grabNMove(const QPoint &point, bool needGrab); |
|
||||||
void grabNMove(const QPointF &point, bool needGrab); |
UBMagnifierParams params; |
||||||
|
|
||||||
|
signals: |
||||||
|
void magnifierMoved_Signal(QPoint newPos); |
||||||
|
void magnifierClose_Signal(); |
||||||
|
void magnifierZoomIn_Signal(); |
||||||
|
void magnifierZoomOut_Signal(); |
||||||
|
void magnifierResized_Signal(qreal newPercentSize); |
||||||
|
|
||||||
protected: |
protected: |
||||||
void paintEvent(QPaintEvent *); |
void paintEvent(QPaintEvent *); |
||||||
void timerEvent(QTimerEvent *); |
void timerEvent(QTimerEvent *); |
||||||
|
|
||||||
int sizePercentFromScene; |
virtual void mousePressEvent ( QMouseEvent * event ); |
||||||
|
virtual void mouseMoveEvent ( QMouseEvent * event ); |
||||||
|
virtual void mouseReleaseEvent ( QMouseEvent * event ); |
||||||
|
|
||||||
|
QPoint mMousePressPos; |
||||||
|
qreal mMousePressDelta; |
||||||
|
bool mShouldMoveWidget; |
||||||
|
bool mShouldResizeWidget; |
||||||
|
|
||||||
|
|
||||||
|
QPixmap *sClosePixmap; |
||||||
|
QPixmap *sIncreasePixmap; |
||||||
|
QPixmap *sDecreasePixmap; |
||||||
|
QPixmap *mResizeItem; |
||||||
|
|
||||||
|
bool isCusrsorAlreadyStored; |
||||||
|
QCursor mOldCursor; |
||||||
|
QCursor mResizeCursor; |
||||||
|
|
||||||
private: |
private: |
||||||
int zoom; |
|
||||||
int zWidth; |
|
||||||
int zHeight; |
|
||||||
int zWidthHalf; |
|
||||||
int zHeightHalf; |
|
||||||
bool inTimer; |
bool inTimer; |
||||||
|
bool m_isInteractive; |
||||||
|
|
||||||
int timerUpdate; |
int timerUpdate; |
||||||
QPoint updPoint; |
QPoint updPointGrab; |
||||||
QPointF updPointF; |
QPoint updPointMove; |
||||||
|
|
||||||
QPixmap pMap; |
QPixmap pMap; |
||||||
QBitmap bmpMask; |
QBitmap bmpMask; |
||||||
QPen borderPen; |
QPen borderPen; |
||||||
|
|
||||||
QGraphicsView *gView; |
QWidget *gView; |
||||||
QGraphicsView *mView; |
QWidget *mView; |
||||||
}; |
}; |
||||||
|
|
||||||
#endif // UBMAGNIFER_H
|
#endif // UBMAGNIFIER_H
|
||||||
|
@ -0,0 +1,195 @@ |
|||||||
|
/*
|
||||||
|
* 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 "UBPageNavigationWidget.h" |
||||||
|
#include "core/UBApplication.h" |
||||||
|
#include "board/UBBoardController.h" |
||||||
|
#include "core/memcheck.h" |
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Constructor |
||||||
|
* @param parent as the parent widget |
||||||
|
* @param name as the object name |
||||||
|
*/ |
||||||
|
UBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) |
||||||
|
, mNavigator(NULL) |
||||||
|
, mLayout(NULL) |
||||||
|
, mHLayout(NULL) |
||||||
|
, mPageNbr(NULL) |
||||||
|
, mClock(NULL) |
||||||
|
{ |
||||||
|
setObjectName(name); |
||||||
|
mName = "PageNavigator"; |
||||||
|
|
||||||
|
mIconToRight = QPixmap(":images/pages_open.png"); |
||||||
|
mIconToLeft = QPixmap(":images/pages_close.png"); |
||||||
|
|
||||||
|
// Build the gui
|
||||||
|
mLayout = new QVBoxLayout(this); |
||||||
|
//mLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin());
|
||||||
|
setLayout(mLayout); |
||||||
|
|
||||||
|
mNavigator = new UBDocumentNavigator(this); |
||||||
|
mNavigator->setStyleSheet(QString("background-color : transparent;")); |
||||||
|
mLayout->addWidget(mNavigator, 1); |
||||||
|
|
||||||
|
mHLayout = new QHBoxLayout(); |
||||||
|
mLayout->addLayout(mHLayout, 0); |
||||||
|
|
||||||
|
mPageNbr = new QLabel(this); |
||||||
|
mClock = new QLabel(this); |
||||||
|
mHLayout->addWidget(mPageNbr); |
||||||
|
mHLayout->addWidget(mClock); |
||||||
|
|
||||||
|
// Configure the page number indicator
|
||||||
|
mPageNbr->setStyleSheet(QString("QLabel { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }")); |
||||||
|
setPageNumber(0, 0); |
||||||
|
mPageNbr->setAlignment(Qt::AlignHCenter); |
||||||
|
|
||||||
|
// Configure the clock
|
||||||
|
mClock->setStyleSheet(QString("QLabel {color: white; background-color: transparent; text-align: center; font-family: Arial; font-weight: bold; font-size: 20px}")); |
||||||
|
mTimeFormat = QLocale::system().timeFormat(QLocale::ShortFormat); |
||||||
|
mClock->setAlignment(Qt::AlignHCenter); |
||||||
|
|
||||||
|
//strip seconds
|
||||||
|
mTimeFormat = mTimeFormat.remove(":ss"); |
||||||
|
mTimeFormat = mTimeFormat.remove(":s"); |
||||||
|
mTimerID = startTimer(1000); |
||||||
|
|
||||||
|
connect(mNavigator, SIGNAL(changeCurrentPage()), this, SLOT(changeCurrentPage())); |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Destructor |
||||||
|
*/ |
||||||
|
UBPageNavigationWidget::~UBPageNavigationWidget() |
||||||
|
{ |
||||||
|
killTimer(mTimerID); |
||||||
|
|
||||||
|
if(NULL != mClock) |
||||||
|
{ |
||||||
|
delete mClock; |
||||||
|
mClock = NULL; |
||||||
|
} |
||||||
|
if(NULL != mPageNbr) |
||||||
|
{ |
||||||
|
delete mPageNbr; |
||||||
|
mPageNbr = NULL; |
||||||
|
} |
||||||
|
if(NULL != mHLayout) |
||||||
|
{ |
||||||
|
delete mHLayout; |
||||||
|
mHLayout = NULL; |
||||||
|
} |
||||||
|
if(NULL != mLayout) |
||||||
|
{ |
||||||
|
delete mLayout; |
||||||
|
mLayout = NULL; |
||||||
|
} |
||||||
|
if(NULL != mNavigator) |
||||||
|
{ |
||||||
|
delete mNavigator; |
||||||
|
mNavigator = NULL; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the current document in the navigator |
||||||
|
* @param document as the given document |
||||||
|
*/ |
||||||
|
void UBPageNavigationWidget::setDocument(UBDocumentProxy *document) |
||||||
|
{ |
||||||
|
if(mNavigator->currentDoc() != document) |
||||||
|
{ |
||||||
|
mNavigator->setDocument(document); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Change the current page |
||||||
|
*/ |
||||||
|
void UBPageNavigationWidget::changeCurrentPage() |
||||||
|
{ |
||||||
|
// Get the index of the page to display
|
||||||
|
int iPage = mNavigator->selectedPageNumber(); |
||||||
|
if(NO_PAGESELECTED != iPage) |
||||||
|
{ |
||||||
|
// Display the selected page
|
||||||
|
UBApplication::boardController->setActiveDocumentScene(mNavigator->currentDoc(), iPage); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Refresh the thumbnails widget |
||||||
|
*/ |
||||||
|
void UBPageNavigationWidget::refresh() |
||||||
|
{ |
||||||
|
mNavigator->setDocument(UBApplication::boardController->activeDocument()); |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Handle the resize event |
||||||
|
* @param event as the resize event |
||||||
|
*/ |
||||||
|
void UBPageNavigationWidget::resizeEvent(QResizeEvent *event) |
||||||
|
{ |
||||||
|
emit resizeRequest(event); |
||||||
|
//UBDockPalette::resizeEvent(event);
|
||||||
|
if(NULL != mNavigator) |
||||||
|
{ |
||||||
|
mNavigator->setMinimumHeight(height() - 2*border()); |
||||||
|
} |
||||||
|
UBSettings::settings()->navigPaletteWidth->set(width()); |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Notify a timer event |
||||||
|
* @param event as the timer event |
||||||
|
*/ |
||||||
|
void UBPageNavigationWidget::timerEvent(QTimerEvent *event) |
||||||
|
{ |
||||||
|
Q_UNUSED(event); |
||||||
|
updateTime(); |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Update the current time |
||||||
|
*/ |
||||||
|
void UBPageNavigationWidget::updateTime() |
||||||
|
{ |
||||||
|
if (mClock) |
||||||
|
{ |
||||||
|
mClock->setText(QLocale::system().toString (QTime::currentTime(), mTimeFormat)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the page number |
||||||
|
* @param current as the current page |
||||||
|
* @param total as the total number of pages |
||||||
|
*/ |
||||||
|
void UBPageNavigationWidget::setPageNumber(int current, int total) |
||||||
|
{ |
||||||
|
mPageNbr->setText(QString("%1 / %2").arg(current).arg(total)); |
||||||
|
} |
||||||
|
|
||||||
|
int UBPageNavigationWidget::customMargin() |
||||||
|
{ |
||||||
|
return 5; |
||||||
|
} |
||||||
|
|
||||||
|
int UBPageNavigationWidget::border() |
||||||
|
{ |
||||||
|
return 15; |
||||||
|
} |
@ -0,0 +1,68 @@ |
|||||||
|
/*
|
||||||
|
* 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 UBPAGENAVIGATIONWIDGET_H |
||||||
|
#define UBPAGENAVIGATIONWIDGET_H |
||||||
|
|
||||||
|
#include <QVBoxLayout> |
||||||
|
#include <QHBoxLayout> |
||||||
|
#include <QMouseEvent> |
||||||
|
#include <QResizeEvent> |
||||||
|
#include <QTimerEvent> |
||||||
|
#include <QLabel> |
||||||
|
#include <QString> |
||||||
|
|
||||||
|
#include "UBDocumentNavigator.h" |
||||||
|
#include "UBDockPaletteWidget.h" |
||||||
|
#include "document/UBDocumentProxy.h" |
||||||
|
|
||||||
|
class UBPageNavigationWidget : public UBDockPaletteWidget |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
public: |
||||||
|
UBPageNavigationWidget(QWidget* parent=0, const char* name="UBPageNavigationWidget"); |
||||||
|
~UBPageNavigationWidget(); |
||||||
|
void setDocument(UBDocumentProxy* document); |
||||||
|
void refresh(); |
||||||
|
|
||||||
|
signals: |
||||||
|
void resizeRequest(QResizeEvent* event); |
||||||
|
|
||||||
|
public slots: |
||||||
|
void setPageNumber(int current, int total); |
||||||
|
|
||||||
|
protected: |
||||||
|
virtual void resizeEvent(QResizeEvent *event); |
||||||
|
virtual void timerEvent(QTimerEvent *event); |
||||||
|
|
||||||
|
private: |
||||||
|
void updateTime(); |
||||||
|
int customMargin(); |
||||||
|
int border(); |
||||||
|
|
||||||
|
/** The thumbnails navigator widget */ |
||||||
|
UBDocumentNavigator* mNavigator; |
||||||
|
/** The layout */ |
||||||
|
QVBoxLayout* mLayout; |
||||||
|
QHBoxLayout* mHLayout; |
||||||
|
QLabel* mPageNbr; |
||||||
|
QLabel* mClock; |
||||||
|
QString mTimeFormat; |
||||||
|
int mTimerID; |
||||||
|
|
||||||
|
private slots: |
||||||
|
void changeCurrentPage(); |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // UBPAGENAVIGATIONWIDGET_H
|
@ -0,0 +1,73 @@ |
|||||||
|
/*
|
||||||
|
* 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 "UBRightPalette.h" |
||||||
|
|
||||||
|
UBRightPalette::UBRightPalette(QWidget *parent, const char *name):UBDockPalette(parent) |
||||||
|
, mpLibWidget(NULL) |
||||||
|
{ |
||||||
|
setObjectName(name); |
||||||
|
setOrientation(eUBDockOrientation_Right); |
||||||
|
setOrientation(eUBDockOrientation_Right); |
||||||
|
mCollapseWidth = 180; |
||||||
|
mLastWidth = 300; |
||||||
|
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height()); |
||||||
|
mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin()); |
||||||
|
|
||||||
|
mpLibWidget = new UBLibWidget(this); |
||||||
|
addTabWidget(mpLibWidget); |
||||||
|
} |
||||||
|
|
||||||
|
UBRightPalette::~UBRightPalette() |
||||||
|
{ |
||||||
|
if(NULL != mpLibWidget) |
||||||
|
{ |
||||||
|
delete mpLibWidget; |
||||||
|
mpLibWidget = NULL; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
UBLibWidget* UBRightPalette::libWidget() |
||||||
|
{ |
||||||
|
return mpLibWidget; |
||||||
|
} |
||||||
|
|
||||||
|
void UBRightPalette::mouseMoveEvent(QMouseEvent *event) |
||||||
|
{ |
||||||
|
if(mCanResize) |
||||||
|
{ |
||||||
|
UBDockPalette::mouseMoveEvent(event); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
//qDebug() << "Mouse move event detected!" ;
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UBRightPalette::resizeEvent(QResizeEvent *event) |
||||||
|
{ |
||||||
|
UBDockPalette::resizeEvent(event); |
||||||
|
UBSettings::settings()->libPaletteWidth->set(width()); |
||||||
|
emit resized(); |
||||||
|
} |
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Update the maximum width |
||||||
|
*/ |
||||||
|
void UBRightPalette::updateMaxWidth() |
||||||
|
{ |
||||||
|
setMaximumWidth((int)((parentWidget()->width() * 2)/3)); |
||||||
|
setMaximumHeight(parentWidget()->height()); |
||||||
|
setMinimumHeight(parentWidget()->height()); |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
/*
|
||||||
|
* 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 UBRIGHTPALETTE_H |
||||||
|
#define UBRIGHTPALETTE_H |
||||||
|
|
||||||
|
#include "UBDockPalette.h" |
||||||
|
#include "UBLibWidget.h" |
||||||
|
|
||||||
|
class UBRightPalette : public UBDockPalette |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
public: |
||||||
|
UBRightPalette(QWidget* parent=0, const char* name="UBRightPalette"); |
||||||
|
~UBRightPalette(); |
||||||
|
|
||||||
|
UBLibWidget* libWidget(); |
||||||
|
|
||||||
|
signals: |
||||||
|
void resized(); |
||||||
|
|
||||||
|
protected: |
||||||
|
void updateMaxWidth(); |
||||||
|
void mouseMoveEvent(QMouseEvent *event); |
||||||
|
void resizeEvent(QResizeEvent *event); |
||||||
|
|
||||||
|
private: |
||||||
|
UBLibWidget* mpLibWidget; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // UBRIGHTPALETTE_H
|
@ -0,0 +1,142 @@ |
|||||||
|
/*
|
||||||
|
* 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 <QDebug> |
||||||
|
|
||||||
|
#include "UBGraphicsCache.h" |
||||||
|
|
||||||
|
#include "core/UBApplication.h" |
||||||
|
|
||||||
|
#include "board/UBBoardController.h" |
||||||
|
#include "board/UBBoardView.h" |
||||||
|
#include "domain/UBGraphicsScene.h" |
||||||
|
|
||||||
|
|
||||||
|
UBGraphicsCache::UBGraphicsCache():QGraphicsRectItem() |
||||||
|
, mMaskColor(Qt::black) |
||||||
|
, mMaskShape(eMaskShape_Circle) |
||||||
|
, mShapeWidth(100) |
||||||
|
, mDrawMask(false) |
||||||
|
{ |
||||||
|
// Get the board size and pass it to the shape
|
||||||
|
QRect boardRect = UBApplication::boardController->displayView()->rect(); |
||||||
|
setRect(-15*boardRect.width(), -15*boardRect.height(), 30*boardRect.width(), 30*boardRect.height()); |
||||||
|
setZValue(CACHE_ZVALUE); |
||||||
|
} |
||||||
|
|
||||||
|
UBGraphicsCache::~UBGraphicsCache() |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
UBItem* UBGraphicsCache::deepCopy() const |
||||||
|
{ |
||||||
|
UBGraphicsCache* copy = new UBGraphicsCache(); |
||||||
|
|
||||||
|
copy->setPos(this->pos()); |
||||||
|
copy->setRect(this->rect()); |
||||||
|
copy->setZValue(this->zValue()); |
||||||
|
copy->setTransform(this->transform()); |
||||||
|
|
||||||
|
// TODO UB 4.7 ... complete all members ?
|
||||||
|
|
||||||
|
return copy; |
||||||
|
} |
||||||
|
|
||||||
|
QColor UBGraphicsCache::maskColor() |
||||||
|
{ |
||||||
|
return mMaskColor; |
||||||
|
} |
||||||
|
|
||||||
|
void UBGraphicsCache::setMaskColor(QColor color) |
||||||
|
{ |
||||||
|
mMaskColor = color; |
||||||
|
} |
||||||
|
|
||||||
|
eMaskShape UBGraphicsCache::maskshape() |
||||||
|
{ |
||||||
|
return mMaskShape; |
||||||
|
} |
||||||
|
|
||||||
|
void UBGraphicsCache::setMaskShape(eMaskShape shape) |
||||||
|
{ |
||||||
|
mMaskShape = shape; |
||||||
|
} |
||||||
|
|
||||||
|
void UBGraphicsCache::init() |
||||||
|
{ |
||||||
|
setFlag(QGraphicsItem::ItemIsMovable, true); |
||||||
|
setFlag(QGraphicsItem::ItemIsSelectable, true); |
||||||
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); |
||||||
|
} |
||||||
|
|
||||||
|
void UBGraphicsCache::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
||||||
|
{ |
||||||
|
Q_UNUSED(option); |
||||||
|
Q_UNUSED(widget); |
||||||
|
|
||||||
|
setZValue(CACHE_ZVALUE); |
||||||
|
|
||||||
|
painter->setBrush(mMaskColor); |
||||||
|
painter->setPen(mMaskColor); |
||||||
|
|
||||||
|
QPainterPath path; |
||||||
|
path.addRect(rect()); |
||||||
|
|
||||||
|
if(mDrawMask) |
||||||
|
{ |
||||||
|
if(eMaskShape_Circle == mMaskShape) |
||||||
|
{ |
||||||
|
path.addEllipse(mShapePos, mShapeWidth, mShapeWidth); |
||||||
|
} |
||||||
|
else if(eMaskShap_Rectangle == mMaskShape) |
||||||
|
{ |
||||||
|
path.addRect(mShapePos.x(), mShapePos.y(), mShapeWidth, mShapeWidth); |
||||||
|
} |
||||||
|
path.setFillRule(Qt::OddEvenFill); |
||||||
|
} |
||||||
|
|
||||||
|
painter->drawPath(path); |
||||||
|
} |
||||||
|
|
||||||
|
void UBGraphicsCache::mousePressEvent(QGraphicsSceneMouseEvent *event) |
||||||
|
{ |
||||||
|
Q_UNUSED(event); |
||||||
|
mShapePos = event->pos(); |
||||||
|
mDrawMask = true; |
||||||
|
update(); |
||||||
|
} |
||||||
|
|
||||||
|
void UBGraphicsCache::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
||||||
|
{ |
||||||
|
mShapePos = event->pos(); |
||||||
|
update(); |
||||||
|
} |
||||||
|
|
||||||
|
void UBGraphicsCache::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
||||||
|
{ |
||||||
|
Q_UNUSED(event); |
||||||
|
mDrawMask = false; |
||||||
|
update(); |
||||||
|
} |
||||||
|
|
||||||
|
int UBGraphicsCache::shapeWidth() |
||||||
|
{ |
||||||
|
return mShapeWidth; |
||||||
|
} |
||||||
|
|
||||||
|
void UBGraphicsCache::setShapeWidth(int width) |
||||||
|
{ |
||||||
|
mShapeWidth = width; |
||||||
|
} |
@ -0,0 +1,61 @@ |
|||||||
|
/*
|
||||||
|
* 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 UBGRAPHICSCACHE_H |
||||||
|
#define UBGRAPHICSCACHE_H |
||||||
|
|
||||||
|
#include <QColor> |
||||||
|
#include <QGraphicsSceneMouseEvent> |
||||||
|
|
||||||
|
#include "domain/UBItem.h" |
||||||
|
|
||||||
|
#define CACHE_ZVALUE 100000 |
||||||
|
|
||||||
|
typedef enum |
||||||
|
{ |
||||||
|
eMaskShape_Circle, |
||||||
|
eMaskShap_Rectangle |
||||||
|
}eMaskShape; |
||||||
|
|
||||||
|
class UBGraphicsCache : public QGraphicsRectItem, public UBItem |
||||||
|
{ |
||||||
|
public: |
||||||
|
UBGraphicsCache(); |
||||||
|
~UBGraphicsCache(); |
||||||
|
virtual UBItem* deepCopy() const; |
||||||
|
|
||||||
|
QColor maskColor(); |
||||||
|
void setMaskColor(QColor color); |
||||||
|
eMaskShape maskshape(); |
||||||
|
void setMaskShape(eMaskShape shape); |
||||||
|
int shapeWidth(); |
||||||
|
void setShapeWidth(int width); |
||||||
|
|
||||||
|
protected: |
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
||||||
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event); |
||||||
|
void mousePressEvent(QGraphicsSceneMouseEvent *event); |
||||||
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); |
||||||
|
|
||||||
|
private: |
||||||
|
void init(); |
||||||
|
|
||||||
|
QColor mMaskColor; |
||||||
|
eMaskShape mMaskShape; |
||||||
|
int mShapeWidth; |
||||||
|
bool mDrawMask; |
||||||
|
QPointF mShapePos; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // UBGRAPHICSCACHE_H
|
@ -1,18 +1,20 @@ |
|||||||
|
|
||||||
HEADERS += src/tools/UBGraphicsRuler.h \ |
HEADERS += src/tools/UBGraphicsRuler.h \ |
||||||
src/tools/UBGraphicsTriangle.h \ |
src/tools/UBGraphicsTriangle.h \ |
||||||
src/tools/UBGraphicsProtractor.h \ |
src/tools/UBGraphicsProtractor.h \ |
||||||
src/tools/UBGraphicsCompass.h \ |
src/tools/UBGraphicsCompass.h \ |
||||||
src/tools/UBToolsManager.h \ |
src/tools/UBToolsManager.h \ |
||||||
src/tools/UBGraphicsCurtainItem.h \ |
src/tools/UBGraphicsCurtainItem.h \ |
||||||
src/tools/UBGraphicsCurtainItemDelegate.h \ |
src/tools/UBGraphicsCurtainItemDelegate.h \ |
||||||
src/tools/UBAbstractDrawRuler.h |
src/tools/UBAbstractDrawRuler.h \ |
||||||
|
src/tools/UBGraphicsCache.h |
||||||
SOURCES += src/tools/UBGraphicsRuler.cpp \ |
|
||||||
src/tools/UBGraphicsTriangle.cpp \ |
SOURCES += src/tools/UBGraphicsRuler.cpp \ |
||||||
src/tools/UBGraphicsProtractor.cpp \ |
src/tools/UBGraphicsTriangle.cpp \ |
||||||
src/tools/UBGraphicsCompass.cpp \ |
src/tools/UBGraphicsProtractor.cpp \ |
||||||
src/tools/UBToolsManager.cpp \ |
src/tools/UBGraphicsCompass.cpp \ |
||||||
src/tools/UBGraphicsCurtainItem.cpp \ |
src/tools/UBToolsManager.cpp \ |
||||||
src/tools/UBGraphicsCurtainItemDelegate.cpp \ |
src/tools/UBGraphicsCurtainItem.cpp \ |
||||||
src/tools/UBAbstractDrawRuler.cpp |
src/tools/UBGraphicsCurtainItemDelegate.cpp \ |
||||||
|
src/tools/UBAbstractDrawRuler.cpp \ |
||||||
|
src/tools/UBGraphicsCache.cpp |
||||||
|