Krita Source Code Documentation
Loading...
Searching...
No Matches
KoRuler.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 SPDX-FileCopyrightText: 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3 SPDX-FileCopyrightText: 2006 Peter Simonsson <peter.simonsson@gmail.com>
4 SPDX-FileCopyrightText: 2007 C. Boemann <cbo@boemann.dk>
5 SPDX-FileCopyrightText: 2007 Thomas Zander <zander@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#ifndef koRuler_h
11#define koRuler_h
12
13
14#include "kritawidgets_export.h"
15
16#include <QWidget>
17#include <QTextOption>
18
19class QPaintEvent;
20
21class KoViewConverter;
22class KoCanvasBase;
23class KoRulerPrivate;
24class KoUnit;
25
29class KRITAWIDGETS_EXPORT KoRuler : public QWidget
30{
31Q_OBJECT
32public:
39 KoRuler(QWidget* parent, Qt::Orientation orientation, const KoViewConverter* viewConverter);
40 ~KoRuler() override;
41
43 struct Tab {
44 qreal position { 0.0 };
45 QTextOption::TabType type { QTextOption::LeftTab };
46 };
47
49 KoUnit unit() const;
50
52 qreal rulerLength() const;
53
55 Qt::Orientation orientation() const;
56
58 qreal firstLineIndent() const;
59
61 qreal paragraphIndent() const;
62
64 qreal endIndent() const;
65
68 QWidget *tabChooser();
69
75 void setPopupActionList(const QList<QAction*> &popupActionList);
80 QList<QAction*> popupActionList() const;
81
83 QSize minimumSizeHint() const override;
84
86 QSize sizeHint() const override;
87
88public Q_SLOTS:
90 void setUnit(const KoUnit &unit);
91
96 void setOffset(int offset);
97
99 void setRulerLength(qreal length);
100
106 void setActiveRange(qreal start, qreal end);
107
114 void setOverrideActiveRange(qreal start, qreal end);
115
119 void setRightToLeft(bool isRightToLeft);
120
125 void setShowIndents(bool show);
126
131 void setFirstLineIndent(qreal indent);
132
137 void setParagraphIndent(qreal indent);
138
143 void setEndIndent(qreal indent);
144
149 void setShowMousePosition(bool show);
150
154 bool showMousePosition() const;
155
161 void updateMouseCoordinate(int coordinate);
162
167 void setShowSelectionBorders(bool show);
168
174 void updateSelectionBorders(qreal first, qreal second);
175
180 void setShowTabs(bool show);
181
186 void setRelativeTabs(bool relative);
187
193 void updateTabs(const QList<Tab> &tabs, qreal tabDistance);
194
195 /***
196 * Return the list of tabs set on this ruler.
197 */
198 QList<Tab> tabs() const;
199
204 void clearHotSpots();
205
212 void setHotSpot(qreal position, int id = -1);
213
219 bool removeHotSpot(int id);
220
227 void createGuideToolConnection(KoCanvasBase *canvas);
228
229 void setUnitPixelMultiple2(bool enabled);
230
231Q_SIGNALS:
236 void indentsChanged(bool final);
237
244 void tabChanged(int originalTabIndex, KoRuler::Tab *tab);
245
248
249 void hotSpotChanged(int id, qreal newPosition);
250
252 void guideLineCreated(Qt::Orientation orientation, qreal viewPosition);
253
254 void guideCreationInProgress(Qt::Orientation orientation, const QPoint &globalPos);
255 void guideCreationFinished(Qt::Orientation orientation, const QPoint &globalPos);
256
257protected:
259 void paintEvent(QPaintEvent* event) override;
261 void mousePressEvent(QMouseEvent *ev) override;
263 void mouseReleaseEvent(QMouseEvent *ev) override;
265 void mouseMoveEvent(QMouseEvent *ev) override;
266
267private:
269 friend class KoRulerPrivate;
270};
271
272#endif
qreal length(const QPointF &vec)
Definition Ellipse.cc:82
void guideCreationFinished(Qt::Orientation orientation, const QPoint &globalPos)
void guideLineCreated(Qt::Orientation orientation, qreal viewPosition)
emitted when the mouse is drag+released outside the ruler
void aboutToChange()
emitted when there the user is about to change a tab or hotspot
void indentsChanged(bool final)
void guideCreationInProgress(Qt::Orientation orientation, const QPoint &globalPos)
KoRulerPrivate *const d
Definition KoRuler.h:268
void hotSpotChanged(int id, qreal newPosition)
void tabChanged(int originalTabIndex, KoRuler::Tab *tab)
For paragraphs each tab definition is represented by this struct.
Definition KoRuler.h:43