File indexing completed on 2024-03-24 15:47:59

0001 /************************************************************************
0002  *                                  *
0003  *  This file is part of Kooka, a scanning/OCR application using    *
0004  *  Qt <http://www.qt.io> and KDE Frameworks <http://www.kde.org>.  *
0005  *                                  *
0006  *  Copyright (C) 2013-2016 Jonathan Marten <jjm@keelhaul.me.uk>    *
0007  *                                  *
0008  *  Kooka is free software; you can redistribute it and/or modify it    *
0009  *  under the terms of the GNU Library General Public License as    *
0010  *  published by the Free Software Foundation and appearing in the  *
0011  *  file COPYING included in the packaging of this file;  either    *
0012  *  version 2 of the License, or (at your option) any later version.    *
0013  *                                  *
0014  *  As a special exception, permission is given to link this program    *
0015  *  with any version of the KADMOS OCR/ICR engine (a product of     *
0016  *  reRecognition GmbH, Kreuzlingen), and distribute the resulting  *
0017  *  executable without including the source code for KADMOS in the  *
0018  *  source distribution.                        *
0019  *                                  *
0020  *  This program is distributed in the hope that it will be useful, *
0021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of  *
0022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   *
0023  *  GNU General Public License for more details.            *
0024  *                                  *
0025  *  You should have received a copy of the GNU General Public       *
0026  *  License along with this program;  see the file COPYING.  If     *
0027  *  not, see <http://www.gnu.org/licenses/>.                *
0028  *                                  *
0029  ************************************************************************/
0030 
0031 #ifndef STATUSBARMANAGER_H
0032 #define STATUSBARMANAGER_H
0033 
0034 #include <qobject.h>
0035 
0036 class KXmlGuiWindow;
0037 class QStatusBar;
0038 class QLabel;
0039 class SizeIndicator;
0040 
0041 /**
0042  * @short Status bar for the Kooka application
0043  *
0044  * This class manages all of the status bar operations and display
0045  * for the Kooka application.
0046  *
0047  * It is a separate class and header file in order to resolve a
0048  * circular dependency between Kooka and KookaView.
0049  *
0050  * @author Jonathan Marten
0051  **/
0052 
0053 class StatusBarManager : public QObject
0054 {
0055     Q_OBJECT
0056 
0057 public:
0058     /**
0059      * Item IDs for the status bar.
0060      *
0061      **/
0062     enum Item {
0063         Message,                    /**< Message line **/
0064         ImageDims,                  /**< Image size indicator **/
0065         PreviewDims,                    /**< Preview size indicator **/
0066         FileSize                    /**< File size indicator **/
0067     };
0068 
0069     /**
0070      * Constructor.
0071      *
0072      * @param mainWindow The parent main window
0073      **/
0074     explicit StatusBarManager(KXmlGuiWindow *mainWindow);
0075 
0076     /**
0077      * Destructor.
0078      **/
0079     virtual ~StatusBarManager()             {}
0080 
0081 public slots:
0082     /**
0083      * Set the text of a status bar item.
0084      *
0085      * @param text The new text
0086      * @param item The status bar item to set
0087      **/
0088     void setStatus(const QString &text, StatusBarManager::Item item = StatusBarManager::Message);
0089 
0090     /**
0091      * Clear the text of a status bar item.
0092      *
0093      * @param item The status bar item to clear
0094      **/
0095     void clearStatus(StatusBarManager::Item item = StatusBarManager::Message);
0096 
0097     /**
0098      * Set the file size in bytes for the graphical indicator.
0099      *
0100      * @param size File size in bytes
0101      **/
0102     void setFileSize(long size);
0103 
0104 private:
0105     void setLabelText(QLabel *l, const QString &text);
0106 
0107 private:
0108     QStatusBar *mStatusBar;
0109     int mMargin;
0110 
0111     QLabel *mMessageLabel;
0112     QLabel *mImageDimsLabel;
0113     QLabel *mPreviewDimsLabel;
0114     SizeIndicator *mFileSize;
0115 };
0116 
0117 #endif                          // STATUSBARMANAGER_H