KTutorial  0.5.1
Public Slots | Signals | Public Member Functions | Protected Member Functions
ktutorial::view::StepWidget Class Reference

Widget to show tutorials. More...

#include <StepWidget.h>

List of all members.

Public Slots

void setStep (Step *step)
 Sets another Step to be shown.

Signals

void finished ()
 This signal is emitted when the Tutorial is closed by the user.

Public Member Functions

 StepWidget (const QString &tutorialName, QWidget *parent=0)
 Creates a new StepWidget.
virtual ~StepWidget ()
 Destroys this StepWidget.
void setMainApplicationWindow (QWidget *mainApplicationWindow)
 Sets the main application window to spy for child dialogs.

Protected Member Functions

virtual void closeEvent (QCloseEvent *event)
 Executes parent handler, emits finished() signal and schedules this StepWidget for deletion.
virtual void keyPressEvent (QKeyEvent *event)
 Adds some common dialog behaviour of KDE.
virtual void mouseMoveEvent (QMouseEvent *event)
 Moves this StepWidget if it is being dragged.
virtual void mousePressEvent (QMouseEvent *event)
 Enters in drag state if needed.
virtual void mouseReleaseEvent (QMouseEvent *event)
 Exits drag state if needed.
virtual void paintEvent (QPaintEvent *event)
 Adjusts the size of the widget and its children before painting.

Detailed Description

Widget to show tutorials.

This widget shows the Steps of a Tutorial. When a new Step is activated, setStep(Step*) is called to show the text and options of that Step to the user. When the user closes the StepWidget, through the close button or using Esc key, the Tutorial is finished.

The StepWidget is shown as a floating widget, always on top of the application (but not on top of other applications). It contains a close button, the text of the active Step and one button for each Option of the Step, if any.

It can be moved from its initial position clicking with the left button and dragging it.

Definition at line 60 of file StepWidget.h.


Constructor & Destructor Documentation

ktutorial::view::StepWidget::StepWidget ( const QString &  tutorialName,
QWidget *  parent = 0 
) [explicit]

Creates a new StepWidget.

Parameters:
tutorialNameThe name of the Tutorial to show.
parentThe parent object.

Definition at line 40 of file StepWidget.cpp.


Member Function Documentation

void ktutorial::view::StepWidget::closeEvent ( QCloseEvent *  event) [protected, virtual]

Executes parent handler, emits finished() signal and schedules this StepWidget for deletion.

close() can't be redefined to emit finished() signal, as it doesn't get a close triggered by the window manager (like using ALT+F4). Moreover, close() itself sends a QCloseEvent, which is handled by this method. Likely, Qt::WA_DeleteOnClose isn't used as it will delete this StepWidget only through close(), but not through a QCloseEvent. Instead, this StepWidget is scheduled for deletion after receiving a QCloseEvent.

Parameters:
eventThe QCloseEvent.

Definition at line 92 of file StepWidget.cpp.

References finished().

void ktutorial::view::StepWidget::keyPressEvent ( QKeyEvent *  event) [protected, virtual]

Adds some common dialog behaviour of KDE.

If Esc key is pressed, the tutorial finishes. It also enters "WhatIsThis" mode if Shift+F1 is pressed. Any other case, executes parent handler.

Parameters:
eventThe QKeyEvent.

Definition at line 98 of file StepWidget.cpp.

void ktutorial::view::StepWidget::mouseMoveEvent ( QMouseEvent *  event) [protected, virtual]

Moves this StepWidget if it is being dragged.

Movement is made using the data of the event and the drag offset.

Parameters:
eventThe QMouseEvent.

Definition at line 114 of file StepWidget.cpp.

void ktutorial::view::StepWidget::mousePressEvent ( QMouseEvent *  event) [protected, virtual]

Enters in drag state if needed.

If left button is clicked it enters in drag state. Further movement of the cursor will move this StepWidget.

Parameters:
eventThe QMouseEvent.

Definition at line 122 of file StepWidget.cpp.

void ktutorial::view::StepWidget::mouseReleaseEvent ( QMouseEvent *  event) [protected, virtual]

Exits drag state if needed.

If left button is clicked it exits drag state.

Parameters:
eventThe QMouseEvent.

Definition at line 133 of file StepWidget.cpp.

void ktutorial::view::StepWidget::paintEvent ( QPaintEvent *  event) [protected, virtual]

Adjusts the size of the widget and its children before painting.

FIXME: isn't a better way to adjust the size than in paintEvent? It seems that adjusting the size in setStep doesn't work as expected. Even if optionsWidget is removed (so it isn't due to the dynamic creation of buttons), if the new size of the widget is smaller than the previous one (due to a smaller text), the previous one is kept. See: http://lists.trolltech.com/qt-interest/2007-01/thread00715-0.html#msg00845

Maybe the problem is that the slot setStep(Step*) is called from a signal and how it is managed it in Qt. I thought I read something about adding widgets runtime and when to do it. Would posting an event in setStep and make the current tasks of that method when handling the event be the solution to the problem?

Parameters:
eventThe QPaintEvent.

Definition at line 142 of file StepWidget.cpp.

void ktutorial::view::StepWidget::setMainApplicationWindow ( QWidget *  mainApplicationWindow)

Sets the main application window to spy for child dialogs.

When a modal dialog is shown, this StepWidget will be reparented to the dialog to avoid being blocked by it. The previous parent will be restored when the modal dialog is hidden.

Parameters:
mainApplicationWindowThe main application window.

Definition at line 70 of file StepWidget.cpp.

References ktutorial::view::WindowOnTopEnforcer::setBaseWindow().

Referenced by ktutorial::customization::DefaultKdeCustomization::showTutorialUI().

void ktutorial::view::StepWidget::setStep ( Step step) [slot]

Sets another Step to be shown.

The text is set and as many buttons as options added.

The size is adjusted and, if it was hidden, this StepWidget is shown.

Parameters:
stepThe step to be shown.

Definition at line 77 of file StepWidget.cpp.

References ktutorial::Step::options(), and ktutorial::Step::text().


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