Chapter 6. KDE Style Reference

by Charles Samuels

In this chapter

The KDE libraries and services are able to provide icons, translations, sounds, data, and network files. It's important to use these resources, rather than your own implementations, because even internal happenings, such as receiving a file from the Internet, may have a system-provided progress bar.

KDE is not just a few applications; it is more a set of libraries that allow users to feel that they are in an environment, not just using the same widget toolkit.

6.1. Accessing the Standard Actions

A new feature of KDE 2.0 is the Kaction class. In a standard toolbar you have standard events. Most applications share toolbars and menu items; rather than sharing those items, they are in fact sharing the KActions. For these events, there is the KStdAction class.

Each KStdAction is created in the following form:

   2 KStdAction::stdActionName(this, SLOT(receiver()), actionCollection());

At the time this chapter was written, KDE provided the following actions that applications may share:

  • aboutApp—Show the About dialog for your application. Required.

  • aboutKDE—Show the About KDE dialog for your application. Also required.

  • actualSize—View the document with no zoom.

  • addBookmark—Add a bookmark for the current position.

  • back—Move back in a list.

  • close—Close the current window. Be aware that you're not terminating the entire application unless this is the only window open. This does not cause the document to close, unless this is the only view for it.

  • configureToolbars—Show the Customize Toolbars dialog box.

  • copy—Copy the data to the clipboard.

  • cut—Cut the currently selected text to the clipboard.

  • editBookmarks—Manage the list of bookmarks for the document.

  • find—Open the Find dialog box.

  • findNext—Try to search for another instance of the text selected in the Find dialog box.

  • findPrev—Search again, but backward.

  • firstPage—Go to the beginning of the document.

  • fitToHeight—Zoom so that the full height of the document is visible.

  • fitToPage—Zoom so that the entire document is visible.

  • fitToWidth—Zoom so that the entire width of the document is visible.

  • forward—Move forward in the list.

  • goTo—Show a dialog, allowing the user to select a general position to go to.

  • gotoLine—Allow the user to select a page from a dialog box.

  • gotoPage—Show a dialog enabling the user to select a page to go to.

  • help—Go to the main Help page.

  • helpContents—Show the table of contents of Help.

  • home—Go to the original position.

  • keyBindings—Configure Key bindings.

  • lastPage—Move to the end of the document.

  • mail—Send this file via email.

  • next—Go to the next page.

  • openNew—Open a new window with an empty document.

  • open—Open a file.

  • openRecent—Return a KRecentFilesAction (a "recently opened files" list in the File menu).

  • paste—Paste data into the document from the clipboard.

  • preferences—Set preferences.

  • print—Print the currently open file.

  • printPreview—Preview how the document will look when printed.

  • prior—Move to the previous page.

  • quit—Closes all views for this document, not for the entire app.

  • redisplay—Refresh the display.

  • redo—Redo a change that was undone.

  • replace—Run a Find and Replace action.

  • reportBug—Show the Report a Bug dialog box. All programs should have this.

  • revert—Destroy changes since the last save.

  • save—Save the currently open file.

  • saveAs—Save the currently open file under a new name.

  • saveOptions—Save all settings to disk.

  • selectAll—Select the entire document.

  • showMenubar—Toggle the visibility of the menubar.

  • showStatusbar—Show or hide the statusbar.

  • showToolbar—Toggle the visibility for the toolbar.

  • spelling—Show the Spell Check dialog box.

  • undo—Undo the previous change.

  • up—Move up a level in a hierarchy.

  • whatsThis—Changes the cursor to the question arrow, enabling the user to click a widget.

  • zoom—Show a Zoom dialog box, enabling users to select their zoom level.

  • zoomIn—Increase the zoom for the document, usually by 10 percent increments.

  • zoomOut—Decrease the zoom by 10 percent.

The standard actions provide their own icons, and the user can select those icons; the settings are set system-wide.

Some special actions also exist, such as openRecent (which returns a KRecentFilesAction) rather than a KAction, showMenubar, showToolbar, and showStatusbar, which return KToggleAction.

These actions are automatically placed into the correct positions in the menus:


  • New

  • Open

  • Open Recent Separator)

  • Save

  • Save As

  • Revert (Separator)

  • Close (Separator)

  • Print (Separator)

  • Quit


  • Undo

  • Redo (Separator)

  • Cut

  • Copy

  • Paste

  • Select All (Separator)

  • Find…

  • Find Next

  • Replace…


  • Actual Size

  • Fit To Page

  • Fit To Page Width

  • Fit To Page Height (Separator)

  • Zoom In

  • Zoom Out

  • Zoom… (Separator)

  • Redisplay (Separator)


  • Up

  • Back

  • Forward

  • Home


  • Add Bookmark

  • Edit Bookmarks (Separator)

  • [Bookmarks]


  • Spelling


  • Show Menubar

  • Show Toolbar

  • Show Statusbar

  • [Show any other hideable elements] (Separator)

  • [Application-specific entries]

  • Save Options

  • Configure Key Bindings…

  • Configure [Appname]…


  • Contents… (Separator)

  • About [Application Name]…

  • About KDE…

Keep in mind that KDE differentiates between "Options" and "Configuration." Options are preferences only for this instance of the application. They are lost when the window is closed. Save Options makes them the default (and causes all other instances to inherit the options immediately). The configuration is relayed through all instances immediately and saved to disk when the OK button is pressed in the dialog.

The application name is all in lowercase; it's recommended that you use the same name you used as the first argument to the KAboutData constructor, as described in Chapter 5, "KDE User Interface Compliance."

The settings are checkable—toggled on and off with a check mark.