[Ktutorial-commits] SF.net SVN: ktutorial:[252] trunk/ktutorial/ktutorial-editor/src/view
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2010-09-24 17:30:35
|
Revision: 252 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=252&view=rev Author: danxuliu Date: 2010-09-24 17:30:22 +0000 (Fri, 24 Sep 2010) Log Message: ----------- -Fix not restoring the normal cursor shape when the target application was closed before the editor was able to decide whether it supported KTutorial or not. -Fix showing the error message several times if the target application was successfully started several times and then failed to start. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.cpp trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.h Modified: trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.cpp 2010-09-21 16:24:13 UTC (rev 251) +++ trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.cpp 2010-09-24 17:30:22 UTC (rev 252) @@ -51,13 +51,8 @@ mTargetApplication->setTargetApplicationFilePath(path); } - connect(mTargetApplication, SIGNAL(started()), - this, SLOT(restoreCursor())); - connect(mTargetApplication, SIGNAL(startFailed(TargetApplication::Error)), - this, SLOT(showErrorMessage(TargetApplication::Error))); + startExpectingTheTargetApplicationToStart(); - QApplication::setOverrideCursor(QCursor(Qt::BusyCursor)); - mTargetApplication->start(); } @@ -84,10 +79,28 @@ return executable; } +void TargetApplicationView::startExpectingTheTargetApplicationToStart() { + //Only knowing if the TargetApplication failed to start is relevant in order + //to show the error message. However, once started the signal must be + //disconnected to avoid showing several error messages (for example, if the + //target application fails after being started several times by this view). + //finished() is also connected, as if the target application is closed + //before it could be checked whether it supports KTutorial or not, only + //finished() signal is emitted. + connect(mTargetApplication, SIGNAL(started()), + this, SLOT(stopExpectingTheTargetApplicationToStart())); + connect(mTargetApplication, SIGNAL(startFailed(TargetApplication::Error)), + this, SLOT(showErrorMessage(TargetApplication::Error))); + connect(mTargetApplication, SIGNAL(finished()), + this, SLOT(stopExpectingTheTargetApplicationToStart())); + + QApplication::setOverrideCursor(QCursor(Qt::BusyCursor)); +} + //private slots: void TargetApplicationView::showErrorMessage(TargetApplication::Error error) { - restoreCursor(); + stopExpectingTheTargetApplicationToStart(); QString caption = i18nc("@title:window", "Problem starting the target \ application"); @@ -111,6 +124,13 @@ mTargetApplication->setTargetApplicationFilePath(""); } -void TargetApplicationView::restoreCursor() { +void TargetApplicationView::stopExpectingTheTargetApplicationToStart() { + disconnect(mTargetApplication, SIGNAL(started()), + this, SLOT(stopExpectingTheTargetApplicationToStart())); + disconnect(mTargetApplication, SIGNAL(startFailed(TargetApplication::Error)), + this, SLOT(showErrorMessage(TargetApplication::Error))); + disconnect(mTargetApplication, SIGNAL(finished()), + this, SLOT(stopExpectingTheTargetApplicationToStart())); + QApplication::restoreOverrideCursor(); } Modified: trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.h 2010-09-21 16:24:13 UTC (rev 251) +++ trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.h 2010-09-24 17:30:22 UTC (rev 252) @@ -42,7 +42,7 @@ QWidget* parent = 0); /** - * Convenienve method to start the target application. + * Convenience method to start the target application. * It asks for the executable to be executed if the target application does * not have one set yet. When the application is started, the cursor is set * to the busy shape until the target application has started or failed to @@ -70,6 +70,12 @@ */ QString askApplicationFilePath(); + /** + * Connects to the TargetApplication signals and sets the cursor to the busy + * shape. + */ + void startExpectingTheTargetApplicationToStart(); + private Q_SLOTS: /** @@ -81,9 +87,10 @@ void showErrorMessage(TargetApplication::Error error); /** - * Restores the cursor to the normal shape. + * Disconnects from the TargetApplication signals and restores the normal + * cursor. */ - void restoreCursor(); + void stopExpectingTheTargetApplicationToStart(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |