Ticket #4364: scaleMax.diff

File scaleMax.diff, 2.9 KB (added by Joep Admiraal, 12 years ago)

1st version of the scalemax patch.

  • mythgallery/mythgallery/gallerysettings.cpp

     
    3434    return gc;
    3535};
    3636
     37static HostCheckBox *MythGalleryScaleMax()
     38{
     39    HostCheckBox *gc = new HostCheckBox("GalleryScaleMax");
     40    gc->setLabel(QObject::tr("Scale Max"));
     41    gc->setValue(true);
     42    gc->setHelpText(QObject::tr("If set, images are scaled to fill the whole screen. If cleared, they are scaled to fit in the screen."));
     43    return gc;
     44};
     45
    3746static HostComboBox *MythGallerySortOrder()
    3847{
    3948    HostComboBox *gc = new HostComboBox("GallerySortOrder");
     
    215224    general->setLabel(QObject::tr("MythGallery Settings (General)"));
    216225    general->addChild(MythGalleryDir());
    217226    general->addChild(MythGalleryThumbnailLocation());
     227    general->addChild(MythGalleryScaleMax());
    218228    general->addChild(MythGallerySortOrder());
    219229    general->addChild(MythGalleryImportDirs());
    220230    general->addChild(MythGalleryMoviePlayerCmd());
  • mythgallery/mythgallery/galleryutil.cpp

     
    409409    if ((sz.width() > 0) && (sz.height() > 0))
    410410        imageAspect = (double)sz.width() / (double)sz.height();
    411411
    412     // scale to dest height for most images
    413     int scalewidth = (int)((float)dest.height() * imageAspect / pixelAspect);
    414     int scaleheight = dest.height();
    415     if (scalewidth > dest.width())
     412    int scaleWidth;
     413    int scaleHeight;
     414    if (gContext->GetNumSetting("GalleryScaleMax", 0))
    416415    {
    417         // scale to dest width for extra wide images
    418         scalewidth = dest.width();
    419         scaleheight = (int)((float)dest.width() * pixelAspect / imageAspect);
     416        // scale-max to dest width for most images
     417        scaleWidth = dest.width();
     418        scaleHeight = (int)((float)dest.width() * pixelAspect / imageAspect);
     419        if (scaleHeight < dest.height())
     420        {
     421            // scale-max to dest height for extra wide images
     422            scaleWidth = (int)((float)dest.height() * imageAspect / pixelAspect);
     423            scaleHeight = dest.height();
     424        }
    420425    }
     426    else
     427    {
     428        // scale-min to dest height for most images
     429        scaleWidth = (int)((float)dest.height() * imageAspect / pixelAspect);
     430        scaleHeight = dest.height();
     431        if (scaleWidth > dest.width())
     432        {
     433            // scale-min to dest width for extra wide images
     434            scaleWidth = dest.width();
     435            scaleHeight = (int)((float)dest.width() * pixelAspect / imageAspect);
     436        }
     437    }
    421438
    422     sz.scale(scalewidth, scaleheight, QSize::ScaleFree);
     439    sz.scale(scaleWidth, scaleHeight, QSize::ScaleFree);
    423440    return sz;
    424441}
    425442