Changeset 35956 in vbox
- Timestamp:
- Feb 14, 2011 11:43:07 AM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSFDetails.cpp
r33882 r35956 7 7 8 8 /* 9 * Copyright (C) 2008-201 0Oracle Corporation9 * Copyright (C) 2008-2011 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 */ 19 19 20 #include "UIMachineSettingsSFDetails.h"21 #include "VBoxGlobal.h"22 23 20 /* Qt includes */ 24 21 #include <QDir> 25 22 #include <QPushButton> 26 23 27 UIMachineSettingsSFDetails::UIMachineSettingsSFDetails (DialogType aType, 28 bool aEnableSelector, /* for "permanent" checkbox */ 29 const SFoldersNameList &aUsedNames, 30 QWidget *aParent /* = NULL */) 31 : QIWithRetranslateUI2<QIDialog> (aParent) 32 , mType (aType) 33 , mUsePermanent (aEnableSelector) 34 , mUsedNames (aUsedNames) 24 /* Other includes */ 25 #include "UIMachineSettingsSFDetails.h" 26 #include "VBoxGlobal.h" 27 28 UIMachineSettingsSFDetails::UIMachineSettingsSFDetails(DialogType type, 29 bool fEnableSelector, /* for "permanent" checkbox */ 30 const SFoldersNameList &usedNames, 31 QWidget *pParent /* = 0 */) 32 : QIWithRetranslateUI2<QIDialog>(pParent) 33 , m_type(type) 34 , m_fUsePermanent(fEnableSelector) 35 , m_usedNames(usedNames) 35 36 { 36 /* Apply UI decorations */37 Ui::UIMachineSettingsSFDetails::setupUi 37 /* Apply UI decorations: */ 38 Ui::UIMachineSettingsSFDetails::setupUi(this); 38 39 39 mCbPermanent->setHidden (!aEnableSelector);40 41 /* No reset button */42 m PsPath->setResetEnabled (false);40 /* Setup widgets: */ 41 mPsPath->setResetEnabled(false); 42 mPsPath->setHomeDir(QDir::homePath()); 43 mCbPermanent->setHidden(!fEnableSelector); 43 44 44 45 /* Setup connections: */ 45 connect (mPsPath, SIGNAL (currentIndexChanged (int)), 46 this, SLOT (onSelectPath())); 47 connect (mPsPath, SIGNAL (pathChanged (const QString &)), 48 this, SLOT (onSelectPath())); 49 connect (mLeName, SIGNAL (textChanged (const QString &)), 50 this, SLOT (validate())); 46 connect(mPsPath, SIGNAL(currentIndexChanged(int)), this, SLOT(sltSelectPath())); 47 connect(mPsPath, SIGNAL(pathChanged(const QString &)), this, SLOT(sltSelectPath())); 48 connect(mLeName, SIGNAL(textChanged(const QString &)), this, SLOT(sltValidate())); 49 if (fEnableSelector) 50 connect(mCbPermanent, SIGNAL(toggled(bool)), this, SLOT(sltValidate())); 51 51 52 if (aEnableSelector) 53 { 54 connect (mCbPermanent, SIGNAL (toggled (bool)), 55 this, SLOT (validate())); 56 } 57 58 /* Applying language settings */ 52 /* Applying language settings: */ 59 53 retranslateUi(); 60 54 61 /* Validate the initial field s*/62 validate();55 /* Validate the initial field values: */ 56 sltValidate(); 63 57 58 /* Adjust dialog size: */ 64 59 adjustSize(); 65 60 66 61 #ifdef Q_WS_MAC 67 setSizePolicy 68 setFixedSize 62 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 63 setFixedSize(minimumSize()); 69 64 #endif /* Q_WS_MAC */ 70 65 } 71 66 72 void UIMachineSettingsSFDetails::setPath (const QString &aPath)67 void UIMachineSettingsSFDetails::setPath(const QString &strPath) 73 68 { 74 mPsPath->setPath (aPath);69 mPsPath->setPath(strPath); 75 70 } 76 71 … … 80 75 } 81 76 82 void UIMachineSettingsSFDetails::setName (const QString &aName)77 void UIMachineSettingsSFDetails::setName(const QString &strName) 83 78 { 84 mLeName->setText (aName);79 mLeName->setText(strName); 85 80 } 86 81 … … 90 85 } 91 86 92 void UIMachineSettingsSFDetails::setWriteable (bool aWritable)87 void UIMachineSettingsSFDetails::setWriteable(bool fWritable) 93 88 { 94 mCbReadonly->setChecked (!aWritable);89 mCbReadonly->setChecked(!fWritable); 95 90 } 96 91 … … 100 95 } 101 96 102 void UIMachineSettingsSFDetails::setAutoMount (bool aAutoMount)97 void UIMachineSettingsSFDetails::setAutoMount(bool fAutoMount) 103 98 { 104 mCbAutoMount->setChecked (aAutoMount);99 mCbAutoMount->setChecked(fAutoMount); 105 100 } 106 101 … … 110 105 } 111 106 112 void UIMachineSettingsSFDetails::setPermanent (bool aPermanent)107 void UIMachineSettingsSFDetails::setPermanent(bool fPermanent) 113 108 { 114 mCbPermanent->setChecked (aPermanent);109 mCbPermanent->setChecked(fPermanent); 115 110 } 116 111 117 112 bool UIMachineSettingsSFDetails::isPermanent() const 118 113 { 119 return m UsePermanent ? mCbPermanent->isChecked() : true;114 return m_fUsePermanent ? mCbPermanent->isChecked() : true; 120 115 } 121 116 122 117 void UIMachineSettingsSFDetails::retranslateUi() 123 118 { 124 /* Translate uic generated strings */125 Ui::UIMachineSettingsSFDetails::retranslateUi 119 /* Translate uic generated strings: */ 120 Ui::UIMachineSettingsSFDetails::retranslateUi(this); 126 121 127 switch (m Type)122 switch (m_type) 128 123 { 129 124 case AddType: 130 setWindowTitle (tr("Add Share"));125 setWindowTitle(tr("Add Share")); 131 126 break; 132 127 case EditType: 133 setWindowTitle (tr("Edit Share"));128 setWindowTitle(tr("Edit Share")); 134 129 break; 135 130 default: 136 AssertMsgFailed (("Incorrect SF Dialog type\n"));131 AssertMsgFailed(("Incorrect shared-folders dialog type: %d\n", m_type)); 137 132 } 138 133 } 139 134 140 void UIMachineSettingsSFDetails:: validate()135 void UIMachineSettingsSFDetails::sltValidate() 141 136 { 142 UISharedFolderType resultType = 143 mUsePermanent && !mCbPermanent->isChecked() ? ConsoleType : MachineType; 144 SFolderName pair = qMakePair (mLeName->text(), resultType); 137 UISharedFolderType resultType = m_fUsePermanent && !mCbPermanent->isChecked() ? ConsoleType : MachineType; 138 SFolderName pair = qMakePair(mLeName->text(), resultType); 145 139 146 mButtonBox->button (QDialogButtonBox::Ok)->setEnabled(!mPsPath->path().isEmpty() &&147 148 149 150 !mUsedNames.contains (pair));140 mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(!mPsPath->path().isEmpty() && 141 QDir(mPsPath->path()).exists() && 142 !mLeName->text().trimmed().isEmpty() && 143 !mLeName->text().contains(" ") && 144 !m_usedNames.contains (pair)); 151 145 } 152 146 153 void UIMachineSettingsSFDetails:: onSelectPath()147 void UIMachineSettingsSFDetails::sltSelectPath() 154 148 { 155 149 if (!mPsPath->isPathSelected()) 156 150 return; 157 151 158 QString folderName(mPsPath->path());159 #if defined (Q_ OS_WIN) || defined (Q_OS_OS2)160 if ( folderName[0].isLetter() && folderName[1] == ':' && folderName[2] == 0)152 QString strFolderName(mPsPath->path()); 153 #if defined (Q_WS_WIN) || defined (Q_OS_OS2) 154 if (strFolderName[0].isLetter() && strFolderName[1] == ':' && strFolderName[2] == 0) 161 155 { 162 156 /* VBoxFilePathSelectorWidget returns root path as 'X:', which is invalid path. 163 * Append the trailing backslash to get a valid root path 'X:\'. 164 */ 165 folderName += "\\"; 166 mPsPath->setPath(folderName); 157 * Append the trailing backslash to get a valid root path 'X:\': */ 158 strFolderName += "\\"; 159 mPsPath->setPath(strFolderName); 167 160 } 168 #endif 169 QDir folder (folderName);161 #endif /* Q_WS_WIN || Q_OS_OS2 */ 162 QDir folder(strFolderName); 170 163 if (!folder.isRoot()) 164 { 171 165 /* Processing non-root folder */ 172 mLeName->setText (folder.dirName().replace(' ', '_')); 166 mLeName->setText(folder.dirName().replace(' ', '_')); 167 } 173 168 else 174 169 { 175 /* Processing root folder */176 #if defined (Q_ OS_WIN) || defined (Q_OS_OS2)177 mLeName->setText (folderName.toUpper()[0] + "_DRIVE");178 #elif defined (Q_ OS_UNIX)179 mLeName->setText 170 /* Processing root folder: */ 171 #if defined (Q_WS_WIN) || defined (Q_OS_OS2) 172 mLeName->setText(strFolderName.toUpper()[0] + "_DRIVE"); 173 #elif defined (Q_WS_X11) 174 mLeName->setText("ROOT"); 180 175 #endif 181 176 } 182 /* Validate the field s*/183 validate();177 /* Validate the field values: */ 178 sltValidate(); 184 179 } 185 180 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSFDetails.h
r33882 r35956 6 6 7 7 /* 8 * Copyright (C) 2008 Oracle Corporation8 * Copyright (C) 2008-2011 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 #define __UIMachineSettingsSFDetails_h__ 21 21 22 /* Includes */ 22 23 #include "UIMachineSettingsSFDetails.gen.h" 23 24 #include "QIDialog.h" … … 25 26 #include "UIMachineSettingsSF.h" 26 27 28 /* Shared folders details dialog: */ 27 29 class UIMachineSettingsSFDetails : public QIWithRetranslateUI2<QIDialog>, 28 public Ui::UIMachineSettingsSFDetails30 public Ui::UIMachineSettingsSFDetails 29 31 { 30 32 Q_OBJECT; … … 38 40 }; 39 41 40 UIMachineSettingsSFDetails (DialogType aType,41 bool aEnableSelector, /* for "permanent" checkbox */42 const SFoldersNameList &aUsedNames,43 QWidget *aParent = NULL);42 UIMachineSettingsSFDetails(DialogType type, 43 bool fEnableSelector, /* for "permanent" checkbox */ 44 const SFoldersNameList &usedNames, 45 QWidget *pParent = 0); 44 46 45 void setPath (const QString &aPath);47 void setPath(const QString &strPath); 46 48 QString path() const; 47 49 48 void setName (const QString &aName);50 void setName(const QString &strName); 49 51 QString name() const; 50 52 51 void setWriteable (bool aWriteable);53 void setWriteable(bool fWriteable); 52 54 bool isWriteable() const; 53 55 54 void setAutoMount (bool aAutoMount);56 void setAutoMount(bool fAutoMount); 55 57 bool isAutoMounted() const; 56 58 57 void setPermanent (bool aPermanent);59 void setPermanent(bool fPermanent); 58 60 bool isPermanent() const; 59 61 … … 64 66 private slots: 65 67 66 void onSelectPath();67 void validate();68 void sltSelectPath(); 69 void sltValidate(); 68 70 69 71 private: 70 72 71 /* Private member vars */ 72 DialogType mType; 73 bool mUsePermanent; 74 SFoldersNameList mUsedNames; 73 DialogType m_type; 74 bool m_fUsePermanent; 75 SFoldersNameList m_usedNames; 75 76 }; 76 77
Note:
See TracChangeset
for help on using the changeset viewer.