Source Code (Use browser search to find items of interest.)

Class Index

kdelibs'KDockWindow (./kdelibs/kdeui/kdockwindow.h:60)

class KDockWindow : public QLabel
{
    Q_OBJECT
public:

    /**
     * Construct a KDockWindow widget just like any other widget.
     *
     * The parent widget @p parent has a special meaning:
     * Besides owning the dock window, the parent widget will
     * dissappear from taskbars when it is iconified while the dock
     * window is visible. This is the desired behaviour. After all,
     * the dock window @bf is the parent's taskbar icon.
     *
     * Furthermore, the parent widget is shown or raised respectively
     * when the user clicks on the dock window with the left mouse
     * button.
     **/
    KDockWindow( QWidget* parent = 0, const char* name  = 0 );

    /*
      Destructor
     */
    ~KDockWindow();


protected:

    /**
       Reimplemented to provide the standard show/raise behaviour
       for the parentWidget() and the context menu.

       Feel free to reimplement this if you need something special.
     */
    void mousePressEvent( QMouseEvent * );

    /**
       Reimplemented to provide the standard show/raise behaviour
       for the parentWidget() and the context menu.

       Feel free to reimplement this if you need something special.
     */
    void mouseReleaseEvent( QMouseEvent * );

    /**
       Access to the context menu. This makes it easy to add new items
       to it.
     */
    KPopupMenu* contextMenu();


    /**
       Makes it easy to adjust some menu items right before the
       context menu becomes visible.
     */
    virtual void contextMenuAboutToShow( KPopupMenu* menu );
    
    /**
       Reimplemented for internal reasons.
     */
    void showEvent( QShowEvent * );
    
private slots:
    void toggleMinimizeRestore();

private:
    KPopupMenu* menu;
    KDockWindowPrivate* d;
    int minimizeRestoreId;
    uint hasQuit :1;
};


kdelibs'KDockWindow::KDockWindow() (./kdelibs/kdeui/kdockwindow.cpp:26)

KDockWindow::KDockWindow( QWidget* parent, const char* name )
    : QLabel( parent, name, WType_TopLevel )
{
    KWin::setDockWindow( winId(), parent?parent->topLevelWidget()->winId():0 );
    hasQuit = 0;
    menu = new KPopupMenu( this );
    menu->setTitle( kapp->caption() );
}


kdelibs'KDockWindow::~KDockWindow() (./kdelibs/kdeui/kdockwindow.cpp:35)

KDockWindow::~KDockWindow()
{

}



kdelibs'KDockWindow::showEvent() (./kdelibs/kdeui/kdockwindow.cpp:41)

void KDockWindow::showEvent( QShowEvent * )
{
    if ( !hasQuit ) {
	menu->insertSeparator();
	if ( parentWidget() ) {
	    minimizeRestoreId = menu->insertItem(i18n("Minimize"), this, SLOT( toggleMinimizeRestore() ) );
	    menu->insertItem(i18n("Quit"), parentWidget(), SLOT(close() ) );
	}
	else {
	    minimizeRestoreId = -1;
	    menu->insertItem(i18n("Quit"), qApp, SLOT(closeAllWindows() ) );
	}
	hasQuit = 1;
    }
}


kdelibs'KDockWindow::contextMenu() (./kdelibs/kdeui/kdockwindow.cpp:57)

KPopupMenu* KDockWindow::contextMenu()
{
    return menu;
}



kdelibs'KDockWindow::mousePressEvent() (./kdelibs/kdeui/kdockwindow.cpp:63)

void KDockWindow::mousePressEvent( QMouseEvent * )
{
}




kdelibs'KDockWindow::mouseReleaseEvent() (./kdelibs/kdeui/kdockwindow.cpp:69)

void KDockWindow::mouseReleaseEvent( QMouseEvent * e)
{
    if ( !rect().contains( e->pos() ) )
	return;
    
    switch ( e->button() ) {
    case LeftButton:
	if ( parentWidget() ){

	  if ( parentWidget()->isVisible() ) {
	    parentWidget()->hide();
	  } else {
	    parentWidget()->show();
	    KWin::setActiveWindow( parentWidget()->winId() );
	  }
	}
	break;
    case MidButton:
	// fall through
    case RightButton:
	if ( parentWidget() ) {
	    if ( parentWidget()->isVisible() )
		menu->changeItem( minimizeRestoreId, i18n("Minimize") );
	    else
		menu->changeItem( minimizeRestoreId, i18n("Restore") );
	}
	contextMenuAboutToShow( menu );
	menu->popup( e->globalPos() );
	break;
    default:
	// nothing
	break;
    }
}



kdelibs'KDockWindow::contextMenuAboutToShow() (./kdelibs/kdeui/kdockwindow.cpp:105)

void KDockWindow::contextMenuAboutToShow( KPopupMenu* )
{
}



kdelibs'KDockWindow::toggleMinimizeRestore() (./kdelibs/kdeui/kdockwindow.cpp:110)

void KDockWindow::toggleMinimizeRestore()
{
    if ( !parentWidget() )
	return;
    if ( !parentWidget()->isVisible() ) {
	parentWidget()->show();
	KWin::setActiveWindow( parentWidget()->winId() );
    } else {
	parentWidget()->hide();
    }
}