|
|
A KDE-style toolbar.
KToolBar can be dragged around in and between different docks.
A KToolBar can contain all sorts of widgets.
KToolBar can be used as a standalone widget, but KMainWindow provides easy factories and management of one or more toolbars. Once you have a KToolBar object, you can insert items into it with the insert... methods, or remove them with the removeItem() method. This can be done at any time; the toolbar will be automatically updated. There are also many methods to set per-child properties like alignment and toggle behaviour.
KToolBar uses a global config group to load toolbar settings on construction. It will reread this config group on a KApplication::appearanceChanged() signal.
enum |
enum |
The state of the status bar.
enum |
Possible bar positions.
|
Constructor.
The toolbar will read in various global config settings for things like icon size and text position, etc. However, some of the settings will be honored only if _honor_mode is set to true. All other toolbars will be IconOnly and use Medium icons.
Parameters:
~ |
[virtual]
int |
Insert a button (a KToolbarButton) with a pixmap. The pixmap is loaded by the button itself based on the global icon settings.
You should connect to one or more signals in KToolBar:
clicked() , pressed() , released() , or
highlighted() and if the button is a toggle button
(setToggle() ) toggled() . Those signals have id
of a button that caused the signal. If you want to bind a popup
to button, see setButton().
Parameters:
Returns: The item index.
int |
This is the same as above, but with specified signals and slots to which this button will be connected.
You can add more signals with addConnection().
Parameters:
Returns: The item index.
int |
Insert a button (a KToolbarButton) with the specified pixmap. This pixmap will be used as the "active" one and the disabled and default ones will be autogenerated.
It is recommended that you use the insertButton function that allows you to specify the icon name rather then the pixmap itself. Specifying the icon name is much more flexible.
You should connect to one or more signals in KToolBar:
clicked() , pressed() , released() , or
highlighted() and if the button is a toggle button
(setToggle() ) toggled() . Those signals have id
of a button that caused the signal. If you want to bind a popup
to button, see setButton().
Parameters:
Returns: The item index.
int |
This is the same as above, but with specified signals and slots to which this button will be connected.
You can add more signals with addConnection().
Parameters:
Returns: The item index.
int |
Insert a button with popupmenu.
Button will have small
triangle. You have to connect to popup's signals. The
signals KButton::pressed(), KButton::released(),
KButton::clicked() or KButton::doubleClicked() are not
emmited by
this button (see setDelayedPopup() for that).
You can add custom popups which inherit QPopupMenu to get popups
with tables, drawings etc. Just don't fiddle with events there.
int |
Inserts a KLineEdit. You have to specify signals and slots to which KLineEdit will be connected. KLineEdit has all slots QLineEdit has, plus signals KLineEdit::completion and KLineEdit::rotation KLineEdit can be set to autoresize itself to full free width in toolbar, that is to last right aligned item. For that, toolbar must be set to full width (which it is by default).
Returns: Item index.
See also: KLineEdit, setItemAutoSized(), KLineEdit
int |
Insert KComboBox with list.
Can be writable, but cannot contain pixmaps. By default inserting policy is AtBottom, i.e. typed items are placed at the bottom of the list. Can be autosized. If the size argument is specified as -1, the width of the combobox is automatically computed.
Returns: Item index.
See also: KComboBox, setItemAutoSized(), KComboBox
int |
Insert KComboBox with list.
Can be writable, but cannot contain pixmaps. By default inserting policy is AtBottom, i.e. typed items are placed at the bottom of the list. Can be autosized. If the size argument is specified as -1, the width of the combobox is automatically computed.
Returns: Item index.
See also: KComboBox, setItemAutoSized(), KComboBox
int |
Insert KComboBox with text.
The rest is the same as above.
Returns: Item index.
See also: KComboBox, KComboBox
int |
Insert separator.
int |
Insert line separator.
int |
Insert a user-defined widget. The widget must
have this
toolbar as its parent.
Widget must have a QWidget for base class. Widget can be autosized to full width. If you forget about it, you can get a pointer to this widget with getWidget().
Returns: Item index.
int |
Insert an animated widget. A KAnimWidget will be created internally using the icon list you provide. This will emit a signal (clicked()) whenever the animation widget is clicked.
Parameters:
Returns: The item index
int |
Insert an animated widget. A KAnimWidget will be created internally using the icon name you provide. This will emit a signal (clicked()) whenever the animation widget is clicked.
Parameters:
Returns: The item index
KAnimWidget * |
This will return a pointer to the given animated widget, if it exists.
Parameters:
Returns: A pointer to the current animated widget or 0L
void |
Adds connections to items.
It is important that you
know the id
of particular item. Nothing happens if you forget id.
void |
Enable/disable item.
void |
Set button pixmap.
Can be used while button is visible.
void |
Set button icon.
Can be used while button is visible.
void |
Set delayed popup for a button.
Delayed popup is what you see in Netscape Navigator's Previous and Next buttons: If you click them you go back or forth. If you press them long enough, you get a history-menu. This is exactly what we do here.
You will insert normal a button with connection (or use signals from toolbar):
bar->insertButton(pixmap, id, const SIGNAL(clicked ()), this, SLOT (slotClick()), true, "click or wait for popup"); |
bar->setDelayedPopup (id, historyPopup);Don't add delayed popups to buttons which have normal popups. You may add popups which are derived from @ref QPopupMenu. You may add popups that are already in the menu bar or are submenus of other popups. |
void |
Make a button an autorepeat button.
Toggle buttons, buttons with menus, or buttons with delayed menus cannot be made into autorepeat buttons. Moreover, you can and will receive only the signal clicked(), but not pressed() or released(). When the user presses this button, you will receive the signal clicked(), and if the button is still pressed after some time, you will receive more clicked() signals separated by regular intervals. Since this uses QButton::setAutoRepeat() , I can't quantify 'some'.
void |
Make button a toggle button if flag
is true.
void |
Toggle a togglebutton.
If the button is a toggle button (see setToggle())
the button state will be toggled. This will also cause the toolbar to
emit the signal KButton::toggled() with parameter id.
You must connect to
this signal, or use addConnection() to connect directly to the
button signal KButton::toggled().
void |
See a toggle button state.
If the button is a toggle button (see setToggle()) this will set its state flag. This will also emit the signal KButton::toggled().
bool |
Returns: true
if button is on, false
if button is off or if the
button is not a toggle button.
void |
Set text in line editor.
Cursor is set at end of text.
QString |
Retreive line editor text.
If you want to store this text, you have to deep-copy it somewhere.
void |
Insert text in combobox id
at position index.
void |
Insert list in combobox id
at position index.
void |
Insert list in combobox id
at position index.
void |
Remove item index
from combobox id.
void |
Set item index
to be current item in combobox id.
void |
Change item index
in combobox id
to text.
index
= -1 refers current item (one displayed in the button).
void |
Clear combobox id.
Does not delete it or hide it.
QString |
Return text of item index
from combobox id.
index
= -1 refers to current item.
KComboBox * |
Retrieve a pointer to the combobox.
Example:
KComboBox *combo = toolbar->getCombo(combo_id); |
That way you can get access to other public methods that KComboBox provides.
KLineEdit * |
Retrieve a pointer to KToolBarLined.
Example:
KLineEdit * lined = toolbar->getKTollBarLined(lined_id); |
That way you can get access to other public methods that KLineEdit provides. KLineEdit is the same thing as QLineEdit plus completion signals.
KToolBarButton * |
Retrieve a pointer to KToolBarButton.
Example:
KToolBarButton * button = toolbar->getButton(button_id); |
That way you can get access to other public methods that KToolBarButton provides.
Using this method is not recommended.
void |
Align item to the right.
This works only if toolbar is set to full width.
QWidget * |
Retrieve a pointer to an inserted widget.
Wrong ids are not tested. You can do with this whatever you want, except change its height (hardcoded). If you change its width you will probbably have to call toolbar->updateRects (true)
See also: QWidget, updateRects()
void |
Set item autosized.
This works only if the toolbar is set to full width.
Only one
item can be autosized, and it has to be
the last left-aligned item. Items that come after this must be right
aligned. Items that can be right aligned are Lineds, Frames, Widgets and
Combos. An autosized item will resize itself whenever the toolbar geometry
changes to the last right-aligned item (or to end of toolbar if there
are no right-aligned items.)
See also: setFullWidth(), alignItemRight()
void |
Remove all items.
The toolbar is redrawn after it.
void |
Remove item id.
Item is deleted. Toolbar is redrawn after it.
void |
Hide item.
void |
Show item.
void |
Set toolbar to full parent size (default).
In full size mode the bar extends over the parent's full width or height. If the mode is disabled the toolbar tries to take as much space as it needs without wrapping, but it does not exceed the parent box. You can force a certain width or height with setMaxWidth() or setMaxHeight().
If you want to use right-aligned items or auto-sized items you must use full size mode.
bool |
[const]
Returns: true
if the full-size mode is enabled. Otherwise
it returns @false.
void |
Enable or disable moving of toolbar.
void |
Set position of toolbar.
BarPosition |
[const]
Retrieve position of toolbar.
bool |
Show, hide, or toggle toolbar.
This method is provided for compatibility only, please use show() and/or hide() instead.
void |
Use setMaximumHeight() instead.
int |
Use maximumHeight() instead. Retrieve the value that was set with setMaxHeight().
void |
Use setMaximumWidth() instead. Set maximal width of horizontal (top or bottom) toolbar.
int |
Use maximumWidth() instead. Retrieve the value that was set with setMaxWidth().
void |
Set title for toolbar when it floats.
Titles are however not (yet) visible. You can't change toolbar's title while it's floating.
void |
Use enableMoving() instead.
void |
Set the kind of painting for buttons.
Choose from:
void |
Similar to setIconText(IconText it) but allows you to
disable or enable updating. If update
is false, then the
buttons will not be updated. This is useful only if you know
that you will be forcing an update later.
IconText |
[const]
Returns: The current text style for buttons.
void |
Set the icon size to load. Usually you should not call this, the icon size is taken care of by KIconLoader and globally configured. By default, the toolbar will load icons of size 32 for main toolbars and 22 for other toolbars
Parameters:
void |
Same as setIconText(int size) but allows you to disable the toolbar update.
Parameters:
int |
[const]
Returns: The current icon size for buttons.
void |
This allows you to enable or disable the context menu.
Parameters:
bool |
[const]
Returns whether or not the context menu is disabled
Returns: The context menu state
void |
This will inform a toolbar button to ignore certain style changes. Specifically, it will ignore IconText (always IconOnly) and will not allow image effects to apply.
Parameters:
void |
int |
Returns: the number of items in the toolbar
void |
Instruct the toolbar to save it's current state to either the app config file or to the XML-GUI resource file (whichever has precedence).
void |
Save the toolbar settings to group configGroup
in config.
void |
Read the toolbar settings from group configGroup
in config
and apply them.
void |
Tell the toolbar what XML-GUI resource file it should use to save it's state. The state of the toolbar (position, size, etc) is saved in KConfig files if the application does not use XML-GUI.. but if the app does, then it's saved the XML file. This function allows this to happen.
Parameters:
void |
Assign a (translated) text to this toolbar. This is used for the tooltip on the handle, and when listing the toolbars.
QString |
[const]
Returns: the toolbar's text.
void |
QSizePolicy |
[const]
bool |
[const]
void |
void |
void |
void |
void |
void |
void |
[signal]
Emitted when button id
is clicked.
void |
[signal]
Emitted when button id
is double-clicked.
Note: you will always recive two clicked() , pressed() and released() signals. There is no way to avoid it - at least no easy way. If you need to resolve this all you can do is set up timers which wait for QApplication::doubleClickInterval() to expire. If in that time you don't get this signal, you may belive that button was only clicked and not double-clicked. And please note that butons with popup menus do not emit this signal, but those with delayed popup do.
void |
[signal]
Emitted when button id
is pressed.
void |
[signal]
Emits when button id
is released.
void |
[signal]
Emitted when a toggle button changes state.
Emitted also if you change state with setButton() or toggleButton() If you make a button normal again, with setToggle (false), this signal won't be emitted.
void |
[signal]
This signal is emitted when item id gets highlighted/unhighlighted (i.e when mouse enters/exits).
Note that this signal is emitted from
all buttons (normal, disabled and toggle) even when there is no visible
change in buttons (i.e., buttons do not raise when mouse enters).
The parameter isHighlighted
is true
when mouse enters and false
when
mouse exits.
void |
[signal]
This signal is emitted when item id gets highlighted/unhighlighted (i.e when mouse enters/exits).
Note that this signal is emitted from all buttons (normal, disabled and toggle) even when there is no visible change in buttons (i.e., buttons do not raise when mouse enters).
void |
[signal]
Emitted when toolbar changes position, or when an item is removed from toolbar.
If you subclass KMainWindow and reimplement KMainWindow::resizeEvent() be sure to connect to this signal. Note: You can connect this signal to a slot that doesn't take parameter.
void |
[signal]
This signal is emited when toolbar detects changing of following parameters: highlighting, button-size, button-mode. This signal is internal, aimed to buttons.
bool |
[static signal]
Returns: global setting for "Highlight buttons under mouse"
bool |
[static signal]
Returns: global setting for "Toolbars transparent when moving"
IconText |
[static signal]
Returns: global setting for "Icon Text"
void |
[protected]
void |
[protected]
void |
[protected]
void |
[protected]
void |
[protected]
bool |
[protected]