Changeset 60827 in vbox for trunk/src/VBox
- Timestamp:
- May 4, 2016 12:13:49 PM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilePathSelector.cpp
r60770 r60827 5 5 6 6 /* 7 * Copyright (C) 2008-201 3Oracle Corporation7 * Copyright (C) 2008-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 21 22 /* Local includes*/22 /* GUI includes: */ 23 23 # include "QIFileDialog.h" 24 24 # include "QIToolButton.h" … … 29 29 # include "VBoxGlobal.h" 30 30 31 /* Global includes*/31 /* Other VBox includes: */ 32 32 # include <iprt/assert.h> 33 34 /* Qt includes: */ 33 35 # include <QAction> 34 36 # include <QApplication> … … 50 52 51 53 52 /** 53 * Returns first position of difference between passed strings. 54 */ 54 /** Returns first position of difference between passed strings. */ 55 55 static int differFrom (const QString &aS1, const QString &aS2) 56 56 { … … 209 209 } 210 210 211 /**212 * Returns @c true if the selected (active) combobox item is a path item.213 *214 * May be used in @c activated() signal handlers to distinguish between215 * non-path items like "Other..." or "Reset" that get temporarily activated216 * when performing the corresponding action and the item that contains a217 * real selected file/folder path.218 */219 211 bool UIFilePathSelector::isPathSelected() const 220 212 { -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilePathSelector.h
r60770 r60827 5 5 6 6 /* 7 * Copyright (C) 2008-201 3Oracle Corporation7 * Copyright (C) 2008-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 #define ___UIFilePathSelector_h___ 20 20 21 /* VBox includes*/21 /* GUI includes: */ 22 22 #include "QIWithRetranslateUI.h" 23 23 24 /* Qt includes */24 /* Qt includes: */ 25 25 #include <QComboBox> 26 26 27 /* VBox forward declarations*/27 /* Forward declarations: */ 28 28 class QILabel; 29 29 class QILineEdit; 30 31 /* Qt forward declarations */32 30 class QHBoxLayout; 33 31 class QAction; … … 35 33 36 34 35 /** QComboBox extension providing GUI with 36 * possibility to choose/reflect file/folder path. */ 37 37 class UIFilePathSelector: public QIWithRetranslateUI<QComboBox> 38 38 { … … 41 41 public: 42 42 43 /** Modes file-path selector operates in. */ 43 44 enum Mode 44 45 { … … 48 49 }; 49 50 51 /** Constructs file-path selector passing @a aParent to QComboBox base-class. */ 50 52 UIFilePathSelector (QWidget *aParent); 53 /** Destructs file-path selector. */ 51 54 ~UIFilePathSelector(); 52 55 56 /** Defines the @a aMode to operate in. */ 53 57 void setMode (Mode aMode); 58 /** Returns the mode to operate in. */ 54 59 Mode mode() const; 55 60 61 /** Defines whether the possibility to edit the path is @a aOn. */ 56 62 void setEditable (bool aOn); 63 /** Returns whether the path is editable. */ 57 64 bool isEditable() const; 58 65 66 /** Defines whether the reseting to defauilt path is @a aEnabled. */ 59 67 void setResetEnabled (bool aEnabled); 68 /** Returns whether the reseting to defauilt path is enabled. */ 60 69 bool isResetEnabled () const; 61 70 71 /** Defines the file-dialog @a aTitle. */ 62 72 void setFileDialogTitle (const QString& aTitle); 73 /** Returns the file-dialog title. */ 63 74 QString fileDialogTitle() const; 64 75 76 /** Defines the file-dialog @a aFilters. */ 65 77 void setFileFilters (const QString& aFilters); 78 /** Returns the file-dialog filters. */ 66 79 QString fileFilters() const; 67 80 81 /** Defines the file-dialog default save @a aExt. */ 68 82 void setDefaultSaveExt (const QString &aExt); 83 /** Returns the file-dialog default save extension. */ 69 84 QString defaultSaveExt() const; 70 85 86 /** Resets path modified state to false. */ 71 87 void resetModified(); 88 /** Returns whether the path is modified. */ 72 89 bool isModified() const; 90 /** Returns whether the path is selected. */ 73 91 bool isPathSelected() const; 74 92 93 /** Returns the path. */ 75 94 QString path() const; 76 95 77 96 signals: 97 98 /** Notify listeners about path changed. */ 78 99 void pathChanged (const QString &); 79 100 80 101 public slots: 81 102 103 /** Defines the @a aPath and @a aRefreshText after that. */ 82 104 void setPath (const QString &aPath, bool aRefreshText = true); 105 106 /** Defines the @a aHomeDir. */ 83 107 void setHomeDir (const QString &aHomeDir); 84 108 85 109 protected: 86 110 111 /** Handles resize @a aEvent. */ 87 112 void resizeEvent (QResizeEvent *aEvent); 113 114 /** Handles focus-in @a aEvent. */ 88 115 void focusInEvent (QFocusEvent *aEvent); 116 /** Handles focus-out @a aEvent. */ 89 117 void focusOutEvent (QFocusEvent *aEvent); 118 119 /** Preprocesses every @a aEv sent to @a aObj. */ 90 120 bool eventFilter (QObject *aObj, QEvent *aEv); 121 122 /** Handles translation event. */ 91 123 void retranslateUi(); 92 124 93 125 private slots: 94 126 127 /** Handles combo-box activation. */ 95 128 void onActivated (int aIndex); 129 130 /** Handles combo-box text editing. */ 96 131 void onTextEdited (const QString &aPath); 132 133 /** Handles combo-box text copying. */ 97 134 void copyToClipboard(); 135 136 /** Refreshes combo-box text according to chosen path. */ 98 137 void refreshText(); 99 138 100 139 private: 101 140 141 /** Provokes change to @a aPath and @a aRefreshText after that. */ 102 142 void changePath (const QString &aPath, bool aRefreshText = true); 143 144 /** Call for file-dialog to choose path. */ 103 145 void selectPath(); 146 147 /** Returns default icon. */ 104 148 QIcon defaultIcon() const; 149 150 /** Returns full path @a aAbsolute if necessary. */ 105 151 QString fullPath (bool aAbsolute = true) const; 152 153 /** Shrinks the reflected text to @a aWidth pixels. */ 106 154 QString shrinkText (int aWidth) const; 107 155 108 /* Private member vars*/156 /** Holds the copy action instance. */ 109 157 QAction *mCopyAction; 158 159 /** Holds the mode to operate in. */ 110 160 Mode mMode; 161 162 /** Holds the path. */ 111 163 QString mPath; 164 /** Holds the home directory. */ 112 165 QString mHomeDir; 166 167 /** Holds the file-dialog filters. */ 113 168 QString mFileFilters; 169 /** Holds the file-dialog default save extension. */ 114 170 QString mDefaultSaveExt; 171 /** Holds the file-dialog title. */ 115 172 QString mFileDialogTitle; 173 174 /** Holds the cached text for empty path. */ 116 175 QString mNoneStr; 176 /** Holds the cached tool-tip for empty path. */ 117 177 QString mNoneTip; 178 179 /** Holds whether the path is editable. */ 118 180 bool mIsEditable; 181 182 /** Holds whether we are in editable mode. */ 119 183 bool mIsEditableMode; 184 /** Holds whether we are expecting mouse events. */ 120 185 bool mIsMouseAwaited; 121 186 187 /** Holds whether the path is modified. */ 122 188 bool mModified; 123 189 };
Note:
See TracChangeset
for help on using the changeset viewer.