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

List:       kde-commits
Subject:    branches/work/kooka-kde4
From:       Jonathan Marten <jjm () keelhaul ! me ! uk>
Date:       2010-11-16 18:23:02
Message-ID: 20101116182302.2FB0CAC8A4 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1197841 by marten:

libkscan: Make the two ScanParams messages, displayed when no scanner
is selected or there is a problem, non-application specific.  Generate
standard messages via protected virtual functions so they can be
overridden by the application.

Kooka: Generate our own "Gallery Mode" message with links to activate
the scanner device select/add actions.


 M  +1 -0      kooka/CMakeLists.txt  
 A             kooka/kookascanparams.cpp   [License: GPL (v2) (+Qt exception)]
 A             kooka/kookascanparams.h   [License: GPL (v2) (+Qt exception)]
 M  +5 -3      kooka/kookaview.cpp  
 M  +2 -1      kooka/kookaview.h  
 M  +2 -0      libkscan/kscanoption.h  
 M  +48 -31    libkscan/scanparams.cpp  
 M  +36 -1     libkscan/scanparams.h  


--- branches/work/kooka-kde4/kooka/CMakeLists.txt #1197840:1197841
@@ -129,6 +129,7 @@
   kookaview.cpp
   kookapref.cpp			# -> kookaprefs
   prefspages.cpp
+  kookascanparams.cpp
   imgsaver.cpp			# -> imagesaver
   formatdialog.cpp
   kookaimage.cpp
--- branches/work/kooka-kde4/kooka/kookaview.cpp #1197840:1197841
@@ -55,7 +55,6 @@
 #include <kmainwindow.h>
 
 #include "libkscan/scandevices.h"
-#include "libkscan/scanparams.h"
 #include "libkscan/kscandevice.h"
 #include "libkscan/imgscaninfo.h"
 #include "libkscan/deviceselector.h"
@@ -73,6 +72,7 @@
 #include "ocrresedit.h"
 #include "scanparamsdialog.h"
 #include "kookagallery.h"
+#include "kookascanparams.h"
 #include "scangallery.h"
 
 #ifndef KDE4
@@ -494,8 +494,10 @@
 
     if (mScanParams!=NULL) closeScanDevice();		// remove existing GUI object
 
-    mScanParams = new ScanParams(this);			// and create a new one
-    Q_CHECK_PTR(mScanParams);
+    mScanParams = new KookaScanParams(this);		// and create a new one
+    connect(mScanParams, SIGNAL(actionSelectScanner()), SLOT(slotSelectDevice()));
+    connect(mScanParams, SIGNAL(actionAddScanner()), SLOT(slotAddDevice()));
+
     mParamsSite->setWidget(mScanParams);
 
     if (!selDevice.isEmpty())				// connect to the selected scanner
--- branches/work/kooka-kde4/kooka/kookaview.h #1197840:1197841
@@ -52,6 +52,7 @@
 class KookaGallery;
 class OcrResEdit;
 class ScanGallery;
+class KookaScanParams;
 class ScanParams;
 class ImgScanInfo;
 class Previewer;
@@ -226,7 +227,7 @@
     ThumbView *mThumbView;
     Previewer *mPreviewCanvas;
     KookaGallery *mGallery;
-    ScanParams *mScanParams;
+    KookaScanParams *mScanParams;
 
     KScanDevice *mScanDevice;
 
--- branches/work/kooka-kde4/libkscan/kscanoption.h #1197840:1197841
@@ -79,6 +79,8 @@
     /**
      * Copy constructor
      **/
+    // TODO: try to eliminate
+    // used only by KScanOptSet::backupOption(const KScanOption &opt)
     KScanOption(const KScanOption &so);
 
     /**
--- branches/work/kooka-kde4/libkscan/scanparams.cpp #1197840:1197841
@@ -94,6 +94,9 @@
 
     mFirstGTEdit = true;
 
+    mProblemMessage = NULL;
+    mNoScannerMessage = NULL;
+
     // Preload the scan mode icons.  The ones from libksane, which will be
     // available if kdegraphics is installed, look better than our rather
     // ancient ones, so use those if possible.  Set canReturnNull to true
@@ -524,44 +527,58 @@
 }
 
 
-// TODO: this is Kooka-specific, add a setNoScannerMessage() or make it protected
-// so that an application's class can override it
 void ScanParams::createNoScannerMsg(bool galleryMode)
 {
-    QString msg;
-    if (galleryMode)
+    QWidget *lab;
+    if (galleryMode) lab = messageScannerNotSelected();
+    else lab = messageScannerProblem();
+
+    QGridLayout *lay = dynamic_cast<QGridLayout *>(layout());
+    if (lay!=NULL) lay->addWidget(lab, 0, 0, Qt::AlignTop);
+}
+
+
+QWidget *ScanParams::messageScannerNotSelected()
     {
-        msg = i18n("<qt>\
-<b>Gallery Mode: No scanner selected</b>\
-<p>\
-In this mode you can browse, manipulate and OCR images already in the gallery.\
-<p>\
-Select a scanner device \
-(use the menu option <i>Settings&nbsp;- Select Scan&nbsp;Device</i>) \
-to perform scanning.");
+    if (mNoScannerMessage==NULL)
+    {
+        mNoScannerMessage = new QLabel(
+            i18n("<qt>"
+                 "<b>No scanner selected</b>"
+                 "<p>"
+                 "Select a scanner device to perform scanning."));
+
+        mNoScannerMessage->setWordWrap(true);
     }
-    else
+
+    return (mNoScannerMessage);
+}
+
+
+QWidget *ScanParams::messageScannerProblem()
     {
-        msg = i18n("<qt>\
-<b>Problem: No scanner found, or unable to access it</b>\
-<p>\
-There was a problem using the SANE (Scanner Access Now Easy) library to access \
-the scanner device.  There may be a problem with your SANE installation, or it \
-may not be configured to support your scanner.\
-<p>\
-Check that SANE is correctly installed and configured on your system, and \
-also that the scanner device name and settings are correct.\
-<p>\
-See the SANE project home page \
-(<a href=\"http://www.sane-project.org\">www.sane-project.org</a>) \
-for more information on SANE installation and setup.");
+    if (mProblemMessage==NULL)
+    {
+        mProblemMessage = new QLabel(
+            i18n("<qt>"
+                 "<b>Problem: No scanner found, or unable to access it</b>"
+                 "<p>"
+                 "There was a problem using the SANE (Scanner Access Now Easy) library to access "
+                 "the scanner device.  There may be a problem with your SANE installation, or it "
+                 "may not be configured to support your scanner."
+                 "<p>"
+                 "Check that SANE is correctly installed and configured on your system, and "
+                 "also that the scanner device name and settings are correct."
+                 "<p>"
+                 "See the SANE project home page "
+                 "(<a href=\"http://www.sane-project.org\">www.sane-project.org</a>) "
+                 "for more information on SANE installation and setup."));
+
+        mProblemMessage->setWordWrap(true);
+        mProblemMessage->setOpenExternalLinks(true);
     }
 
-    QLabel *lab = new QLabel(msg, this);
-    lab->setWordWrap(true);
-    lab->setOpenExternalLinks(true);
-    QGridLayout *lay = dynamic_cast<QGridLayout *>(layout());
-    if (lay!=NULL) lay->addWidget(lab, 0, 0, Qt::AlignTop);
+    return (mProblemMessage);
 }
 
 
--- branches/work/kooka-kde4/libkscan/scanparams.h #1197840:1197841
@@ -60,7 +60,7 @@
     };
 
     ScanParams(QWidget *parent);
-    ~ScanParams();
+    virtual ~ScanParams();
 
     bool connectDevice(KScanDevice *newScanDevice, bool galleryMode = false);
 
@@ -70,6 +70,38 @@
     void slotAcquirePreview();
     void slotStartScan();
 
+protected:
+    /**
+     * Create a widget (e.g. a QLabel showing an appropriate message)
+     * which is displayed if no scanner is selected.  This happens if
+     * the @c newScanDevice parameter to @c connectDevice() is NULL and
+     * the @c galleryMode parameter is @c true.
+     *
+     * @return the created widget
+     *
+     * @note The returned widget is added to the GUI, so it will be deleted
+     * when the ScanParams object is deleted.
+     *
+     * @see messageScannerProblem
+     */
+    virtual QWidget *messageScannerNotSelected();
+
+    /**
+     * Create a widget (e.g. a QLabel showing an appropriate message)
+     * which is displayed if a scanner is selected but there is an error
+     * opening or connecting to it.  This happens if the @c newScanDevice
+     * parameter to @c connectDevice() is NULL but the @c galleryMode
+     * parameter is @c false (the default).
+     *
+     * @return the created widget
+     *
+     * @note The returned widget is added to the GUI, so it will be deleted
+     * when the ScanParams object is deleted.
+     *
+     * @see messageScannerNotSelected
+     */
+    virtual QWidget *messageScannerProblem();
+
 protected slots:
     /**
      * connected to the button which opens the source selection dialog
@@ -161,6 +193,9 @@
     QIcon mIconGray;
     QIcon mIconLineart;
     QIcon mIconHalftone;
+
+    QLabel *mProblemMessage;
+    QLabel *mNoScannerMessage;
 };
 
 #endif							// SCANPARAMS_H
[prev in list] [next in list] [prev in thread] [next in thread] 

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