Changeset 10658 in vbox for trunk/src/VBox
- Timestamp:
- Jul 15, 2008 1:36:57 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxPathSelector.h
r10649 r10658 2 2 * 3 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * VirtualBox Qt extensions: VBox PathSelectorclass declaration4 * VirtualBox Qt extensions: VBoxFilePathSelectorWidget class declaration 5 5 */ 6 6 … … 21 21 */ 22 22 23 #ifndef __VBox PathSelector_h__24 #define __VBox PathSelector_h__23 #ifndef __VBoxFilePathSelectorWidget_h__ 24 #define __VBoxFilePathSelectorWidget_h__ 25 25 26 26 #include "QIWithRetranslateUI.h" … … 39 39 class QComboBox; 40 40 41 class VBox PathSelector: public QIWithRetranslateUI<QWidget>41 class VBoxFilePathSelectorWidget: public QIWithRetranslateUI<QWidget> 42 42 { 43 43 Q_OBJECT; … … 45 45 public: 46 46 47 VBoxPathSelector (QWidget *aParent = NULL); 48 ~VBoxPathSelector(); 47 enum SelectorMode 48 { 49 PathMode = 0, 50 FileMode 51 }; 52 53 VBoxFilePathSelectorWidget (QWidget *aParent = NULL); 54 ~VBoxFilePathSelectorWidget(); 55 56 void setMode (SelectorMode aMode); 57 SelectorMode mode() const; 49 58 50 59 void setLineEditWhatsThis (const QString &aText); … … 75 84 76 85 void init(); 86 QIcon defaultIcon() const; 87 QString filePath (const QString &aName, bool bLast) const; 77 88 78 89 /* Private member vars */ 79 QString mPath; 80 QString mNoneStr; 90 SelectorMode mMode; 91 QString mPath; 92 QString mNoneStr; 93 81 94 #ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR 82 95 QComboBox *mCbPath; … … 91 104 }; 92 105 93 #endif /* __VBox PathSelector_h__ */106 #endif /* __VBoxFilePathSelectorWidget_h__ */ 94 107 -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGLSettingsGeneral.cpp
r10212 r10658 31 31 Ui::VBoxGLSettingsGeneral::setupUi (this); 32 32 33 mPsVRDP->setMode (VBoxFilePathSelectorWidget::FileMode); 34 33 35 /* Setup connections */ 34 connect (m TbVdiSelect, SIGNAL (clicked()), this, SLOT (onSelectFolderClicked()));35 connect (m TbMachSelect, SIGNAL (clicked()), this, SLOT (onSelectFolderClicked()));36 connect (m TbVRDPSelect, SIGNAL (clicked()), this, SLOT (onSelectFolderClicked()));37 connect (m TbVdiReset, SIGNAL (clicked()), this, SLOT (onResetFolderClicked()));38 connect (m TbMachReset, SIGNAL (clicked()), this, SLOT (onResetFolderClicked()));39 connect (m TbVRDPReset, SIGNAL (clicked()), this, SLOT (onResetFolderClicked()));36 connect (mPsVdi, SIGNAL (selectPath()), this, SLOT (onSelectFolderClicked())); 37 connect (mPsMach, SIGNAL (selectPath()), this, SLOT (onSelectFolderClicked())); 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())); 40 42 41 43 /* Applying language settings */ … … 46 48 const VBoxGlobalSettings &) 47 49 { 48 m LeVdi->setText(aProps.GetDefaultVDIFolder());49 m LeMach->setText(aProps.GetDefaultMachineFolder());50 m LeVRDP->setText(aProps.GetRemoteDisplayAuthLibrary());50 mPsVdi->setPath (aProps.GetDefaultVDIFolder()); 51 mPsMach->setPath (aProps.GetDefaultMachineFolder()); 52 mPsVRDP->setPath (aProps.GetRemoteDisplayAuthLibrary()); 51 53 } 52 54 … … 54 56 VBoxGlobalSettings &) 55 57 { 56 if (m LeVdi->isModified())57 aProps.SetDefaultVDIFolder (m LeVdi->text());58 if (aProps.isOk() && m LeMach->isModified())59 aProps.SetDefaultMachineFolder (m LeMach->text());60 if (m LeVRDP->isModified())61 aProps.SetRemoteDisplayAuthLibrary (m LeVRDP->text());58 if (mPsVdi->isModified()) 59 aProps.SetDefaultVDIFolder (mPsVdi->path()); 60 if (aProps.isOk() && mPsMach->isModified()) 61 aProps.SetDefaultMachineFolder (mPsMach->path()); 62 if (mPsVdi->isModified()) 63 aProps.SetRemoteDisplayAuthLibrary (mPsVRDP->path()); 62 64 } 63 65 64 66 void VBoxGLSettingsGeneral::setOrderAfter (QWidget *aWidget) 65 67 { 66 setTabOrder (aWidget, mLeVdi); 67 setTabOrder (mLeVdi, mTbVdiSelect); 68 setTabOrder (mTbVdiSelect, mTbVdiReset); 69 setTabOrder (mTbVdiReset, mLeMach); 70 setTabOrder (mLeMach, mTbMachSelect); 71 setTabOrder (mTbMachSelect, mTbMachReset); 72 setTabOrder (mTbMachReset, mLeVRDP); 73 setTabOrder (mLeVRDP, mTbVRDPSelect); 74 setTabOrder (mTbVRDPSelect, mTbVRDPReset); 68 setTabOrder (aWidget, mPsVdi); 69 setTabOrder (mPsVdi, mPsMach); 70 setTabOrder (mPsMach, mPsVRDP); 75 71 } 76 72 … … 79 75 /* Translate uic generated strings */ 80 76 Ui::VBoxGLSettingsGeneral::retranslateUi (this); 77 78 mPsVdi->setLineEditWhatsThis (tr ("Displays the path to the default VDI folder. This folder is used, if not explicitly specified otherwise, when adding existing or creating new virtual hard disks.")); 79 mPsVdi->setSelectorWhatsThis (tr ("Opens a dialog to select the default VDI folder.")); 80 mPsVdi->setResetWhatsThis (tr ("Resets the VDI folder path to the default value. The actual default path will be displayed after accepting the changes and opening this dialog again.")); 81 82 mPsMach->setLineEditWhatsThis (tr ("Displays the path to the default virtual machine folder. This folder is used, if not explicitly specified otherwise, when creating new virtual machines.")); 83 mPsMach->setSelectorWhatsThis (tr ("Opens a dialog to select the default virtual machine folder.")); 84 mPsMach->setResetWhatsThis (tr ("Resets the virtual machine folder path to the default value. The actual default path will be displayed after accepting the changes and opening this dialog again.")); 85 86 mPsVRDP->setLineEditWhatsThis (tr ("Displays the path to the library that provides authentication for Remote Display (VRDP) clients.")); 87 mPsVRDP->setSelectorWhatsThis (tr ("Opens a dialog to select the VRDP authentication library file.")); 88 mPsVRDP->setResetWhatsThis (tr ("Resets the authentication library file to the default value. The actual default library file will be displayed after accepting the changes and opening this dialog again.")); 81 89 } 82 90 83 91 void VBoxGLSettingsGeneral::onResetFolderClicked() 84 92 { 85 QToolButton *tb = qobject_cast<QToolButton*> (sender()); 86 Assert (tb); 87 88 QLineEdit *le = 0; 89 if (tb == mTbVdiReset) le = mLeVdi; 90 else if (tb == mTbMachReset) le = mLeMach; 91 else if (tb == mTbVRDPReset) le = mLeVRDP; 92 Assert (le); 93 94 /* Do this instead of le->setText (QString::null) to cause 95 * isModified() return true */ 96 le->selectAll(); 97 le->del(); 93 VBoxFilePathSelectorWidget *ps = qobject_cast<VBoxFilePathSelectorWidget*> (sender()); 94 Assert (ps); 95 ps->setPath (""); 98 96 } 99 97 100 98 void VBoxGLSettingsGeneral::onSelectFolderClicked() 101 99 { 102 QToolButton *tb = qobject_cast<QToolButton*> (sender());103 Assert ( tb);100 VBoxFilePathSelectorWidget *ps = qobject_cast<VBoxFilePathSelectorWidget*> (sender()); 101 Assert (ps); 104 102 105 QLineEdit *le = 0; 106 if (tb == mTbVdiSelect) le = mLeVdi; 107 else if (tb == mTbMachSelect) le = mLeMach; 108 else if (tb == mTbVRDPSelect) le = mLeVRDP; 109 Assert (le); 110 111 QString initDir = VBoxGlobal::getFirstExistingDir (le->text()); 103 QString initDir = VBoxGlobal::getFirstExistingDir (ps->path()); 112 104 if (initDir.isNull()) 113 105 initDir = vboxGlobal().virtualBox().GetHomeFolder(); 114 106 115 QString path = le == mLeVRDP ? 107 108 QString path = ps == mPsVRDP ? 116 109 VBoxGlobal::getOpenFileName (initDir, QString::null, this, QString::null) : 117 110 VBoxGlobal::getExistingDirectory (initDir, this); … … 123 116 path.remove (QRegExp ("[\\\\/]$")); 124 117 125 /* Do this instead of le->setText (QString::null) to cause 126 * isModified() return true */ 127 le->selectAll(); 128 le->insert (path); 118 ps->setPath (path); 129 119 } 130 120 -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxPathSelector.cpp
r10649 r10658 2 2 * 3 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * VirtualBox Qt extensions: VBox PathSelectorclass implementation4 * VirtualBox Qt extensions: VBoxFilePathSelectorWidget class implementation 5 5 */ 6 6 … … 43 43 }; 44 44 45 VBox PathSelector::VBoxPathSelector(QWidget *aParent /* = NULL */)45 VBoxFilePathSelectorWidget::VBoxFilePathSelectorWidget (QWidget *aParent /* = NULL */) 46 46 : QIWithRetranslateUI<QWidget> (aParent) 47 , mMode (PathMode) 47 48 { 48 49 init(); 49 50 } 50 51 51 VBox PathSelector::~VBoxPathSelector()52 VBoxFilePathSelectorWidget::~VBoxFilePathSelectorWidget() 52 53 { 53 54 delete mIconProvider; 54 55 } 55 56 56 void VBoxPathSelector::setLineEditWhatsThis (const QString &aText) 57 void VBoxFilePathSelectorWidget::setMode (SelectorMode aMode) 58 { 59 mMode = aMode; 60 } 61 62 VBoxFilePathSelectorWidget::SelectorMode VBoxFilePathSelectorWidget::mode() const 63 { 64 return mMode; 65 } 66 67 void VBoxFilePathSelectorWidget::setLineEditWhatsThis (const QString &aText) 57 68 { 58 69 #ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR … … 63 74 } 64 75 65 void VBox PathSelector::setSelectorWhatsThis (const QString &aText)76 void VBoxFilePathSelectorWidget::setSelectorWhatsThis (const QString &aText) 66 77 { 67 78 #ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR … … 72 83 } 73 84 74 void VBox PathSelector::setResetWhatsThis (const QString &aText)85 void VBoxFilePathSelectorWidget::setResetWhatsThis (const QString &aText) 75 86 { 76 87 #ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR … … 81 92 } 82 93 83 bool VBox PathSelector::isModified() const94 bool VBoxFilePathSelectorWidget::isModified() const 84 95 { 85 96 #ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR … … 90 101 } 91 102 92 void VBox PathSelector::setPath (const QString &aPath)103 void VBoxFilePathSelectorWidget::setPath (const QString &aPath) 93 104 { 94 105 mPath = aPath; … … 99 110 icon = mIconProvider->icon (fi); 100 111 else 101 icon = mIconProvider->icon (QFileIconProvider::Folder);112 icon = defaultIcon(); 102 113 if (tmpPath.isEmpty()) 103 114 tmpPath = mNoneStr; 104 115 #ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR 105 QDir dir (tmpPath); 106 mCbPath->setItemText (PathId, dir.dirName()); 116 mCbPath->setItemText (PathId, filePath (tmpPath, true)); 107 117 mCbPath->setItemIcon (PathId, icon); 108 118 #else /* VBOX_USE_COMBOBOX_PATH_SELECTOR */ … … 110 120 * isModified() return true */ 111 121 mLePath->selectAll(); 112 mLePath->insert ( tmpPath);122 mLePath->insert (filePath (tmpPath, false)); 113 123 mLbIcon->setPixmap (icon.pixmap (16, 16)); 114 124 #endif /* !VBOX_USE_COMBOBOX_PATH_SELECTOR */ 115 125 } 116 126 117 QString VBox PathSelector::path() const127 QString VBoxFilePathSelectorWidget::path() const 118 128 { 119 129 return mPath; 120 130 } 121 131 122 void VBox PathSelector::retranslateUi()132 void VBoxFilePathSelectorWidget::retranslateUi() 123 133 { 124 134 #ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR … … 129 139 } 130 140 131 void VBox PathSelector::cbActivated (int aIndex)141 void VBoxFilePathSelectorWidget::cbActivated (int aIndex) 132 142 { 133 143 #ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR … … 151 161 } 152 162 153 void VBox PathSelector::init()163 void VBoxFilePathSelectorWidget::init() 154 164 { 155 165 mIconProvider = new QFileIconProvider(); … … 158 168 #ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR 159 169 mCbPath = new QComboBox(); 170 mCbPath->setMinimumWidth (200); 160 171 mCbPath->insertItem (PathId, ""); 161 172 mCbPath->insertItem (SelectId, ""); … … 167 178 mLbIcon = new QLabel(); 168 179 mLePath = new QLineEdit(); 180 mLePath->setMinimumWidth (180); 169 181 mLePath->setReadOnly (true); 170 182 mTbSelect = new QToolButton(); … … 188 200 } 189 201 202 QIcon VBoxFilePathSelectorWidget::defaultIcon() const 203 { 204 if (mMode == PathMode) 205 return mIconProvider->icon (QFileIconProvider::Folder); 206 else 207 return mIconProvider->icon (QFileIconProvider::File); 208 } 209 210 QString VBoxFilePathSelectorWidget::filePath (const QString &aName, bool bLast) const 211 { 212 if (mMode == PathMode) 213 { 214 QDir dir (aName); 215 if (bLast) 216 return dir.dirName(); 217 else 218 return dir.path(); 219 } 220 else 221 { 222 QFileInfo fi (aName); 223 if (bLast) 224 return fi.fileName(); 225 else 226 return fi.filePath(); 227 } 228 } 229 -
trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxGLSettingsGeneral.ui
r10536 r10658 23 23 <x>0</x> 24 24 <y>0</y> 25 <width>3 63</width>26 <height>1 44</height>25 <width>377</width> 26 <height>162</height> 27 27 </rect> 28 28 </property> … … 49 49 </property> 50 50 <property name="buddy" > 51 <cstring>m LeVdi</cstring>51 <cstring>mPsVdi</cstring> 52 52 </property> 53 53 </widget> 54 54 </item> 55 55 <item row="0" column="1" > 56 <widget class="QLineEdit" name="mLeVdi" > 57 <property name="sizePolicy" > 58 <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" > 59 <horstretch>0</horstretch> 60 <verstretch>0</verstretch> 61 </sizepolicy> 62 </property> 63 <property name="whatsThis" > 64 <string>Displays the path to the default VDI folder. This folder is used, if not explicitly specified otherwise, when adding existing or creating new virtual hard disks.</string> 65 </property> 66 </widget> 67 </item> 68 <item row="0" column="2" > 69 <widget class="QToolButton" name="mTbVdiSelect" > 70 <property name="whatsThis" > 71 <string>Opens a dialog to select the default VDI folder.</string> 72 </property> 73 <property name="icon" > 74 <iconset resource="../VirtualBox.qrc" >:/select_file_16px.png</iconset> 75 </property> 76 <property name="autoRaise" > 77 <bool>true</bool> 78 </property> 79 </widget> 80 </item> 81 <item row="0" column="3" > 82 <widget class="QToolButton" name="mTbVdiReset" > 83 <property name="whatsThis" > 84 <string>Resets the VDI folder path to the default value. The actual default path will be displayed after accepting the changes and opening this dialog again.</string> 85 </property> 86 <property name="icon" > 87 <iconset resource="../VirtualBox.qrc" >:/eraser_16px.png</iconset> 88 </property> 89 <property name="autoRaise" > 90 <bool>true</bool> 91 </property> 92 </widget> 56 <widget class="VBoxFilePathSelectorWidget" native="1" name="mPsVdi" /> 93 57 </item> 94 58 <item row="1" column="0" > … … 101 65 </property> 102 66 <property name="buddy" > 103 <cstring>m LeMach</cstring>67 <cstring>mPsMach</cstring> 104 68 </property> 105 69 </widget> 106 70 </item> 107 71 <item row="1" column="1" > 108 <widget class="QLineEdit" name="mLeMach" > 109 <property name="whatsThis" > 110 <string>Displays the path to the default virtual machine folder. This folder is used, if not explicitly specified otherwise, when creating new virtual machines.</string> 111 </property> 112 </widget> 72 <widget class="VBoxFilePathSelectorWidget" native="1" name="mPsMach" /> 113 73 </item> 114 <item row="1" column="2" > 115 <widget class="QToolButton" name="mTbMachSelect" > 116 <property name="whatsThis" > 117 <string>Opens a dialog to select the default virtual machine folder.</string> 118 </property> 119 <property name="icon" > 120 <iconset resource="../VirtualBox.qrc" >:/select_file_16px.png</iconset> 121 </property> 122 <property name="autoRaise" > 123 <bool>true</bool> 124 </property> 125 </widget> 126 </item> 127 <item row="1" column="3" > 128 <widget class="QToolButton" name="mTbMachReset" > 129 <property name="whatsThis" > 130 <string>Resets the virtual machine folder path to the default value. The actual default path will be displayed after accepting the changes and opening this dialog again.</string> 131 </property> 132 <property name="icon" > 133 <iconset resource="../VirtualBox.qrc" >:/eraser_16px.png</iconset> 134 </property> 135 <property name="autoRaise" > 136 <bool>true</bool> 137 </property> 138 </widget> 139 </item> 140 <item row="2" column="0" colspan="4" > 74 <item row="2" column="0" colspan="2" > 141 75 <widget class="Line" name="line" > 142 76 <property name="orientation" > … … 154 88 </property> 155 89 <property name="buddy" > 156 <cstring>m LeVRDP</cstring>90 <cstring>mPsVRDP</cstring> 157 91 </property> 158 92 </widget> 159 93 </item> 160 94 <item row="3" column="1" > 161 <widget class="QLineEdit" name="mLeVRDP" > 162 <property name="whatsThis" > 163 <string>Displays the path to the library that provides authentication for Remote Display (VRDP) clients.</string> 164 </property> 165 </widget> 166 </item> 167 <item row="3" column="2" > 168 <widget class="QToolButton" name="mTbVRDPSelect" > 169 <property name="whatsThis" > 170 <string>Opens a dialog to select the VRDP authentication library file.</string> 171 </property> 172 <property name="icon" > 173 <iconset resource="../VirtualBox.qrc" >:/select_file_16px.png</iconset> 174 </property> 175 <property name="autoRaise" > 176 <bool>true</bool> 177 </property> 178 </widget> 179 </item> 180 <item row="3" column="3" > 181 <widget class="QToolButton" name="mTbVRDPReset" > 182 <property name="whatsThis" > 183 <string>Resets the authentication library file to the default value. The actual default library file will be displayed after accepting the changes and opening this dialog again.</string> 184 </property> 185 <property name="icon" > 186 <iconset resource="../VirtualBox.qrc" >:/eraser_16px.png</iconset> 187 </property> 188 <property name="autoRaise" > 189 <bool>true</bool> 190 </property> 191 </widget> 95 <widget class="VBoxFilePathSelectorWidget" native="1" name="mPsVRDP" /> 192 96 </item> 193 97 <item row="4" column="1" > … … 206 110 </layout> 207 111 </widget> 112 <customwidgets> 113 <customwidget> 114 <class>VBoxFilePathSelectorWidget</class> 115 <extends>QWidget</extends> 116 <header>VBoxPathSelector.h</header> 117 <container>1</container> 118 </customwidget> 119 </customwidgets> 208 120 <resources> 209 121 <include location="../VirtualBox.qrc" /> -
trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxVMSettingsGeneral.ui
r10650 r10658 852 852 </item> 853 853 <item row="4" column="1" > 854 <widget class="VBox PathSelector" native="1" name="mPsSnapshot" />854 <widget class="VBoxFilePathSelectorWidget" native="1" name="mPsSnapshot" /> 855 855 </item> 856 856 <item row="5" column="1" > … … 977 977 </customwidget> 978 978 <customwidget> 979 <class>VBox PathSelector</class>979 <class>VBoxFilePathSelectorWidget</class> 980 980 <extends>QWidget</extends> 981 <header>VBox PathSelector.h</header>981 <header>VBoxFilePathSelectorWidget.h</header> 982 982 <container>1</container> 983 983 </customwidget>
Note:
See TracChangeset
for help on using the changeset viewer.