Changeset 60829 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- May 4, 2016 1:47:14 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
r60828 r60829 20 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 21 22 /* GUI includes: */23 # include "QIFileDialog.h"24 # include "QIToolButton.h"25 # include "QILabel.h"26 # include "QILineEdit.h"27 # include "UIIconPool.h"28 # include "UIFilePathSelector.h"29 # include "VBoxGlobal.h"30 31 /* Other VBox includes: */32 # include <iprt/assert.h>33 34 22 /* Qt includes: */ 35 23 # include <QAction> … … 42 30 # include <QTimer> 43 31 32 /* GUI includes: */ 33 # include "QIFileDialog.h" 34 # include "QILabel.h" 35 # include "QILineEdit.h" 36 # include "QIToolButton.h" 37 # include "UIIconPool.h" 38 # include "UIFilePathSelector.h" 39 # include "VBoxGlobal.h" 40 41 /* Other VBox includes: */ 42 # include <iprt/assert.h> 43 44 44 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 45 45 … … 68 68 UIFilePathSelector::UIFilePathSelector(QWidget *pParent /* = 0 */) 69 69 : QIWithRetranslateUI<QComboBox>(pParent) 70 , m_pCopyAction(new QAction(this))71 70 , m_enmMode(Mode_Folder) 72 71 , m_strHomeDir(QDir::current().absolutePath()) 73 72 , m_fEditable(true) 73 , m_fModified(false) 74 74 , m_fEditableMode(false) 75 75 , m_fMouseAwaited(false) 76 , m_ fModified(false)76 , m_pCopyAction(new QAction(this)) 77 77 { 78 78 /* Populate items: */ … … 106 106 } 107 107 108 UIFilePathSelector::~UIFilePathSelector()109 {110 }111 112 void UIFilePathSelector::setMode(Mode enmMode)113 {114 m_enmMode = enmMode;115 }116 117 UIFilePathSelector::Mode UIFilePathSelector::mode() const118 {119 return m_enmMode;120 }121 122 108 void UIFilePathSelector::setEditable(bool fEditable) 123 109 { … … 169 155 } 170 156 171 void UIFilePathSelector::resetModified()172 {173 m_fModified = false;174 }175 176 bool UIFilePathSelector::isModified() const177 {178 return m_fModified;179 }180 181 void UIFilePathSelector::setFileDialogTitle(const QString& strTitle)182 {183 m_strFileDialogTitle = strTitle;184 }185 186 QString UIFilePathSelector::fileDialogTitle() const187 {188 return m_strFileDialogTitle;189 }190 191 void UIFilePathSelector::setFileDialogFilters(const QString& strFilters)192 {193 m_strFileDialogFilters = strFilters;194 }195 196 QString UIFilePathSelector::fileDialogFilters() const197 {198 return m_strFileDialogFilters;199 }200 201 void UIFilePathSelector::setFileDialogDefaultSaveExtension(const QString &strDefaultSaveExtension)202 {203 m_strFileDialogDefaultSaveExtension = strDefaultSaveExtension;204 }205 206 QString UIFilePathSelector::fileDialogDefaultSaveExtension() const207 {208 return m_strFileDialogDefaultSaveExtension;209 }210 211 157 bool UIFilePathSelector::isPathSelected() const 212 158 { … … 230 176 { 231 177 m_strHomeDir = strHomeDir; 178 } 179 180 bool UIFilePathSelector::eventFilter(QObject *pObject, QEvent *pEvent) 181 { 182 if (m_fMouseAwaited && (pEvent->type() == QEvent::MouseButtonPress)) 183 QTimer::singleShot(0, this, SLOT(refreshText())); 184 185 return QIWithRetranslateUI<QComboBox>::eventFilter(pObject, pEvent); 232 186 } 233 187 … … 260 214 } 261 215 QIWithRetranslateUI<QComboBox>::focusOutEvent(pEvent); 262 }263 264 bool UIFilePathSelector::eventFilter(QObject *pObject, QEvent *pEvent)265 {266 if (m_fMouseAwaited && (pEvent->type() == QEvent::MouseButtonPress))267 QTimer::singleShot(0, this, SLOT(refreshText()));268 269 return QIWithRetranslateUI<QComboBox>::eventFilter(pObject, pEvent);270 216 } 271 217 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilePathSelector.h
r60828 r60829 19 19 #define ___UIFilePathSelector_h___ 20 20 21 /* Qt includes: */ 22 #include <QComboBox> 23 21 24 /* GUI includes: */ 22 25 #include "QIWithRetranslateUI.h" 23 26 24 /* Qt includes: */25 #include <QComboBox>26 27 27 /* Forward declarations: */ 28 class QAction; 29 class QHBoxLayout; 28 30 class QILabel; 29 31 class QILineEdit; 30 class QHBoxLayout;31 class QAction;32 32 class QIToolButton; 33 33 … … 38 38 { 39 39 Q_OBJECT; 40 41 signals: 42 43 /** Notify listeners about @a strPath changed. */ 44 void pathChanged(const QString &strPath); 40 45 41 46 public: … … 51 56 /** Constructs file-path selector passing @a pParent to QComboBox base-class. */ 52 57 UIFilePathSelector(QWidget *pParent = 0); 53 /** Destructs file-path selector. */54 ~UIFilePathSelector();55 58 56 59 /** Defines the @a enmMode to operate in. */ 57 void setMode(Mode enmMode) ;60 void setMode(Mode enmMode) { m_enmMode = enmMode; } 58 61 /** Returns the mode to operate in. */ 59 Mode mode() const ;62 Mode mode() const { return m_enmMode; } 60 63 61 64 /** Defines whether the path is @a fEditable. */ … … 70 73 71 74 /** Defines the file-dialog @a strTitle. */ 72 void setFileDialogTitle(const QString &strTitle) ;75 void setFileDialogTitle(const QString &strTitle) { m_strFileDialogTitle = strTitle; } 73 76 /** Returns the file-dialog title. */ 74 QString fileDialogTitle() const ;77 QString fileDialogTitle() const { return m_strFileDialogTitle; } 75 78 76 79 /** Defines the file-dialog @a strFilters. */ 77 void setFileDialogFilters(const QString &strFilters) ;80 void setFileDialogFilters(const QString &strFilters) { m_strFileDialogFilters = strFilters; } 78 81 /** Returns the file-dialog filters. */ 79 QString fileDialogFilters() const ;82 QString fileDialogFilters() const { return m_strFileDialogFilters; } 80 83 81 84 /** Defines the file-dialog @a strDefaultSaveExtension. */ 82 void setFileDialogDefaultSaveExtension(const QString &strDefaultSaveExtension) ;85 void setFileDialogDefaultSaveExtension(const QString &strDefaultSaveExtension) { m_strFileDialogDefaultSaveExtension = strDefaultSaveExtension; } 83 86 /** Returns the file-dialog default save extension. */ 84 QString fileDialogDefaultSaveExtension() const ;87 QString fileDialogDefaultSaveExtension() const { return m_strFileDialogDefaultSaveExtension; } 85 88 86 89 /** Resets path modified state to false. */ 87 void resetModified() ;90 void resetModified() { m_fModified = false; } 88 91 /** Returns whether the path is modified. */ 89 bool isModified() const ;92 bool isModified() const { return m_fModified; } 90 93 /** Returns whether the path is selected. */ 91 94 bool isPathSelected() const; … … 93 96 /** Returns the path. */ 94 97 QString path() const; 95 96 signals:97 98 /** Notify listeners about @a strPath changed. */99 void pathChanged(const QString &strPath);100 98 101 99 public slots: … … 109 107 protected: 110 108 109 /** Preprocesses every @a pEvent sent to @a pObject. */ 110 bool eventFilter(QObject *pObject, QEvent *pEvent); 111 111 112 /** Handles resize @a pEvent. */ 112 113 void resizeEvent(QResizeEvent *pEvent); … … 116 117 /** Handles focus-out @a pEvent. */ 117 118 void focusOutEvent(QFocusEvent *pEvent); 118 119 /** Preprocesses every @a pEvent sent to @a pObject. */120 bool eventFilter(QObject *pObject, QEvent *pEvent);121 119 122 120 /** Handles translation event. */ … … 154 152 QString shrinkText(int iWidth) const; 155 153 156 /** Holds the copy action instance. */157 QAction *m_pCopyAction;158 159 154 /** Holds the mode to operate in. */ 160 155 Mode m_enmMode; … … 165 160 QString m_strHomeDir; 166 161 162 /** Holds the file-dialog title. */ 163 QString m_strFileDialogTitle; 167 164 /** Holds the file-dialog filters. */ 168 165 QString m_strFileDialogFilters; 169 166 /** Holds the file-dialog default save extension. */ 170 167 QString m_strFileDialogDefaultSaveExtension; 171 /** Holds the file-dialog title. */172 QString m_strFileDialogTitle;173 168 174 169 /** Holds the cached text for empty path. */ … … 179 174 /** Holds whether the path is editable. */ 180 175 bool m_fEditable; 176 /** Holds whether the path is modified. */ 177 bool m_fModified; 181 178 182 179 /** Holds whether we are in editable mode. */ … … 185 182 bool m_fMouseAwaited; 186 183 187 /** Holds whether the path is modified. */188 bool m_fModified;184 /** Holds the copy action instance. */ 185 QAction *m_pCopyAction; 189 186 }; 190 187
Note:
See TracChangeset
for help on using the changeset viewer.