- Timestamp:
- Oct 11, 2021 6:11:33 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 147396
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilePathSelector.cpp
r91445 r91669 60 60 , m_enmMode(Mode_Folder) 61 61 , m_strInitialPath(QDir::current().absolutePath()) 62 , m_fResetEnabled(true) 62 63 , m_fEditable(true) 63 64 , m_fModified(false) … … 66 67 , m_fToolTipOverriden(false) 67 68 , m_pCopyAction(new QAction(this)) 69 , m_iRecentListSeparatorPosition(ResetId + 1) 68 70 , m_enmRecentMediaListType(UIMediumDeviceType_Invalid) 69 71 { … … 154 156 void UIFilePathSelector::setResetEnabled(bool fEnabled) 155 157 { 158 /* Cache requested state: */ 159 m_fResetEnabled = fEnabled; 160 161 /* Update recent list separator position: */ 162 m_iRecentListSeparatorPosition = fEnabled ? ResetId + 1 : ResetId; 163 156 164 if (!fEnabled && count() - 1 == ResetId) 157 165 removeItem(ResetId); … … 344 352 void UIFilePathSelector::onActivated(int iIndex) 345 353 { 346 switch (iIndex) 347 { 348 case SelectId: 349 { 350 selectPath(); 351 break; 352 } 353 case ResetId: 354 { 355 if (m_strDefaultPath.isEmpty()) 356 changePath(QString()); 357 else 358 changePath(m_strDefaultPath); 359 break; 360 } 361 default: 362 { 363 if (iIndex >= RecentListSeparator) 364 { 365 changePath(itemText(iIndex)); 366 update(); 367 } 368 break; 369 } 370 } 354 /* Since the presence of ResetId and position of recent list separator 355 * are dynamical now, we should control condition more carefully: */ 356 if (iIndex == SelectId) 357 selectPath(); 358 else if (m_fResetEnabled && iIndex == ResetId) 359 { 360 if (m_strDefaultPath.isEmpty()) 361 changePath(QString()); 362 else 363 changePath(m_strDefaultPath); 364 } 365 else if (iIndex >= m_iRecentListSeparatorPosition) 366 { 367 /* Switch back to Path item early, lineEdit() in refreshText() 368 * should be related to this exactly item: */ 369 setCurrentIndex(PathId); 370 changePath(itemText(iIndex)); 371 } 372 371 373 setCurrentIndex(PathId); 372 374 setFocus(); … … 390 392 bool fRefreshText /* = true */) 391 393 { 392 const QString strOldPath = m_strPath;394 const QString strOldPath = QDir::toNativeSeparators(m_strPath); 393 395 setPath(strPath, fRefreshText); 394 396 if (!m_fModified && m_strPath != strOldPath) … … 613 615 { 614 616 /* Remove the recent media list from the end of the combo: */ 615 while (count() >= static_cast<int>(RecentListSeparator)) 616 { 617 while (count() >= m_iRecentListSeparatorPosition) 617 618 removeItem(count() - 1); 618 }619 619 620 620 … … 641 641 return; 642 642 643 insertSeparator( RecentListSeparator);643 insertSeparator(m_iRecentListSeparatorPosition); 644 644 foreach (const QString strPath, recentMedia) 645 645 addItem(strPath); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilePathSelector.h
r91445 r91669 66 66 PathId = 0, 67 67 SelectId, 68 ResetId, 69 RecentListSeparator 68 ResetId 70 69 }; 71 70 … … 205 204 QString m_strNoneToolTipFocused; 206 205 206 /** Holds whether editor has Reset action. */ 207 bool m_fResetEnabled; 208 207 209 /** Holds whether the path is editable. */ 208 210 bool m_fEditable; … … 224 226 QString m_strDefaultPath; 225 227 228 /** Holds the recent list separator position. */ 229 int m_iRecentListSeparatorPosition; 226 230 /** Holds whether medium type for recent media list. If it is UIMediumDeviceType_Invalid the recent list is not shown. */ 227 231 UIMediumDeviceType m_enmRecentMediaListType;
Note:
See TracChangeset
for help on using the changeset viewer.