Changeset View
Changeset View
Standalone View
Standalone View
effects/cube/cube.cpp
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | 50 | CubeEffect::CubeEffect() | |||
---|---|---|---|---|---|
86 | , useShaders(false) | 86 | , useShaders(false) | ||
87 | , cylinderShader(0) | 87 | , cylinderShader(0) | ||
88 | , sphereShader(0) | 88 | , sphereShader(0) | ||
89 | , zOrderingFactor(0.0f) | 89 | , zOrderingFactor(0.0f) | ||
90 | , mAddedHeightCoeff1(0.0f) | 90 | , mAddedHeightCoeff1(0.0f) | ||
91 | , mAddedHeightCoeff2(0.0f) | 91 | , mAddedHeightCoeff2(0.0f) | ||
92 | , m_cubeCapBuffer(NULL) | 92 | , m_cubeCapBuffer(NULL) | ||
93 | , m_proxy(this) | 93 | , m_proxy(this) | ||
94 | , m_cubeAction(new QAction(this)) | ||||
95 | , m_cylinderAction(new QAction(this)) | ||||
96 | , m_sphereAction(new QAction(this)) | ||||
94 | { | 97 | { | ||
95 | desktopNameFont.setBold(true); | 98 | desktopNameFont.setBold(true); | ||
96 | desktopNameFont.setPointSize(14); | 99 | desktopNameFont.setPointSize(14); | ||
97 | 100 | | |||
98 | if (effects->compositingType() == OpenGL2Compositing) { | 101 | if (effects->compositingType() == OpenGL2Compositing) { | ||
99 | m_reflectionShader = ShaderManager::instance()->generateShaderFromResources(ShaderTrait::MapTexture, QString(), QStringLiteral("cube-reflection.glsl")); | 102 | m_reflectionShader = ShaderManager::instance()->generateShaderFromResources(ShaderTrait::MapTexture, QString(), QStringLiteral("cube-reflection.glsl")); | ||
100 | m_capShader = ShaderManager::instance()->generateShaderFromResources(ShaderTrait::MapTexture, QString(), QStringLiteral("cube-cap.glsl")); | 103 | m_capShader = ShaderManager::instance()->generateShaderFromResources(ShaderTrait::MapTexture, QString(), QStringLiteral("cube-cap.glsl")); | ||
101 | } else { | 104 | } else { | ||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 123 | { | |||
179 | timeLine.setCurveShape(QTimeLine::EaseInOutCurve); | 182 | timeLine.setCurveShape(QTimeLine::EaseInOutCurve); | ||
180 | timeLine.setDuration(rotationDuration); | 183 | timeLine.setDuration(rotationDuration); | ||
181 | 184 | | |||
182 | verticalTimeLine.setCurveShape(QTimeLine::EaseInOutCurve); | 185 | verticalTimeLine.setCurveShape(QTimeLine::EaseInOutCurve); | ||
183 | verticalTimeLine.setDuration(rotationDuration); | 186 | verticalTimeLine.setDuration(rotationDuration); | ||
184 | 187 | | |||
185 | // do not connect the shortcut if we use cylinder or sphere | 188 | // do not connect the shortcut if we use cylinder or sphere | ||
186 | if (!shortcutsRegistered) { | 189 | if (!shortcutsRegistered) { | ||
187 | QAction* cubeAction = new QAction(this); | 190 | QAction* cubeAction = m_cubeAction; | ||
188 | cubeAction->setObjectName(QStringLiteral("Cube")); | 191 | cubeAction->setObjectName(QStringLiteral("Cube")); | ||
189 | cubeAction->setText(i18n("Desktop Cube")); | 192 | cubeAction->setText(i18n("Desktop Cube")); | ||
190 | KGlobalAccel::self()->setDefaultShortcut(cubeAction, QList<QKeySequence>() << Qt::CTRL + Qt::Key_F11); | 193 | KGlobalAccel::self()->setDefaultShortcut(cubeAction, QList<QKeySequence>() << Qt::CTRL + Qt::Key_F11); | ||
191 | KGlobalAccel::self()->setShortcut(cubeAction, QList<QKeySequence>() << Qt::CTRL + Qt::Key_F11); | 194 | KGlobalAccel::self()->setShortcut(cubeAction, QList<QKeySequence>() << Qt::CTRL + Qt::Key_F11); | ||
192 | effects->registerGlobalShortcut(Qt::CTRL + Qt::Key_F11, cubeAction); | 195 | effects->registerGlobalShortcut(Qt::CTRL + Qt::Key_F11, cubeAction); | ||
193 | effects->registerPointerShortcut(Qt::ControlModifier | Qt::AltModifier, Qt::LeftButton, cubeAction); | 196 | effects->registerPointerShortcut(Qt::ControlModifier | Qt::AltModifier, Qt::LeftButton, cubeAction); | ||
194 | cubeShortcut = KGlobalAccel::self()->shortcut(cubeAction); | 197 | cubeShortcut = KGlobalAccel::self()->shortcut(cubeAction); | ||
195 | QAction* cylinderAction = new QAction(this); | 198 | QAction* cylinderAction = m_cylinderAction; | ||
196 | cylinderAction->setObjectName(QStringLiteral("Cylinder")); | 199 | cylinderAction->setObjectName(QStringLiteral("Cylinder")); | ||
197 | cylinderAction->setText(i18n("Desktop Cylinder")); | 200 | cylinderAction->setText(i18n("Desktop Cylinder")); | ||
198 | KGlobalAccel::self()->setShortcut(cylinderAction, QList<QKeySequence>()); | 201 | KGlobalAccel::self()->setShortcut(cylinderAction, QList<QKeySequence>()); | ||
199 | effects->registerGlobalShortcut(QKeySequence(), cylinderAction); | 202 | effects->registerGlobalShortcut(QKeySequence(), cylinderAction); | ||
200 | cylinderShortcut = KGlobalAccel::self()->shortcut(cylinderAction); | 203 | cylinderShortcut = KGlobalAccel::self()->shortcut(cylinderAction); | ||
201 | QAction* sphereAction = new QAction(this); | 204 | QAction* sphereAction = m_sphereAction; | ||
202 | sphereAction->setObjectName(QStringLiteral("Sphere")); | 205 | sphereAction->setObjectName(QStringLiteral("Sphere")); | ||
203 | sphereAction->setText(i18n("Desktop Sphere")); | 206 | sphereAction->setText(i18n("Desktop Sphere")); | ||
204 | KGlobalAccel::self()->setShortcut(sphereAction, QList<QKeySequence>()); | 207 | KGlobalAccel::self()->setShortcut(sphereAction, QList<QKeySequence>()); | ||
205 | sphereShortcut = KGlobalAccel::self()->shortcut(sphereAction); | 208 | sphereShortcut = KGlobalAccel::self()->shortcut(sphereAction); | ||
206 | effects->registerGlobalShortcut(QKeySequence(), sphereAction); | 209 | effects->registerGlobalShortcut(QKeySequence(), sphereAction); | ||
207 | connect(cubeAction, SIGNAL(triggered(bool)), this, SLOT(toggleCube())); | 210 | connect(cubeAction, SIGNAL(triggered(bool)), this, SLOT(toggleCube())); | ||
208 | connect(cylinderAction, SIGNAL(triggered(bool)), this, SLOT(toggleCylinder())); | 211 | connect(cylinderAction, SIGNAL(triggered(bool)), this, SLOT(toggleCylinder())); | ||
209 | connect(sphereAction, SIGNAL(triggered(bool)), this, SLOT(toggleSphere())); | 212 | connect(sphereAction, SIGNAL(triggered(bool)), this, SLOT(toggleSphere())); | ||
210 | connect(KGlobalAccel::self(), &KGlobalAccel::globalShortcutChanged, this, &CubeEffect::globalShortcutChanged); | 213 | connect(KGlobalAccel::self(), &KGlobalAccel::globalShortcutChanged, this, &CubeEffect::globalShortcutChanged); | ||
211 | shortcutsRegistered = true; | 214 | shortcutsRegistered = true; | ||
212 | } | 215 | } | ||
213 | 216 | | |||
214 | // set the cap color on the shader | 217 | // set the cap color on the shader | ||
215 | if (m_capShader && m_capShader->isValid()) { | 218 | if (m_capShader && m_capShader->isValid()) { | ||
216 | ShaderBinder binder(m_capShader); | 219 | ShaderBinder binder(m_capShader); | ||
217 | m_capShader->setUniform(GLShader::Color, capColor); | 220 | m_capShader->setUniform(GLShader::Color, capColor); | ||
218 | } | 221 | } | ||
222 | | ||||
223 | // touch borders | ||||
224 | const QVector<ElectricBorder> relevantBorders{ElectricLeft, ElectricTop, ElectricRight, ElectricBottom}; | ||||
225 | for (auto e : relevantBorders) { | ||||
226 | effects->unregisterTouchBorder(e, m_cubeAction); | ||||
227 | effects->unregisterTouchBorder(e, m_sphereAction); | ||||
228 | effects->unregisterTouchBorder(e, m_cylinderAction); | ||||
229 | } | ||||
230 | auto touchEdge = [] (const QList<int> touchBorders, QAction *action) { | ||||
231 | for (int i : touchBorders) { | ||||
232 | effects->registerTouchBorder(ElectricBorder(i), action); | ||||
233 | } | ||||
234 | }; | ||||
235 | touchEdge(CubeConfig::touchBorderActivate(), m_cubeAction); | ||||
236 | touchEdge(CubeConfig::touchBorderActivateCylinder(), m_cylinderAction); | ||||
237 | touchEdge(CubeConfig::touchBorderActivateSphere(), m_sphereAction); | ||||
219 | } | 238 | } | ||
220 | 239 | | |||
221 | CubeEffect::~CubeEffect() | 240 | CubeEffect::~CubeEffect() | ||
222 | { | 241 | { | ||
223 | delete wallpaper; | 242 | delete wallpaper; | ||
224 | delete capTexture; | 243 | delete capTexture; | ||
225 | delete cylinderShader; | 244 | delete cylinderShader; | ||
226 | delete sphereShader; | 245 | delete sphereShader; | ||
▲ Show 20 Lines • Show All 1672 Lines • Show Last 20 Lines |