VirtualBox

Changeset 67173 in vbox


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

FE/Qt: Selector UI: Tools pane: Snapshot pane: Split snapshot details into Attributes and Details tabs.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector
Files:
2 edited

Legend:

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

    r67168 r67173  
    2121
    2222/* Qt includes: */
     23# include <QHBoxLayout>
    2324# include <QDateTime>
     25# include <QGridLayout>
    2426# include <QLabel>
    2527# include <QLineEdit>
    2628# include <QPushButton>
    2729# include <QScrollArea>
     30# include <QTabWidget>
    2831# include <QTextEdit>
     32# include <QVBoxLayout>
    2933
    3034/* GUI includes: */
     
    264268UISnapshotDetailsWidget::UISnapshotDetailsWidget(QWidget *pParent /* = 0 */)
    265269    : QIWithRetranslateUI<QWidget>(pParent)
     270    , m_pTabWidget(0)
     271    , m_pLayoutOptions(0)
     272    , m_pLabelTaken(0), m_pLabelTakenText(0)
    266273    , m_pLabelName(0), m_pEditorName(0)
    267     , m_pLabelTaken(0), m_pLabelTakenText(0)
    268274    , m_pLabelThumbnail(0)
    269275    , m_pLabelDescription(0), m_pBrowserDescription(0)
    270     , m_pLabelDetails(0), m_pBrowserDetails(0)
     276    , m_pLayoutDetails(0)
     277    , m_pBrowserDetails(0)
    271278{
    272279    /* Prepare: */
     
    324331{
    325332    /* Translate labels: */
     333    m_pTabWidget->setTabText(0, tr("&Attributes"));
     334    m_pTabWidget->setTabText(1, tr("D&etails"));
    326335    m_pLabelName->setText(tr("&Name:"));
    327336    m_pLabelTaken->setText(tr("Taken:"));
    328337    m_pLabelDescription->setText(tr("&Description:"));
    329     m_pLabelDetails->setText(tr("D&etails:"));
    330338
    331339    /* And if snapshot is valid: */
     
    370378{
    371379    /* Create layout: */
    372     QGridLayout *pLayout = new QGridLayout(this);
    373     AssertPtrReturnVoid(pLayout);
    374     {
    375         /* Create name label: */
    376         m_pLabelName = new QLabel;
    377         AssertPtrReturnVoid(m_pLabelName);
     380    new QVBoxLayout(this);
     381    AssertPtrReturnVoid(layout());
     382    {
     383        /* Configure layout: */
     384        layout()->setContentsMargins(0, 0, 0, 0);
     385
     386        /* Prepare tab-widget: */
     387        prepareTabWidget();
     388    }
     389}
     390
     391void UISnapshotDetailsWidget::prepareTabWidget()
     392{
     393    /* Create tab-widget: */
     394    m_pTabWidget = new QTabWidget;
     395    AssertPtrReturnVoid(m_pTabWidget);
     396    {
     397        /* Prepare 'Options' tab: */
     398        prepareTabOptions();
     399        /* Prepare 'Details' tab: */
     400        prepareTabDetails();
     401
     402        /* Add into layout: */
     403        layout()->addWidget(m_pTabWidget);
     404    }
     405}
     406
     407void UISnapshotDetailsWidget::prepareTabOptions()
     408{
     409    /* Create widget itself: */
     410    QWidget *pWidget = new QWidget;
     411    AssertPtrReturnVoid(pWidget);
     412    {
     413        /* Create 'Options' layout: */
     414        m_pLayoutOptions = new QGridLayout(pWidget);
     415        AssertPtrReturnVoid(m_pLayoutOptions);
    378416        {
    379             /* Configure label: */
    380             m_pLabelName->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    381 
    382             /* Add to layout: */
    383             pLayout->addWidget(m_pLabelName, 0, 0);
     417            /* Create taken label: */
     418            m_pLabelTaken = new QLabel;
     419            AssertPtrReturnVoid(m_pLabelTaken);
     420            {
     421                /* Configure label: */
     422                m_pLabelTaken->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
     423
     424                /* Add to layout: */
     425                m_pLayoutOptions->addWidget(m_pLabelTaken, 0, 0);
     426            }
     427            /* Create taken text: */
     428            m_pLabelTakenText = new QLabel;
     429            AssertPtrReturnVoid(m_pLabelTakenText);
     430            {
     431                /* Configure label: */
     432                QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Minimum);
     433                policy.setHorizontalStretch(1);
     434                m_pLabelTakenText->setSizePolicy(policy);
     435
     436                /* Add to layout: */
     437                m_pLayoutOptions->addWidget(m_pLabelTakenText, 0, 1);
     438            }
     439
     440            /* Create name label: */
     441            m_pLabelName = new QLabel;
     442            AssertPtrReturnVoid(m_pLabelName);
     443            {
     444                /* Configure label: */
     445                m_pLabelName->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
     446
     447                /* Add to layout: */
     448                m_pLayoutOptions->addWidget(m_pLabelName, 1, 0);
     449            }
     450            /* Create name editor: */
     451            m_pEditorName = new QLineEdit;
     452            AssertPtrReturnVoid(m_pEditorName);
     453            {
     454                /* Configure editor: */
     455                m_pLabelName->setBuddy(m_pEditorName);
     456                QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Minimum);
     457                policy.setHorizontalStretch(1);
     458                m_pEditorName->setSizePolicy(policy);
     459                connect(m_pEditorName, &QLineEdit::textChanged,
     460                        this, &UISnapshotDetailsWidget::sltHandleNameChange);
     461
     462                /* Add to layout: */
     463                m_pLayoutOptions->addWidget(m_pEditorName, 1, 1);
     464            }
     465
     466            /* Create thumbnail label: */
     467            m_pLabelThumbnail = new QLabel;
     468            AssertPtrReturnVoid(m_pLabelThumbnail);
     469            {
     470                /* Configure label: */
     471                m_pLabelThumbnail->installEventFilter(this);
     472                m_pLabelThumbnail->setFrameShape(QFrame::Panel);
     473                m_pLabelThumbnail->setFrameShadow(QFrame::Sunken);
     474                m_pLabelThumbnail->setCursor(Qt::PointingHandCursor);
     475                m_pLabelThumbnail->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
     476                m_pLabelThumbnail->setAutoFillBackground(true);
     477                QPalette pal = m_pLabelThumbnail->palette();
     478                pal.setColor(QPalette::Window, Qt::black);
     479                m_pLabelThumbnail->setPalette(pal);
     480
     481                /* Add to layout: */
     482                m_pLayoutOptions->addWidget(m_pLabelThumbnail, 0, 2, 2, 1);
     483            }
     484
     485            /* Create description label: */
     486            m_pLabelDescription = new QLabel;
     487            AssertPtrReturnVoid(m_pLabelDescription);
     488            {
     489                /* Configure label: */
     490                m_pLabelDescription->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignTop);
     491
     492                /* Add to layout: */
     493                m_pLayoutOptions->addWidget(m_pLabelDescription, 2, 0);
     494            }
     495            /* Create description browser: */
     496            m_pBrowserDescription = new QTextEdit;
     497            AssertPtrReturnVoid(m_pBrowserDescription);
     498            {
     499                /* Configure browser: */
     500                m_pLabelDescription->setBuddy(m_pBrowserDescription);
     501                m_pBrowserDescription->setTabChangesFocus(true);
     502                m_pBrowserDescription->setAcceptRichText(false);
     503                QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     504                policy.setHorizontalStretch(1);
     505                m_pBrowserDescription->setSizePolicy(policy);
     506                connect(m_pBrowserDescription, &QTextEdit::textChanged,
     507                        this, &UISnapshotDetailsWidget::sltHandleDescriptionChange);
     508
     509                /* Add to layout: */
     510                m_pLayoutOptions->addWidget(m_pBrowserDescription, 2, 1, 1, 2);
     511            }
    384512        }
    385         /* Create name editor: */
    386         m_pEditorName = new QLineEdit;
    387         AssertPtrReturnVoid(m_pEditorName);
     513
     514        /* Add to tab-widget: */
     515        m_pTabWidget->addTab(pWidget, QString());
     516    }
     517}
     518
     519void UISnapshotDetailsWidget::prepareTabDetails()
     520{
     521    /* Create widget itself: */
     522    QWidget *pWidget = new QWidget;
     523    AssertPtrReturnVoid(pWidget);
     524    {
     525        /* Create 'Details' layout: */
     526        m_pLayoutDetails = new QVBoxLayout(pWidget);
     527        AssertPtrReturnVoid(m_pLayoutDetails);
    388528        {
    389             /* Configure editor: */
    390             m_pLabelName->setBuddy(m_pEditorName);
    391             QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    392             policy.setHorizontalStretch(1);
    393             m_pEditorName->setSizePolicy(policy);
    394             connect(m_pEditorName, &QLineEdit::textChanged,
    395                     this, &UISnapshotDetailsWidget::sltHandleNameChange);
    396 
    397             /* Add to layout: */
    398             pLayout->addWidget(m_pEditorName, 0, 1);
     529            /* Create details browser: */
     530            m_pBrowserDetails = new QTextEdit;
     531            AssertPtrReturnVoid(m_pBrowserDetails);
     532            {
     533                /* Configure browser: */
     534                m_pBrowserDetails->setReadOnly(true);
     535                m_pBrowserDetails->setFrameShadow(QFrame::Plain);
     536                m_pBrowserDetails->setFrameShape(QFrame::NoFrame);
     537                m_pBrowserDetails->viewport()->setAutoFillBackground(false);
     538                QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     539                policy.setHorizontalStretch(1);
     540                m_pBrowserDetails->setSizePolicy(policy);
     541                m_pBrowserDetails->setFocus();
     542
     543                /* Add to layout: */
     544                m_pLayoutDetails->addWidget(m_pBrowserDetails);
     545            }
    399546        }
    400547
    401         /* Create taken label: */
    402         m_pLabelTaken = new QLabel;
    403         AssertPtrReturnVoid(m_pLabelTaken);
    404         {
    405             /* Configure label: */
    406             m_pLabelTaken->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    407 
    408             /* Add to layout: */
    409             pLayout->addWidget(m_pLabelTaken, 1, 0);
    410         }
    411         /* Create taken text: */
    412         m_pLabelTakenText = new QLabel;
    413         AssertPtrReturnVoid(m_pLabelTakenText);
    414         {
    415             /* Configure label: */
    416             QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    417             policy.setHorizontalStretch(1);
    418             m_pLabelTakenText->setSizePolicy(policy);
    419 
    420             /* Add to layout: */
    421             pLayout->addWidget(m_pLabelTakenText, 1, 1);
    422         }
    423 
    424         /* Create thumbnail label: */
    425         m_pLabelThumbnail = new QLabel;
    426         AssertPtrReturnVoid(m_pLabelThumbnail);
    427         {
    428             /* Configure label: */
    429             m_pLabelThumbnail->installEventFilter(this);
    430             m_pLabelThumbnail->setFrameShape(QFrame::Panel);
    431             m_pLabelThumbnail->setFrameShadow(QFrame::Sunken);
    432             m_pLabelThumbnail->setCursor(Qt::PointingHandCursor);
    433             m_pLabelThumbnail->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
    434 
    435             /* Add to layout: */
    436             pLayout->addWidget(m_pLabelThumbnail, 0, 2, 2, 1);
    437         }
    438 
    439         /* Create description label: */
    440         m_pLabelDescription = new QLabel;
    441         AssertPtrReturnVoid(m_pLabelDescription);
    442         {
    443             /* Configure label: */
    444             m_pLabelDescription->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignTop);
    445 
    446             /* Add to layout: */
    447             pLayout->addWidget(m_pLabelDescription, 2, 0);
    448         }
    449         /* Create description browser: */
    450         m_pBrowserDescription = new QTextEdit;
    451         AssertPtrReturnVoid(m_pBrowserDescription);
    452         {
    453             /* Configure browser: */
    454             m_pLabelDescription->setBuddy(m_pBrowserDescription);
    455             m_pBrowserDescription->setTabChangesFocus(true);
    456             m_pBrowserDescription->setAcceptRichText(false);
    457             QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    458             policy.setHorizontalStretch(1);
    459             m_pBrowserDescription->setSizePolicy(policy);
    460             connect(m_pBrowserDescription, &QTextEdit::textChanged,
    461                     this, &UISnapshotDetailsWidget::sltHandleDescriptionChange);
    462 
    463             /* Add to layout: */
    464             pLayout->addWidget(m_pBrowserDescription, 2, 1, 1, 2);
    465         }
    466 
    467         /* Create details label: */
    468         m_pLabelDetails = new QLabel;
    469         AssertPtrReturnVoid(m_pLabelDetails);
    470         {
    471             /* Configure label: */
    472             m_pLabelDetails->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignTop);
    473 
    474             /* Add to layout: */
    475             pLayout->addWidget(m_pLabelDetails, 3, 0);
    476         }
    477         /* Create details browser: */
    478         m_pBrowserDetails = new QTextEdit;
    479         AssertPtrReturnVoid(m_pBrowserDetails);
    480         {
    481             /* Configure browser: */
    482             m_pLabelDetails->setBuddy(m_pBrowserDetails);
    483             m_pBrowserDetails->setReadOnly(true);
    484             m_pBrowserDetails->setFrameShadow(QFrame::Plain);
    485             m_pBrowserDetails->setFrameShape(QFrame::NoFrame);
    486             m_pBrowserDetails->viewport()->setAutoFillBackground(false);
    487             QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    488             policy.setHorizontalStretch(1);
    489             m_pBrowserDetails->setSizePolicy(policy);
    490             m_pBrowserDetails->setFocus();
    491 
    492             /* Add to layout: */
    493             pLayout->addWidget(m_pBrowserDetails, 3, 1, 1, 2);
    494         }
     548        /* Add to tab-widget: */
     549        m_pTabWidget->addTab(pWidget, QString());
    495550    }
    496551}
     
    532587        // TODO: Check whether layout manipulations are really
    533588        //       necessary, they looks a bit dangerous to me..
    534         QGridLayout *pLayout = qobject_cast<QGridLayout*>(layout());
    535         AssertPtrReturnVoid(pLayout);
    536589        if (m_pixmapThumbnail.isNull())
    537590        {
    538591            m_pLabelThumbnail->setPixmap(QPixmap());
    539592
    540             pLayout->removeWidget(m_pLabelThumbnail);
     593            m_pLayoutOptions->removeWidget(m_pLabelThumbnail);
    541594            m_pLabelThumbnail->setHidden(true);
    542595
    543             pLayout->removeWidget(m_pEditorName);
    544             pLayout->removeWidget(m_pLabelTakenText);
    545             pLayout->addWidget(m_pEditorName, 0, 1, 1, 2);
    546             pLayout->addWidget(m_pLabelTakenText, 1, 1, 1, 2);
     596            m_pLayoutOptions->removeWidget(m_pLabelTakenText);
     597            m_pLayoutOptions->removeWidget(m_pEditorName);
     598            m_pLayoutOptions->addWidget(m_pLabelTakenText, 0, 1, 1, 2);
     599            m_pLayoutOptions->addWidget(m_pEditorName, 1, 1, 1, 2);
    547600        }
    548601        else
     
    551604            const int iIconMetric = pStyle->pixelMetric(QStyle::PM_LargeIconSize);
    552605            m_pLabelThumbnail->setPixmap(m_pixmapThumbnail.scaled(QSize(1, iIconMetric),
    553                                                              Qt::KeepAspectRatioByExpanding,
    554                                                              Qt::SmoothTransformation));
    555 
    556             pLayout->removeWidget(m_pEditorName);
    557             pLayout->removeWidget(m_pLabelTakenText);
    558             pLayout->addWidget(m_pEditorName, 0, 1);
    559             pLayout->addWidget(m_pLabelTakenText, 1, 1);
    560 
    561             pLayout->removeWidget(m_pLabelThumbnail);
    562             pLayout->addWidget(m_pLabelThumbnail, 0, 2, 2, 1);
     606                                                                  Qt::KeepAspectRatioByExpanding,
     607                                                                  Qt::SmoothTransformation));
     608
     609            m_pLayoutOptions->removeWidget(m_pLabelTakenText);
     610            m_pLayoutOptions->removeWidget(m_pEditorName);
     611            m_pLayoutOptions->addWidget(m_pLabelTakenText, 0, 1);
     612            m_pLayoutOptions->addWidget(m_pEditorName, 1, 1);
     613
     614            m_pLayoutOptions->removeWidget(m_pLabelThumbnail);
     615            m_pLayoutOptions->addWidget(m_pLabelThumbnail, 0, 2, 2, 1);
    563616            m_pLabelThumbnail->setHidden(false);
    564617        }
     
    571624        // TODO: Check whether layout manipulations are really
    572625        //       necessary, they looks a bit dangerous to me..
    573         QGridLayout *pLayout = qobject_cast<QGridLayout*>(layout());
    574         AssertPtrReturnVoid(pLayout);
    575626        {
    576627            m_pLabelThumbnail->setPixmap(QPixmap());
    577628
    578             pLayout->removeWidget(m_pLabelThumbnail);
     629            m_pLayoutOptions->removeWidget(m_pLabelThumbnail);
    579630            m_pLabelThumbnail->setHidden(true);
    580631
    581             pLayout->removeWidget(m_pEditorName);
    582             pLayout->removeWidget(m_pLabelTakenText);
    583             pLayout->addWidget(m_pEditorName, 0, 1, 1, 2);
    584             pLayout->addWidget(m_pLabelTakenText, 1, 1, 1, 2);
     632            m_pLayoutOptions->removeWidget(m_pEditorName);
     633            m_pLayoutOptions->removeWidget(m_pLabelTakenText);
     634            m_pLayoutOptions->addWidget(m_pLabelTakenText, 0, 1, 1, 2);
     635            m_pLayoutOptions->addWidget(m_pEditorName, 1, 1, 1, 2);
    585636        }
    586637    }
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.h

    r67168 r67173  
    2929
    3030/* Forward declarations: */
     31class QGridLayout;
    3132class QLabel;
    3233class QLineEdit;
     34class QTabWidget;
    3335class QTextEdit;
     36class QVBoxLayout;
    3437
    3538
     
    105108    /** Prepares all. */
    106109    void prepare();
     110    /** Prepares tab-widget. */
     111    void prepareTabWidget();
     112    /** Prepares 'Options' tab. */
     113    void prepareTabOptions();
     114    /** Prepares 'Details' tab. */
     115    void prepareTabDetails();
    107116
    108117    /** Loads snapshot data. */
     
    125134    QPixmap  m_pixmapScreenshot;
    126135
    127     /** Holds the name label instance. */
    128     QLabel    *m_pLabelName;
    129     /** Holds the name editor instance. */
    130     QLineEdit *m_pEditorName;
     136    /** Holds the tab-widget instance. */
     137    QTabWidget *m_pTabWidget;
     138
     139    /** Holds the 'Options' layout instance. */
     140    QGridLayout *m_pLayoutOptions;
    131141
    132142    /** Holds the taken label instance. */
     
    134144    /** Holds the taken text instance. */
    135145    QLabel *m_pLabelTakenText;
     146
     147    /** Holds the name label instance. */
     148    QLabel    *m_pLabelName;
     149    /** Holds the name editor instance. */
     150    QLineEdit *m_pEditorName;
    136151
    137152    /** Holds the thumbnail label instance. */
     
    143158    QTextEdit *m_pBrowserDescription;
    144159
    145     /** Holds the details label instance. */
    146     QLabel    *m_pLabelDetails;
     160    /** Holds the 'Details' layout instance. */
     161    QVBoxLayout *m_pLayoutDetails;
     162
    147163    /** Holds the description editor instance. */
    148164    QTextEdit *m_pBrowserDetails;
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