KNewFileMenu

Search for usage in LXR

#include <KNewFileMenu>

Inheritance diagram for 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 ()
 

Public Member Functions

 KNewFileMenu (QObject *parent)
 
 ~KNewFileMenu () override
 
bool isCreateDirectoryRunning ()
 
bool isCreateFileRunning ()
 
bool isModal () const
 
void setModal (bool modality)
 
void setNewFileShortcutAction (QAction *action)
 
void setNewFolderShortcutAction (QAction *action)
 
void setParentWidget (QWidget *parentWidget)
 
void setSelectDirWhenAlreadyExist (bool b)
 
void setSupportedMimeTypes (const QStringList &mime)
 
void setWorkingDirectory (const QUrl &directory)
 
QStringList supportedMimeTypes () const
 
QUrl workingDirectory () const
 
- Public Member Functions inherited from KActionMenu
void addAction (QAction *action)
 
QToolButton::ToolButtonPopupMode popupMode () const
 
void setPopupMode (QToolButton::ToolButtonPopupMode popupMode)
 
- Public Member Functions inherited from QWidgetAction
 QWidgetAction (QObject *parent)
 
QWidgetdefaultWidget () const const
 
void releaseWidget (QWidget *widget)
 
QWidgetrequestWidget (QWidget *parent)
 
void setDefaultWidget (QWidget *widget)
 
- Public Member Functions inherited from QAction
 QAction (const QIcon &icon, const QString &text, QObject *parent)
 
 QAction (const QString &text, QObject *parent)
 
 QAction (QObject *parent)
 
QActionGroupactionGroup () const const
 
void activate (ActionEvent event)
 
QList< QGraphicsWidget * > associatedGraphicsWidgets () const const
 
QList< QObject * > associatedObjects () const const
 
QList< QWidget * > associatedWidgets () const const
 
bool autoRepeat () const const
 
void changed ()
 
void checkableChanged (bool checkable)
 
QVariant data () const const
 
void enabledChanged (bool enabled)
 
QFont font () const const
 
void hover ()
 
void hovered ()
 
QIcon icon () const const
 
QString iconText () const const
 
bool isCheckable () const const
 
bool isChecked () const const
 
bool isEnabled () const const
 
bool isIconVisibleInMenu () const const
 
bool isSeparator () const const
 
bool isShortcutVisibleInContextMenu () const const
 
bool isVisible () const const
 
QMenumenu () const const
 
MenuRole menuRole () const const
 
QWidgetparentWidget () const const
 
Priority priority () const const
 
void resetEnabled ()
 
void setActionGroup (QActionGroup *group)
 
void setAutoRepeat (bool)
 
void setCheckable (bool)
 
void setChecked (bool)
 
void setData (const QVariant &data)
 
void setDisabled (bool b)
 
void setEnabled (bool)
 
void setFont (const QFont &font)
 
void setIcon (const QIcon &icon)
 
void setIconText (const QString &text)
 
void setIconVisibleInMenu (bool visible)
 
void setMenu (QMenu *menu)
 
void setMenuRole (MenuRole menuRole)
 
void setPriority (Priority priority)
 
void setSeparator (bool b)
 
void setShortcut (const QKeySequence &shortcut)
 
void setShortcutContext (Qt::ShortcutContext context)
 
void setShortcuts (const QList< QKeySequence > &shortcuts)
 
void setShortcuts (QKeySequence::StandardKey key)
 
void setShortcutVisibleInContextMenu (bool show)
 
void setStatusTip (const QString &statusTip)
 
void setText (const QString &text)
 
void setToolTip (const QString &tip)
 
void setVisible (bool)
 
void setWhatsThis (const QString &what)
 
QKeySequence shortcut () const const
 
Qt::ShortcutContext shortcutContext () const const
 
QList< QKeySequenceshortcuts () const const
 
bool showStatusText (QObject *object)
 
QString statusTip () const const
 
QString text () const const
 
void toggle ()
 
void toggled (bool checked)
 
QString toolTip () const const
 
void trigger ()
 
void triggered (bool checked)
 
void visibleChanged ()
 
QString whatsThis () const const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

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 QWidgetcreateWidget (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
 
QObjectsender () 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.

Author
Björn Ruberg bjoer.nosp@m.n@ru.nosp@m.berg-.nosp@m.wege.nosp@m.ner.d.nosp@m.e Made dialogs working asynchronously
David Faure faure.nosp@m.@kde.nosp@m..org Ideas and code for the new template handling mechanism ('link' desktop files) from Christoph Pickart picka.nosp@m.rt@i.nosp@m.am.un.nosp@m.i-bo.nosp@m.nn.de

Definition at line 46 of file knewfilemenu.h.

Constructor & Destructor Documentation

◆ KNewFileMenu()

KNewFileMenu::KNewFileMenu ( QObject * parent)

Constructor.

Parameters
parentthe 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()

KNewFileMenu::~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

void KNewFileMenu::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

void KNewFileMenu::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

void KNewFileMenu::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

void KNewFileMenu::directoryCreated ( const QUrl & url)
signal

Emitted once the directory url has been successfully created.

◆ directoryCreationRejected

void KNewFileMenu::directoryCreationRejected ( const QUrl & url)
signal

Emitted once the creation for directory url has been rejected.

Since
6.2

◆ directoryCreationStarted

void KNewFileMenu::directoryCreationStarted ( const QUrl & url)
signal

Emitted once the creation job for directory url has been started.

Since
6.2

◆ fileCreated

void KNewFileMenu::fileCreated ( const QUrl & url)
signal

Emitted once the file (or symlink) url has been successfully created.

◆ fileCreationRejected

void KNewFileMenu::fileCreationRejected ( const QUrl & url)
signal

Emitted once the creation for file url has been rejected.

Since
6.2

◆ fileCreationStarted

void KNewFileMenu::fileCreationStarted ( const QUrl & url)
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

void KNewFileMenu::selectExistingDir ( const QUrl & url)
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

void KNewFileMenu::slotResult ( KJob * job)
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:
This file is part of the KDE documentation.
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.