Changeset 67168 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- May 31, 2017 12:20:29 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro
r67162 r67168 24 24 src/VBoxTakeSnapshotDlg.ui \ 25 25 src/UIVMLogViewer.ui \ 26 src/selector/UISnapshotDetailsWidget.ui \27 26 src/settings/UISettingsDialog.ui \ 28 27 src/settings/global/UIGlobalSettingsGeneral.ui \ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.cpp
r67164 r67168 22 22 /* Qt includes: */ 23 23 # include <QDateTime> 24 # include <QLabel> 25 # include <QLineEdit> 24 26 # include <QPushButton> 25 27 # include <QScrollArea> 28 # include <QTextEdit> 26 29 27 30 /* GUI includes: */ … … 261 264 UISnapshotDetailsWidget::UISnapshotDetailsWidget(QWidget *pParent /* = 0 */) 262 265 : 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) 263 271 { 264 272 /* Prepare: */ … … 295 303 { 296 304 /* We have filter for thumbnail label only: */ 297 AssertReturn(pObject == m LbThumbnail, false);305 AssertReturn(pObject == m_pLabelThumbnail, false); 298 306 299 307 /* For a mouse-press event inside the thumbnail area: */ … … 315 323 void UISnapshotDetailsWidget::retranslateUi() 316 324 { 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:")); 319 330 320 331 /* And if snapshot is valid: */ … … 325 336 326 337 /* Translate the picture tool-tip: */ 327 m LbThumbnail->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.")); 328 339 329 340 /* Rebuild the details report: */ 330 m TeDetails->setText(vboxGlobal().detailsReport(comMachine, false /* with links? */));341 m_pBrowserDetails->setText(vboxGlobal().detailsReport(comMachine, false /* with links? */)); 331 342 } 332 343 else 333 344 { 334 345 /* Clear the picture tool-tip: */ 335 m LbThumbnail->setToolTip(QString());346 m_pLabelThumbnail->setToolTip(QString()); 336 347 337 348 /* Clear the details report: */ 338 m TeDetails->clear();349 m_pBrowserDetails->clear(); 339 350 } 340 351 } … … 342 353 void UISnapshotDetailsWidget::sltHandleNameChange() 343 354 { 344 m_newData.m_strName = mLeName->text(); 355 m_newData.m_strName = m_pEditorName->text(); 356 // TODO: Validate 345 357 //revalidate(m_pErrorPaneName); 346 358 notify(); … … 349 361 void UISnapshotDetailsWidget::sltHandleDescriptionChange() 350 362 { 351 m_newData.m_strDescription = mTeDescription->toPlainText(); 363 m_newData.m_strDescription = m_pBrowserDescription->toPlainText(); 364 // TODO: Validate 352 365 //revalidate(m_pErrorPaneName); 353 366 notify(); … … 356 369 void UISnapshotDetailsWidget::prepare() 357 370 { 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); 365 388 { 366 389 /* 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, 368 395 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, 376 461 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); 393 494 } 394 495 } … … 398 499 { 399 500 /* Read general snapshot properties: */ 400 m LeName->setText(m_newData.m_strName);401 m TeDescription->setText(m_newData.m_strDescription);501 m_pEditorName->setText(m_newData.m_strName); 502 m_pBrowserDescription->setText(m_newData.m_strDescription); 402 503 403 504 /* If there is a snapshot: */ … … 409 510 bool fDateTimeToday = timestamp.date() == QDate::currentDate(); 410 511 QString dateTime = fDateTimeToday ? timestamp.time().toString(Qt::LocalDate) : timestamp.toString(Qt::LocalDate); 411 m TxTaken->setText(dateTime);512 m_pLabelTakenText->setText(dateTime); 412 513 413 514 /* Read snapshot display contents: */ … … 435 536 if (m_pixmapThumbnail.isNull()) 436 537 { 437 m LbThumbnail->setPixmap(QPixmap());438 439 pLayout->removeWidget(m LbThumbnail);440 m LbThumbnail->setHidden(true);441 442 pLayout->removeWidget(m LeName);443 pLayout->removeWidget(m TxTaken);444 pLayout->addWidget(m LeName, 0, 1, 1, 2);445 pLayout->addWidget(m TxTaken, 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); 446 547 } 447 548 else … … 449 550 const QStyle *pStyle = QApplication::style(); 450 551 const int iIconMetric = pStyle->pixelMetric(QStyle::PM_LargeIconSize); 451 m LbThumbnail->setPixmap(m_pixmapThumbnail.scaled(QSize(1, iIconMetric),552 m_pLabelThumbnail->setPixmap(m_pixmapThumbnail.scaled(QSize(1, iIconMetric), 452 553 Qt::KeepAspectRatioByExpanding, 453 554 Qt::SmoothTransformation)); 454 555 455 pLayout->removeWidget(m LeName);456 pLayout->removeWidget(m TxTaken);457 pLayout->addWidget(m LeName, 0, 1);458 pLayout->addWidget(m TxTaken, 1, 1);459 460 pLayout->removeWidget(m LbThumbnail);461 pLayout->addWidget(m LbThumbnail, 0, 2, 2, 1);462 m LbThumbnail->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); 463 564 } 464 565 } … … 466 567 { 467 568 /* Clear snapshot timestamp info: */ 468 m TxTaken->clear();569 m_pLabelTakenText->clear(); 469 570 470 571 // TODO: Check whether layout manipulations are really … … 473 574 AssertPtrReturnVoid(pLayout); 474 575 { 475 m LbThumbnail->setPixmap(QPixmap());476 477 pLayout->removeWidget(m LbThumbnail);478 m LbThumbnail->setHidden(true);479 480 pLayout->removeWidget(m LeName);481 pLayout->removeWidget(m TxTaken);482 pLayout->addWidget(m LeName, 0, 1, 1, 2);483 pLayout->addWidget(m TxTaken, 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); 484 585 } 485 586 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.h
r67164 r67168 19 19 #define ___UISnapshotDetailsWidget_h___ 20 20 21 /* Qt includes: */ 22 #include <QWidget> 23 21 24 /* GUI includes: */ 22 25 #include "QIWithRetranslateUI.h" 23 #include "UISnapshotDetailsWidget.gen.h"24 26 25 27 /* COM includes: */ 26 28 #include "CSnapshot.h" 29 30 /* Forward declarations: */ 31 class QLabel; 32 class QLineEdit; 33 class QTextEdit; 27 34 28 35 … … 58 65 59 66 /** QWidget extension providing GUI with snapshot details-widget. */ 60 class UISnapshotDetailsWidget : public QIWithRetranslateUI<QWidget> , public Ui::UISnapshotDetailsWidget67 class UISnapshotDetailsWidget : public QIWithRetranslateUI<QWidget> 61 68 { 62 69 Q_OBJECT; … … 117 124 /** Holds the cached screenshot. */ 118 125 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; 119 149 }; 120 150
Note:
See TracChangeset
for help on using the changeset viewer.