VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/VBoxFilePathSelectorWidget.h@ 23373

Last change on this file since 23373 was 20524, checked in by vboxsync, 16 years ago

FE/Qt4: differ between open/save dialogs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VirtualBox Qt extensions: VBoxFilePathSelectorWidget class declaration
5 */
6
7/*
8 * Copyright (C) 2008 Sun Microsystems, Inc.
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#ifndef __VBoxFilePathSelectorWidget_h__
24#define __VBoxFilePathSelectorWidget_h__
25
26/* VBox includes */
27#include "QIWithRetranslateUI.h"
28
29/* Qt includes */
30#include <QComboBox>
31
32/* VBox forward declarations */
33class QILabel;
34class QILineEdit;
35
36/* Qt forward declarations */
37class QHBoxLayout;
38class QFileIconProvider;
39class QAction;
40class QPushButton;
41
42////////////////////////////////////////////////////////////////////////////////
43// VBoxFilePathSelectorWidget
44
45class VBoxFilePathSelectorWidget: public QIWithRetranslateUI<QComboBox>
46{
47 Q_OBJECT;
48
49public:
50
51 enum Mode
52 {
53 Mode_Folder = 0,
54 Mode_File_Open,
55 Mode_File_Save
56 };
57
58 VBoxFilePathSelectorWidget (QWidget *aParent);
59 ~VBoxFilePathSelectorWidget();
60
61 void setMode (Mode aMode);
62 Mode mode() const;
63
64 void setEditable (bool aOn);
65 bool isEditable() const;
66
67 void setResetEnabled (bool aEnabled);
68 bool isResetEnabled () const;
69
70 void setFileDialogTitle (const QString& aTitle);
71 QString fileDialogTitle() const;
72
73 void setFileFilters (const QString& aFilters);
74 QString fileFilters() const;
75
76 void setDefaultSaveExt (const QString &aExt);
77 QString defaultSaveExt() const;
78
79 void resetModified();
80 bool isModified() const;
81 bool isPathSelected() const;
82
83 QString path() const;
84
85signals:
86 void pathChanged (const QString &);
87
88public slots:
89
90 void setPath (const QString &aPath, bool aRefreshText = true);
91 void setHomeDir (const QString &aHomeDir);
92
93protected:
94
95 void resizeEvent (QResizeEvent *aEvent);
96 void focusInEvent (QFocusEvent *aEvent);
97 void focusOutEvent (QFocusEvent *aEvent);
98 bool eventFilter (QObject *aObj, QEvent *aEv);
99 void retranslateUi();
100
101private slots:
102
103 void onActivated (int aIndex);
104 void onTextEdited (const QString &aPath);
105 void copyToClipboard();
106 void refreshText();
107
108private:
109
110 void changePath (const QString &aPath, bool aRefreshText = true);
111 void selectPath();
112 QIcon defaultIcon() const;
113 QString fullPath (bool aAbsolute = true) const;
114 QString shrinkText (int aWidth) const;
115
116 /* Private member vars */
117 QFileIconProvider *mIconProvider;
118 QAction *mCopyAction;
119 Mode mMode;
120 QString mPath;
121 QString mHomeDir;
122 QString mFileFilters;
123 QString mDefaultSaveExt;
124 QString mFileDialogTitle;
125 QString mNoneStr;
126 QString mNoneTip;
127 bool mIsEditable;
128 bool mIsEditableMode;
129 bool mIsMouseAwaited;
130
131 bool mModified;
132};
133
134////////////////////////////////////////////////////////////////////////////////
135// VBoxEmptyFileSelector
136
137class VBoxEmptyFileSelector: public QIWithRetranslateUI<QWidget>
138{
139 Q_OBJECT;
140
141public:
142 enum ButtonPosition
143 {
144 LeftPosition,
145 RightPosition
146 };
147
148 VBoxEmptyFileSelector (QWidget *aParent = NULL);
149
150 void setMode (VBoxFilePathSelectorWidget::Mode aMode);
151 VBoxFilePathSelectorWidget::Mode mode() const;
152
153 void setButtonPosition (ButtonPosition aPos);
154 ButtonPosition buttonPosition() const;
155
156 void setEditable (bool aOn);
157 bool isEditable() const;
158
159 void setChooserVisible (bool aOn);
160 bool isChooserVisible() const;
161
162 QString path() const;
163
164 void setDefaultSaveExt (const QString &aExt);
165 QString defaultSaveExt() const;
166
167 bool isModified () const { return mIsModified; }
168 void resetModified () { mIsModified = false; }
169
170 void setFileDialogTitle (const QString& aTitle);
171 QString fileDialogTitle() const;
172
173 void setFileFilters (const QString& aFilters);
174 QString fileFilters() const;
175
176 void setHomeDir (const QString& aDir);
177 QString homeDir() const;
178
179signals:
180 void pathChanged (QString);
181
182public slots:
183 void setPath (const QString& aPath);
184
185protected:
186 void retranslateUi();
187
188private slots:
189 void choose();
190 void textChanged (const QString& aPath);
191
192private:
193 /* Private member vars */
194 QHBoxLayout *mMainLayout;
195 QWidget *mPathWgt;
196 QILabel *mLabel;
197 VBoxFilePathSelectorWidget::Mode mMode;
198 QILineEdit *mLineEdit;
199 QPushButton *mSelectButton;
200 QString mFileDialogTitle;
201 QString mFileFilters;
202 QString mDefaultSaveExt;
203 QString mHomeDir;
204 bool mIsModified;
205 QString mPath;
206};
207
208#endif /* __VBoxFilePathSelectorWidget_h__ */
209
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette