VirtualBox

Ignore:
Timestamp:
May 31, 2017 12:20:29 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Selector UI: Tools pane: Snapshot pane: Snapshot details widget: Get rid of .ui file.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro

    r67162 r67168  
    2424    src/VBoxTakeSnapshotDlg.ui \
    2525    src/UIVMLogViewer.ui \
    26     src/selector/UISnapshotDetailsWidget.ui \
    2726    src/settings/UISettingsDialog.ui \
    2827    src/settings/global/UIGlobalSettingsGeneral.ui \
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.cpp

    r67164 r67168  
    2222/* Qt includes: */
    2323# include <QDateTime>
     24# include <QLabel>
     25# include <QLineEdit>
    2426# include <QPushButton>
    2527# include <QScrollArea>
     28# include <QTextEdit>
    2629
    2730/* GUI includes: */
     
    261264UISnapshotDetailsWidget::UISnapshotDetailsWidget(QWidget *pParent /* = 0 */)
    262265    : QIWithRetranslateUI<QWidget>(pParent)
     266    , m_pLabelName(0), m_pEditorName(0)
     267    , m_pLabelTaken(0), m_pLabelTakenText(0)
     268    , m_pLabelThumbnail(0)
     269    , m_pLabelDescription(0), m_pBrowserDescription(0)
     270    , m_pLabelDetails(0), m_pBrowserDetails(0)
    263271{
    264272    /* Prepare: */
     
    295303{
    296304    /* We have filter for thumbnail label only: */
    297     AssertReturn(pObject == mLbThumbnail, false);
     305    AssertReturn(pObject == m_pLabelThumbnail, false);
    298306
    299307    /* For a mouse-press event inside the thumbnail area: */
     
    315323void UISnapshotDetailsWidget::retranslateUi()
    316324{
    317     /* Translate uic generated strings: */
    318     Ui::UISnapshotDetailsWidget::retranslateUi(this);
     325    /* Translate labels: */
     326    m_pLabelName->setText(tr("&Name:"));
     327    m_pLabelTaken->setText(tr("Taken:"));
     328    m_pLabelDescription->setText(tr("&Description:"));
     329    m_pLabelDetails->setText(tr("D&etails:"));
    319330
    320331    /* And if snapshot is valid: */
     
    325336
    326337        /* Translate the picture tool-tip: */
    327         mLbThumbnail->setToolTip(m_pixmapScreenshot.isNull() ? QString() : tr("Click to enlarge the screenshot."));
     338        m_pLabelThumbnail->setToolTip(m_pixmapScreenshot.isNull() ? QString() : tr("Click to enlarge the screenshot."));
    328339
    329340        /* Rebuild the details report: */
    330         mTeDetails->setText(vboxGlobal().detailsReport(comMachine, false /* with links? */));
     341        m_pBrowserDetails->setText(vboxGlobal().detailsReport(comMachine, false /* with links? */));
    331342    }
    332343    else
    333344    {
    334345        /* Clear the picture tool-tip: */
    335         mLbThumbnail->setToolTip(QString());
     346        m_pLabelThumbnail->setToolTip(QString());
    336347
    337348        /* Clear the details report: */
    338         mTeDetails->clear();
     349        m_pBrowserDetails->clear();
    339350    }
    340351}
     
    342353void UISnapshotDetailsWidget::sltHandleNameChange()
    343354{
    344     m_newData.m_strName = mLeName->text();
     355    m_newData.m_strName = m_pEditorName->text();
     356    // TODO: Validate
    345357    //revalidate(m_pErrorPaneName);
    346358    notify();
     
    349361void UISnapshotDetailsWidget::sltHandleDescriptionChange()
    350362{
    351     m_newData.m_strDescription = mTeDescription->toPlainText();
     363    m_newData.m_strDescription = m_pBrowserDescription->toPlainText();
     364    // TODO: Validate
    352365    //revalidate(m_pErrorPaneName);
    353366    notify();
     
    356369void UISnapshotDetailsWidget::prepare()
    357370{
    358     /* Apply UI decorations: */
    359     Ui::UISnapshotDetailsWidget::setupUi(this);
    360 
    361     /* Layout created in the .ui file: */
    362     {
    363         /* Name editor created in the .ui file: */
    364         AssertPtrReturnVoid(mLeName);
     371    /* 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);
     378        {
     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);
     384        }
     385        /* Create name editor: */
     386        m_pEditorName = new QLineEdit;
     387        AssertPtrReturnVoid(m_pEditorName);
    365388        {
    366389            /* Configure editor: */
    367             connect(mLeName, &QLineEdit::textChanged,
     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,
    368395                    this, &UISnapshotDetailsWidget::sltHandleNameChange);
    369         }
    370 
    371         /* Description editor created in the .ui file: */
    372         AssertPtrReturnVoid(mTeDescription);
    373         {
    374             /* Configure editor: */
    375             connect(mTeDescription, &QTextEdit::textChanged,
     396
     397            /* Add to layout: */
     398            pLayout->addWidget(m_pEditorName, 0, 1);
     399        }
     400
     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,
    376461                    this, &UISnapshotDetailsWidget::sltHandleDescriptionChange);
    377         }
    378 
    379         /* Thumbnail label created in the .ui file: */
    380         AssertPtrReturnVoid(mLbThumbnail);
    381         {
    382             /* Configure thumbnail label: */
    383             mLbThumbnail->setCursor(Qt::PointingHandCursor);
    384             mLbThumbnail->installEventFilter(this);
    385         }
    386 
    387         /* Details browser created in the .ui file: */
    388         AssertPtrReturnVoid(mTeDetails);
    389         {
    390             /* Configure details browser: */
    391             mTeDetails->viewport()->setAutoFillBackground(false);
    392             mTeDetails->setFocus();
     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);
    393494        }
    394495    }
     
    398499{
    399500    /* Read general snapshot properties: */
    400     mLeName->setText(m_newData.m_strName);
    401     mTeDescription->setText(m_newData.m_strDescription);
     501    m_pEditorName->setText(m_newData.m_strName);
     502    m_pBrowserDescription->setText(m_newData.m_strDescription);
    402503
    403504    /* If there is a snapshot: */
     
    409510        bool fDateTimeToday = timestamp.date() == QDate::currentDate();
    410511        QString dateTime = fDateTimeToday ? timestamp.time().toString(Qt::LocalDate) : timestamp.toString(Qt::LocalDate);
    411         mTxTaken->setText(dateTime);
     512        m_pLabelTakenText->setText(dateTime);
    412513
    413514        /* Read snapshot display contents: */
     
    435536        if (m_pixmapThumbnail.isNull())
    436537        {
    437             mLbThumbnail->setPixmap(QPixmap());
    438 
    439             pLayout->removeWidget(mLbThumbnail);
    440             mLbThumbnail->setHidden(true);
    441 
    442             pLayout->removeWidget(mLeName);
    443             pLayout->removeWidget(mTxTaken);
    444             pLayout->addWidget(mLeName, 0, 1, 1, 2);
    445             pLayout->addWidget(mTxTaken, 1, 1, 1, 2);
     538            m_pLabelThumbnail->setPixmap(QPixmap());
     539
     540            pLayout->removeWidget(m_pLabelThumbnail);
     541            m_pLabelThumbnail->setHidden(true);
     542
     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);
    446547        }
    447548        else
     
    449550            const QStyle *pStyle = QApplication::style();
    450551            const int iIconMetric = pStyle->pixelMetric(QStyle::PM_LargeIconSize);
    451             mLbThumbnail->setPixmap(m_pixmapThumbnail.scaled(QSize(1, iIconMetric),
     552            m_pLabelThumbnail->setPixmap(m_pixmapThumbnail.scaled(QSize(1, iIconMetric),
    452553                                                             Qt::KeepAspectRatioByExpanding,
    453554                                                             Qt::SmoothTransformation));
    454555
    455             pLayout->removeWidget(mLeName);
    456             pLayout->removeWidget(mTxTaken);
    457             pLayout->addWidget(mLeName, 0, 1);
    458             pLayout->addWidget(mTxTaken, 1, 1);
    459 
    460             pLayout->removeWidget(mLbThumbnail);
    461             pLayout->addWidget(mLbThumbnail, 0, 2, 2, 1);
    462             mLbThumbnail->setHidden(false);
     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);
     563            m_pLabelThumbnail->setHidden(false);
    463564        }
    464565    }
     
    466567    {
    467568        /* Clear snapshot timestamp info: */
    468         mTxTaken->clear();
     569        m_pLabelTakenText->clear();
    469570
    470571        // TODO: Check whether layout manipulations are really
     
    473574        AssertPtrReturnVoid(pLayout);
    474575        {
    475             mLbThumbnail->setPixmap(QPixmap());
    476 
    477             pLayout->removeWidget(mLbThumbnail);
    478             mLbThumbnail->setHidden(true);
    479 
    480             pLayout->removeWidget(mLeName);
    481             pLayout->removeWidget(mTxTaken);
    482             pLayout->addWidget(mLeName, 0, 1, 1, 2);
    483             pLayout->addWidget(mTxTaken, 1, 1, 1, 2);
     576            m_pLabelThumbnail->setPixmap(QPixmap());
     577
     578            pLayout->removeWidget(m_pLabelThumbnail);
     579            m_pLabelThumbnail->setHidden(true);
     580
     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);
    484585        }
    485586    }
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.h

    r67164 r67168  
    1919#define ___UISnapshotDetailsWidget_h___
    2020
     21/* Qt includes: */
     22#include <QWidget>
     23
    2124/* GUI includes: */
    2225#include "QIWithRetranslateUI.h"
    23 #include "UISnapshotDetailsWidget.gen.h"
    2426
    2527/* COM includes: */
    2628#include "CSnapshot.h"
     29
     30/* Forward declarations: */
     31class QLabel;
     32class QLineEdit;
     33class QTextEdit;
    2734
    2835
     
    5865
    5966/** QWidget extension providing GUI with snapshot details-widget. */
    60 class UISnapshotDetailsWidget : public QIWithRetranslateUI<QWidget>, public Ui::UISnapshotDetailsWidget
     67class UISnapshotDetailsWidget : public QIWithRetranslateUI<QWidget>
    6168{
    6269    Q_OBJECT;
     
    117124    /** Holds the cached screenshot. */
    118125    QPixmap  m_pixmapScreenshot;
     126
     127    /** Holds the name label instance. */
     128    QLabel    *m_pLabelName;
     129    /** Holds the name editor instance. */
     130    QLineEdit *m_pEditorName;
     131
     132    /** Holds the taken label instance. */
     133    QLabel *m_pLabelTaken;
     134    /** Holds the taken text instance. */
     135    QLabel *m_pLabelTakenText;
     136
     137    /** Holds the thumbnail label instance. */
     138    QLabel *m_pLabelThumbnail;
     139
     140    /** Holds the description label instance. */
     141    QLabel    *m_pLabelDescription;
     142    /** Holds the description editor instance. */
     143    QTextEdit *m_pBrowserDescription;
     144
     145    /** Holds the details label instance. */
     146    QLabel    *m_pLabelDetails;
     147    /** Holds the description editor instance. */
     148    QTextEdit *m_pBrowserDetails;
    119149};
    120150
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