~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to plugins/artistictextshape/ArtisticTextShapeConfigWidget.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#ifndef ARTISTICTEXTSHAPECONFIGWIDGET_H
22
22
#define ARTISTICTEXTSHAPECONFIGWIDGET_H
23
23
 
24
 
#include "ui_ArtisticTextShapeConfigWidget.h"
 
24
#include <ui_ArtisticTextShapeConfigWidget.h>
25
25
 
26
26
#include "ArtisticTextShape.h"
27
27
 
28
28
#include <KoShapeConfigWidgetBase.h>
29
29
 
30
 
#include <QUndoCommand>
31
 
#include <KLocale>
32
 
 
33
30
class ArtisticTextShape;
34
31
 
35
 
class ArtisticTextShapeConfigWidget : public KoShapeConfigWidgetBase
 
32
class ArtisticTextShapeConfigWidget : public QWidget
36
33
{
37
34
    Q_OBJECT
38
35
public:
39
36
    ArtisticTextShapeConfigWidget();
40
 
    /// reimplemented
41
 
    virtual void open(KoShape *shape);
42
 
    /// reimplemented
43
 
    virtual void save();
44
 
    /// reimplemented
45
 
    virtual bool showOnShapeCreate() { return false; }
46
 
    /// reimplemented
47
 
    virtual QUndoCommand * createCommand();
48
 
 
49
 
private:
50
 
    class ChangeFont : public QUndoCommand
51
 
    {
52
 
    public:
53
 
        ChangeFont( ArtisticTextShapeConfigWidget *widget, const QFont &font )
54
 
            : m_widget( widget ), m_font( font )
55
 
        {
56
 
            m_shape = widget->m_shape;
57
 
            setText( i18n("Change font") );
58
 
        }
59
 
        virtual void undo()
60
 
        {
61
 
            if ( m_shape ) {
62
 
                m_shape->setFont( m_oldFont );
63
 
                m_widget->open( m_shape );
64
 
            }
65
 
        }
66
 
        virtual void redo()
67
 
        {
68
 
            if ( m_shape ) {
69
 
                m_oldFont = m_shape->font();
70
 
                m_shape->setFont( m_font );
71
 
                m_widget->open( m_shape );
72
 
            }
73
 
        }
74
 
    private:
75
 
        ArtisticTextShapeConfigWidget *m_widget;
76
 
        ArtisticTextShape *m_shape;
77
 
        QFont m_font;
78
 
        QFont m_oldFont;
79
 
    };
80
 
    class ChangeText : public QUndoCommand
81
 
    {
82
 
    public:
83
 
        ChangeText( ArtisticTextShapeConfigWidget *widget, const QString &text )
84
 
            : m_widget( widget ), m_text( text )
85
 
        {
86
 
            m_shape = widget->m_shape;
87
 
            setText( i18n("Change text") );
88
 
        }
89
 
        virtual void undo()
90
 
        {
91
 
            if ( m_shape ) {
92
 
                m_shape->setText( m_oldText );
93
 
                m_widget->open( m_shape );
94
 
            }
95
 
        }
96
 
        virtual void redo()
97
 
        {
98
 
            if ( m_shape ) {
99
 
                m_oldText = m_shape->text();
100
 
                m_shape->setText( m_text );
101
 
                m_widget->open( m_shape );
102
 
            }
103
 
        }
104
 
    private:
105
 
        ArtisticTextShapeConfigWidget *m_widget;
106
 
        ArtisticTextShape *m_shape;
107
 
        QString m_text;
108
 
        QString m_oldText;
109
 
    };
110
 
    class ChangeAnchor : public QUndoCommand
111
 
    {
112
 
    public:
113
 
        ChangeAnchor( ArtisticTextShapeConfigWidget *widget, ArtisticTextShape::TextAnchor anchor )
114
 
            : m_widget( widget ), m_anchor( anchor )
115
 
        {
116
 
            m_shape = widget->m_shape;
117
 
            setText( i18n("Change text anchor") );
118
 
        }
119
 
        virtual void undo()
120
 
        {
121
 
            if ( m_shape ) {
122
 
                m_shape->setTextAnchor( m_oldAnchor );
123
 
                m_widget->open( m_shape );
124
 
            }
125
 
        }
126
 
        virtual void redo()
127
 
        {
128
 
            if ( m_shape ) {
129
 
                m_oldAnchor = m_shape->textAnchor();
130
 
                m_shape->setTextAnchor( m_anchor );
131
 
                m_widget->open( m_shape );
132
 
            }
133
 
        }
134
 
    private:
135
 
        ArtisticTextShapeConfigWidget *m_widget;
136
 
        ArtisticTextShape *m_shape;
137
 
        ArtisticTextShape::TextAnchor m_anchor;
138
 
        ArtisticTextShape::TextAnchor m_oldAnchor;
139
 
    };
 
37
 
 
38
public slots:
 
39
    /// initializes widget from given shape
 
40
    void initializeFromShape(ArtisticTextShape *shape, KoCanvasBase *canvas);
 
41
 
 
42
    /// updates the widget form the current one
 
43
    void updateWidget();
 
44
 
 
45
private slots:
 
46
    void propertyChanged();
140
47
 
141
48
private:
142
49
    void blockChildSignals( bool block );
143
50
    Ui::ArtisticTextShapeConfigWidget widget;
144
51
    ArtisticTextShape * m_shape;
 
52
    KoCanvasBase * m_canvas;
145
53
    QButtonGroup * m_anchorGroup;
146
54
};
147
55