- Timestamp:
- Aug 14, 2008 3:27:03 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 34771
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxFilePathSelectorWidget.h
r11361 r11427 44 44 }; 45 45 46 VBoxFilePathSelectorWidget (QWidget *aParent = 0);46 VBoxFilePathSelectorWidget (QWidget *aParent); 47 47 ~VBoxFilePathSelectorWidget(); 48 48 … … 53 53 bool isResetEnabled () const; 54 54 55 #if 056 57 /// @todo enabling this requires to allow to customize the names of the58 /// "Other..." and "Reset" items too which is not yet done.59 60 void setNoneToolTip (const QString &aText);61 void setSelectToolTip (const QString &aText);62 void setResetToolTip (const QString &aText);63 64 #endif /* 0 */65 66 55 bool isModified() const; 67 68 public slots:69 56 70 57 void setPath (const QString &aPath); … … 74 61 75 62 void selectPath(); 76 void resetPath();77 63 78 64 protected: … … 89 75 90 76 QIcon defaultIcon() const; 91 QString f ilePath() const;77 QString fullPath (bool aAbsolute = true) const; 92 78 QString shrinkText (int aWidth) const; 93 79 void refreshText(); -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGLSettingsGeneral.h
r10212 r11427 49 49 private slots: 50 50 51 void onResetFolderClicked();52 51 void onSelectFolderClicked(); 53 52 }; -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsGeneral.h
r10167 r11427 64 64 65 65 void selectSnapshotFolder(); 66 void resetSnapshotFolder();67 66 68 67 private: -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxFilePathSelectorWidget.cpp
r11361 r11427 22 22 23 23 #include "VBoxFilePathSelectorWidget.h" 24 #include "VBoxGlobal.h" 24 25 25 26 /* Qt includes */ … … 30 31 #include <QFileIconProvider> 31 32 32 #include <VBoxDefs.h>33 34 33 enum 35 34 { … … 39 38 }; 40 39 41 VBoxFilePathSelectorWidget::VBoxFilePathSelectorWidget (QWidget *aParent /* = 0 */)40 VBoxFilePathSelectorWidget::VBoxFilePathSelectorWidget (QWidget *aParent) 42 41 : QIWithRetranslateUI<QComboBox> (aParent) 43 42 , mIconProvider (new QFileIconProvider()) … … 50 49 insertItem (ResetId, ""); 51 50 51 /* Attaching known icons */ 52 setItemIcon (SelectId, VBoxGlobal::iconSet (":/select_file_16px.png")); 53 setItemIcon (ResetId, VBoxGlobal::iconSet (":/eraser_16px.png")); 54 52 55 /* Setup context menu */ 53 56 addAction (mCopyAction); … … 65 68 setContextMenuPolicy (Qt::ActionsContextMenu); 66 69 setMinimumWidth (200); 67 /* Set path to None */68 setPath (QString::null);69 70 } 70 71 … … 89 90 removeItem (ResetId); 90 91 else if (aEnabled && count() - 1 == ResetId - 1) 92 { 91 93 insertItem (ResetId, ""); 94 setItemIcon (ResetId, VBoxGlobal::iconSet (":/eraser_16px.png")); 95 } 92 96 retranslateUi(); 93 97 } 94 98 95 bool VBoxFilePathSelectorWidget::isResetEnabled 99 bool VBoxFilePathSelectorWidget::isResetEnabled() const 96 100 { 97 101 return (count() - 1 == ResetId); 98 102 } 99 103 100 #if 0101 102 /// @todo enabling this requires to allow to customize the names of the103 /// "Other..." and "Reset" items too which is not yet done.104 105 void VBoxFilePathSelectorWidget::setNoneToolTip (const QString &aText)106 {107 mNoneTip = aText;108 if (mPath.isNull())109 {110 setItemData (PathId, mNoneTip, Qt::ToolTipRole);111 setToolTip (mNoneTip);112 }113 }114 115 void VBoxFilePathSelectorWidget::setSelectToolTip (const QString &aText)116 {117 setItemData (SelectId, aText, Qt::ToolTipRole);118 }119 120 void VBoxFilePathSelectorWidget::setResetToolTip (const QString &aText)121 {122 setItemData (ResetId, aText, Qt::ToolTipRole);123 }124 125 #endif /* 0 */126 127 104 bool VBoxFilePathSelectorWidget::isModified() const 128 105 { … … 133 110 { 134 111 mPath = aPath.isEmpty() ? QString::null : aPath; 135 136 112 refreshText(); 137 113 } … … 150 126 void VBoxFilePathSelectorWidget::retranslateUi() 151 127 { 152 /* how do we interpret the "nothing selected" item? */128 /* How do we interpret the "nothing selected" item? */ 153 129 if (isResetEnabled()) 154 130 { … … 179 155 setItemText (ResetId, tr ("Reset")); 180 156 181 /* set tooltips of the above two items based on the mode */157 /* Set tooltips of the above two items based on the mode */ 182 158 switch (mMode) 183 159 { … … 217 193 case ResetId: 218 194 { 219 emit resetPath();195 setPath (QString::null); 220 196 break; 221 197 } … … 228 204 void VBoxFilePathSelectorWidget::copyToClipboard() 229 205 { 230 QString text = itemData (PathId, Qt::ToolTipRole).toString(); 206 QString text (fullPath()); 207 /* Copy the current text to the selection and global clipboard. */ 208 if (QApplication::clipboard()->supportsSelection()) 209 QApplication::clipboard()->setText (text, QClipboard::Selection); 231 210 QApplication::clipboard()->setText (text, QClipboard::Clipboard); 232 QApplication::clipboard()->setText (text, QClipboard::Selection);233 211 } 234 212 … … 241 219 } 242 220 243 QString VBoxFilePathSelectorWidget::filePath() const 244 { 245 /// @todo (r=dmik) why is it used as if it always returns a full path while 246 /// it actually may not? 247 221 QString VBoxFilePathSelectorWidget::fullPath (bool aAbsolute) const 222 { 248 223 if (!mPath.isNull()) 249 224 { … … 251 226 { 252 227 case Mode_Folder: 253 return QDir (mPath).path(); 228 return aAbsolute ? QDir (mPath).absolutePath() : 229 QDir (mPath).path(); 254 230 case Mode_File: 255 return QFileInfo (mPath).filePath(); 231 return aAbsolute ? QFileInfo (mPath).absoluteFilePath() : 232 QFileInfo (mPath).filePath(); 256 233 default: 257 234 AssertFailedBreak(); 258 235 } 259 236 } 260 261 237 return QString::null; 262 238 } … … 264 240 QString VBoxFilePathSelectorWidget::shrinkText (int aWidth) const 265 241 { 266 QString fullText = filePath();242 QString fullText (fullPath (false)); 267 243 if (fullText.isEmpty()) 268 244 return fullText; … … 300 276 int newSize = fontMetrics().width (fullText); 301 277 302 return newSize < oldSize ? fullText : f ilePath();278 return newSize < oldSize ? fullText : fullPath (false); 303 279 } 304 280 … … 329 305 defaultIcon()); 330 306 331 /* S tore full path astooltip */332 setToolTip (f ilePath());307 /* Set the tooltip */ 308 setToolTip (fullPath()); 333 309 setItemData (PathId, toolTip(), Qt::ToolTipRole); 334 310 } -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGLSettingsGeneral.cpp
r11361 r11427 37 37 connect (mPsMach, SIGNAL (selectPath()), this, SLOT (onSelectFolderClicked())); 38 38 connect (mPsVRDP, SIGNAL (selectPath()), this, SLOT (onSelectFolderClicked())); 39 connect (mPsVdi, SIGNAL (resetPath()), this, SLOT (onResetFolderClicked()));40 connect (mPsMach, SIGNAL (resetPath()), this, SLOT (onResetFolderClicked()));41 connect (mPsVRDP, SIGNAL (resetPath()), this, SLOT (onResetFolderClicked()));42 39 43 40 /* Applying language settings */ … … 89 86 } 90 87 91 void VBoxGLSettingsGeneral::onResetFolderClicked()92 {93 VBoxFilePathSelectorWidget *ps = qobject_cast<VBoxFilePathSelectorWidget*> (sender());94 Assert (ps);95 ps->setPath (QString::null);96 }97 98 88 void VBoxGLSettingsGeneral::onSelectFolderClicked() 99 89 { -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsGeneral.cpp
r11361 r11427 77 77 connect (mPsSnapshot, SIGNAL (selectPath()), 78 78 this, SLOT (selectSnapshotFolder())); 79 connect (mPsSnapshot, SIGNAL (resetPath()),80 this, SLOT (resetSnapshotFolder()));81 79 connect (mTbBootItemUp, SIGNAL (clicked()), 82 80 this, SLOT (moveBootItemUp())); … … 467 465 } 468 466 469 void VBoxVMSettingsGeneral::resetSnapshotFolder()470 {471 mPsSnapshot->setPath (QString::null);472 }473 474 467 void VBoxVMSettingsGeneral::adjustBootOrderTWSize() 475 468 {
Note:
See TracChangeset
for help on using the changeset viewer.