Changeset View
Changeset View
Standalone View
Standalone View
effects/windowgeometry/windowgeometry.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 41 | #define myResizeString "Window geometry display, %1 and %2 are the new size," \ | |||
---|---|---|---|---|---|
43 | "Width: %1 (%3)\nHeight: %2 (%4)" | 43 | "Width: %1 (%3)\nHeight: %2 (%4)" | ||
44 | #define myCoordString_0 "Window geometry display, %1 and %2 are the cartesian x and y coordinates" \ | 44 | #define myCoordString_0 "Window geometry display, %1 and %2 are the cartesian x and y coordinates" \ | ||
45 | " - avoid reformatting or suffixes like 'px'", \ | 45 | " - avoid reformatting or suffixes like 'px'", \ | ||
46 | "X: %1\nY: %2" | 46 | "X: %1\nY: %2" | ||
47 | #define myCoordString_1 "Window geometry display, %1 and %2 are the cartesian x and y coordinates," \ | 47 | #define myCoordString_1 "Window geometry display, %1 and %2 are the cartesian x and y coordinates," \ | ||
48 | " %3 and %4 are the resp. increments - avoid reformatting or suffixes like 'px'", \ | 48 | " %3 and %4 are the resp. increments - avoid reformatting or suffixes like 'px'", \ | ||
49 | "X: %1 (%3)\nY: %2 (%4)" | 49 | "X: %1 (%3)\nY: %2 (%4)" | ||
50 | reconfigure(ReconfigureAll); | 50 | reconfigure(ReconfigureAll); | ||
51 | QFont fnt; fnt.setBold(true); fnt.setPointSize(12); | | |||
52 | for (int i = 0; i < 3; ++i) { | | |||
53 | myMeasure[i] = effects->effectFrame(EffectFrameUnstyled, false); | | |||
54 | myMeasure[i]->setFont(fnt); | | |||
55 | } | | |||
56 | myMeasure[0]->setAlignment(Qt::AlignLeft | Qt::AlignTop); | | |||
57 | myMeasure[1]->setAlignment(Qt::AlignCenter); | | |||
58 | myMeasure[2]->setAlignment(Qt::AlignRight | Qt::AlignBottom); | | |||
59 | | ||||
60 | QAction* a = new QAction(this); | 51 | QAction* a = new QAction(this); | ||
61 | a->setObjectName(QStringLiteral("WindowGeometry")); | 52 | a->setObjectName(QStringLiteral("WindowGeometry")); | ||
62 | a->setText(i18n("Toggle window geometry display (effect only)")); | 53 | a->setText(i18n("Toggle window geometry display (effect only)")); | ||
63 | 54 | | |||
64 | KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::CTRL + Qt::SHIFT + Qt::Key_F11); | 55 | KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << Qt::CTRL + Qt::SHIFT + Qt::Key_F11); | ||
65 | KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::CTRL + Qt::SHIFT + Qt::Key_F11); | 56 | KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << Qt::CTRL + Qt::SHIFT + Qt::Key_F11); | ||
66 | effects->registerGlobalShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_F11, a); | 57 | effects->registerGlobalShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_F11, a); | ||
67 | 58 | | |||
68 | connect(a, SIGNAL(triggered(bool)), this, SLOT(toggle())); | 59 | connect(a, SIGNAL(triggered(bool)), this, SLOT(toggle())); | ||
69 | 60 | | |||
70 | connect(effects, SIGNAL(windowStartUserMovedResized(KWin::EffectWindow*)), this, SLOT(slotWindowStartUserMovedResized(KWin::EffectWindow*))); | 61 | connect(effects, SIGNAL(windowStartUserMovedResized(KWin::EffectWindow*)), this, SLOT(slotWindowStartUserMovedResized(KWin::EffectWindow*))); | ||
71 | connect(effects, SIGNAL(windowFinishUserMovedResized(KWin::EffectWindow*)), this, SLOT(slotWindowFinishUserMovedResized(KWin::EffectWindow*))); | 62 | connect(effects, SIGNAL(windowFinishUserMovedResized(KWin::EffectWindow*)), this, SLOT(slotWindowFinishUserMovedResized(KWin::EffectWindow*))); | ||
72 | connect(effects, SIGNAL(windowStepUserMovedResized(KWin::EffectWindow*,QRect)), this, SLOT(slotWindowStepUserMovedResized(KWin::EffectWindow*,QRect))); | 63 | connect(effects, SIGNAL(windowStepUserMovedResized(KWin::EffectWindow*,QRect)), this, SLOT(slotWindowStepUserMovedResized(KWin::EffectWindow*,QRect))); | ||
73 | } | 64 | } | ||
74 | 65 | | |||
75 | WindowGeometry::~WindowGeometry() | 66 | WindowGeometry::~WindowGeometry() | ||
76 | { | 67 | { | ||
77 | for (int i = 0; i < 3; ++i) | 68 | for (int i = 0; i < 3; ++i) | ||
78 | delete myMeasure[i]; | 69 | delete myMeasure[i]; | ||
79 | } | 70 | } | ||
80 | 71 | | |||
72 | void WindowGeometry::createFrames() | ||||
73 | { | ||||
74 | if (myMeasure[0]) { | ||||
75 | return; | ||||
76 | } | ||||
77 | QFont fnt; fnt.setBold(true); fnt.setPointSize(12); | ||||
78 | for (int i = 0; i < 3; ++i) { | ||||
79 | myMeasure[i] = effects->effectFrame(EffectFrameUnstyled, false); | ||||
80 | myMeasure[i]->setFont(fnt); | ||||
81 | } | ||||
82 | myMeasure[0]->setAlignment(Qt::AlignLeft | Qt::AlignTop); | ||||
83 | myMeasure[1]->setAlignment(Qt::AlignCenter); | ||||
84 | myMeasure[2]->setAlignment(Qt::AlignRight | Qt::AlignBottom); | ||||
85 | | ||||
86 | } | ||||
87 | | ||||
81 | void WindowGeometry::reconfigure(ReconfigureFlags) | 88 | void WindowGeometry::reconfigure(ReconfigureFlags) | ||
82 | { | 89 | { | ||
83 | WindowGeometryConfiguration::self()->read(); | 90 | WindowGeometryConfiguration::self()->read(); | ||
84 | iHandleMoves = WindowGeometryConfiguration::move(); | 91 | iHandleMoves = WindowGeometryConfiguration::move(); | ||
85 | iHandleResizes = WindowGeometryConfiguration::resize(); | 92 | iHandleResizes = WindowGeometryConfiguration::resize(); | ||
86 | } | 93 | } | ||
87 | 94 | | |||
88 | void WindowGeometry::paintScreen(int mask, QRegion region, ScreenPaintData &data) | 95 | void WindowGeometry::paintScreen(int mask, QRegion region, ScreenPaintData &data) | ||
89 | { | 96 | { | ||
90 | effects->paintScreen(mask, region, data); | 97 | effects->paintScreen(mask, region, data); | ||
91 | if (iAmActivated && iAmActive) { | 98 | if (iAmActivated && iAmActive) { | ||
92 | for (int i = 0; i < 3; ++i) | 99 | for (int i = 0; i < 3; ++i) | ||
93 | myMeasure[i]->render(infiniteRegion(), 1.0, .66); | 100 | myMeasure[i]->render(infiniteRegion(), 1.0, .66); | ||
94 | } | 101 | } | ||
95 | } | 102 | } | ||
96 | 103 | | |||
97 | void WindowGeometry::toggle() | 104 | void WindowGeometry::toggle() | ||
98 | { | 105 | { | ||
99 | iAmActivated = !iAmActivated; | 106 | iAmActivated = !iAmActivated; | ||
107 | createFrames(); | ||||
100 | } | 108 | } | ||
101 | 109 | | |||
102 | void WindowGeometry::slotWindowStartUserMovedResized(EffectWindow *w) | 110 | void WindowGeometry::slotWindowStartUserMovedResized(EffectWindow *w) | ||
103 | { | 111 | { | ||
104 | if (!iAmActivated) | 112 | if (!iAmActivated) | ||
105 | return; | 113 | return; | ||
106 | if (w->isUserResize() && !iHandleResizes) | 114 | if (w->isUserResize() && !iHandleResizes) | ||
107 | return; | 115 | return; | ||
108 | if (w->isUserMove() && !iHandleMoves) | 116 | if (w->isUserMove() && !iHandleMoves) | ||
109 | return; | 117 | return; | ||
110 | 118 | | |||
119 | createFrames(); | ||||
111 | iAmActive = true; | 120 | iAmActive = true; | ||
112 | myResizeWindow = w; | 121 | myResizeWindow = w; | ||
113 | myOriginalGeometry = w->geometry(); | 122 | myOriginalGeometry = w->geometry(); | ||
114 | myCurrentGeometry = w->geometry(); | 123 | myCurrentGeometry = w->geometry(); | ||
115 | slotWindowStepUserMovedResized(w, w->geometry()); | 124 | slotWindowStepUserMovedResized(w, w->geometry()); | ||
116 | } | 125 | } | ||
117 | 126 | | |||
118 | void WindowGeometry::slotWindowFinishUserMovedResized(EffectWindow *w) | 127 | void WindowGeometry::slotWindowFinishUserMovedResized(EffectWindow *w) | ||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |