org.kde.koala
public class KMainWindow extends QMainWindow implements KXMLGUIBuilderInterface, KXMLGUIClientInterface
See Also: KApplication
UNKNOWN: %KDE top level main window.
Field Summary | |
---|---|
static int | Create |
static int | Keys |
static int | NoDCOPObject
Flags that can be passed in an argument to the constructor to
change the behavior.
|
static int | Save |
static int | StatusBar |
static int | ToolBar |
Constructor Summary | |
---|---|
protected | KMainWindow(Class dummy) |
KMainWindow(QWidget parent, String name, int f)
Construct a main window. | |
KMainWindow(QWidget parent, String name) | |
KMainWindow(QWidget parent) | |
KMainWindow() | |
KMainWindow(int cflags, QWidget parent, String name, int f)
Overloaded constructor which allows passing some KMainWindow.CreationFlags. | |
KMainWindow(int cflags, QWidget parent, String name) | |
KMainWindow(int cflags, QWidget parent) | |
KMainWindow(int cflags) |
Method Summary | |
---|---|
KAccel | accel() |
KAction | action(String name)
Retrieves an action of the client by name. |
KAction | action(QDomElement element)
Retrieves an action for a given QDomElement. |
KActionCollection | actionCollection()
Retrieves the entire action collection for the GUI client. |
void | addStateActionDisabled(String state, String action) |
void | addStateActionEnabled(String state, String action) |
void | appHelpActivated()
Open the help page for the application.
|
void | applyMainWindowSettings(KConfig config, String groupName, boolean force)
Read settings for statusbar, menubar and toolbar from their respective
groups in the config file and apply them. |
void | applyMainWindowSettings(KConfig config, String groupName) |
void | applyMainWindowSettings(KConfig config) |
String | autoSaveGroup() |
boolean | autoSaveSettings() |
void | beginXMLPlug(QWidget arg1) |
KXMLGUIClientInterface | builderClient() |
KInstanceInterface | builderInstance() |
static boolean | canBeRestored(int number)
Session Management
Try to restore the toplevel widget as defined by the number (1..X).
|
protected void | childEvent(QChildEvent e) |
String | className() |
static String | classNameOfToplevel(int number)
Returns the className() of the number of the toplevel window which
should be restored.
|
KXMLGUIBuilderInterface | clientBuilder()
Retrieves the client's GUI builder or null if no client specific
builder has been assigned via setClientBuilder() |
protected void | closeEvent(QCloseEvent arg1)
Reimplemented to call the queryClose() and queryExit() handlers.
|
int | configureToolbars()
Show a standard configure toolbar dialog.
|
protected void | conserveMemory()
This function will attempt to give up some memory after the GUI
is built. |
ArrayList | containerTags() |
QWidget | createContainer(QWidget parent, int index, QDomElement element, int[] id)
Creates a container (menubar/menu/toolbar/statusbar/separator/...)
from an element in the XML file |
int | createCustomElement(QWidget parent, int index, QDomElement element) |
void | createGUI(String xmlfile, boolean _conserveMemory)
Create a GUI given a local XML file.
|
void | createGUI(String xmlfile) |
void | createGUI() |
void | createStandardStatusBarAction()
Sets whether KMainWindow should provide a menu that allows showing/hiding
of the statusbar ( using KToggleStatusBarAction ).
|
KPopupMenu | customHelpMenu(boolean showWhatsThis)
Returns the help menu. |
KPopupMenu | customHelpMenu() |
ArrayList | customTags() |
void | dispose() Delete the wrapped C++ instance ahead of finalize() |
QDomDocument | domDocument() |
void | endXMLPlug() |
KXMLGUIFactory | factory()
Retrieves a pointer to the KXMLGUIFactory this client is
associated with (will return null if the client's GUI has not been built
by a KXMLGUIFactory. |
protected void | finalize() Deletes the wrapped C++ instance |
void | finalizeGUI(KXMLGUIClientInterface client) |
void | finalizeGUI(boolean force) |
static String | findMostRecentXMLFile(String[] files, StringBuffer doc) |
KXMLGUIFactory | guiFactory() |
boolean | hasMenuBar()
Returns true, if there is a menubar |
KPopupMenu | helpMenu(String aboutAppText, boolean showWhatsThis)
Retrieve the standard help menu.
|
KPopupMenu | helpMenu(String aboutAppText) |
KPopupMenu | helpMenu() |
void | hide()
Reimplementation of QMainWindow.hide() |
void | ignoreInitialGeometry()
Used from Konqueror when reusing the main window. |
boolean | initialGeometrySet() |
void | insertChildClient(KXMLGUIClientInterface child)
Use this method to make a client a child client of another client.
|
KInstanceInterface | instance() |
boolean | isDisposed() Has the wrapped C++ instance been deleted? |
boolean | isHelpMenuEnabled()
Return true when the help menu is enabled |
boolean | isStandardToolBarMenuEnabled() |
KMenuBar | kmenuBar()
Returns a pointer to the menu bar.
|
KStatusBar | kstatusBar()
Returns a pointer to the status bar.
|
String | localXMLFile() |
ArrayList | memberList()
List of members of KMainWindow class. |
QMetaObject | metaObject() |
protected void | paintEvent(QPaintEvent e)
List of members of KMainWindow class. |
KXMLGUIClientInterface | parentClient()
KXMLGUIClients can form a simple child/parent object tree. |
protected void | parseGeometry(boolean parsewidth) |
void | prepareXMLUnplug(QWidget arg1) |
protected boolean | queryClose()
Called before the window is closed, either by the user or indirectly by
the session manager.
|
protected boolean | queryExit()
Called before the very last window is closed, either by the
user or indirectly by the session manager.
|
protected void | readGlobalProperties(KConfig sessionConfig)
The counterpart of saveGlobalProperties().
|
protected void | readProperties(KConfig arg1)
Read your instance-specific properties. |
protected boolean | readPropertiesInternal(KConfig arg1, int arg2) |
void | reloadXML()
Forces this client to re-read its XML resource file. |
void | removeChildClient(KXMLGUIClientInterface child)
Removes the given child from the client's children list. |
void | removeContainer(QWidget container, QWidget parent, QDomElement element, int id)
Removes the given (and previously via createContainer )
created container. |
void | removeCustomElement(QWidget parent, int id) |
void | resetAutoSaveSettings()
Disable the auto-save-settings feature.
|
protected void | resizeEvent(QResizeEvent e) |
boolean | restore(int number, boolean show)
Restore the session specified by number.
Returns false if this
fails, otherwise returns true and shows the window.
|
boolean | restore(int number) |
protected void | restoreWindowSize(KConfig config)
For inherited classes
Note that the group must be set before calling, and that
a -geometry on the command line has priority. |
static void | RESTORE(String typeName) |
protected void | saveAutoSaveSettings()
This slot should only be called in case you reimplement closeEvent() and
if you are using the "auto-save" feature. |
protected void | saveGlobalProperties(KConfig sessionConfig)
Save your application-wide properties. |
void | saveMainWindowSettings(KConfig config, String groupName)
Save settings for statusbar, menubar and toolbar to their respective
groups in the config file config. |
void | saveMainWindowSettings(KConfig config) |
protected void | saveNewToolbarConfig()
Rebuilds the GUI after KEditToolbar changed the toolbar layout. |
protected void | saveProperties(KConfig arg1)
Save your instance-specific properties. |
protected void | savePropertiesInternal(KConfig arg1, int arg2) |
protected void | saveWindowSize(KConfig config)
For inherited classes
Note that the group must be set before calling |
void | setAutoSaveSettings(String groupName, boolean saveWindowSize)
Call this to enable "auto-save" of toolbar/menubar/statusbar settings
(and optionally window size).
|
void | setAutoSaveSettings(String groupName) |
void | setAutoSaveSettings() |
void | setBuilderClient(KXMLGUIClientInterface client) |
void | setBuilderInstance(KInstanceInterface instance) |
void | setCaption(String caption)
Makes a KDE compliant caption. |
void | setCaption(String caption, boolean modified)
Makes a KDE compliant caption. |
void | setClientBuilder(KXMLGUIBuilderInterface builder)
A client can have an own KXMLGUIBuilder.
|
protected void | setDOMDocument(QDomDocument document, boolean merge)
Sets the Document for the part, describing the layout of the GUI.
|
protected void | setDOMDocument(QDomDocument document) |
void | setFactory(KXMLGUIFactory factory)
This method is called by the KXMLGUIFactory as soon as the client
is added to the KXMLGUIFactory's GUI. |
void | setFrameBorderWidth(int arg1) |
void | setHelpMenuEnabled(boolean showHelpMenu)
Enables the build of a standard help menu when calling createGUI().
|
void | setHelpMenuEnabled() |
void | setIcon(QPixmap arg1) |
protected void | setInstance(KInstanceInterface instance)
Sets the instance ( KInstance) for this part.
|
protected void | setLocalXMLFile(String file) |
void | setPlainCaption(String caption)
Make a plain caption without any modifications. |
void | setSettingsDirty()
Tell the main window that it should save its settings when being closed.
|
void | setStandardToolBarMenuEnabled(boolean enable)
Sets whether KMainWindow should provide a menu that allows showing/hiding
the available toolbars ( using KToggleToolBarAction ) . |
protected boolean | settingsDirty()
For inherited classes |
protected String | settingsGroup()
For inherited classes |
void | setupGUI(int options, String xmlfile)
Configures the current windows and its actions in the typical KDE
fashion. |
void | setupGUI(int options) |
void | setupGUI() |
void | setupGUI(QSize defaultSize, int options, String xmlfile)
Configures the current windows and its actions in the typical KDE
fashion. |
void | setupGUI(QSize defaultSize, int options) |
void | setupGUI(QSize defaultSize) |
void | setupToolbarMenuActions() |
protected void | setXML(String document, boolean merge)
Sets the XML for the part.
|
protected void | setXML(String document) |
protected void | setXMLFile(String file, boolean merge, boolean setXMLDoc)
Sets the name of the rc file containing the XML for the part.
|
protected void | setXMLFile(String file, boolean merge) |
protected void | setXMLFile(String file) |
void | setXMLGUIBuildDocument(QDomDocument doc) |
void | show()
Reimplementation of QMainWindow.show() |
protected void | showAboutApplication()
This slot does nothing.
|
void | slotStateChanged(String newstate)
Apply a state change
Enable and disable actions as defined in the XML rc file |
void | slotStateChanged(String newstate, int arg2)
Apply a state change
Enable and disable actions as defined in the XML rc file,
can "reverse" the state (disable the actions which should be
enabled, and vice-versa) if specified. |
protected void | stateChanged(String newstate, int reverse)
Actions can collectively be assigned a "State". |
protected void | stateChanged(String newstate) |
KToolBar | toolBar(String name)
Returns a pointer to the toolbar with the specified name.
|
KToolBar | toolBar() |
KAction | toolBarMenuAction()
Returns a pointer to the mainwindows action responsible for the toolbars menu |
void | unplugActionList(String name)
The complement of plugActionList() ... |
QWidget | widget() |
String | xmlFile()
This will return the name of the XML file as set by setXMLFile().
|
QDomDocument | xmlguiBuildDocument() |
UNKNOWN: Flags that can be passed in an argument to the constructor to change the behavior.
See Also: KMainWindow
UNKNOWN:
Parameters: parent The widget parent. This is usually 0 but it may also be the window
group leader. In that case, the KMainWindow becomes sort of a
secondary window. name The object name. For session management and window management to work
properly, all main windows in the application should have a
different name. When passing 0 (the default), KMainWindow will create
a unique name, but it's recommended to explicitly pass a window name that will
also describe the type of the window. If there can be several windows of the same
type, append '#' (hash) to the name, and KMainWindow will append numbers to make
the names unique. For example, for a mail client which has one main window showing
the mails and folders, and which can also have one or more windows for composing
mails, the name for the folders window should be e.g. "mainwindow" and
for the composer windows "composer#". f Specify the widget flags. The default is
WType_TopLevel and WDestructiveClose. TopLevel indicates that a
main window is a toplevel window, regardless of whether it has a
parent or not. DestructiveClose indicates that a main window is
automatically destroyed when its window is closed. Pass 0 if
you do not want this behavior.
KMainWindows must be created on the heap with 'new', like:
KMainWindow kmw = new KMainWindow (...);
See Also: ://doc#trolltech#com/3#2/qt#html#WidgetFlags-enum
UNKNOWN: Construct a main window.
UNKNOWN: Overloaded constructor which allows passing some KMainWindow.CreationFlags.
Returns: A KAccel instance bound to this mainwindow. Used automatically by KAction to make keybindings work in all cases.
UNKNOWN:
UNKNOWN: Retrieves an action of the client by name.
UNKNOWN: Retrieves an action for a given QDomElement.
See Also: (
org.kde.qt.QWidget*
UNKNOWN: Retrieves the entire action collection for the GUI client.
KIconLoader &loader = KGlobal.iconLoader(); QPixmap pixmap = loader.loadIcon( "help" ); toolBar(0).insertButton( pixmap, 0, SIGNAL("clicked()"), this, SLOT("appHelpActivated()"), true, i18n("Help") );
UNKNOWN: Open the help page for the application.
Parameters: config Config file to read the settings from. groupName Group name to use. If not specified, the last used group name is used. force if set, even default settings are re-applied
UNKNOWN: Read settings for statusbar, menubar and toolbar from their respective groups in the config file and apply them.
Returns: the group used for setting-autosaving. Only meaningful if setAutoSaveSettings() was called. This can be useful for forcing a save or an apply, e.g. before and after using KEditToolbar.
UNKNOWN:
Returns: the current autosave setting, i.e. true if setAutoSaveSettings() was called, false by default or if resetAutoSaveSettings() was called.
UNKNOWN:
false
returned.
That means clients could simply do the following:
if (kapp.isRestored()){ int n = 1; while (KMainWindow.canBeRestored(n)){ (new childMW).restore(n); n++; } } else { // create default application as usual }Note that QWidget.show() is called implicitly in restore. With this you can easily restore all toplevel windows of your application. If your application uses different kinds of toplevel windows, then you can use KMainWindow.classNameOfToplevel(n) to determine the exact type before calling the childMW constructor in the example from above. If your client has only one kind of toplevel widgets (which should be pretty usual) then you should use the RESTORE-macro for backwards compatibility with 3.1 and 3.0 branches:
if (kapp.isRestored()) RESTORE(childMW) else { // create default application as usual }The macro expands to the term above but is easier to use and less code to write. For new code or if you have more than one kind of toplevel widget (each derived from KMainWindow, of course), you can use the templated kRestoreMainWindows global functions:
if (kapp.isRestored()) kRestoreMainWindows< childMW1, childMW2, childMW3 >(); else { // create default application as usual }Currently, these functions are provided for up to three template arguments. If you need more, tell us. To help you in deciding whether or not you can use kRestoreMainWindows, a define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS is provided.
See Also: KMainWindow KMainWindow
UNKNOWN: Session Management
number
of the toplevel window which
should be restored.
This is only useful if your application uses
different kinds of toplevel windows.UNKNOWN: Returns the className() of the number
of the toplevel window which should be restored.
UNKNOWN: Retrieves the client's GUI builder or 0L if no client specific builder has been assigned via setClientBuilder()
UNKNOWN: Reimplemented to call the queryClose() and queryExit() handlers.
KStdAction.configureToolbars( guiFactory(), SLOT("configureToolbars()"), actionCollection() );
UNKNOWN: Show a standard configure toolbar dialog.
UNKNOWN: This function will attempt to give up some memory after the GUI is built.
Parameters: parent The parent for the container index The index where the container should be inserted into the parent container/widget element The element from the DOM tree describing the container (use it to access container specified attributes or child elements) id The id to be used for this container
UNKNOWN: Creates a container (menubar/menu/toolbar/statusbar/separator/.
xmlfile
is NULL,
then it will try to construct a local XML filename like
appnameui.rc where 'appname' is your app's name. If that file
does not exist, then the XML UI code will only use the global
(standard) XML file for the layout purposes.
Note that when passing true for the conserveMemory argument subsequent
calls to guiFactory().addClient/removeClient may not work as expected.
Also retrieving references to containers like popup menus or toolbars using
the container method will not work.Parameters: xmlfile The local xmlfile (relative or absolute) _conserveMemory Specify whether createGUI() should call KXMLGUIClient.conserveMemory() to free all memory allocated by the QDomDocument and by the KXMLGUIFactory.
UNKNOWN: Create a GUI given a local XML file.
UNKNOWN: Sets whether KMainWindow should provide a menu that allows showing/hiding of the statusbar ( using KToggleStatusBarAction ).
menuBar().insertItem( i18n("&Help"), customHelpMenu() );
Parameters: showWhatsThis Set this to false
if you do not want to include
the "What's This" menu entry.
Returns: A standard help menu.
UNKNOWN: Returns the help menu.
Returns: The parsed XML in a QDomDocument, set by setXMLFile() or setXML(). This document describes the layout of the GUI.
UNKNOWN:
UNKNOWN: Retrieves a pointer to the KXMLGUIFactory this client is associated with (will return 0L if the client's GUI has not been built by a KXMLGUIFactory.
UNKNOWN:
UNKNOWN: Returns true, if there is a menubar
KPopupMenu help = helpMenu(); menuBar().insertItem( i18n("&Help"), help );
Parameters: aboutAppText The string that is used in the application specific dialog box. If you leave this string empty the information in the global KAboutData of the application will be used to make a standard dialog box. showWhatsThis Set this to false if you do not want to include the "What's This" menu entry.
Returns: A standard help menu.
UNKNOWN: Retrieve the standard help menu.
UNKNOWN: Reimplementation of QMainWindow.hide()
UNKNOWN:
Returns: true if a -geometry argument was given on the command line, and this is the first window created (the one on which this option applies)
UNKNOWN:
UNKNOWN: Use this method to make a client a child client of another client.
Returns: The instance ( KInstance ) for this GUI client.
UNKNOWN:
true
when the help menu is enabledUNKNOWN: Return true
when the help menu is enabled
UNKNOWN: Returns a pointer to the menu bar.
See Also: KActionCollection
UNKNOWN: Returns a pointer to the status bar.
UNKNOWN: List of members of KMainWindow class.
UNKNOWN: KXMLGUIClients can form a simple child/parent object tree.
false
will cancel
the closing, and, if KApplication.sessionSaving() is true, it will also
cancel KDE logout.
Reimplement this function to prevent the user from losing data.
Example:
switch ( KMessageBox.warningYesNoCancel( this, i18n("Save changes to document foo?")) ) { case KMessageBox.Yes : // save document here. If saving fails, return false; return true; case KMessageBox.No : return true; default: // cancel return false;Note that you should probably not actually close the document from within this method, as it may be called by the session manager before the session is saved. If the document is closed before the session save occurs, its location might not be properly saved. In addition, the session shutdown may be canceled, in which case the document should remain open.
See Also: KMainWindow KApplication
UNKNOWN: Called before the window is closed, either by the user or indirectly by the session manager.
true.
Returning false
will
cancel the exiting. In the latter case, the last window will
remain visible. If KApplication.sessionSaving() is true, refusing
the exit will also cancel KDE logout.See Also: KMainWindow KApplication
UNKNOWN: Called before the very last window is closed, either by the user or indirectly by the session manager.
UNKNOWN: The counterpart of saveGlobalProperties().
UNKNOWN: Read your instance-specific properties.
UNKNOWN: Forces this client to re-read its XML resource file.
child
from the client's children list.UNKNOWN: Removes the given child
from the client's children list.
UNKNOWN: Removes the given (and previously via createContainer ) created container.
UNKNOWN: Disable the auto-save-settings feature.
number.
Returns false
if this
fails, otherwise returns true
and shows the window.
You should call canBeRestored() first.
If show
is true (default), this widget will be shown automatically.UNKNOWN: Restore the session specified by number.
UNKNOWN: For inherited classes Note that the group must be set before calling, and that a -geometry on the command line has priority.
void MyMainWindow.closeEvent( QCloseEvent e ) { // Save settings if auto-save is enabled, and settings have changed if ( settingsDirty() && autoSaveSettings() ) saveAutoSaveSettings(); .. }
See Also: KMainWindow KMainWindow
UNKNOWN: This slot should only be called in case you reimplement closeEvent() and if you are using the "auto-save" feature.
UNKNOWN: Save your application-wide properties.
config.
Parameters: config Config file to save the settings to. groupName Group name to use. If not specified, the last used group name is used
UNKNOWN: Save settings for statusbar, menubar and toolbar to their respective groups in the config file config.
See Also: KMainWindow
UNKNOWN: Rebuilds the GUI after KEditToolbar changed the toolbar layout.
kconfig
object, since
KMainWindow uses one group for each window. Please
reimplement these function in childclasses.
Note: No user interaction is allowed
in this function!UNKNOWN: Save your instance-specific properties.
UNKNOWN: For inherited classes Note that the group must be set before calling
Parameters: groupName a name that identifies this "type of window". You can have several types of window in the same application. saveWindowSize set it to true to include the window size when saving. Typically, you will call setAutoSaveSettings() in your KMainWindow-inherited class constructor, and it will take care of restoring and saving automatically. Make sure you call this _after all_ your bars have been created. To make sure that KMainWindow propertly obtains the default size of the window you should do the following: - Remove hard coded resize() calls in the constructor or main, they should be removed in favor of letting the automatic resizing determine the default window size. Hard coded window sizes will be wrong for users that have big fonts, use different styles, long/small translations, large toolbars, and other factors. - Put the setAutoSaveSettings ( or setupGUI() ) call after all widgets have been created and placed inside the main window (i.e. for 99% of apps setCentralWidget()) - Widgets that inherit from QWidget (like game boards) should overload "QSize sizeHint() const;" to specify a default size rather than letting QWidget.adjust use the default size of 0x0.
UNKNOWN: Call this to enable "auto-save" of toolbar/menubar/statusbar settings (and optionally window size).
Parameters: caption Your caption. Do not include the application name in this string. It will be added automatically according to the KDE standard.
UNKNOWN: Makes a KDE compliant caption.
Parameters: caption Your caption. Do not include the application name in this string. It will be added automatically according to the KDE standard. modified Specify whether the document is modified. This displays an additional sign in the title bar, usually "**".
UNKNOWN: Makes a KDE compliant caption.
UNKNOWN: A client can have an own KXMLGUIBuilder.
UNKNOWN: Sets the Document for the part, describing the layout of the GUI.
UNKNOWN: This method is called by the KXMLGUIFactory as soon as the client is added to the KXMLGUIFactory's GUI.
UNKNOWN: Enables the build of a standard help menu when calling createGUI().
UNKNOWN:
UNKNOWN: Sets the instance ( KInstance) for this part.
Parameters: caption Your caption. This is the string that will be displayed in the window title.
UNKNOWN: Make a plain caption without any modifications.
UNKNOWN: Tell the main window that it should save its settings when being closed.
UNKNOWN: Sets whether KMainWindow should provide a menu that allows showing/hiding the available toolbars ( using KToggleToolBarAction ) .
UNKNOWN: For inherited classes
UNKNOWN: For inherited classes
See Also: StandardWindowOptions
UNKNOWN: Configures the current windows and its actions in the typical KDE fashion.
defaultSize
The default size of the window
Typically this function replaces createGUI().See Also: StandardWindowOptions
UNKNOWN: Configures the current windows and its actions in the typical KDE fashion.
UNKNOWN:
UNKNOWN: Sets the XML for the part.
Parameters: file Either an absolute path for the file, or simply the filename, which will then be assumed to be installed in the "data" resource, under a directory named like the instance. merge Whether to merge with the global document. setXMLDoc Specify whether to call setXML. Default is true. and the DOM document at once.
UNKNOWN: Sets the name of the rc file containing the XML for the part.
UNKNOWN:
UNKNOWN: Reimplementation of QMainWindow.show()
void MyMainLevel.setupInterface() { .. menuBar().insertItem( i18n("&Help"), customHelpMenu() ); .. } void MyMainLevel.showAboutApplication() {}
UNKNOWN: This slot does nothing.
UNKNOWN: Apply a state change
UNKNOWN: Apply a state change
Parameters: newstate Name of a State in the XMLfile. reverse If the flag reverse is set to StateReverse, the State is reversed. (actions to be enabled will be disabled and action to be disabled will be enabled) Default is reverse=false.
UNKNOWN: Actions can collectively be assigned a "State".
Parameters: name The internal name of the toolbar. If no name is specified "mainToolBar" is assumed.
Returns: A pointer to the toolbar
UNKNOWN: Returns a pointer to the toolbar with the specified name.
UNKNOWN: Returns a pointer to the mainwindows action responsible for the toolbars menu
UNKNOWN: The complement of plugActionList() .
Returns: The name of the XML file or null
UNKNOWN: This will return the name of the XML file as set by setXMLFile().
UNKNOWN: