aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
authorHenry Hu <henry.hu.sh@gmail.com>2016-05-12 03:45:03 -0400
committerHenry Hu <henry.hu.sh@gmail.com>2016-05-12 03:45:03 -0400
commit8f0f9a0ef707799cef942170243d6bc28a86b577 (patch)
treeff76add4fc5e19071d4283ba8b35848bd204cd63 /src-qt5
parentMerge branch 'master' of github.com:pcbsd/lumina (diff)
downloadlumina-8f0f9a0ef707799cef942170243d6bc28a86b577.tar.gz
lumina-8f0f9a0ef707799cef942170243d6bc28a86b577.tar.bz2
lumina-8f0f9a0ef707799cef942170243d6bc28a86b577.zip
add 2 options for background image: fit and full
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/core-utils/lumina-config/mainUI.cpp2
-rw-r--r--src-qt5/core/lumina-desktop/LDesktop.cpp30
2 files changed, 32 insertions, 0 deletions
diff --git a/src-qt5/core-utils/lumina-config/mainUI.cpp b/src-qt5/core-utils/lumina-config/mainUI.cpp
index 4bf067c5..5062a5ef 100644
--- a/src-qt5/core-utils/lumina-config/mainUI.cpp
+++ b/src-qt5/core-utils/lumina-config/mainUI.cpp
@@ -268,6 +268,8 @@ void MainUI::setupMenus(){
//Available Wallpaper layout options
ui->combo_desk_layout->clear();
ui->combo_desk_layout->addItem(tr("Automatic"), "stretch");
+ ui->combo_desk_layout->addItem(tr("Fullscreen"), "full");
+ ui->combo_desk_layout->addItem(tr("Fit screen"), "fit");
ui->combo_desk_layout->addItem(tr("Tile"), "tile");
ui->combo_desk_layout->addItem(tr("Center"), "center");
ui->combo_desk_layout->addItem(tr("Top Left"), "topleft");
diff --git a/src-qt5/core/lumina-desktop/LDesktop.cpp b/src-qt5/core/lumina-desktop/LDesktop.cpp
index 72b267b0..5f959629 100644
--- a/src-qt5/core/lumina-desktop/LDesktop.cpp
+++ b/src-qt5/core/lumina-desktop/LDesktop.cpp
@@ -509,9 +509,39 @@ void LDesktop::UpdateBackground(){
}else if( format == "bottomleft"){ style = "QWidget#bgWindow{ background: black url(%1); background-position: bottom left; background-repeat: no-repeat; }";
}else if( format == "bottomright"){ style = "QWidget#bgWindow{ background: black url(%1); background-position: bottom right; background-repeat: no-repeat; }";
}else if( format == "tile"){ style = "QWidget#bgWindow{ background-color: black; border-image:url(%1) repeat;}";
+ }else if( format == "full" || format == "fit") { style = "";
}else{ /* STRETCH*/ style = "QWidget#bgWindow{ background-color: black; border-image:url(%1) stretch;}"; }
style = style.arg(bgFile);
bgWindow->setStyleSheet(style);
+ if(!bgFile.startsWith("rgb(") && (format == "full" || format == "fit")){
+ // Load the background file and scale
+ QPixmap background(bgFile);
+ Qt::AspectRatioMode mode;
+ if (format == "full") {
+ mode = Qt::KeepAspectRatioByExpanding;
+ } else {
+ mode = Qt::KeepAspectRatio;
+ }
+ background = background.scaled(bgWindow->size(), mode);
+ // Put the image at the center (for fit)
+ int dx = 0, dy = 0;
+ if (background.width() < bgWindow->width()) {
+ dx = (bgWindow->width() - background.width()) / 2;
+ }
+ if (background.height() < bgWindow->height()) {
+ dy = (bgWindow->height() - background.height()) / 2;
+ }
+ QPixmap fullBg(bgWindow->size());
+ fullBg.fill(Qt::black);
+ QPainter painter(&fullBg);
+ painter.setBrush(background);
+ painter.setBrushOrigin(dx, dy);
+ painter.drawRect(dx, dy, background.width(), background.height());
+ // Set the background
+ QPalette palette;
+ palette.setBrush(QPalette::Background, fullBg);
+ bgWindow->setPalette(palette);
+ }
bgWindow->show();
//Now reset the timer for the next change (if appropriate)
if(bgtimer->isActive()){ bgtimer->stop(); }
bgstack15