KTutorial
0.5.1
|
A tutorial. More...
#include <Tutorial.h>
Public Slots | |
void | nextStep (const QString &id) |
Activates the next Step in the Tutorial. | |
void | finish () |
Finishes this Tutorial. | |
Signals | |
void | finished (Tutorial *tutorial) |
This signal is emitted when this Tutorial finishes. | |
void | stepActivated (Step *step) |
This signal is emitted when a Step is activated. | |
Public Member Functions | |
Tutorial (TutorialInformation *tutorialInformation) | |
Creates a new Tutorial with the specified TutorialInformation. | |
virtual | ~Tutorial () |
Destroys this Tutorial. | |
Q_INVOKABLE TutorialInformation * | tutorialInformation () const |
Returns the TutorialInformation of this Tutorial. | |
Q_INVOKABLE void | addStep (Step *step) |
Adds a new Step to this Tutorial. | |
void | start () |
Starts this Tutorial. | |
void | nextStep (Step *step) |
Activates the next step in the Tutorial. | |
Protected Member Functions | |
void | setTutorialInformation (TutorialInformation *tutorialInformation) |
Sets the information about this Tutorial. | |
virtual void | setup () |
Sets up the Tutorial before activating start Step. | |
virtual void | tearDown () |
Sets up the Tutorial before activating start Step. |
A tutorial.
A tutorial is composed by some information about it and several steps. The steps are shown to the user, one at a time, and the tutorial advances as the user completes each Step.
The information is stored in a TutorialInformation object associated with the Tutorial. It must be provided when the Tutorial is created. Subclasses can set it to 0, but must initialize it in their own constructor code. Don't delete the TutorialInformation in subclasses, as it is deleted when the Tutorial is destroyed.
Steps are the main elements in a Tutorial. They are each of the phases the user must complete when following a Tutorial. A Tutorial will have several Steps (each with a unique identifier), but it must contain at least a Step with "start" id. This will be the starting point of the Tutorial, and the first one to be activated.
To activate a Step, any of Tutorial::nextStep must be called. You are advised to use the QString version for convenience. Steps can activate another step when a condition is met or an option selected using an overloaded version of addOption and addWaitFor methods provided for convenience.
The Tutorial finishes when the user closes it. It can happen in an intermediate Step or when there are no more Steps. When making a Tutorial, add a final Step which notifies the user that the Tutorial is done and that it can be closed.
To create a Tutorial embedded in the application code the easiest way is subclassing Tutorial. In the constructor of the subclass, initialize the information about the Tutorial and add all the Steps with their WaitFors and Options. Add as many slots as needed to the class to connect them with the WaitFors and Options when added to their Steps. If something must be set before starting the Tutorial redefine setup(), if something must be cleaned after finishing the tutorial redefine tearDown(), and you are done.
Definition at line 72 of file Tutorial.h.
ktutorial::Tutorial::Tutorial | ( | TutorialInformation * | tutorialInformation | ) | [explicit] |
Creates a new Tutorial with the specified TutorialInformation.
When deriving from this class you may need to set the TutorialInformation to 0. In that case, remember to set the TutorialInformation in the constructor body!
tutorialInformation | The TutorialInformation for this Tutorial. |
Definition at line 38 of file Tutorial.cpp.
References ktutorial::TutorialPrivate::mCurrentStep, ktutorial::TutorialPrivate::mTutorialInformation, and tutorialInformation().
ktutorial::Tutorial::~Tutorial | ( | ) | [virtual] |
Destroys this Tutorial.
It also destroys the TutorialInformation.
Definition at line 44 of file Tutorial.cpp.
References ktutorial::TutorialPrivate::mTutorialInformation.
void ktutorial::Tutorial::addStep | ( | Step * | step | ) |
Adds a new Step to this Tutorial.
The order in which Steps are added has no relevance. Changing the active Step to another Step must be done with any of Tutorial::nextStep.
The Step is reparented to this Tutorial, and thus deleted when this Tutorial is deleted.
This method can be invoked from a script.
step | The Step to add. |
Definition at line 53 of file Tutorial.cpp.
References ktutorial::TutorialInformation::id(), ktutorial::Step::id(), ktutorial::TutorialPrivate::mSteps, ktutorial::TutorialPrivate::mTutorialInformation, and nextStep().
void ktutorial::Tutorial::finish | ( | ) | [slot] |
Finishes this Tutorial.
The current step is deactivated, this tutorial is cleaned, and finished signal is emitted.
If a KTutorial customization is used, this method must be called when the user finished the tutorial from the UI.
Definition at line 111 of file Tutorial.cpp.
References finished(), ktutorial::TutorialPrivate::mCurrentStep, ktutorial::Step::setActive(), and tearDown().
Referenced by start().
void ktutorial::Tutorial::finished | ( | Tutorial * | tutorial | ) | [signal] |
void ktutorial::Tutorial::nextStep | ( | Step * | step | ) |
Activates the next step in the Tutorial.
Call this method when the Tutorial has to pass to another Step. Consider using nextStep(const QString&) instead for convenience.
step | The Step to change to. |
Definition at line 92 of file Tutorial.cpp.
References ktutorial::TutorialPrivate::mQueuedSteps.
Referenced by addStep(), nextStep(), start(), and ktutorial::editorsupport::EditorSupport::testScriptedTutorial().
void ktutorial::Tutorial::nextStep | ( | const QString & | id | ) | [slot] |
Activates the next Step in the Tutorial.
The identifier must be of one of the Steps added to this Tutorial.
Call this method when the Tutorial has to pass to another Step.
This method can be invoked from a script.
id | The identifier of the next Step to set. |
Definition at line 82 of file Tutorial.cpp.
References ktutorial::TutorialInformation::id(), ktutorial::TutorialPrivate::mSteps, ktutorial::TutorialPrivate::mTutorialInformation, and nextStep().
void ktutorial::Tutorial::setTutorialInformation | ( | TutorialInformation * | tutorialInformation | ) | [protected] |
Sets the information about this Tutorial.
Remember to set it if you derive from Tutorial class.
tutorialInformation | The TutorialInformation to set. |
Definition at line 124 of file Tutorial.cpp.
References ktutorial::TutorialPrivate::mTutorialInformation, and tutorialInformation().
void ktutorial::Tutorial::setup | ( | ) | [protected, virtual] |
Sets up the Tutorial before activating start Step.
Tutorial subclasses can redefine it if they need to set up something before start.
Reimplemented in ktutorial::scripting::ScriptedTutorial.
Definition at line 129 of file Tutorial.cpp.
Referenced by start().
void ktutorial::Tutorial::start | ( | ) |
Starts this Tutorial.
It sets up the tutorial and activates the start step.
This method is used internally. Do not call this method yourself.
Definition at line 69 of file Tutorial.cpp.
References finish(), ktutorial::TutorialInformation::id(), ktutorial::TutorialPrivate::mSteps, ktutorial::TutorialPrivate::mTutorialInformation, nextStep(), and setup().
Referenced by ktutorial::TutorialManager::start(), and ktutorial::editorsupport::EditorSupport::testScriptedTutorial().
void ktutorial::Tutorial::stepActivated | ( | Step * | step | ) | [signal] |
void ktutorial::Tutorial::tearDown | ( | ) | [protected, virtual] |
Sets up the Tutorial before activating start Step.
Tutorial subclasses can redefine it if they need to set up something before start.
Reimplemented in ktutorial::scripting::ScriptedTutorial, and ktutorial::UsingKTutorial.
Definition at line 132 of file Tutorial.cpp.
Referenced by finish().
Returns the TutorialInformation of this Tutorial.
This method can be invoked from a script.
Definition at line 49 of file Tutorial.cpp.
References ktutorial::TutorialPrivate::mTutorialInformation.
Referenced by ktutorial::TutorialManager::registerTutorial(), setTutorialInformation(), ktutorial::customization::DefaultKdeCustomization::showTutorialUI(), Tutorial(), and ktutorial::scripting::ScriptedTutorial::tutorialInformationAsObject().