KNewFileMenu
#include <KNewFileMenu>
Signals | |
void | directoryCreated (const QUrl &url) |
void | directoryCreationRejected (const QUrl &url) |
void | directoryCreationStarted (const QUrl &url) |
void | fileCreated (const QUrl &url) |
void | fileCreationRejected (const QUrl &url) |
void | fileCreationStarted (const QUrl &url) |
void | selectExistingDir (const QUrl &url) |
Public Slots | |
void | checkUpToDate () |
void | createDirectory () |
void | createFile () |
Protected Slots | |
virtual void | slotResult (KJob *job) |
Additional Inherited Members | |
Public Types inherited from QAction | |
enum | ActionEvent |
enum | MenuRole |
enum | Priority |
Public Types inherited from QObject | |
typedef | QObjectList |
Properties inherited from QAction | |
autoRepeat | |
checkable | |
checked | |
enabled | |
font | |
icon | |
iconText | |
iconVisibleInMenu | |
menuRole | |
priority | |
shortcut | |
shortcutContext | |
shortcutVisibleInContextMenu | |
statusTip | |
text | |
toolTip | |
visible | |
whatsThis | |
Properties inherited from QObject | |
objectName | |
Static Public Member Functions inherited from QObject | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
Public Attributes inherited from QAction | |
AboutQtRole | |
AboutRole | |
ApplicationSpecificRole | |
HighPriority | |
Hover | |
LowPriority | |
NormalPriority | |
NoRole | |
PreferencesRole | |
QuitRole | |
TextHeuristicRole | |
Trigger | |
Protected Member Functions inherited from QWidgetAction | |
QList< QWidget * > | createdWidgets () const const |
virtual QWidget * | createWidget (QWidget *parent) |
virtual void | deleteWidget (QWidget *widget) |
virtual bool | event (QEvent *event) override |
virtual bool | eventFilter (QObject *obj, QEvent *event) override |
Protected Member Functions inherited from QAction | |
Protected Member Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Detailed Description
The 'Create New' submenu, for creating files using templates (e.g. "new HTML file") and directories.
The same instance can be used by both for the File menu and the RMB popup menu, in a file manager. This is also used in the file dialog's RMB menu.
To use this class, you need to connect aboutToShow() of the File menu with slotCheckUpToDate() and to call slotCheckUpToDate() before showing the RMB popupmenu.
KNewFileMenu automatically updates the list of templates shown if installed templates are added/updated/deleted.
Definition at line 46 of file knewfilemenu.h.
Constructor & Destructor Documentation
◆ KNewFileMenu()
KNewFileMenu::KNewFileMenu | ( | QObject * | parent | ) |
Constructor.
- Parameters
-
parent the parent object, for ownership. If the parent object is a widget, it will also be used as the parent widget for any dialogs that this class might show. Otherwise, call setParentWidget.
- Since
- 5.100
Definition at line 1392 of file knewfilemenu.cpp.
◆ ~KNewFileMenu()
|
overridedefault |
Destructor.
KNewMenu uses internally a globally shared cache, so that multiple instances of it don't need to parse the installed templates multiple times. Therefore you can safely create and delete KNewMenu instances without a performance issue.
Member Function Documentation
◆ checkUpToDate
|
slot |
Checks if updating the list is necessary IMPORTANT : Call this in the slot for aboutToShow.
Definition at line 1433 of file knewfilemenu.cpp.
◆ createDirectory
|
slot |
Call this to create a new directory as if the user had done it using a popupmenu.
This is useful to make sure that creating a directory with a key shortcut (e.g. F10) triggers the exact same code as when using the New menu. Requirements: since 5.97 call setWorkingDirectory first (for older releases call setPopupFiles first), and keep this KNewFileMenu instance alive (the mkdir is async).
Definition at line 1462 of file knewfilemenu.cpp.
◆ createFile
|
slot |
Call this to create a new file as if the user had done it using a popupmenu.
This is useful to make sure that creating a directory with a key shortcut (e.g. Shift-F10) triggers the exact same code as when using the New menu. Requirements: since 5.97 call setWorkingDirectory first (for older releases call setPopupFiles first), and keep this KNewFileMenu instance alive (the copy is async).
- Since
- 5.53
Definition at line 1524 of file knewfilemenu.cpp.
◆ directoryCreated
|
signal |
Emitted once the directory url
has been successfully created.
◆ directoryCreationRejected
|
signal |
Emitted once the creation for directory url
has been rejected.
- Since
- 6.2
◆ directoryCreationStarted
|
signal |
Emitted once the creation job for directory url
has been started.
- Since
- 6.2
◆ fileCreated
|
signal |
Emitted once the file (or symlink) url
has been successfully created.
◆ fileCreationRejected
|
signal |
Emitted once the creation for file url
has been rejected.
- Since
- 6.2
◆ fileCreationStarted
|
signal |
Emitted once the creation job for file url
has been started.
- Since
- 6.2
◆ isCreateDirectoryRunning()
bool KNewFileMenu::isCreateDirectoryRunning | ( | ) |
Use this to check if namejob for new directory creation still running.
Namejob is what spawns the new directory dialog, which can be slow in, for example, network folders.
- Since
- 6.2
Definition at line 1488 of file knewfilemenu.cpp.
◆ isCreateFileRunning()
bool KNewFileMenu::isCreateFileRunning | ( | ) |
Use this to check if the file creation process is still running.
- Since
- 6.2
Definition at line 1544 of file knewfilemenu.cpp.
◆ isModal()
bool KNewFileMenu::isModal | ( | ) | const |
Returns the modality of dialogs.
Definition at line 1549 of file knewfilemenu.cpp.
◆ selectExistingDir
|
signal |
Emitted when trying to create a new directory that has the same name as an existing one, so that KDirOperator can select the existing item in the view (in case the user wants to use that directory instead of creating a new one).
- Since
- 5.76
◆ setModal()
void KNewFileMenu::setModal | ( | bool | modality | ) |
Sets the modality of dialogs created by KNewFile.
Set to false if you do not want to block your application window when entering a new directory name i.e.
Definition at line 1554 of file knewfilemenu.cpp.
◆ setNewFileShortcutAction()
void KNewFileMenu::setNewFileShortcutAction | ( | QAction * | action | ) |
Use this to set a shortcut for the new file action.
The shortcut is copied from
- Parameters
-
action.
- Since
- 5.100
Definition at line 1644 of file knewfilemenu.cpp.
◆ setNewFolderShortcutAction()
void KNewFileMenu::setNewFolderShortcutAction | ( | QAction * | action | ) |
Use this to set a shortcut for the "New Folder" action.
The shortcut is copied from
- Parameters
-
action.
- Since
- 5.100
Definition at line 1639 of file knewfilemenu.cpp.
◆ setParentWidget()
void KNewFileMenu::setParentWidget | ( | QWidget * | parentWidget | ) |
Sets a parent widget for the dialogs shown by KNewFileMenu.
This is strongly recommended, for apps with a main window.
Definition at line 1559 of file knewfilemenu.cpp.
◆ setSelectDirWhenAlreadyExist()
void KNewFileMenu::setSelectDirWhenAlreadyExist | ( | bool | b | ) |
Whether on not the dialog should emit selectExistingDir
when trying to create an exist directory.
default: false
- Since
- 5.76
Definition at line 1264 of file knewfilemenu.cpp.
◆ setSupportedMimeTypes()
void KNewFileMenu::setSupportedMimeTypes | ( | const QStringList & | mime | ) |
Only show the files in a given set of MIME types.
This is useful in specialized applications (while file managers, on the other hand, want to show all MIME types).
Definition at line 1564 of file knewfilemenu.cpp.
◆ setWorkingDirectory()
void KNewFileMenu::setWorkingDirectory | ( | const QUrl & | directory | ) |
Set the working directory.
Files will be created relative to this directory.
- Since
- 5.97.
Definition at line 1616 of file knewfilemenu.cpp.
◆ slotResult
|
protectedvirtualslot |
Called when the job that copied the template has finished.
This method is virtual so that error handling can be reimplemented. Make sure to call the base class slotResult when !job->error() though.
Definition at line 1569 of file knewfilemenu.cpp.
◆ supportedMimeTypes()
QStringList KNewFileMenu::supportedMimeTypes | ( | ) | const |
Returns the MIME types set in supportedMimeTypes()
Definition at line 1611 of file knewfilemenu.cpp.
◆ workingDirectory()
QUrl KNewFileMenu::workingDirectory | ( | ) | const |
Returns the working directory.
Files will be created relative to this directory.
- Since
- 5.97.
Definition at line 1634 of file knewfilemenu.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:04:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.