From 5868f102f25c3f4e96936d2419871cfc24fa97a0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 26 Aug 2019 16:49:58 +0200 Subject: [PATCH 1/3] [packagechooser] Less-bad "no selection" image - It's only "less bad", not actually a good image, composed from Breeze "empty" and "generic packages" icon. --- .../packagechooser/images/no-selection.png | Bin 4618 -> 1709 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/modules/packagechooser/images/no-selection.png b/src/modules/packagechooser/images/no-selection.png index f9dbbbac45d0b03667f66be54664fdc5dce71983..437c97051cb9d0d16049ebff1bdc6cffe1ddb8a1 100644 GIT binary patch literal 1709 zcmd^9`BT$J6yI+Mm;eGwXF}Bmt1XNpBzR(_K&+I2q~Mi7DuE~pB4VhN5+g^zY7a)x zVW`mn83v2+MFcD01kJ$!MwF{k2#|vY6ha_`1QG~G(jdx@{RiBco%i-#`}yp=eZL(J zC9bvIU<&|P8ypmH6adJgLI7oB5s{b5V=V%m6cmvRfJ5{0h6=VjYy`k2Iym6KaeARz zCP<)+ekRgtZl#^wbnIYo@RlT1W9~M2Vav^+WA^G^|IM=3^dAyMGIj}$VoTl{caF{2 zc1Gh$ZFsTm3vw{JrK`ED-7)4nTbGwDm^V;A_07PrCZ=#V3^B9hqOy$mvhv`Z6vZ1|E1k zUcQk=i60rCJ05~$i2ceXM2GgJ3yF#9i{bBRcdm0cw= z(mEm5B~PRlaWa0&JgZl=JNh@IEXwKQhsZ^hx%t90F=l^y>=PJas*=^vHCPJLl`ErN?+r{u4f*Yc!51T1rLO3sU2ot2l9IO2(h{z9-2k z#-VG+?Cj)*rkfrf9{;?}!Gw}~FjwkwI-owjB3xAL%Scl7Ks-r5+s9&^bQT(985-j$ z7QfcpCr{ap1asHd0hAkXB7w~;K=6W?R0L>5f^0NEI)5~dzN`p5leo}5IN8BK=T*hS z8FPz64{kSZMG2Wp+D`L?nj0QLXu*gQK1RxeKyCaWawCxinCh3d85$ z7GNr2mCi8C6VJ>%o3M6Xi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A!WC8d&?XQDO#rj~Xw7%kBJ%%&ikr6!gLpfwO} z`JG}8I3q1c7n&GV>EaimIo0DY5!H3Vrc0~%1?YbmC^=7^RCLp-B~#i!x7vQ!-$3-? z4(R?fLcU(?{`TFWB1C>E)FDq?p8a2{VxGW3dK^og3rn3Ec}%+)*Zb4dKwVP4FPT0{ z(sTbj`%&u;*PmMdO<2hl*T}A)b}68YsYM~@Z7&>Ri~lbKV~h8oTPs&es%@TqNqI2+ zTk}6X5|aYA;&P^hx+x%asGmm0Nu*&T@N*~u>2bS*wBlb=!Xf)g^3^{UAforW$6+q@ z0Fmg4Kg*fz#R>Ur?_Rk zSM;?WC6+b)P}s}|DXjt%4bir1*q~~YYPqDUN3bUXKZXjaa%@!jiFZWwtsnaM^_k_r zmIDCFS|L3@Ejw;%uAUjR?et_<05xev_osK+fmC$dg?pTQS}Qrx@8_)F0hap-yyE^? zSwt+u5z}Mia$0+c82OvbPsg|*EnXeKur6DVqJN0_U6n(YaE1(X7$sWtJbcFVCEU&{ z$ZdP+3^(3)2%u2$M~%(eRI-{$62jB*6I(ewQLA6LG=8}!0XM!YtDZTn@Wtvy9>}|y zcGgR;T|k|4TJ2W@1gJf8C!cZfbV4ej`YH(VumO$*&y?+anpRc#QE?Xxvv@ zL@cz1fA2A2Ur(P*ee>R*{gra^JA*qY`$*|B%MD^6{M`(513Avh-P2=I6z?piePOsN xBVY5l{veK&2QXRX_CK=1zjxaI)n&&PvHiG~mG*{#Gy8G}7@aoLd#Qtu_z$sg6Py45 From 6035a74a93c070c960c0cd4701a6c6f810bdb30c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 26 Aug 2019 20:34:32 +0200 Subject: [PATCH 2/3] [packagechooser] Align the screenshot - hcenter + vcenter the screenshot - make it expand as necessary - fill in some sample text --- src/modules/packagechooser/page_package.ui | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/modules/packagechooser/page_package.ui b/src/modules/packagechooser/page_package.ui index 17a960549..496c478a1 100644 --- a/src/modules/packagechooser/page_package.ui +++ b/src/modules/packagechooser/page_package.ui @@ -37,21 +37,36 @@ - TextLabel + Product Name + + + 1 + 0 + + TextLabel + + Qt::AlignCenter + + + + 0 + 2 + + - TextLabel + Long Product Description true From d8a587e16e3b45cb99abf289a6c7ec021c0b62c4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 26 Aug 2019 21:40:16 +0200 Subject: [PATCH 3/3] [packagechooser] Scale screenshot - if the screenshot is too large, scale it down - (doesn't react to window resizes though) --- .../packagechooser/PackageChooserPage.cpp | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/modules/packagechooser/PackageChooserPage.cpp b/src/modules/packagechooser/PackageChooserPage.cpp index 6f565c914..f0a6579b4 100644 --- a/src/modules/packagechooser/PackageChooserPage.cpp +++ b/src/modules/packagechooser/PackageChooserPage.cpp @@ -52,6 +52,37 @@ PackageChooserPage::PackageChooserPage( PackageChooserMode mode, QWidget* parent } } +/** @brief size the given @p pixmap to @p size + * + * This is "smart" in the sense that it tries to keep the image un-scaled + * (if it's just a little too big) and otherwise scales as needed. + * + * Returns a copy if any modifications are done. + */ +static QPixmap +smartClip( const QPixmap& pixmap, QSize size ) +{ + auto pixSize = pixmap.size(); + if ( ( pixSize.width() <= size.width() ) && ( pixSize.height() <= size.height() ) ) + { + return pixmap; + } + + // only slightly bigger? Trim the edges + constexpr int margin = 16; + if ( ( pixSize.width() <= size.width() + margin ) && ( pixSize.height() <= size.height() + margin ) ) + { + int x = pixSize.width() <= size.width() ? 0 : ( pixSize.width() - size.width() / 2 ); + int new_width = pixSize.width() <= size.width() ? pixSize.width() : size.width(); + int y = pixSize.height() <= size.height() ? 0 : ( pixSize.height() - size.height() / 2 ); + int new_height = pixSize.height() <= size.height() ? pixSize.height() : size.height(); + + return pixmap.copy( x, y, new_width, new_height ); + } + + return pixmap.scaled( size, Qt::KeepAspectRatio ); +} + void PackageChooserPage::currentChanged( const QModelIndex& index ) { @@ -66,8 +97,17 @@ PackageChooserPage::currentChanged( const QModelIndex& index ) const auto* model = ui->products->model(); ui->productName->setText( model->data( index, PackageListModel::NameRole ).toString() ); - ui->productScreenshot->setPixmap( model->data( index, PackageListModel::ScreenshotRole ).value< QPixmap >() ); ui->productDescription->setText( model->data( index, PackageListModel::DescriptionRole ).toString() ); + + QPixmap currentScreenshot = model->data( index, PackageListModel::ScreenshotRole ).value< QPixmap >(); + if ( currentScreenshot.isNull() ) + { + ui->productScreenshot->setPixmap( m_introduction.screenshot ); + } + else + { + ui->productScreenshot->setPixmap( smartClip( currentScreenshot, ui->productScreenshot->size() ) ); + } } }