![]() |
Workspace 7.1.0
|
Widget for specifying a file or directory name. More...
#include <Workspace/Widgets/filenamewidget.h>
Inherits QFrame.
Public Slots | |
void | resetFileName () |
void | setAcceptMode (QFileDialog::AcceptMode mode) |
void | setDirectoryMode (bool mode) |
void | setFileName (const QString &str) |
void | setHighlightInvalidFilePath (bool highlightInvalidFilePath) |
void | setNameFilters (const QStringList &filters) |
void | setShowRefreshButton (bool show) |
void | setShowTextField (bool show) |
void | setWarningMode (bool warningsOn) |
void | showRelativeToWorkspaceCheckbox (bool show) |
Signals | |
void | acceptModeChanged (QFileDialog::AcceptMode mode) |
void | directoryModeChanged (bool mode) |
void | editingFinished () |
void | fileNameChanged (const QString &fileName) |
void | forceFileReload () |
void | nameFiltersChanged (const QStringList &filters) |
void | showRefreshButtonChanged (bool show) |
void | userEditingFinished () |
void | warningModeChanged (bool mode) |
Public Member Functions | |
FileNameWidget (QWidget *parent=nullptr) | |
~FileNameWidget () override | |
QFileDialog::AcceptMode | getAcceptMode () const |
bool | getDirectoryMode () const |
QString | getFileName () const |
bool | getHighlightInvalidFilePath () const |
const QStringList & | getNameFilters () const |
bool | getShowRefreshButton () const |
bool | getShowRelativePathCheckBox () const |
bool | getShowTextField () const |
bool | getWarningMode () const |
void | setReadOnly (bool b) |
Protected Member Functions | |
void | enterEvent (QEvent *event) override |
Properties | |
QFileDialog::AcceptMode | acceptMode |
bool | directoryMode |
QString | fileName |
bool | highlightInvalidFilePath |
QStringList | nameFilters |
bool | showRefreshButton |
bool | showRelativePathCheckBox |
bool | showTextField |
bool | warnIfFileExists |
The widget is relatively simple, consisting of a line edit and a button. The button opens a file dialog which allows users to traverse the file system in order to select a file (or directory). It offers some basic configuration of the file dialog to customise it to the intended use of the widget.
FileNameWidget | ( | QWidget * | parent = nullptr | ) |
The widget is initially constructed with no filters, the accept mode set to QFileDialog::AcceptOpen
, the directory mode set to off and to not warn if the file name already exists.
|
overridedefault |
|
signal |
|
signal |
|
signal |
This signal is emitted when the line edit part of the widget loses focus, when the user presses Return or Enter in the line edit part of the widget, or when the user accepts a selection from the file dialog opened via the button on the widget. Client code wanting to be notified of updates in a "batched" mode rather than every character change as the user types should connect to this signal rather than fileNameChanged().
|
overrideprotected |
|
signal |
This signal is emitted any time the file name changes for any reason. This includes both user interaction and the file name being changed programmatically. It also includes the file name being changed as a result of a selection from the file dialog opened from the button on the widget.
Since this signal is emitted for each character change as the user types, it is often not the signal client code wants to connect to for committing the changes to some data structure, etc.. For a more "batched" approach, editingFinished() can be used to detect when a set of changes should be committed, leaving the fileNameChanged() signal to be used only to receive notification that a change took place without actually storing the changed text.
|
signal |
signals that the refresh button has been pressed and the file should be reloaded, even if the filename has not changed.
QFileDialog::AcceptMode getAcceptMode | ( | ) | const |
bool getDirectoryMode | ( | ) | const |
QString getFileName | ( | ) | const |
bool getHighlightInvalidFilePath | ( | ) | const |
const QStringList & getNameFilters | ( | ) | const |
bool getShowRefreshButton | ( | ) | const |
bool getShowRelativePathCheckBox | ( | ) | const |
bool getShowTextField | ( | ) | const |
bool getWarningMode | ( | ) | const |
The warnings referred to by this function are only raised when the user sets a file name via the file system browser button.
|
signal |
|
slot |
Clears the file name.
|
slot |
mode | Controls whether the file dialog created by the button will behave as a load or save dialog. |
The default value for the accept mode is QFileDialog::AcceptOpen
.
|
slot |
mode | If true, then the file dialog created by the button will be configured to return a directory name rather than a file name. This is entirely analogous to the QFileDialog::Directory enum value. If mode is false, QFileDialog::AnyFile is used instead. |
The default value for the directory mode is false
.
|
slot |
str | The new file name for the widget. |
|
slot |
highlightInvalidFilePath | Toggles highlighting behaviour of line edit for invalid file paths. |
|
slot |
filters | The set of file name filters to be used in the file dialog. If these are empty, no filter will be used. |
The default filter is empty.
void setReadOnly | ( | bool | b | ) |
|
slot |
show | If true then a refresh button appears alongside the folder button. |
|
slot |
show | Toggles visibility of the text field. |
|
slot |
warningsOn | If true, then warn the user if they specify a file name for which a file already exists. It is assumed that the file named will be written to, so the warning message will refer to overwriting the file. |
The warnings referred to by this function are only raised when the user sets a file name via the file system browser button. Calling this function with warningsOn set to true
only makes sense if the accept mode is set to QFileDialog::AcceptSave
.
The default warning mode is false
(ie no warnings).
|
signal |
|
slot |
show | Toggles visibility of the relative path checkbox. |
|
signal |
|
signal |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |