VirtualBox

Changeset 67176 in vbox


Ignore:
Timestamp:
May 31, 2017 2:50:59 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
115852
Message:

FE/Qt: Selector UI: Tools pane: Snapshot pane: A bit of HiDPI support for snapshot screenshot code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.cpp

    r67173 r67176  
    3333
    3434/* GUI includes: */
     35# include "UIDesktopWidgetWatchdog.h"
    3536# include "UISnapshotDetailsWidget.h"
    3637# include "UIMessageCenter.h"
     
    8283    /** Prepares all. */
    8384    void prepare();
     85
     86    /** Adjusts window size. */
     87    void adjustWindowSize();
    8488
    8589    /** Adjusts picture. */
     
    169173    m_fZoomMode = !m_fZoomMode;
    170174
     175    /* Adjust the windiow size: */
     176    adjustWindowSize();
    171177    /* Adjust the picture: */
    172178    adjustPicture();
     
    222228    }
    223229
    224     /* Calculate aspect-ratio: */
    225     double dAspectRatio = (double)m_pixmapScreenshot.height() / m_pixmapScreenshot.width();
     230    /* Apply language settings: */
     231    retranslateUi();
     232
     233    /* Adjust window size: */
     234    adjustWindowSize();
     235
     236    /* Center according requested widget: */
     237    VBoxGlobal::centerWidget(this, parentWidget(), false);
     238}
     239
     240void UIScreenshotViewer::adjustWindowSize()
     241{
     242    /* Acquire current host-screen size, fallback to 1024x768 if failed: */
     243    QSize screenSize = gpDesktop->screenGeometry(parentWidget()).size();
     244    if (!screenSize.isValid())
     245        screenSize = QSize(1024, 768);
     246    const int iInitWidth = screenSize.width() * .50 /* 50% of host-screen width */;
     247
     248    /* Calculate screenshot aspect-ratio: */
     249    const double dAspectRatio = (double)m_pixmapScreenshot.height() / m_pixmapScreenshot.width();
     250
    226251    /* Calculate maximum window size: */
    227     const QSize maxSize = m_pixmapScreenshot.size() + QSize(m_pScrollArea->frameWidth() * 2, m_pScrollArea->frameWidth() * 2);
     252    const QSize maxSize = m_fZoomMode
     253                        ? screenSize * .9 /* 90% of host-screen size */ +
     254                          QSize(m_pScrollArea->frameWidth() * 2, m_pScrollArea->frameWidth() * 2)
     255                        : m_pixmapScreenshot.size() /* just the screenshot size */ +
     256                          QSize(m_pScrollArea->frameWidth() * 2, m_pScrollArea->frameWidth() * 2);
     257
    228258    /* Calculate initial window size: */
    229     const QSize initSize = QSize(640, (int)(640 * dAspectRatio)).boundedTo(maxSize);
     259    const QSize initSize = QSize(iInitWidth, (int)(iInitWidth * dAspectRatio)).boundedTo(maxSize);
    230260
    231261    /* Apply maximum window size restrictions: */
     
    233263    /* Apply initial window size: */
    234264    resize(initSize);
    235 
    236     /* Apply language settings: */
    237     retranslateUi();
    238 
    239     /* Center according requested widget: */
    240     VBoxGlobal::centerWidget(this, parentWidget(), false);
    241265}
    242266
     
    245269    if (m_fZoomMode)
    246270    {
     271        /* Adjust visual aspects: */
    247272        m_pScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    248273        m_pScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     
    254279    else
    255280    {
     281        /* Adjust visual aspects: */
    256282        m_pScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    257283        m_pScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette