Commit d5ec11fa authored by Ilia Ryabokon's avatar Ilia Ryabokon

Text delegate algn buttons

parent 5d686fff
...@@ -59,7 +59,7 @@ void UBGraphicsItemZLevelUndoCommand::undo(){ ...@@ -59,7 +59,7 @@ void UBGraphicsItemZLevelUndoCommand::undo(){
if(mDest == UBZLayerController::down || mDest == UBZLayerController::bottom){ if(mDest == UBZLayerController::down || mDest == UBZLayerController::bottom){
// Move up // Move up
QList<QGraphicsItem*>::iterator downIt = mItems.end(); QList<QGraphicsItem*>::iterator downIt = mItems.end();
for(downIt; downIt >= mItems.begin(); downIt--){ for(; downIt >= mItems.begin(); downIt--){
for(int i=0; i<zDiff; i++) for(int i=0; i<zDiff; i++)
mpScene->changeZLevelTo(*downIt, UBZLayerController::up); mpScene->changeZLevelTo(*downIt, UBZLayerController::up);
} }
......
This diff is collapsed.
...@@ -37,6 +37,64 @@ ...@@ -37,6 +37,64 @@
class UBGraphicsTextItem; class UBGraphicsTextItem;
class AlignTextButton : public DelegateButton
{
Q_OBJECT
public:
static const int MAX_KIND = 3;
enum kind_t{
k_left = 0
, k_center
, k_right
, k_mixed
};
AlignTextButton(const QString & fileName, QGraphicsItem* pDelegated, QGraphicsItem * parent = 0, Qt::WindowFrameSection section = Qt::TopLeftSection);
virtual ~AlignTextButton();
void setKind(int pKind);
int kind() {return mKind;}
void setNextKind();
int nextKind() const;
void setMixedButtonVisible(bool v = true) {mHideMixed = !v;}
bool isMixedButtonVisible() {return !mHideMixed;}
private:
QSvgRenderer *rndFromKind(int pknd)
{
switch (pknd) {
case k_left:
return lft;
break;
case k_center:
return cntr;
break;
case k_right:
return rght;
break;
case k_mixed:
return mxd;
break;
}
return 0;
}
QSvgRenderer *curRnd() {return rndFromKind(mKind);}
QPointer<QSvgRenderer> lft;
QPointer<QSvgRenderer> cntr;
QPointer<QSvgRenderer> rght;
QPointer<QSvgRenderer> mxd;
int mKind;
bool mHideMixed;
};
class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
{ {
Q_OBJECT Q_OBJECT
...@@ -67,8 +125,11 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate ...@@ -67,8 +125,11 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
virtual void positionHandles(); virtual void positionHandles();
private: virtual bool mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual bool mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private:
UBGraphicsTextItem* delegated(); UBGraphicsTextItem* delegated();
DelegateButton* mFontButton; DelegateButton* mFontButton;
...@@ -76,10 +137,7 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate ...@@ -76,10 +137,7 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
DelegateButton* mDecreaseSizeButton; DelegateButton* mDecreaseSizeButton;
DelegateButton* mIncreaseSizeButton; DelegateButton* mIncreaseSizeButton;
DelegateButton* mAlignLeftButton; DelegateButton* mAlignButton;
DelegateButton* mAlignCenterButton;
DelegateButton* mAlignRightButton;
DelegateButton* mAlighMixed;
int mLastFontPixelSize; int mLastFontPixelSize;
...@@ -89,9 +147,26 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate ...@@ -89,9 +147,26 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
private: private:
void customize(QFontDialog &fontDialog); void customize(QFontDialog &fontDialog);
void ChangeTextSize(qreal factor, textChangeMode changeMode); void ChangeTextSize(qreal factor, textChangeMode changeMode);
void updateAlighButtonState();
bool oneBlockSelection();
void saveTextCursorFormats();
void restoreTextCursorFormats();
QFont createDefaultFont(); QFont createDefaultFont();
QAction *mEditableAction; QAction *mEditableAction;
struct selectionData_t {
selectionData_t()
: mButtonIsPressed(false)
{}
bool mButtonIsPressed;
int position;
int anchor;
QString html;
QTextDocumentFragment selection;
QList<QTextBlockFormat> fmts;
} mSelectionData;
private slots: private slots:
...@@ -101,9 +176,12 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate ...@@ -101,9 +176,12 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
void decreaseSize(); void decreaseSize();
void increaseSize(); void increaseSize();
void alignButtonProcess();
void onCursorPositionChanged(const QTextCursor& cursor);
void onModificationChanged(bool ch);
private: private:
const int delta; const int delta;
}; };
#endif /* UBGRAPHICSTEXTITEMDELEGATE_H_ */ #endif /* UBGRAPHICSTEXTITEMDELEGATE_H_ */
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