// Set the background // NOTE: The background is controlled by Qt because setting it as a CSS background is too slow void On::setWallpaper() { GSettings *backgroundSettings = g_settings_new("org.gnome.desktop.background"); QString bg = QUrl::fromEncoded(g_variant_get_string(g_settings_get_value(backgroundSettings, "picture-uri"), 0)).toString(); QPalette p = palette(); QRect rect = this->rect(); if (!bg.isEmpty()) { bg = bg.remove("file://"); QPixmap background(QFileInfo(bg).canonicalFilePath()); if (background.isNull()) { background = QPixmap("/usr/share/themes/Asturix/backgrounds/asturix4.jpg"); } QSize size(rect.width(), rect.height()); QPixmap pixmap(background.scaledToWidth(size.width(), Qt::SmoothTransformation)); //QPixmap pixmap(background.scaled(size, Qt::KeepAspectRatio)); //QPixmap pixmap(background.scaled(size)); p.setBrush(QPalette::Background, pixmap); // TODO: Modes. picture-options: zoom, fill, span, scale, center, tile } else { QColor primColor(g_variant_get_string(g_settings_get_value(backgroundSettings, "primary-color"), 0)); qDebug(g_variant_get_string(g_settings_get_value(backgroundSettings, "primary-color"), 0)); QColor secColor(g_variant_get_string(g_settings_get_value(backgroundSettings, "secondary-color"), 0)); QString mode = QString(g_variant_get_string(g_settings_get_value(backgroundSettings, "color-shading-type"), 0)); QBrush brush; if (mode == "solid") { brush = QBrush(primColor); } else if (mode == "vertical") { QLinearGradient grad(QPointF(0, 0), QPointF(0, rect.height())); grad.setColorAt(0, primColor); grad.setColorAt(1, secColor); brush = QBrush(grad); } else { QLinearGradient grad(QPointF(0, 0), QPointF(rect.width(), 0)); grad.setColorAt(0, primColor); grad.setColorAt(1, secColor); brush = QBrush(grad); } p.setBrush(QPalette::Background, brush); } setPalette(p); p.setBrush(QPalette::Base, Qt::transparent); page()->setPalette(p); setAttribute(Qt::WA_OpaquePaintEvent, false); g_object_unref(backgroundSettings); }
void DebugDrawer::render() { #ifdef ENABLE_DEBUGDRAW if(!isDrawing) return; if (!mRenderZOnSB) { setupStateBlocks(); String fontCacheDir = Con::getVariable("$GUI::fontCacheDirectory"); mFont = GFont::create("Arial", 12, fontCacheDir); } SimTime curTime = Sim::getCurrentTime(); GFX->disableShaders(); for(DebugPrim **walk = &mHead; *walk; ) { DebugPrim *p = *walk; // Set up Z testing... if(p->useZ) GFX->setStateBlock(mRenderZOnSB); else GFX->setStateBlock(mRenderZOffSB); Point3F d; switch(p->type) { case DebugPrim::Tri: PrimBuild::begin( GFXLineStrip, 4); PrimBuild::color(p->color); PrimBuild::vertex3fv(p->a); PrimBuild::vertex3fv(p->b); PrimBuild::vertex3fv(p->c); PrimBuild::vertex3fv(p->a); PrimBuild::end(); break; case DebugPrim::Box: d = p->a - p->b; GFX->getDrawUtil()->drawWireCube(d * 0.5, (p->a + p->b) * 0.5, p->color); break; case DebugPrim::Line: PrimBuild::begin( GFXLineStrip, 2); PrimBuild::color(p->color); PrimBuild::vertex3fv(p->a); PrimBuild::vertex3fv(p->b); PrimBuild::end(); break; case DebugPrim::Text: { GFXTransformSaver saver; Point3F result; if (MathUtils::mProjectWorldToScreen(p->a, &result, GFX->getViewport(), GFX->getWorldMatrix(), GFX->getProjectionMatrix())) { GFX->setClipRect(GFX->getViewport()); ColorI primColor(p->color.red * 255.0f, p->color.blue * 255.0f, p->color.green * 255.0f, p->color.alpha * 255.0f); GFX->getDrawUtil()->drawText(mFont, Point2I(result.x, result.y), p->mText, &primColor); } } break; } // Ok, we've got data, now freeze here if needed. if (shouldToggleFreeze) { isFrozen = !isFrozen; shouldToggleFreeze = false; } if(p->dieTime <= curTime && !isFrozen && p->dieTime != U32_MAX) { *walk = p->next; mPrimChunker.free(p); } else walk = &((*walk)->next); } #endif }