Summary: | a dialog for showing progress bars would be useful | ||
---|---|---|---|
Product: | [Applications] kdialog | Reporter: | Magnus Johansson <magnus> |
Component: | general | Assignee: | David Faure <faure> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
Magnus Johansson
2003-10-21 14:49:12 UTC
CVS commit by binner: Presenting a simple non-cancelable progress bar dialog for kdialog > dialog=`kdialog --title Example --progressbar "Working..."` > dcop $dialog setValue 50 > dcop $dialog QCStringList interfaces() QCStringList functions() void setTotalSteps(int) int totalSteps() void setValue(int) int value() void setLabel(QString) void close() CCMAIL: 66342@bugs.kde.org A progressdialog.cpp 1.1 [GPL (v2+)] A progressdialog.h 1.1 [GPL (v2+)] A progressdialogiface.h 1.1 [no copyright] M +1 -1 Makefile.am 1.3 M +19 -1 kdialog.cpp 1.23 M +10 -0 widgets.cpp 1.8 M +1 -0 widgets.h 1.6 --- kdebase/kdialog/Makefile.am #1.2:1.3 @@ -4,5 +4,5 @@ bin_PROGRAMS = kdialog -kdialog_SOURCES = kdialog.cpp widgets.cpp klistboxdialog.cpp +kdialog_SOURCES = kdialog.cpp widgets.cpp klistboxdialog.cpp progressdialog.cpp progressdialogiface.skel kdialog_LDADD = $(LIB_KIO) kdialog_LDFLAGS = $(all_libraries) $(KDE_RPATH) --- kdebase/kdialog/kdialog.cpp #1.22:1.23 @@ -75,4 +75,5 @@ static KCmdLineOptions options[] = { "getsaveurl [startDir] [filter]", I18N_NOOP("File dialog to save a URL"), 0 }, { "geticon [group] [context]", I18N_NOOP("Icon chooser dialog"), 0 }, + { "progressbar <text> [totalsteps]", I18N_NOOP("Progress bar dialog"), 0}, // TODO gauge stuff, reading values from stdin @@ -478,4 +479,21 @@ static int directCommand(KCmdLineArgs *a } + // --progressbar text totalsteps + if (args->isSet("progressbar")) + { + cout << "DCOPRef(kdialog-" << getpid() << ",ProgressDialog)" << endl; + if (fork()) + exit(0); + close(1); + + int totalsteps = 100; + QString text = QString::fromLocal8Bit(args->getOption("progressbar")); + + if (args->count() == 1) + totalsteps = QString::fromLocal8Bit(args->arg(0)).toInt(); + + return Widgets::progressBar(0, title, text, totalsteps) ? 1 : 0; + } + KCmdLineArgs::usage(); return -2; // NOTREACHED --- kdebase/kdialog/widgets.cpp #1.7:1.8 @@ -24,4 +24,5 @@ #include "widgets.h" #include "klistboxdialog.h" +#include "progressdialog.h" #include <kinputdialog.h> #include <kpassdlg.h> @@ -201,2 +202,11 @@ bool Widgets::radioBox(QWidget *parent, return retcode; } + +bool Widgets::progressBar(QWidget *parent, const QString& title, const QString& text, int totalSteps) +{ + ProgressDialog dlg( parent, title, text, totalSteps ); + kapp->setTopWidget( &dlg ); + dlg.setCaption( title ); + dlg.exec(); + return dlg.wasCancelled(); +} --- kdebase/kdialog/widgets.h #1.5:1.6 @@ -34,4 +34,5 @@ namespace Widgets bool radioBox(QWidget *parent, const QString& title, const QString& text, const QStringList& args, QString &result); bool comboBox(QWidget *parent, const QString& title, const QString& text, const QStringList& args, QString &result); + bool progressBar(QWidget *parent, const QString& title, const QString& text, int totalSteps); } CVS commit by binner: Added setAutoClose(bool), showCancelButton(bool) and wasCancelled() CCMAIL: 66342-done@bugs.kde.org M +29 -6 progressdialog.cpp 1.3 M +9 -3 progressdialog.h 1.3 M +7 -2 progressdialogiface.h 1.3 --- kdebase/kdialog/progressdialog.cpp #1.2:1.3 @@ -32,19 +32,21 @@ void ProgressDialog::setTotalSteps( int { progressBar()->setTotalSteps( totalSteps ); + if ( progress()>=totalSteps ) showCancelButton( false ); } -int ProgressDialog::totalSteps() +int ProgressDialog::totalSteps() const { return progressBar()->totalSteps(); } -void ProgressDialog::setProgress( int value ) +void ProgressDialog::setProgress( int progress ) { - progressBar()->setProgress( value ); + progressBar()->setProgress( progress ); + if (progress>=totalSteps() ) showCancelButton( false ); } -int ProgressDialog::progress() +int ProgressDialog::progress() const { return progressBar()->progress(); @@ -56,4 +58,25 @@ void ProgressDialog::setLabel(const QStr } +void ProgressDialog::showCancelButton( bool show ) +{ + setAllowCancel( false ); + KProgressDialog::showCancelButton( show ); +} + +bool ProgressDialog::wasCancelled() const +{ + return KProgressDialog::wasCancelled(); +} + +void ProgressDialog::setAutoClose( bool close ) +{ + KProgressDialog::setAutoClose( close ); +} + +bool ProgressDialog::autoClose() const +{ + return KProgressDialog::autoClose(); +} + void ProgressDialog::close() { --- kdebase/kdialog/progressdialog.h #1.2:1.3 @@ -31,11 +31,17 @@ class ProgressDialog : public KProgressD void setTotalSteps( int ); - int totalSteps(); + int totalSteps() const; void setProgress( int ); - int progress(); + int progress() const; void setLabel(const QString&); + void showCancelButton(bool show); + bool wasCancelled() const; + + void setAutoClose( bool ); + bool autoClose() const; + void close(); }; --- kdebase/kdialog/progressdialogiface.h #1.2:1.3 @@ -10,11 +10,16 @@ class ProgressDialogIface : virtual publ virtual void setTotalSteps( int ) =0; - virtual int totalSteps() =0; + virtual int totalSteps() const =0; virtual void setProgress( int ) =0; - virtual int progress() =0; + virtual int progress() const =0; virtual void setLabel( const QString& ) =0; + virtual void showCancelButton ( bool ) =0; + virtual bool wasCancelled() const =0; + + virtual void setAutoClose( bool ) =0; + virtual bool autoClose() const =0; virtual void close() =0; }; |