KNewFileMenu
#include <KNewFileMenu>

Signals | |
void | directoryCreated (const QUrl &url) |
void | fileCreated (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 | |
![]() | |
enum | ActionEvent |
enum | MenuRole |
enum | Priority |
![]() | |
autoRepeat | |
checkable | |
checked | |
enabled | |
font | |
icon | |
iconText | |
iconVisibleInMenu | |
menuRole | |
priority | |
shortcut | |
shortcutContext | |
shortcutVisibleInContextMenu | |
statusTip | |
text | |
toolTip | |
visible | |
whatsThis | |
![]() | |
objectName | |
![]() | |
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) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
![]() | |
AboutQtRole | |
AboutRole | |
ApplicationSpecificRole | |
HighPriority | |
Hover | |
LowPriority | |
NormalPriority | |
NoRole | |
PreferencesRole | |
QuitRole | |
TextHeuristicRole | |
Trigger | |
![]() | |
typedef | QObjectList |
![]() | |
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 |
![]() | |
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.
- Since
- 4.5
Definition at line 47 of file knewfilemenu.h.
Constructor & Destructor Documentation
◆ KNewFileMenu() [1/2]
KNewFileMenu::KNewFileMenu | ( | KActionCollection * | collection, |
const QString & | name, | ||
QObject * | parent | ||
) |
Constructor.
- Parameters
-
collection the KActionCollection the QAction with name name
should be added to.name action name, when adding the action to collection
parent the parent object, for ownership. If the parent object is a widget, it will also used as parent widget for any dialogs that this class might show. Otherwise, call setParentWidget.
- Note
- If you want the "Create directory..." action shortcut to show up next to its text, make sure to have an action with name "create_dir" (and shortcut set) in
collection
. This will only work with KIO >= 5.27. From KIO >= 5.53, an action named "create_file" (and shortcut set) incollection
will be linked to the creation of the first file template (either from XDG_TEMPLATES_DIR or from :/kio5/newfile-templates)
- Deprecated:
- since 5.100, use KNewFileMenu(QObject *) instead. To associate the action shortcuts use setNewFileShortcutAction() and setNewFolderShortcutAction()
Definition at line 1382 of file knewfilemenu.cpp.
◆ KNewFileMenu() [2/2]
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 1404 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 1422 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 1451 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 1503 of file knewfilemenu.cpp.
◆ directoryCreated
|
signal |
Emitted once the directory url
has been successfully created.
◆ fileCreated
|
signal |
Emitted once the file (or symlink) url
has been successfully created.
◆ isModal()
bool KNewFileMenu::isModal | ( | ) | const |
Returns the modality of dialogs.
Definition at line 1517 of file knewfilemenu.cpp.
◆ popupFiles()
Returns the files that the popup is shown for.
- Deprecated:
- since 5.97, use KNewFileMenu::workingDirectory().
Definition at line 1523 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 1529 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 1645 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 1640 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 1554 of file knewfilemenu.cpp.
◆ setPopupFiles()
Set the files the popup is shown for Call this before showing up the menu.
- Deprecated:
- since 5.97, use KNewFileMenu::setWorkingDirectory(const QUrl &).
Definition at line 1535 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 1253 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 1559 of file knewfilemenu.cpp.
◆ setViewShowsHiddenFiles()
void KNewFileMenu::setViewShowsHiddenFiles | ( | bool | b | ) |
Set if the directory view currently shows dot files.
- Deprecated:
- since 5.97. Calling this has no effect.
Definition at line 1565 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 1617 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 1571 of file knewfilemenu.cpp.
◆ supportedMimeTypes()
QStringList KNewFileMenu::supportedMimeTypes | ( | ) | const |
Returns the MIME types set in supportedMimeTypes()
Definition at line 1612 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 1635 of file knewfilemenu.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:54:45 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.