[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/kleopatra/crypto
From: Frank Osterfeld <frank.osterfeld () kdemail ! net>
Date: 2008-04-27 8:57:04
Message-ID: 1209286624.885086.7306.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 801634 by osterfeld:
Add "Keep window open when done" checkbox
M +28 -8 gui/resultpage.cpp
M +2 -0 gui/resultpage.h
M +9 -3 gui/wizard.cpp
M +15 -1 gui/wizardpage.cpp
M +4 -0 gui/wizardpage.h
M +12 -2 taskcollection.cpp
M +2 -0 taskcollection.h
--- trunk/KDE/kdepim/kleopatra/crypto/gui/resultpage.cpp #801633:801634
@@ -41,6 +41,7 @@
#include <KLocalizedString>
+#include <QCheckBox>
#include <QHBoxLayout>
#include <QIcon>
#include <QLabel>
@@ -62,8 +63,10 @@
void progress( const QString & msg, int progress, int total );
void result( const shared_ptr<const Task::Result> & result );
void started( const shared_ptr<Task> & result );
+ void allDone();
void addResultWidget( ResultItemWidget* widget );
-
+ void keepOpenWhenDone( bool keep );
+
shared_ptr<TaskCollection> m_tasks;
QProgressBar* m_progressBar;
QLabel* m_progressLabel;
@@ -71,6 +74,7 @@
int m_lastErrorItemIndex;
ScrollArea* m_scrollArea;
ResultListWidget* m_resultList;
+ QCheckBox* m_keepOpenCB;
};
void ResultPage::Private::addResultWidget( ResultItemWidget* widget )
@@ -94,6 +98,11 @@
m_resultList = new ResultListWidget;
connect( m_resultList, SIGNAL(linkActivated(QString)), q, \
SIGNAL(linkActivated(QString)) ); layout->addWidget( m_resultList );
+ m_keepOpenCB = new QCheckBox;
+ m_keepOpenCB->setText( i18n( "Keep open after operation completed" ) );
+ m_keepOpenCB->setChecked(true );
+ connect( m_keepOpenCB, SIGNAL(toggled(bool)), q, SLOT(keepOpenWhenDone(bool)) );
+ layout->addWidget( m_keepOpenCB );
}
void ResultPage::Private::progress( const QString & msg, int progress, int total )
@@ -105,15 +114,23 @@
m_progressBar->setValue( progress );
}
+void ResultPage::Private::keepOpenWhenDone( bool )
+{
+}
+
+void ResultPage::Private::allDone()
+{
+ assert( m_tasks );
+ q->setAutoAdvance( !m_keepOpenCB->isChecked() && !m_tasks->errorOccurred() );
+ m_progressBar->setRange( 0, 100 );
+ m_progressBar->setValue( 100 );
+ m_progressLabel->setText( i18n( "All operations completed." ) );
+ m_tasks.reset();
+ emit q->completeChanged();
+}
+
void ResultPage::Private::result( const shared_ptr<const Task::Result> & )
{
- if ( m_tasks->allTasksCompleted() ) {
- m_progressBar->setRange( 0, 100 );
- m_progressBar->setValue( 100 );
- m_progressLabel->setText( i18n( "All operations completed." ) );
- m_tasks.reset();
- emit q->completeChanged();
- }
}
void ResultPage::Private::started( const shared_ptr<Task> & task )
@@ -140,10 +157,13 @@
d->m_resultList->setTaskCollection( coll );
connect( d->m_tasks.get(), SIGNAL(progress(QString,int,int)),
this, SLOT(progress(QString,int,int)) );
+ connect( d->m_tasks.get(), SIGNAL(done()),
+ this, SLOT(allDone()) );
connect( d->m_tasks.get(), SIGNAL(result(boost::shared_ptr<const \
Kleo::Crypto::Task::Result>)),
this, SLOT(result(boost::shared_ptr<const Kleo::Crypto::Task::Result>)) \
);
connect( d->m_tasks.get(), \
SIGNAL(started(boost::shared_ptr<Kleo::Crypto::Task>)),
this, SLOT(started(boost::shared_ptr<Kleo::Crypto::Task>)) );
+ emit completeChanged();
}
bool ResultPage::isComplete() const
--- trunk/KDE/kdepim/kleopatra/crypto/gui/resultpage.h #801633:801634
@@ -70,6 +70,8 @@
Q_PRIVATE_SLOT( d, void progress( QString, int, int ) )
Q_PRIVATE_SLOT( d, void result( boost::shared_ptr<const \
Kleo::Crypto::Task::Result> ) )
Q_PRIVATE_SLOT( d, void started( boost::shared_ptr<Kleo::Crypto::Task> ) )
+ Q_PRIVATE_SLOT( d, void keepOpenWhenDone( bool ) )
+ Q_PRIVATE_SLOT( d, void allDone() )
};
}
--- trunk/KDE/kdepim/kleopatra/crypto/gui/wizard.cpp #801633:801634
@@ -47,6 +47,7 @@
#include <QFrame>
#include <QLabel>
#include <QStackedWidget>
+#include <QTimer>
#include <QVBoxLayout>
#include <QWizard>
@@ -85,13 +86,16 @@
QLabel* subTitleLabel;
QFrame* explanationFrame;
QLabel* explanationLabel;
+ QTimer* nextPageTimer;
};
Wizard::Private::Private( Wizard * qq )
: q( qq ), currentId( -1 ), stack( new QStackedWidget )
{
- const QWizard wiz;
+ nextPageTimer = new QTimer( q );
+ nextPageTimer->setInterval( 0 );
+ connect( nextPageTimer, SIGNAL(timeout()), q, SLOT(next()) );
nextItem = KGuiItem( i18n( "&Next" ) );
finishItem = KStandardGuiItem::ok();
QVBoxLayout * const top = new QVBoxLayout( q );
@@ -130,7 +134,7 @@
q->connect( cancelButton, SIGNAL( clicked() ), q, SLOT( reject() ) );
backButton = new QPushButton;
- backButton->setText( wiz.buttonText( QWizard::BackButton ) );
+ backButton->setText( i18n( "Back" ) );
q->connect( backButton, SIGNAL( clicked() ), q, SLOT( back() ) );
box->addButton( backButton, QDialogButtonBox::ActionRole );
@@ -167,7 +171,8 @@
nextButton->setEnabled( canGoToNext );
cancelButton->setEnabled( !isLast || !canGoToNext );
backButton->setEnabled( q->canGoToPreviousPage() );
-
+ if ( page && page->autoAdvance() && page->isComplete() )
+ nextPageTimer->start();
}
void Wizard::Private::updateHeader()
@@ -208,6 +213,7 @@
connect( widget, SIGNAL( titleChanged() ), this, SLOT( updateHeader() ) );
connect( widget, SIGNAL( subTitleChanged() ), this, SLOT( updateHeader() ) );
connect( widget, SIGNAL( explanationChanged() ), this, SLOT( updateHeader() ) );
+ connect( widget, SIGNAL( autoAdvanceChanged() ), this, SLOT( \
updateButtonStates() ) ); }
void Wizard::setPageOrder( const std::vector<int>& pageOrder )
--- trunk/KDE/kdepim/kleopatra/crypto/gui/wizardpage.cpp #801633:801634
@@ -48,6 +48,7 @@
private:
bool commitPage;
+ bool autoAdvance;
QString title;
QString subTitle;
QString explanation;
@@ -56,7 +57,7 @@
WizardPage::Private::Private( WizardPage * qq )
- : q( qq ), commitPage( false )
+ : q( qq ), commitPage( false ), autoAdvance( false )
{
}
@@ -80,6 +81,19 @@
d->commitPage = commitPage;
}
+bool WizardPage::autoAdvance() const
+{
+ return d->autoAdvance;
+}
+
+void WizardPage::setAutoAdvance( bool enabled )
+{
+ if ( d->autoAdvance == enabled )
+ return;
+ d->autoAdvance = enabled;
+ emit autoAdvanceChanged();
+}
+
QString WizardPage::title() const
{
return d->title;
--- trunk/KDE/kdepim/kleopatra/crypto/gui/wizardpage.h #801633:801634
@@ -57,6 +57,9 @@
bool isCommitPage() const;
void setCommitPage( bool commitPage );
+ bool autoAdvance() const;
+ void setAutoAdvance( bool enabled );
+
QString title() const;
void setTitle( const QString& title );
@@ -74,6 +77,7 @@
void explanationChanged();
void titleChanged();
void subTitleChanged();
+ void autoAdvanceChanged();
protected:
--- trunk/KDE/kdepim/kleopatra/crypto/taskcollection.cpp #801633:801634
@@ -62,10 +62,11 @@
mutable int m_totalSize;
mutable int m_processedSize;
int m_nCompleted;
- QString m_lastProgressMessage;
+ QString m_lastProgressMessage;
+ bool m_errorOccurred;
};
-TaskCollection::Private::Private( TaskCollection* qq ) : q( qq ), m_totalSize( 0 ), \
m_processedSize( 0 ), m_nCompleted( 0 ) +TaskCollection::Private::Private( \
TaskCollection* qq ) : q( qq ), m_totalSize( 0 ), m_processedSize( 0 ), m_nCompleted( \
0 ), m_errorOccurred( false ) {
}
@@ -92,10 +93,14 @@
void TaskCollection::Private::taskResult( const shared_ptr<const Task::Result> & \
result ) {
+ assert( result );
++m_nCompleted;
+ m_errorOccurred = m_errorOccurred || result->hasError();
m_lastProgressMessage.clear();
calculateAndEmitProgress();
emit q->result( result );
+ if ( q->allTasksCompleted() )
+ emit q->done();
}
void TaskCollection::Private::taskStarted()
@@ -145,6 +150,11 @@
return d->m_tasks.empty();
}
+bool TaskCollection::errorOccurred() const
+{
+ return d->m_errorOccurred;
+}
+
shared_ptr<Task> TaskCollection::taskById( int id ) const
{
const std::map<int, shared_ptr<Task> >::const_iterator it = d->m_tasks.find( id \
);
--- trunk/KDE/kdepim/kleopatra/crypto/taskcollection.h #801633:801634
@@ -62,11 +62,13 @@
int numberOfCompletedTasks() const;
bool allTasksCompleted() const;
+ bool errorOccurred() const;
Q_SIGNALS:
void progress( const QString & msg, int processed, int total );
void result( const boost::shared_ptr<const Kleo::Crypto::Task::Result> & \
result );
void started( const boost::shared_ptr<Kleo::Crypto::Task> & task );
+ void done();
private:
class Private;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic