VirtualBox

Ignore:
Timestamp:
Dec 13, 2011 9:26:40 AM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: 5984: Summary pages of wizards will now reflect summary without scroll-bars, taking into account real summary size-hint.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
7 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r39453 r39593  
    257257        src/extensions/QITableView.h \
    258258        src/extensions/QIToolButton.h \
     259        src/extensions/QITextEdit.h \
    259260        src/extensions/QITreeView.h \
    260261        src/extensions/QITreeWidget.h \
     
    418419        src/extensions/QIStatusBar.cpp \
    419420        src/extensions/QITableView.cpp \
     421        src/extensions/QITextEdit.cpp \
    420422        src/extensions/QITreeView.cpp \
    421423        src/extensions/QITreeWidget.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITextEdit.cpp

    r39591 r39593  
    33 *
    44 * VBox frontends: Qt GUI ("VirtualBox"):
    5  * QILineEdit class implementation
     5 * VirtualBox Qt extensions: QITextEdit class implementation
    66 */
    77
    88/*
    9  * Copyright (C) 2008 Oracle Corporation
     9 * Copyright (C) 2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1818 */
    1919
    20 #include "QILineEdit.h"
     20/* Local includes: */
     21#include "QITextEdit.h"
    2122
    22 /* Qt includes */
    23 #include <QStyleOptionFrame>
    24 
    25 #if defined (Q_WS_WIN32)
    26 #include <QWindowsVistaStyle>
    27 #include <QLibrary>
    28 #endif
    29 
    30 void QILineEdit::setMinimumWidthByText (const QString &aText)
     23/* Constructor: */
     24QITextEdit::QITextEdit(QWidget *pParent)
     25    : QTextEdit(pParent)
    3126{
    32     setMinimumWidth (featTextWidth (aText).width());
    3327}
    3428
    35 void QILineEdit::setFixedWidthByText (const QString &aText)
     29QSize QITextEdit::sizeHint() const
    3630{
    37     setFixedWidth (featTextWidth (aText).width());
     31    return document()->size().toSize();
    3832}
    3933
    40 QSize QILineEdit::featTextWidth (const QString &aText) const
    41 {
    42     QStyleOptionFrame sof;
    43     sof.initFrom (this);
    44     sof.rect = contentsRect();
    45     sof.lineWidth = hasFrame() ? style()->pixelMetric (QStyle::PM_DefaultFrameWidth) : 0;
    46     sof.midLineWidth = 0;
    47     sof.state |= QStyle::State_Sunken;
    48 
    49     /* The margins are based on qlineedit.cpp of Qt. Maybe they where changed
    50      * at some time in the future. */
    51     QSize sc (fontMetrics().width (aText) + 2*2,
    52               fontMetrics().xHeight()     + 2*1);
    53     QSize sa = style()->sizeFromContents (QStyle::CT_LineEdit, &sof, sc, this);
    54 
    55 #if defined (Q_WS_WIN32)
    56     /* Vista l&f style has a bug where the last parameter of sizeFromContents
    57      * function ('widget' what corresponds to 'this' in our class) is ignored.
    58      * Due to it QLineEdit processed as QComboBox and size calculation includes
    59      * non-existing combo-box button of 23 pix in width. So fixing it here: */
    60     if (qobject_cast <QWindowsVistaStyle*> (style()))
    61     {
    62         /* Check if l&f style theme is really active else painting performed by
    63          * Windows Classic theme and there is no such shifting error. */
    64         typedef bool (*IsAppThemedFunction)();
    65         IsAppThemedFunction isAppThemed =
    66             (IsAppThemedFunction) QLibrary::resolve ("uxtheme", "IsAppThemed");
    67         if (isAppThemed && isAppThemed()) sa -= QSize (23, 0);
    68     }
    69 #endif
    70 
    71     return sa;
    72 }
    73 
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITextEdit.h

    r39591 r39593  
    22 *
    33 * VBox frontends: Qt GUI ("VirtualBox"):
    4  * QILineEdit class declarations
     4 * VirtualBox Qt extensions: QITextEdit class declaration
    55 */
    66
    77/*
    8  * Copyright (C) 2008 Oracle Corporation
     8 * Copyright (C) 2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1717 */
    1818
    19 #ifndef __QILineEdit_h__
    20 #define __QILineEdit_h__
     19#ifndef __QITextEdit_h__
     20#define __QITextEdit_h__
    2121
    22 /* Qt includes */
    23 #include <QLineEdit>
     22/* Global includes: */
     23#include <QTextEdit>
    2424
    25 class QILineEdit: public QLineEdit
     25/* QTextEdit class extension: */
     26class QITextEdit : public QTextEdit
    2627{
     28    Q_OBJECT;
     29
    2730public:
    2831
    29     QILineEdit (QWidget *aParent = 0)
    30         :QLineEdit (aParent) {}
    31     QILineEdit (const QString &aContents, QWidget *aParent = 0)
    32         :QLineEdit (aContents, aParent) {}
     32    /* Constructor: */
     33    QITextEdit(QWidget *pParent = 0);
    3334
    34     void setMinimumWidthByText (const QString &aText);
    35     void setFixedWidthByText (const QString &aText);
    36 
    37 private:
    38 
    39     QSize featTextWidth (const QString &aText) const;
     35    /* Size hint: */
     36    QSize sizeHint() const;
    4037};
    4138
    42 #endif /* __QILineEdit_h__ */
    43 
     39#endif // __QITextEdit_h__
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIFirstRunWzd.cpp

    r38311 r39593  
    77
    88/*
    9  * Copyright (C) 2008-2010 Oracle Corporation
     9 * Copyright (C) 2008-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    285285    .arg(tr("Source", "summary"), source)
    286286    ;
    287     /* Feat summary to 3 lines */
    288     setSummaryFieldLinesNumber(m_pSummaryText, 2);
    289287
    290288    m_pSummaryText->setText("<table cellspacing=0 cellpadding=0>" + summary + "</table>");
     
    296294    retranslateUi();
    297295
     296    /* Update summary geometry: */
     297    m_pSummaryText->updateGeometry();
    298298    /* Summary should initially have focus */
    299299    m_pSummaryText->setFocus();
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIFirstRunWzdPage3.ui

    r33656 r39593  
    44 VBox frontends: Qt4 GUI (&quot;VirtualBox&quot;):
    55
    6      Copyright (C) 2009-2010 Oracle Corporation
     6     Copyright (C) 2009-2011 Oracle Corporation
    77
    88     This file is part of VirtualBox Open Source Edition (OSE), as
     
    5555   </item>
    5656   <item>
    57     <widget class="QTextEdit" name="m_pSummaryText">
     57    <widget class="QITextEdit" name="m_pSummaryText">
    5858     <property name="sizePolicy">
    59       <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
     59      <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
    6060       <horstretch>0</horstretch>
    6161       <verstretch>0</verstretch>
     
    117117   <header>QILabel.h</header>
    118118  </customwidget>
     119  <customwidget>
     120   <class>QITextEdit</class>
     121   <extends>QTextEdit</extends>
     122   <header>QITextEdit.h</header>
     123  </customwidget>
    119124 </customwidgets>
    120125 <resources/>
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizard.cpp

    r39128 r39593  
    996996    .arg(UINewHDWizard::tr("Size", "summary"), sizeFormatted, sizeUnformatted);
    997997
    998     /* Feat summary to 4 lines: */
    999     setSummaryFieldLinesNumber(m_pSummaryText, 4);
    1000 
    1001998    m_pSummaryText->setText("<table cellspacing=0 cellpadding=0>" + strSummary + "</table>");
    1002999}
     
    10071004    retranslateUi();
    10081005
     1006    /* Update summary geometry: */
     1007    m_pSummaryText->updateGeometry();
    10091008    /* Summary should have focus initially: */
    10101009    m_pSummaryText->setFocus();
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageSummary.ui

    r37406 r39593  
    4242   </item>
    4343   <item>
    44     <widget class="QTextEdit" name="m_pSummaryText">
     44    <widget class="QITextEdit" name="m_pSummaryText">
    4545     <property name="sizePolicy">
    46       <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
     46      <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
    4747       <horstretch>0</horstretch>
    4848       <verstretch>0</verstretch>
     
    8888   <header>QILabel.h</header>
    8989  </customwidget>
     90  <customwidget>
     91   <class>QITextEdit</class>
     92   <extends>QTextEdit</extends>
     93   <header>QITextEdit.h</header>
     94  </customwidget>
    9095 </customwidgets>
    9196 <resources/>
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp

    r39476 r39593  
    673673    .arg(tr("Base Memory", "summary"), ram, VBoxGlobal::tr("MB", "size suffix MBytes=1024KBytes"))
    674674    ;
    675     /* Feat summary to 3 lines */
    676     setSummaryFieldLinesNumber(m_pSummaryText, 3);
    677675
    678676    /* Add hard-disk info */
     
    682680            "<tr><td><nobr>%8: </nobr></td><td><nobr>%9</nobr></td></tr>")
    683681            .arg(tr("Start-up Disk", "summary"), field("hardDiskName").toString());
    684         /* Extend summary to 4 lines */
    685         setSummaryFieldLinesNumber(m_pSummaryText, 4);
    686682    }
    687683
     
    701697    retranslateUi();
    702698
     699    /* Update summary geometry: */
     700    m_pSummaryText->updateGeometry();
    703701    /* Summary should have focus initially */
    704702    m_pSummaryText->setFocus();
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzdPage5.ui

    r28800 r39593  
    44 VBox frontends: Qt4 GUI ("VirtualBox"):
    55
    6      Copyright (C) 2009 Oracle Corporation
     6     Copyright (C) 2009-2011 Oracle Corporation
    77
    88     This file is part of VirtualBox Open Source Edition (OSE), as
     
    5151   </item>
    5252   <item>
    53     <widget class="QTextEdit" name="m_pSummaryText">
     53    <widget class="QITextEdit" name="m_pSummaryText">
    5454     <property name="sizePolicy">
    55       <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
     55      <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
    5656       <horstretch>0</horstretch>
    5757       <verstretch>0</verstretch>
     
    9191   <header>QILabel.h</header>
    9292  </customwidget>
     93  <customwidget>
     94   <class>QITextEdit</class>
     95   <extends>QTextEdit</extends>
     96   <header>QITextEdit.h</header>
     97  </customwidget>
    9398 </customwidgets>
    9499 <resources/>
Note: See TracChangeset for help on using the changeset viewer.

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