VirtualBox

Changeset 43982 in vbox for trunk


Ignore:
Timestamp:
Nov 28, 2012 1:32:14 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
82355
Message:

FE/Qt: VM group UI: Details-view: Cleanup (part 2).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp

    r43887 r43982  
    2020/* Qt includes: */
    2121#include <QApplication>
    22 #include <QPainter>
    23 #include <QStyleOptionGraphicsItem>
    24 #include <QTextLayout>
    25 #include <QGraphicsSceneMouseEvent>
     22#include <QGraphicsView>
    2623#include <QStateMachine>
    2724#include <QPropertyAnimation>
    2825#include <QSignalTransition>
     26#include <QTextLayout>
     27#include <QStyleOptionGraphicsItem>
     28#include <QGraphicsSceneMouseEvent>
    2929
    3030/* GUI includes: */
     
    6161    prepareButton();
    6262
    63     /* Update size-policy/hint: */
     63    /* Setup size-policy: */
    6464    setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    65     /* Update: */
     65
     66    /* Update hover access: */
    6667    updateHoverAccessibility();
    6768
    6869    /* Add item to the parent: */
     70    AssertMsg(parentItem(), ("No parent set for details element!"));
    6971    parentItem()->addItem(this);
    7072}
     
    7577    AssertMsg(parentItem(), ("No parent set for details element!"));
    7678    parentItem()->removeItem(this);
    77 }
    78 
    79 DetailsElementType UIGDetailsElement::elementType() const
    80 {
    81     return m_type;
    82 }
    83 
    84 bool UIGDetailsElement::closed() const
    85 {
    86     return m_fClosed;
    87 }
    88 
    89 bool UIGDetailsElement::opened() const
    90 {
    91     return !m_fClosed;
    9279}
    9380
     
    136123void UIGDetailsElement::markAnimationFinished()
    137124{
     125    /* Mark animation as non-running: */
    138126    m_fAnimationRunning = false;
    139127}
     
    152140    updateAnimationParameters();
    153141
    154     /* Toggle element state: */
     142    /* Invert toggle-state: */
    155143    m_fClosed = !m_fClosed;
    156144}
     
    170158    switch (iKey)
    171159    {
    172         /* Layout hints: */
     160        /* Hints: */
    173161        case ElementData_Margin: return 5;
    174162        case ElementData_Spacing: return 10;
     
    347335}
    348336
    349 UITextTable UIGDetailsElement::text() const
    350 {
    351     return m_text;
    352 }
    353 
    354337void UIGDetailsElement::setText(const UITextTable &text)
    355338{
     
    476459void UIGDetailsElement::setAdditionalHeight(int iAdditionalHeight)
    477460{
     461    /* Cache new value: */
    478462    m_iAdditionalHeight = iAdditionalHeight;
     463    /* Update layout: */
    479464    updateLayout();
     465    /* Repaint: */
    480466    update();
    481 }
    482 
    483 int UIGDetailsElement::additionalHeight() const
    484 {
    485     return m_iAdditionalHeight;
    486 }
    487 
    488 UIGraphicsRotatorButton* UIGDetailsElement::button() const
    489 {
    490     return m_pButton;
    491467}
    492468
     
    547523    paintDecorations(pPainter, pOption);
    548524
    549     /* Paint machine info: */
     525    /* Paint element info: */
    550526    paintElementInfo(pPainter, pOption);
    551527}
     
    774750void UIGDetailsElement::mousePressEvent(QGraphicsSceneMouseEvent *pEvent)
    775751{
    776     if (m_fNameHovered)
    777     {
    778         pEvent->accept();
    779         QString strCategory;
    780         if (m_type >= DetailsElementType_General &&
    781             m_type <= DetailsElementType_SF)
    782             strCategory = QString("#%1").arg(gpConverter->toInternalString(m_type));
    783         else if (m_type == DetailsElementType_Description)
    784             strCategory = QString("#%1%%mTeDescription").arg(gpConverter->toInternalString(m_type));
    785         emit sigLinkClicked(strCategory, QString(), machine().GetId());
    786     }
     752    /* Only for hovered header: */
     753    if (!m_fNameHovered)
     754        return;
     755
     756    /* Process link click: */
     757    pEvent->accept();
     758    QString strCategory;
     759    if (m_type >= DetailsElementType_General &&
     760        m_type <= DetailsElementType_SF)
     761        strCategory = QString("#%1").arg(gpConverter->toInternalString(m_type));
     762    else if (m_type == DetailsElementType_Description)
     763        strCategory = QString("#%1%%mTeDescription").arg(gpConverter->toInternalString(m_type));
     764    emit sigLinkClicked(strCategory, QString(), machine().GetId());
    787765}
    788766
    789767void UIGDetailsElement::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *pEvent)
    790768{
     769    /* Only for left-button: */
     770    if (pEvent->button() != Qt::LeftButton)
     771        return;
     772
    791773    /* Process left-button double-click: */
    792     if (pEvent->button() == Qt::LeftButton)
    793         emit sigToggleElement(m_type, closed());
     774    emit sigToggleElement(m_type, closed());
    794775}
    795776
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h

    r42909 r43982  
    7575
    7676    /* API: Element type: */
    77     DetailsElementType elementType() const;
     77    DetailsElementType elementType() const { return m_type; }
    7878
    7979    /* API: Open/close stuff: */
    80     bool closed() const;
    81     bool opened() const;
     80    bool closed() const { return m_fClosed; }
     81    bool opened() const { return !m_fClosed; }
    8282    void close(bool fAnimated = true);
    8383    void open(bool fAnimated = true);
     
    106106    enum ElementData
    107107    {
    108         /* Layout hints: */
     108        /* Hints: */
    109109        ElementData_Margin,
    110110        ElementData_Spacing,
     
    134134
    135135    /* API: Text stuff: */
    136     UITextTable text() const;
     136    UITextTable text() const { return m_text; }
    137137    void setText(const UITextTable &text);
    138138
     
    149149    /* Helpers: Animation stuff: */
    150150    void setAdditionalHeight(int iAdditionalHeight);
    151     int additionalHeight() const;
    152     UIGraphicsRotatorButton* button() const;
    153 
    154 protected:
     151    int additionalHeight() const { return m_iAdditionalHeight; }
     152    UIGraphicsRotatorButton* button() const { return m_pButton; }
     153    bool isAnimationRunning() const { return m_fAnimationRunning; }
     154
     155private:
    155156
    156157    /* API: Children stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp

    r43484 r43982  
    246246    if (closed() && m_pPreview->isVisible())
    247247        m_pPreview->hide();
    248     if (opened() && !m_pPreview->isVisible() && !m_fAnimationRunning)
     248    if (opened() && !m_pPreview->isVisible() && !isAnimationRunning())
    249249        m_pPreview->show();
    250250}
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.h

    r42722 r43982  
    136136private:
    137137
    138     /* Helpers: Size-hint stuff: */
     138    /* Helpers: Layout stuff: */
    139139    int minimumWidthHint() const;
    140140    int minimumHeightHint(bool fClosed) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.cpp

    r42881 r43982  
    2727#include "UIConverter.h"
    2828#include "VBoxGlobal.h"
    29 
    30 /* Other VBox includes: */
    31 #include <iprt/assert.h>
    3229
    3330UIGDetailsGroup::UIGDetailsGroup()
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsItem.cpp

    r43885 r43982  
    8383void UIGDetailsItem::updateSizeHint()
    8484{
     85    /* Update the geometry: */
    8586    updateGeometry();
    8687}
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.cpp

    r43937 r43982  
    2020/* Qt includes: */
    2121#include <QGraphicsScene>
     22#include <QGraphicsSceneContextMenuEvent>
    2223#include <QGraphicsView>
    23 #include <QGraphicsSceneContextMenuEvent>
    2424
    2525/* GUI includes: */
     
    2727#include "UIGDetailsGroup.h"
    2828#include "UIGDetailsElement.h"
    29 #include "UIGChooserItemGroup.h"
    30 #include "UIGChooserItemMachine.h"
    3129#include "VBoxGlobal.h"
    32 #include "UIMessageCenter.h"
    3330#include "UIConverter.h"
    34 
    35 /* COM includes: */
    36 #include "CMachine.h"
    3731
    3832UIGDetailsModel::UIGDetailsModel(QObject *pParent)
     
    6660}
    6761
    68 QPaintDevice* UIGDetailsModel::paintDevice() const
     62QGraphicsView* UIGDetailsModel::paintDevice() const
    6963{
    7064    if (!m_pScene || m_pScene->views().isEmpty())
     
    7367}
    7468
    75 QGraphicsItem* UIGDetailsModel::itemAt(const QPointF &position, const QTransform &deviceTransform /* = QTransform() */) const
    76 {
    77     return scene()->itemAt(position, deviceTransform);
     69QGraphicsItem* UIGDetailsModel::itemAt(const QPointF &position) const
     70{
     71    return scene()->itemAt(position);
    7872}
    7973
    8074void UIGDetailsModel::updateLayout()
    8175{
    82     /* Initialize variables: */
     76    /* Prepare variables: */
    8377    int iSceneMargin = data(DetailsModelData_Margin).toInt();
    84     QSize viewportSize = scene()->views()[0]->viewport()->size();
     78    QSize viewportSize = paintDevice()->viewport()->size();
    8579    int iViewportWidth = viewportSize.width() - 2 * iSceneMargin;
    8680    int iViewportHeight = viewportSize.height() - 2 * iSceneMargin;
    87     /* Set root item position: */
     81
     82    /* Move root: */
    8883    m_pRoot->setPos(iSceneMargin, iSceneMargin);
    89     /* Set root item size: */
     84    /* Resize root: */
    9085    m_pRoot->resize(iViewportWidth, iViewportHeight);
    91     /* Relayout root item: */
     86    /* Layout root content: */
    9287    m_pRoot->updateLayout();
     88
    9389    /* Notify listener about root-item relayouted: */
    9490    emit sigRootItemResized(m_pRoot->geometry().size(), m_pRoot->minimumSizeHint().toSize().width());
     
    108104void UIGDetailsModel::sltToggleElements(DetailsElementType type, bool fToggled)
    109105{
    110     /* Make sure not started yet: */
     106    /* Make sure it is not started yet: */
    111107    if (m_pAnimationCallback)
    112108        return;
     109
    113110    /* Prepare/configure animation callback: */
    114111    m_pAnimationCallback = new UIGDetailsElementAnimationCallback(this, type, fToggled);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.h

    r43937 r43982  
    2323#include <QObject>
    2424#include <QPointer>
    25 #include <QTransform>
    2625#include <QMap>
    2726#include <QSet>
     
    3736class QGraphicsScene;
    3837class QGraphicsSceneContextMenuEvent;
     38class QGraphicsView;
    3939class UIGDetailsGroup;
    4040class UIVMItem;
     
    6363    /* API: Scene stuff: */
    6464    QGraphicsScene* scene() const;
    65     QPaintDevice* paintDevice() const;
    66     QGraphicsItem* itemAt(const QPointF &position, const QTransform &deviceTransform = QTransform()) const;
     65    QGraphicsView* paintDevice() const;
     66    QGraphicsItem* itemAt(const QPointF &position) const;
    6767
    6868    /* API: Layout stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsView.h

    r43936 r43982  
    4040private slots:
    4141
    42     /* Handler: Resize stuff: */
     42    /* Handler: Root-item stuff: */
    4343    void sltHandleRootItemResized(const QSizeF &size, int iMinimumWidth);
    4444
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