KStandardActions
Enumerations | |
enum | StandardAction { ActionNone , New , Open , OpenRecent , Save , SaveAs , Revert , Close , Print , PrintPreview , Mail , Quit , Undo , Redo , Cut , Copy , Paste , SelectAll , Deselect , Find , FindNext , FindPrev , Replace , ActualSize , FitToPage , FitToWidth , FitToHeight , ZoomIn , ZoomOut , Zoom , Redisplay , Up , Back , Forward , Home , Prior , Next , Goto , GotoPage , GotoLine , FirstPage , LastPage , DocumentBack , DocumentForward , AddBookmark , EditBookmarks , Spelling , ShowMenubar , ShowToolbar , ShowStatusbar , KeyBindings , Preferences , ConfigureToolbars , HelpContents , WhatsThis , ReportBug , AboutApp , AboutKDE , ConfigureNotifications , FullScreen , Clear , SwitchApplicationLanguage , DeleteFile , RenameFile , MoveToTrash , Donate , HamburgerMenu } |
Functions | |
QAction * | _kgui_createInternal (StandardAction id, QObject *parent) |
QList< StandardAction > | actionIds () |
template<class Receiver , class Func > | |
QAction * | create (StandardAction id, const Receiver *recvr, Func slot, QObject *parent, std::optional< Qt::ConnectionType > connectionType=std::nullopt) |
QString | name (StandardAction id) |
KStandardShortcut::StandardShortcut | shortcutForActionId (StandardAction id) |
Detailed Description
Convenience methods to access all standard KDE actions.
These actions should be used instead of hardcoding menubar and toolbar items. Using these actions helps your application easily conform to the KDE Human Interface Guidelines.
All of the documentation for QAction holds for KStandardActions also. When in doubt on how things work, check the QAction documentation first. Please note that calling any of these methods automatically adds the action to the actionCollection() of the QObject given by the 'parent' parameter.
Simple Example:
In general, using standard actions should be a drop in replacement for regular actions. For example, if you previously had:
You can replace it with:
Alternatively you can instantiate the action using the StandardAction enums provided. This author can't think of a reason why you would want to, but, hey, if you do, here's how:
Relationship with KActionCollection from KXMLGui
If a KActionCollection is passed as the parent then the action will be automatically added to that collection:
Each action has a unique internal name which can be queried using the name method. For example KStandardActions::name(KStandardActions::Cut) would return 'edit_cut'. This name can be used as a unique identifier for the actions. So if you wanted to add an existing standard action to an action collection you can do so like this:
You can then get a pointer to the action using
- Since
- 6.3
Enumeration Type Documentation
◆ StandardAction
The standard menubar and toolbar actions.
Enumerator | |
---|---|
New | Create a new document or window. |
Open | Open an existing file. |
OpenRecent | Open a recently used document. |
Save | Save the current document. |
SaveAs | Save the current document under a different name. |
Revert | Revert the current document to the last saved version. |
Close | Close the current document. |
Print the current document. | |
PrintPreview | Show a print preview of the current document. |
Send the current document by mail. | |
Quit | Quit the program. |
Undo | Undo the last operation. |
Redo | Redo the last operation. |
Cut | Cut selected area and store it in the clipboard. |
Copy | Copy selected area and store it in the clipboard. |
Paste | Paste the contents of clipboard at the current mouse or cursor. |
SelectAll | Select all elements in the current document. |
Deselect | Deselect any selected elements in the current document. |
Find | Initiate a 'find' request in the current document. |
FindNext | Find the next instance of a stored 'find'. |
FindPrev | Find a previous instance of a stored 'find'. |
Replace | Find and replace matches. |
ActualSize | View the document at its actual size. |
FitToPage | Fit the document view to the size of the current window. |
FitToWidth | Fit the document view to the width of the current window. |
FitToHeight | Fit the document view to the height of the current window. |
ZoomIn | Zoom in the current document. |
ZoomOut | Zoom out the current document. |
Zoom | Select the current zoom level. |
Redisplay | Redisplay or redraw the document. |
Up | Move up (web style menu). |
Back | Move back (web style menu). |
Forward | Move forward (web style menu). |
Home | Go to the "Home" position or document. |
Prior | Scroll up one page. |
Next | Scroll down one page. |
Goto | Jump to some specific location in the document. |
GotoPage | Go to a specific page. |
GotoLine | Go to a specific line. |
FirstPage | Jump to the first page. |
LastPage | Jump to the last page. |
DocumentBack | Move back (document style menu). |
DocumentForward | Move forward (document style menu). |
AddBookmark | Add the current page to the bookmarks tree. |
EditBookmarks | Edit the application bookmarks. |
Spelling | Pop up the spell checker. |
ShowMenubar | Show/Hide the menubar. |
ShowToolbar | Show/Hide the toolbar. |
ShowStatusbar | Show/Hide the statusbar. |
KeyBindings | Display the configure key bindings dialog. |
Preferences | Display the preferences/options dialog. |
ConfigureToolbars | Display the toolbar configuration dialog. |
HelpContents | Display the handbook of the application. |
WhatsThis | Trigger the What's This cursor. |
ReportBug | Open up the Report Bug dialog. |
AboutApp | Display the application's About box. |
AboutKDE | Display the About KDE dialog. |
ConfigureNotifications | Display the notifications configuration dialog. |
FullScreen | Switch to/from full screen mode. |
Clear | Clear the content of the focus widget. |
SwitchApplicationLanguage | Display the Switch Application Language dialog. |
DeleteFile | Permanently deletes files or folders. |
RenameFile | Renames files or folders. |
MoveToTrash | Moves files or folders to the trash. |
Donate | Open donation page on kde.org. |
HamburgerMenu | Opens a menu that substitutes the menubar. |
Definition at line 93 of file kstandardactions.h.
Function Documentation
◆ _kgui_createInternal()
KCONFIGGUI_EXPORT QAction * KStandardActions::_kgui_createInternal | ( | StandardAction | id, |
QObject * | parent ) |
Definition at line 35 of file kstandardactions.cpp.
◆ actionIds()
KCONFIGGUI_EXPORT QList< StandardAction > KStandardActions::actionIds | ( | ) |
Returns a list of all actionIds.
Definition at line 18 of file kstandardactions.cpp.
◆ create()
|
inline |
Creates an action corresponding to one of the KStandardActions::StandardAction actions, which is connected to the given object and slot
, and is owned by parent
.
If not explicitly specified, connectionType
will be AutoConnection for all actions except for ConfigureToolbars it will be QueuedConnection.
- See also
- create(StandardAction, const QObject *, const char *, QObject *)
Definition at line 189 of file kstandardactions.h.
◆ name()
KCONFIGGUI_EXPORT QString KStandardActions::name | ( | StandardAction | id | ) |
This will return the internal name of a given standard action.
Definition at line 170 of file kstandardactions.cpp.
◆ shortcutForActionId()
KCONFIGGUI_EXPORT KStandardShortcut::StandardShortcut KStandardActions::shortcutForActionId | ( | StandardAction | id | ) |
Returns the standardshortcut associated with actionId.
- Parameters
-
id The identifier whose associated shortcut is wanted.
Definition at line 29 of file kstandardactions.cpp.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.