1/***************************************************************************
2 klineal.h - description
3 -------------------
4 begin : Fri Oct 13 2000
5 Copyright : (C) 2000 - 2008 by Till Krech <till@snafu.de>
6 (C) 2009 by Mathias Soeken <msoeken@tzi.de>
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef KLINEAL_H
19#define KLINEAL_H
20
21#include <QWidget>
22
23class QAutoSizeLabel;
24class QToolButton;
25
26class KAction;
27class KActionCollection;
28class KIcon;
29class KMenu;
30class KRulerSystemTray;
31
32class KLineal : public QWidget {
33 Q_OBJECT
34
35public:
36 enum { North = 0, West, South, East };
37
38 KLineal( QWidget *parent = 0 );
39 ~KLineal();
40
41 void move( int x, int y );
42 void move( const QPoint &p );
43 QPoint pos() const;
44 int x() const;
45 int y() const;
46
47protected:
48 void keyPressEvent( QKeyEvent *e );
49 void mousePressEvent( QMouseEvent *e );
50 void mouseReleaseEvent( QMouseEvent *e );
51 void mouseMoveEvent( QMouseEvent *e );
52 void wheelEvent( QWheelEvent *e );
53 void paintEvent( QPaintEvent *e );
54 void enterEvent( QEvent *e );
55 void leaveEvent( QEvent *e );
56
57 void createSystemTray();
58
59private:
60 KAction* addAction( KMenu *menu, KIcon icon, const QString& text,
61 const QObject* receiver, const char* member,
62 const QKeySequence &shortcut, const QString& name );
63 void drawScale( QPainter &painter );
64 void drawBackground( QPainter &painter );
65 void reLength( int percentOfScreen );
66 void reLengthAbsolute( int length );
67 void updateScaleDirectionMenuItem();
68
69 bool mDragging;
70 QPoint mLastClickPos;
71 QPoint mDragOffset;
72 QAutoSizeLabel *mLabel;
73 QAutoSizeLabel *mColorLabel;
74 int mOrientation;
75 int mLongEdgeLen;
76 int mShortEdgeLen;
77 KMenu *mMenu;
78 QAction *mCloseAction;
79 KMenu *mLenMenu;
80 QAction *mFullScreenAction;
81 QAction *mScaleDirectionAction;
82 QAction *mCenterOriginAction;
83 QAction *mOffsetAction;
84 QColor mColor;
85 QCursor mCurrentCursor;
86 QCursor mNorthCursor;
87 QCursor mEastCursor;
88 QCursor mWestCursor;
89 QCursor mSouthCursor;
90 QCursor mDragCursor;
91 QFont mScaleFont;
92 bool mClicked;
93 bool mLeftToRight;
94 int mOffset;
95 bool mRelativeScale;
96 KActionCollection *mActionCollection;
97 int mOpacity;
98 QToolButton *mBtnRotateLeft, *mBtnRotateRight;
99 QToolButton *mCloseButton;
100 KRulerSystemTray *mTrayIcon;
101
102public slots:
103 void setOrientation( int );
104 void setNorth();
105 void setEast();
106 void setSouth();
107 void setWest();
108 void turnLeft();
109 void turnRight();
110 void showMenu();
111 void hideLabel();
112 void showLabel();
113 void adjustLabel();
114 void adjustButtons();
115 void setShortLength();
116 void setMediumLength();
117 void setTallLength();
118 void setFullLength();
119 void switchDirection();
120 void centerOrigin();
121 void slotOffset();
122 void slotLength();
123 void slotOpacity( int value );
124 void slotKeyBindings();
125 void slotPreferences();
126 void switchRelativeScale( bool checked );
127 void copyColor();
128 void saveSettings();
129 void slotClose();
130 void slotQuit();
131 void loadConfig();
132};
133#endif
134