Changeset View
Changeset View
Standalone View
Standalone View
src/QuickEditor/QuickEditor.h
Show All 20 Lines | |||||
21 | #define QUICKEDITOR_H | 21 | #define QUICKEDITOR_H | ||
22 | 22 | | |||
23 | #include <QKeyEvent> | 23 | #include <QKeyEvent> | ||
24 | #include <QPainter> | 24 | #include <QPainter> | ||
25 | #include <QStaticText> | 25 | #include <QStaticText> | ||
26 | #include <QWidget> | 26 | #include <QWidget> | ||
27 | #include <utility> | 27 | #include <utility> | ||
28 | #include <vector> | 28 | #include <vector> | ||
29 | #include <QBrush> | ||||
30 | | ||||
31 | #include <KScreen/kscreen/config.h> | ||||
29 | 32 | | |||
30 | class QMouseEvent; | 33 | class QMouseEvent; | ||
31 | 34 | | |||
35 | | ||||
36 | class ComparableQPoint : public QPoint | ||||
37 | { | ||||
38 | public: | ||||
39 | ComparableQPoint(QPoint& point): QPoint(point.x(), point.y()) | ||||
40 | {} | ||||
41 | | ||||
42 | ComparableQPoint(QPoint point): QPoint(point.x(), point.y()) | ||||
43 | {} | ||||
44 | | ||||
45 | ComparableQPoint(): QPoint() | ||||
46 | {} | ||||
47 | | ||||
48 | // utility class that allows using QMap to sort its keys when they are QPoint | ||||
49 | bool operator<(const ComparableQPoint &other) const { | ||||
50 | return x() < other.x() || y() < other.y(); | ||||
51 | } | ||||
52 | }; | ||||
53 | | ||||
54 | struct OuputInfo { | ||||
55 | qreal dpr; | ||||
56 | QSize newSize; | ||||
57 | QPoint originPos; | ||||
58 | QBrush brush; | ||||
59 | }; | ||||
60 | | ||||
32 | namespace KWayland { | 61 | namespace KWayland { | ||
33 | namespace Client { | 62 | namespace Client { | ||
34 | class PlasmaShell; | 63 | class PlasmaShell; | ||
35 | } | 64 | } | ||
36 | } | 65 | } | ||
37 | 66 | | |||
38 | class QuickEditor: public QWidget | 67 | class QuickEditor: public QWidget | ||
39 | { | 68 | { | ||
40 | Q_OBJECT | 69 | Q_OBJECT | ||
41 | 70 | | |||
42 | public: | 71 | public: | ||
43 | 72 | | |||
44 | explicit QuickEditor(const QPixmap &thePixmap, KWayland::Client::PlasmaShell *plasmashell, QWidget *parent = nullptr); | 73 | explicit QuickEditor(const QPixmap &thePixmap, KWayland::Client::PlasmaShell *plasmashell, KScreen::ConfigPtr mScreenConfiguration, QWidget *parent = nullptr); | ||
45 | virtual ~QuickEditor() = default; | 74 | ~QuickEditor() override { | ||
75 | | ||||
76 | } | ||||
77 | | ||||
78 | public Q_SLOTS: | ||||
79 | void onScreenConfigurationReceived(const KScreen::ConfigPtr mScreenConfiguration); | ||||
46 | 80 | | |||
47 | private: | 81 | private: | ||
48 | 82 | | |||
49 | enum MouseState : short { | 83 | enum MouseState : short { | ||
50 | None = 0, // 0000 | 84 | None = 0, // 0000 | ||
51 | Inside = 1 << 0, // 0001 | 85 | Inside = 1 << 0, // 0001 | ||
52 | Outside = 1 << 1, // 0010 | 86 | Outside = 1 << 1, // 0010 | ||
53 | TopLeft = 5, //101 | 87 | TopLeft = 5, //101 | ||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | |||||
124 | QFont mMidHelpTextFont; | 158 | QFont mMidHelpTextFont; | ||
125 | std::pair<QStaticText, std::vector<QStaticText>> mBottomHelpText[bottomHelpMaxLength]; | 159 | std::pair<QStaticText, std::vector<QStaticText>> mBottomHelpText[bottomHelpMaxLength]; | ||
126 | QFont mBottomHelpTextFont; | 160 | QFont mBottomHelpTextFont; | ||
127 | QRect mBottomHelpBorderBox; | 161 | QRect mBottomHelpBorderBox; | ||
128 | QPoint mBottomHelpContentPos; | 162 | QPoint mBottomHelpContentPos; | ||
129 | int mBottomHelpGridLeftWidth; | 163 | int mBottomHelpGridLeftWidth; | ||
130 | MouseState mMouseDragState; | 164 | MouseState mMouseDragState; | ||
131 | QPixmap mPixmap; | 165 | QPixmap mPixmap; | ||
132 | qreal dprI; | 166 | qreal devicePixelRatio; | ||
167 | qreal devicePixelRatioI; | ||||
133 | QPointF mMousePos; | 168 | QPointF mMousePos; | ||
134 | bool mMagnifierAllowed; | 169 | bool mMagnifierAllowed; | ||
135 | bool mShowMagnifier; | 170 | bool mShowMagnifier; | ||
136 | bool mToggleMagnifier; | 171 | bool mToggleMagnifier; | ||
137 | bool mReleaseToCapture; | 172 | bool mReleaseToCapture; | ||
138 | bool mRememberRegion; | 173 | bool mRememberRegion; | ||
139 | bool mDisableArrowKeys; | 174 | bool mDisableArrowKeys; | ||
140 | QRect mPrimaryScreenGeo; | 175 | QRect mPrimaryScreenGeo; | ||
141 | int mbottomHelpLength; | 176 | int mbottomHelpLength; | ||
177 | QRegion mScreenRegion; | ||||
178 | bool inWayland = false; | ||||
142 | 179 | | |||
143 | // Midpoints of handles | 180 | // Midpoints of handles | ||
144 | QVector<QPointF> mHandlePositions = QVector<QPointF> {8}; | 181 | QVector<QPointF> mHandlePositions = QVector<QPointF> {8}; | ||
145 | // Radius of handles is either handleRadiusMouse or handleRadiusTouch | 182 | // Radius of handles is either handleRadiusMouse or handleRadiusTouch | ||
146 | int mHandleRadius; | 183 | int mHandleRadius; | ||
147 | 184 | | |||
185 | KScreen::ConfigPtr mScreenConfiguration; | ||||
186 | QMap<ComparableQPoint, OuputInfo> mRects; | ||||
148 | Q_SIGNALS: | 187 | Q_SIGNALS: | ||
149 | 188 | | |||
150 | void grabDone(const QPixmap &thePixmap); | 189 | void grabDone(const QPixmap &thePixmap); | ||
151 | void grabCancelled(); | 190 | void grabCancelled(); | ||
191 | | ||||
192 | private: | ||||
193 | | ||||
194 | QMap<ComparableQPoint, OuputInfo> computeCoordinatesAfterScaling(QMap<ComparableQPoint, QPair<qreal, QSize>> outputsRect); | ||||
195 | | ||||
196 | void preparePaint(); | ||||
152 | }; | 197 | }; | ||
153 | 198 | | |||
154 | #endif // QUICKEDITOR_H | 199 | #endif // QUICKEDITOR_H |