QPixmap LDesktopBackground::setBackground(const QString& bgFile, const QString& format, QRect geom) { //if (bgPixmap != NULL) delete bgPixmap; QPixmap bgPixmap(geom.size());// = new QPixmap(size()); if (bgFile.startsWith("rgb(")) { QStringList colors = bgFile.section(")",0,0).section("(",1,1).split(","); QColor color = QColor(colors[0].toInt(), colors[1].toInt(), colors[2].toInt()); bgPixmap.fill(color); } else { bgPixmap.fill(Qt::black); // Load the background file and scale QPixmap bgImage(bgFile); if (format == "stretch" || format == "full" || format == "fit") { Qt::AspectRatioMode mode; if (format == "stretch") { mode = Qt::IgnoreAspectRatio; } else if (format == "full") { mode = Qt::KeepAspectRatioByExpanding; } else { mode = Qt::KeepAspectRatio; } if(bgImage.height() != geom.height() && bgImage.width() != geom.width() ){ bgImage = bgImage.scaled(geom.size(), mode, Qt::SmoothTransformation); } //bgImage = bgImage.scaled(size(), mode); } // Calculate the offset int dx = 0, dy = 0; int drawWidth = bgImage.width(), drawHeight = bgImage.height(); if (format == "fit" || format == "center" || format == "full") { dx = (geom.width() - bgImage.width()) / 2; dy = (geom.height() - bgImage.height()) / 2; } else if (format == "tile") { drawWidth = geom.width(); drawHeight = geom.height(); } else { if (format.endsWith("right")) { dx = geom.width() - bgImage.width(); } if (format.startsWith("bottom")) { dy = geom.height() - bgImage.height(); } } // Draw the background image QPainter painter(&bgPixmap); painter.setBrush(bgImage); painter.setBrushOrigin(dx, dy); painter.drawRect(dx, dy, drawWidth, drawHeight); } //this->repaint(); //make sure the entire thing gets repainted right away //LSession::handle()->XCB->paintRoot(geom, &bgPixmap); return bgPixmap; //show(); }
void Letter::showLetter() { letterEdit = new QTextEdit(this); letterEdit->setReadOnly(true); letterEdit->setAlignment(Qt::AlignHCenter); letterEdit->setFontPointSize(12); QPalette bgPalette; QPixmap bgPixmap(":/data/letter.png"); bgPalette.setBrush(QPalette::Base, QBrush(bgPixmap)); letterEdit->setPalette(bgPalette); letterTimer = new QTimer(this); connect(letterTimer, SIGNAL(timeout()), this, SLOT(appendLetter())); this->layout()->addWidget(letterEdit); letterTimer->start(200); keySequence.clear(); connect(this, SIGNAL(keyMatched(QByteArray)), this, SLOT(fireworks())); }
SplashScreen::SplashScreen(QWidget *parent) : QWidget(parent) { QRect rec = QApplication::desktop()->screenGeometry(); int screenWidth = rec.width(); int screenHeight = rec.height(); this->setWindowFlags(Qt::FramelessWindowHint); this->setGeometry(0,screenHeight/2-150,screenWidth,300); QPixmap bgPixmap(screenWidth,300); QLinearGradient bgGradient(QPointF(0, 0), QPointF(screenWidth, 0)); bgGradient.setColorAt(0, QColor("#6c3d94")); bgGradient.setColorAt(1, QColor("#a13469")); //#3c3c3b QRect rect_linear(0,0,screenWidth,300); QPainter *painter = new QPainter(&bgPixmap); painter->fillRect(rect_linear, bgGradient); painter->end(); bg = new QLabel(this); bg->setPixmap(bgPixmap); bg->setGeometry(0,0,screenWidth,300); splashImage = new QLabel(this); QPixmap newPixmap; if(GetBoolArg("-testnet")) { newPixmap.load(":/images/splash_testnet"); } else { newPixmap.load(":/images/splash"); } splashImage->setPixmap(newPixmap); splashImage->move(screenWidth/2-567/2,50); QFont smallFont; smallFont.setPixelSize(12); versionLabel = new QLabel(this); versionLabel->setStyleSheet("QLabel { color: #3C3C3B; }"); versionLabel->setFont(smallFont); versionLabel->setText(QString::fromStdString(FormatFullVersion()).split("-")[0]); versionLabel->setFixedSize(1000,30); versionLabel->move(screenWidth/2-108,220); QFont largeFont; largeFont.setPixelSize(20); label = new QLabel(this); label->setStyleSheet("QLabel { color: #FFFFFF; }"); label->setFont(largeFont); label->setText("..."); label->setFixedSize(1000,30); label->move(screenWidth/2-108,260); }