[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/apps/kdialog
From:       Laurent Montel <montel () kde ! org>
Date:       2009-01-11 9:22:00
Message-ID: 1231665720.419215.17041.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 909191 by mlaurent:

Add slider dialogbox


 M  +20 -0     kdialog.cpp  
 M  +33 -2     widgets.cpp  
 M  +1 -0      widgets.h  


--- trunk/KDE/kdebase/apps/kdialog/kdialog.cpp #909190:909191
@@ -18,6 +18,7 @@
 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 
+#include <kdebug.h>
 #include "widgets.h"
 
 #include <kmessagebox.h>
@@ -640,7 +641,25 @@
         }
         return 1; // cancelled
     }
+    if (args->isSet("slider"))
+    {
+       int miniValue = 0;
+       int maxValue = 0;
+       int step = 0;
+       QString text = args->getOption( "slider" );
+       if ( args->count() == 3 )
+       {
+           miniValue = args->arg(0).toInt();
+           maxValue = args->arg( 1 ).toInt();
+           step = args->arg( 2 ).toInt();
+       }
+       int result = 0;
 
+       bool returnCode = Widgets::slider(0, title, text, miniValue, maxValue, step, \
result); +       if ( returnCode )
+           cout << result << endl;
+       return returnCode;
+    }
     KCmdLineArgs::usage();
     return -2; // NOTREACHED
 }
@@ -697,6 +716,7 @@
   options.add("separate-output", ki18n("Return list items on separate lines (for \
checklist option and file open with --multiple)"));  options.add("print-winid", \
ki18n("Outputs the winId of each dialog"));  options.add("dontagain <file:entry>", \
ki18n("Config file and option name for saving the \"do-not-show/ask-again\" state")); \
+  options.add( "slider <text> [minvalue] [maxvalue] [step]", ki18n( "Slider \
dialogbox, returns value selected" ) );  
   /* kdialog originally used --embed for attaching the dialog box.  However this is \
                misleading and so we changed to --attach.
      * For backwards compatibility, we silently map --embed to --attach */
--- trunk/KDE/kdebase/apps/kdialog/widgets.cpp #909190:909191
@@ -105,7 +105,7 @@
   kapp->setTopWidget( &dlg );
   KVBox* vbox = new KVBox(&dlg);
   dlg.setMainWidget(vbox);
- 
+
   KTextEdit *edit = new KTextEdit( vbox );
   edit->setReadOnly(true);
 
@@ -139,7 +139,7 @@
   dlg.setCaption( title );
   dlg.setButtons( KDialog::Ok );
   dlg.setModal( true );
-  
+
   kapp->setTopWidget( &dlg );
   KVBox* vbox = new KVBox(&dlg);
 
@@ -305,3 +305,34 @@
   dlg.exec();
   return dlg.wasCancelled();
 }
+
+
+bool Widgets::slider( QWidget *parent, const QString& title, const QString& text, \
int minValue, int maxValue, int step, int &result ) +{
+    KDialog dlg( parent );
+    kapp->setTopWidget( &dlg );
+    dlg.setCaption( title );
+    dlg.setButtons( KDialog::Ok|KDialog::Cancel );
+    dlg.setModal( true );
+    dlg.setDefaultButton( KDialog::Ok );
+
+    KVBox* vbox = new KVBox( &dlg );
+    dlg.setMainWidget( vbox );
+
+    QLabel label (vbox);
+    label.setText (text);
+    QSlider slider (vbox);
+    slider.setMinimum( minValue );
+    slider.setMaximum( maxValue );
+    slider.setSingleStep( step );
+    slider.setTickPosition ( QSlider::TicksAbove );
+    slider.setOrientation( Qt::Horizontal );
+    handleXGeometry(&dlg);
+
+    bool retcode = (dlg.exec() == QDialog::Accepted);
+
+    if (retcode)
+        result = slider.value();
+
+    return retcode;
+}
--- trunk/KDE/kdebase/apps/kdialog/widgets.h #909190:909191
@@ -36,6 +36,7 @@
     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, const QString& defaultEntry, QString &result);
     bool progressBar(QWidget *parent, const QString& title, const QString& text, int \
totalSteps); +    bool slider( QWidget *parent, const QString& title, const QString& \
test, int minValue, int maxValue, int step, int &result );  
     void handleXGeometry(QWidget * dlg);
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic