Changeset 85990 in vbox
- Timestamp:
- Sep 2, 2020 10:06:55 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/global
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsLanguage.cpp
r85822 r85990 200 200 : m_fPolished(false) 201 201 , m_pCache(0) 202 , m_p LanguageTree(0)203 , m_pLa nguageLabel(0)204 , m_pLa nguageInfo(0)202 , m_pTreeWidget(0) 203 , m_pLabelSeparator(0) 204 , m_pLabelInfo(0) 205 205 { 206 206 /* Prepare: */ … … 250 250 251 251 /* Gather new language data: */ 252 QTreeWidgetItem *pCurrentItem = m_p LanguageTree->currentItem();252 QTreeWidgetItem *pCurrentItem = m_pTreeWidget->currentItem(); 253 253 Assert(pCurrentItem); 254 254 if (pCurrentItem) … … 273 273 void UIGlobalSettingsLanguage::retranslateUi() 274 274 { 275 m_pLa nguageLabel->setText(tr("&Interface Languages"));276 QTreeWidgetItem *pTreeWidgetItem = m_p LanguageTree->headerItem();275 m_pLabelSeparator->setText(tr("&Interface Languages")); 276 QTreeWidgetItem *pTreeWidgetItem = m_pTreeWidget->headerItem(); 277 277 if (pTreeWidgetItem) 278 278 { … … 282 282 pTreeWidgetItem->setText(0, tr("Name")); 283 283 } 284 m_p LanguageTree->setWhatsThis(tr("Lists all available user interface "284 m_pTreeWidget->setWhatsThis(tr("Lists all available user interface " 285 285 "languages. The effective language is written in <b>bold</b>. " 286 286 "Select <i>Default</i> to reset to the system default language.")); … … 307 307 { 308 308 /* Remember current info-label width: */ 309 m_pLa nguageInfo->setMinimumTextWidth(m_pLanguageInfo->width());309 m_pLabelInfo->setMinimumTextWidth(m_pLabelInfo->width()); 310 310 } 311 311 … … 317 317 if (pLanguageItem->isBuiltIn()) 318 318 { 319 const QRect rect = m_p LanguageTree->visualItemRect(pLanguageItem);320 pPainter->setPen(m_p LanguageTree->palette().color(QPalette::Mid));319 const QRect rect = m_pTreeWidget->visualItemRect(pLanguageItem); 320 pPainter->setPen(m_pTreeWidget->palette().color(QPalette::Mid)); 321 321 pPainter->drawLine(rect.x(), rect.y() + rect.height() - 1, 322 322 rect.x() + rect.width(), rect.y() + rect.height() - 1); … … 333 333 const bool fEnabled = !pCurrentItem->text (1).isNull(); 334 334 335 m_pLa nguageInfo->setEnabled(fEnabled);336 m_pLa nguageInfo->setText(QString("<table>"335 m_pLabelInfo->setEnabled(fEnabled); 336 m_pLabelInfo->setText(QString("<table>" 337 337 "<tr><td>%1 </td><td>%2</td></tr>" 338 338 "<tr><td>%3 </td><td>%4</td></tr>" … … 346 346 void UIGlobalSettingsLanguage::prepare() 347 347 { 348 prepareWidgets();349 350 348 /* Prepare cache: */ 351 349 m_pCache = new UISettingsCacheGlobalLanguage; 352 350 AssertPtrReturnVoid(m_pCache); 353 351 354 /* Layout created in the .ui file. */ 355 { 356 /* Tree-widget created in the .ui file. */ 357 AssertPtrReturnVoid(m_pLanguageTree); 358 { 359 /* Configure tree-widget: */ 360 m_pLanguageTree->header()->hide(); 361 m_pLanguageTree->hideColumn(1); 362 m_pLanguageTree->hideColumn(2); 363 m_pLanguageTree->hideColumn(3); 364 m_pLanguageTree->setMinimumHeight(150); 365 connect(m_pLanguageTree, &QITreeWidget::painted, 366 this, &UIGlobalSettingsLanguage::sltHandleItemPainting); 367 connect(m_pLanguageTree, &QITreeWidget::currentItemChanged, 368 this, &UIGlobalSettingsLanguage::sltHandleCurrentItemChange); 369 } 370 371 /* Rich-text label created in the .ui file. */ 372 AssertPtrReturnVoid(m_pLanguageInfo); 373 { 374 /* Configure rich-text label: */ 375 m_pLanguageInfo->setWordWrapMode(QTextOption::WordWrap); 376 m_pLanguageInfo->setMinimumHeight(QFontMetrics(m_pLanguageInfo->font(), m_pLanguageInfo).height() * 5); 377 } 378 } 352 /* Prepare everything: */ 353 prepareWidgets(); 354 prepareConnection(); 379 355 380 356 /* Apply language settings: */ … … 384 360 void UIGlobalSettingsLanguage::prepareWidgets() 385 361 { 386 if (objectName().isEmpty()) 387 setObjectName(QStringLiteral("UIGlobalSettingsLanguage")); 388 QGridLayout *pMainLayout = new QGridLayout(this); 389 pMainLayout->setContentsMargins(0, 0, 0, 0); 390 pMainLayout->setObjectName(QStringLiteral("pMainLayout")); 391 m_pLanguageLabel = new QILabelSeparator(); 392 m_pLanguageLabel->setObjectName(QStringLiteral("m_pLanguageLabel")); 393 pMainLayout->addWidget(m_pLanguageLabel, 0, 0, 1, 1); 394 395 m_pLanguageTree = new QITreeWidget(); 396 m_pLanguageTree->setObjectName(QStringLiteral("m_pLanguageTree")); 397 m_pLanguageTree->setRootIsDecorated(false); 398 pMainLayout->addWidget(m_pLanguageTree, 1, 0, 1, 1); 399 400 m_pLanguageInfo = new QIRichTextLabel(); 401 m_pLanguageInfo->setObjectName(QStringLiteral("m_pLanguageInfo")); 402 403 pMainLayout->addWidget(m_pLanguageInfo, 2, 0, 1, 1); 404 m_pLanguageLabel->setBuddy(m_pLanguageTree); 362 /* Prepare main layout: */ 363 QGridLayout *pLayoutMain = new QGridLayout(this); 364 if (pLayoutMain) 365 { 366 pLayoutMain->setContentsMargins(0, 0, 0, 0); 367 368 /* Prepare separator: */ 369 m_pLabelSeparator = new QILabelSeparator(this); 370 if (m_pLabelSeparator) 371 pLayoutMain->addWidget(m_pLabelSeparator, 0, 0); 372 /* Prepare tree-widget: */ 373 m_pTreeWidget = new QITreeWidget(this); 374 if (m_pTreeWidget) 375 { 376 if (m_pLabelSeparator) 377 m_pLabelSeparator->setBuddy(m_pTreeWidget); 378 m_pTreeWidget->header()->hide(); 379 m_pTreeWidget->setColumnCount(4); 380 m_pTreeWidget->hideColumn(1); 381 m_pTreeWidget->hideColumn(2); 382 m_pTreeWidget->hideColumn(3); 383 m_pTreeWidget->setRootIsDecorated(false); 384 385 pLayoutMain->addWidget(m_pTreeWidget, 1, 0); 386 } 387 388 /* Prepare info label: */ 389 m_pLabelInfo = new QIRichTextLabel(this); 390 if (m_pLabelInfo) 391 { 392 m_pLabelInfo->setWordWrapMode(QTextOption::WordWrap); 393 m_pLabelInfo->setMinimumHeight(QFontMetrics(m_pLabelInfo->font(), m_pLabelInfo).height() * 5); 394 395 pLayoutMain->addWidget(m_pLabelInfo, 2, 0); 396 } 397 } 398 } 399 400 void UIGlobalSettingsLanguage::prepareConnection() 401 { 402 connect(m_pTreeWidget, &QITreeWidget::painted, 403 this, &UIGlobalSettingsLanguage::sltHandleItemPainting); 404 connect(m_pTreeWidget, &QITreeWidget::currentItemChanged, 405 this, &UIGlobalSettingsLanguage::sltHandleCurrentItemChange); 405 406 } 406 407 … … 415 416 { 416 417 /* Clear languages tree: */ 417 m_p LanguageTree->clear();418 m_pTreeWidget->clear(); 418 419 419 420 /* Load languages tree: */ … … 429 430 QTranslator translator; 430 431 /* Add the default language: */ 431 new UILanguageItem(m_p LanguageTree);432 new UILanguageItem(m_pTreeWidget); 432 433 /* Add the built-in language: */ 433 new UILanguageItem(m_p LanguageTree, translator, UICommon::vboxBuiltInLanguageName(), true /* built-in */);434 new UILanguageItem(m_pTreeWidget, translator, UICommon::vboxBuiltInLanguageName(), true /* built-in */); 434 435 /* Add all existing languages */ 435 436 for (QStringList::Iterator it = files.begin(); it != files.end(); ++it) … … 450 451 continue; 451 452 452 new UILanguageItem(m_p LanguageTree, translator, regExp.cap(1));453 new UILanguageItem(m_pTreeWidget, translator, regExp.cap(1)); 453 454 } 454 455 455 456 /* Adjust selector list: */ 456 m_p LanguageTree->resizeColumnToContents(0);457 m_pTreeWidget->resizeColumnToContents(0); 457 458 458 459 /* Search for necessary language: */ 459 QList<QTreeWidgetItem*> itemsList = m_p LanguageTree->findItems(strLanguageId, Qt::MatchExactly, 1);460 QList<QTreeWidgetItem*> itemsList = m_pTreeWidget->findItems(strLanguageId, Qt::MatchExactly, 1); 460 461 QTreeWidgetItem *pItem = itemsList.isEmpty() ? 0 : itemsList[0]; 461 462 if (!pItem) 462 463 { 463 464 /* Add an pItem for an invalid language to represent it in the list: */ 464 pItem = new UILanguageItem(m_p LanguageTree, strLanguageId);465 m_p LanguageTree->resizeColumnToContents(0);465 pItem = new UILanguageItem(m_pTreeWidget, strLanguageId); 466 m_pTreeWidget->resizeColumnToContents(0); 466 467 } 467 468 Assert(pItem); 468 469 if (pItem) 469 m_p LanguageTree->setCurrentItem(pItem);470 471 m_p LanguageTree->sortItems(0, Qt::AscendingOrder);472 m_p LanguageTree->scrollToItem(pItem);470 m_pTreeWidget->setCurrentItem(pItem); 471 472 m_pTreeWidget->sortItems(0, Qt::AscendingOrder); 473 m_pTreeWidget->scrollToItem(pItem); 473 474 } 474 475 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsLanguage.h
r85822 r85990 83 83 /** Prepares widgets. */ 84 84 void prepareWidgets(); 85 /** Prepares connections. */ 86 void prepareConnection(); 85 87 /** Cleanups all. */ 86 88 void cleanup(); … … 93 95 94 96 /** Holds whether the page is polished. */ 95 bool m_fPolished;97 bool m_fPolished; 96 98 97 99 /** Holds the page data cache instance. */ … … 100 102 /** @name Widgets 101 103 * @{ */ 102 QITreeWidget *m_pLanguageTree; 103 QILabelSeparator *m_pLanguageLabel; 104 QIRichTextLabel *m_pLanguageInfo; 104 /** Holds the tree-widget instance. */ 105 QITreeWidget *m_pTreeWidget; 106 /** Holds the separator label instance. */ 107 QILabelSeparator *m_pLabelSeparator; 108 /** Holds the info label instance. */ 109 QIRichTextLabel *m_pLabelInfo; 105 110 /** @} */ 106 111 };
Note:
See TracChangeset
for help on using the changeset viewer.