File indexing completed on 2024-04-21 03:42:07

0001 /*
0002     KmPlot - a math. function plotter for the KDE-Desktop
0003 
0004     SPDX-FileCopyrightText: 2004 Fredrik Edemar <f_edemar@linux.se>
0005 
0006     This file is part of the KDE Project.
0007     KmPlot is part of the KDE-EDU Project.
0008 
0009     SPDX-FileCopyrightText: Fredrik Edemar <f_edemar@linux.se>
0010     SPDX-License-Identifier: GPL-2.0-or-later
0011 
0012 */
0013 
0014 #ifndef KMPLOT_H_
0015 #define KMPLOT_H_
0016 
0017 #include <KParts/MainWindow>
0018 #include <KParts/ReadWritePart>
0019 
0020 class QCommandLineParser;
0021 class QLabel;
0022 class KmPlotProgress;
0023 class KToggleFullScreenAction;
0024 
0025 /**
0026  * This is the application "Shell".  It has a menubar, toolbar, and
0027  * statusbar but relies on the "Part" to do all the real work.
0028  *
0029  * @short Application Shell
0030  * @author Fredrik Edemar <f_edemar@linux.se>
0031  */
0032 class KmPlot : public KParts::MainWindow
0033 {
0034     Q_OBJECT
0035 public:
0036     /**
0037      * Default Constructor
0038      */
0039     explicit KmPlot(const QCommandLineParser &parser);
0040 
0041     /**
0042      * Default Destructor
0043      */
0044     virtual ~KmPlot();
0045 
0046     /**
0047      * Use this method to load whatever file/URL you have
0048      */
0049     bool load(const QUrl &url);
0050 
0051 protected:
0052     /// Quits KmPlot after checking if modifications shall be saved.
0053     bool queryClose() Q_DECL_OVERRIDE;
0054 
0055 private slots:
0056     void fileNew();
0057     void applyNewToolbarConfig();
0058     /**
0059      * Called when the cancel button is clicked in the progress bar.
0060      */
0061     void cancelDraw();
0062 
0063 public Q_SLOTS:
0064     // DBus interface
0065     Q_SCRIPTABLE void fileOpen();
0066     Q_SCRIPTABLE void fileOpen(const QString &str)
0067     {
0068         fileOpen(QUrl(str));
0069     }
0070     Q_SCRIPTABLE void setStatusBarText(const QString &, int id);
0071     Q_SCRIPTABLE void openFileInNewWindow(const QString &str)
0072     {
0073         openFileInNewWindow(QUrl(str));
0074     }
0075     Q_SCRIPTABLE void openFileInNewWindow(const QUrl &url);
0076     /**
0077      * Set the progress of drawing the plots, with \p progress ranging from 0
0078      * to 1. After initially calling this function with \p progress less than
0079      * 1, the progress bar will only be shown after a small delay (to avoid it
0080      * flashing quickly when taking only a short while to draw). If \p progress
0081      * is 1, then the progress bar will be hidden.
0082      */
0083     Q_SCRIPTABLE void setDrawProgress(double progress);
0084 
0085 public slots:
0086     /// Called when fullscreen is enabled/disabled
0087     void slotUpdateFullScreen(bool);
0088     void fileOpen(const QUrl &url);
0089 
0090 private:
0091     void setupAccel();
0092     void setupActions();
0093     void setupStatusBar();
0094     bool isModified();
0095 
0096 private:
0097     KParts::ReadWritePart *m_part;
0098     /// The fullscreen action to be plugged/unplugged to the toolbar
0099     KToggleFullScreenAction *m_fullScreen;
0100     /// The progress bar for drawing functions
0101     KmPlotProgress *m_progressBar;
0102     /// The labels set to show information on the statusbar
0103     QList<QLabel *> statusBarLabels;
0104 };
0105 
0106 #endif // KMPLOT_H_