Canorus 0.0
Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Private Slots | List of all members
CAToolButton Class Referenceabstract

Tool button with a menu at the side. More...

#include <toolbutton.h>

Inheritance diagram for CAToolButton:
Inheritance graph
[legend]

Signals

void toggled (bool checked, int id)
 

Public Member Functions

 CAToolButton (QWidget *parent)
 
virtual ~CAToolButton ()
 
int currentId ()
 
virtual void setCurrentId (int id)
 
bool buttonsVisible ()
 
void setDefaultAction (QAction *)
 
virtual void showButtons ()
 
virtual void hideButtons ()
 

Protected Member Functions

CAMainWinmainWin ()
 
void setMainWin (CAMainWin *m)
 
void setPopupWidget (QWidget *w)
 
virtual void wheelEvent (QWheelEvent *)=0
 
void mousePressEvent (QMouseEvent *)
 
QPoint calculateTopLeft (QSize widgetSize)
 

Protected Attributes

CAMainWin_mainWin
 
int _currentId
 
CAToolButtonPopup_popupWidget
 

Private Slots

void handleToggled (bool checked)
 
void handleTriggered ()
 

Detailed Description

Tool button with a menu at the side.

Copyright (c) 2007, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors.

Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.

This widget looks like a button with a small dropdown arrow at the side which opens a custom widget (also called "buttons") where user chooses from various actions then. When the element is selected, the action's icon is replaced with the previous icon on the toolbutton and a signal toggled(bool checked, int id) is emitted.

Remarks
Subclasses must call setPopupWidget() on the floating widget once it's initialized. Showing/hiding is handled in CAToolButton. Subclasses can connect to the show() or hide() signals, which are emitted just before showing or hiding the widget.

Constructor & Destructor Documentation

◆ CAToolButton()

CAToolButton::CAToolButton ( QWidget *  parent)

References _popupWidget, and setMainWin().

Here is the call graph for this function:

◆ ~CAToolButton()

CAToolButton::~CAToolButton ( )
virtual

References _popupWidget.

Member Function Documentation

◆ buttonsVisible()

bool CAToolButton::buttonsVisible ( )
inline

References _popupWidget.

Referenced by mousePressEvent().

Here is the caller graph for this function:

◆ calculateTopLeft()

QPoint CAToolButton::calculateTopLeft ( QSize  size)
protected

This function returns the absolute top-left coordinate where the popup menu or whichever widget should appear when the users clicks on the button.

The problem is that the popup widget should be completely visible in whichever part of the screen the toolbutton is located. Popup widget should also always stick to one corner of the toolbutton.

Parameter size is the width and height needed for the whole widget to appear.

References mainWin().

Referenced by showButtons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ currentId()

int CAToolButton::currentId ( )
inline

◆ handleToggled

void CAToolButton::handleToggled ( bool  checked)
privateslot

Emits toggled( bool, int ) signal.

See also
handleTriggered()

References currentId(), and toggled().

Referenced by setDefaultAction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleTriggered

void CAToolButton::handleTriggered ( )
privateslot

Emits toggled( bool, int ) signal.

See also
handleToggled()

References currentId(), and toggled().

Referenced by setDefaultAction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hideButtons()

void CAToolButton::hideButtons ( )
virtual

Hides the popup widget if it's set

References _popupWidget.

Referenced by mousePressEvent(), CAMenuToolButton::onButtonPressed(), and CAUndoToolButton::onListWidgetItemClicked().

Here is the caller graph for this function:

◆ mainWin()

CAMainWin * CAToolButton::mainWin ( )
inlineprotected

References _mainWin.

Referenced by calculateTopLeft(), and CAUndoToolButton::showButtons().

Here is the caller graph for this function:

◆ mousePressEvent()

void CAToolButton::mousePressEvent ( QMouseEvent *  e)
protected

This function is overriden here in order to show buttons when clicked on the arrow.

References buttonsVisible(), hideButtons(), and showButtons().

Here is the call graph for this function:

◆ setCurrentId()

virtual void CAToolButton::setCurrentId ( int  id)
inlinevirtual

References _currentId.

Referenced by CAUndoToolButton::CAUndoToolButton(), and CAMenuToolButton::setCurrentId().

Here is the caller graph for this function:

◆ setDefaultAction()

void CAToolButton::setDefaultAction ( QAction a)

Sets the new default action a and connects some signals to custom slots made by CAMenuToolButton. Also calls QToolButton::setDefaultAction().

References handleToggled(), handleTriggered(), and toggled().

Referenced by CAUndoToolButton::setDefaultAction(), and CAMainWin::setupCustomUi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMainWin()

void CAToolButton::setMainWin ( CAMainWin m)
inlineprotected

References _mainWin.

Referenced by CAToolButton().

Here is the caller graph for this function:

◆ setPopupWidget()

void CAToolButton::setPopupWidget ( QWidget *  w)
inlineprotected

References _popupWidget, and CAToolButtonPopup::setWidget().

Referenced by CAMenuToolButton::CAMenuToolButton(), and CAUndoToolButton::CAUndoToolButton().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showButtons()

void CAToolButton::showButtons ( )
virtual

Shows the popup widget if it's set

Reimplemented in CAMenuToolButton, and CAUndoToolButton.

References _popupWidget, calculateTopLeft(), and CAToolButtonPopup::sizeHint().

Referenced by mousePressEvent(), CAMenuToolButton::showButtons(), and CAUndoToolButton::showButtons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toggled

void CAToolButton::toggled ( bool  checked,
int  id 
)
signal

◆ wheelEvent()

virtual void CAToolButton::wheelEvent ( QWheelEvent *  )
protectedpure virtual

Implemented in CAMenuToolButton, and CAUndoToolButton.

Member Data Documentation

◆ _currentId

int CAToolButton::_currentId
protected

Referenced by currentId(), and setCurrentId().

◆ _mainWin

CAMainWin* CAToolButton::_mainWin
protected

Referenced by mainWin(), and setMainWin().

◆ _popupWidget

CAToolButtonPopup* CAToolButton::_popupWidget
protected

The documentation for this class was generated from the following files: