[Ktutorial-commits] SF.net SVN: ktutorial:[84] trunk/ktutorial
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2010-02-09 01:57:18
|
Revision: 84 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=84&view=rev Author: danxuliu Date: 2010-02-09 01:57:11 +0000 (Tue, 09 Feb 2010) Log Message: ----------- Ensure that the current step is deactivated when the tutorial finishes. Modified Paths: -------------- trunk/ktutorial/src/KTutorial.cpp trunk/ktutorial/src/Tutorial.cpp trunk/ktutorial/src/Tutorial.h trunk/ktutorial/test/TutorialTest.cpp Modified: trunk/ktutorial/src/KTutorial.cpp =================================================================== --- trunk/ktutorial/src/KTutorial.cpp 2010-02-08 20:03:32 UTC (rev 83) +++ trunk/ktutorial/src/KTutorial.cpp 2010-02-09 01:57:11 UTC (rev 84) @@ -89,7 +89,7 @@ StepWidget* stepWidget = new StepWidget(tutorialName, mParent); connect(tutorial, SIGNAL(stepActivated(Step*)), stepWidget, SLOT(setStep(Step*))); - connect(stepWidget, SIGNAL(finished()), tutorial, SIGNAL(finished())); + connect(stepWidget, SIGNAL(finished()), tutorial, SLOT(finish())); } void KTutorial::disableTutorialsAction() { Modified: trunk/ktutorial/src/Tutorial.cpp =================================================================== --- trunk/ktutorial/src/Tutorial.cpp 2010-02-08 20:03:32 UTC (rev 83) +++ trunk/ktutorial/src/Tutorial.cpp 2010-02-09 01:57:11 UTC (rev 84) @@ -81,3 +81,13 @@ mCurrentStep = step; mCurrentStep->setActive(true); } + +//public slots: + +void Tutorial::finish() { + if (mCurrentStep != 0) { + mCurrentStep->setActive(false); + } + + emit finished(); +} Modified: trunk/ktutorial/src/Tutorial.h =================================================================== --- trunk/ktutorial/src/Tutorial.h 2010-02-08 20:03:32 UTC (rev 83) +++ trunk/ktutorial/src/Tutorial.h 2010-02-09 01:57:11 UTC (rev 84) @@ -137,6 +137,17 @@ */ void nextStep(Step* step); +public slots: + + /** + * Finishes this Tutorial. + * The current step is deactivated and finished signal is emitted. + * + * This slot is used internally. Do not call or connect to this slot + * yourself. + */ + void finish(); + signals: /** Modified: trunk/ktutorial/test/TutorialTest.cpp =================================================================== --- trunk/ktutorial/test/TutorialTest.cpp 2010-02-08 20:03:32 UTC (rev 83) +++ trunk/ktutorial/test/TutorialTest.cpp 2010-02-09 01:57:11 UTC (rev 84) @@ -49,6 +49,8 @@ void testNextStepStep(); void testNextStepStepWithInvalidStep(); + void testFinish(); + }; class MockTutorial: public Tutorial { @@ -329,6 +331,21 @@ QVERIFY(step1->isActive()); } +void TutorialTest::testFinish() { + MockTutorial tutorial(new TutorialInformation("pearlOrientation")); + + Step* stepStart = new Step("start"); + tutorial.addStep(stepStart); + + QSignalSpy finishedSpy(&tutorial, SIGNAL(finished())); + + tutorial.start(); + tutorial.finish(); + + QVERIFY(!stepStart->isActive()); + QCOMPARE(finishedSpy.count(), 1); +} + QTEST_KDEMAIN(TutorialTest, GUI) #include "TutorialTest.moc" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |