Warning, file /education/kmplot/kmplot/maindlg.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 KmPlot - a math. function plotter for the KDE-Desktop 0003 0004 SPDX-FileCopyrightText: 1998, 1999, 2000, 2002 Klaus-Dieter Möller <kd.moeller@t-online.de> 0005 SPDX-FileCopyrightText: 2006 David Saxton <david@bluehaze.org> 0006 0007 This file is part of the KDE Project. 0008 KmPlot is part of the KDE-EDU Project. 0009 0010 SPDX-License-Identifier: GPL-2.0-or-later 0011 */ 0012 0013 /** @file maindlg.h 0014 * @brief Contains the main window class MainDlg. */ 0015 0016 #ifndef MainDlg_included 0017 #define MainDlg_included 0018 0019 // Qt includes 0020 #include <QDomDocument> 0021 #include <QMenu> 0022 #include <QPrinter> 0023 #include <QStack> 0024 #include <QStandardPaths> 0025 0026 // KDE includes 0027 #include <KParts/BrowserExtension> 0028 #include <KParts/Part> 0029 #include <KParts/ReadWritePart> 0030 #include <KPluginFactory> 0031 #include <KSharedConfig> 0032 0033 #undef GrayScale 0034 0035 // local includes 0036 #include "coordsconfigdialog.h" 0037 #include "kmplotio.h" 0038 #include "kprinterdlg.h" 0039 #include "view.h" 0040 0041 class BrowserExtension; 0042 class Calculator; 0043 class FunctionEditor; 0044 class FunctionTools; 0045 class KConfigDialog; 0046 class KConstantEditor; 0047 class QAction; 0048 class KRecentFilesAction; 0049 class QTimer; 0050 0051 class SettingsPageColor; 0052 class SettingsPageFonts; 0053 class SettingsPageGeneral; 0054 class SettingsPageDiagram; 0055 0056 /** 0057 * @short This is the main window of KmPlot. 0058 */ 0059 class MainDlg : public KParts::ReadWritePart 0060 { 0061 Q_OBJECT 0062 0063 public: 0064 /** Constructor. 0065 * @param parentWidget parent widget for this part 0066 * @param parent parent object 0067 */ 0068 MainDlg(QWidget *parentWidget, QObject *parent, const QVariantList & = QVariantList()); 0069 0070 /// Initialized as a pointer to this MainDlg object on creation 0071 static MainDlg *self() 0072 { 0073 return m_self; 0074 } 0075 0076 /// Cleaning up a bit. 0077 virtual ~MainDlg(); 0078 0079 /// Is set to true if a file from an old file format was loaded 0080 static bool oldfileversion; 0081 0082 /// The function editor 0083 FunctionEditor *functionEditor() const 0084 { 0085 return m_functionEditor; 0086 } 0087 0088 /// The coords config dialog 0089 CoordsConfigDialog *coordsDialog(); 0090 0091 /// Returns true if any changes are done 0092 bool isModified() 0093 { 0094 return m_modified; 0095 } 0096 0097 bool queryClose() Q_DECL_OVERRIDE; 0098 0099 /// For inserting the title in the function popup menu 0100 QAction *m_firstFunctionAction; 0101 0102 /// Show the constants editor modal to a parent dialog 0103 void editConstantsModal(QWidget *parent); 0104 0105 /// Check whether the url links to an existing file 0106 static bool fileExists(const QUrl &url); 0107 0108 public Q_SLOTS: 0109 // DBus interface 0110 /// Asks the user and returns true if modified data shall be discarded. 0111 Q_SCRIPTABLE bool checkModified(); 0112 0113 public slots: 0114 /// Implement the coordinate system edit dialog 0115 void editAxes(); 0116 /// Show the constants editor 0117 void editConstants(); 0118 /// Toggle whether the sliders window is shown 0119 void toggleShowSliders(); 0120 /// Revert to the previous document state (in m_undoStack). 0121 void undo(); 0122 /// Revert to the next document state (in m_redoStack). 0123 void redo(); 0124 /// Pushes the previous document state to the undo stack and records the current one 0125 void requestSaveCurrentState(); 0126 0127 /// Save a plot i.e. save the function name and all the settings for the plot 0128 void slotSave(); 0129 /// Save a plot and choose a name for it 0130 void slotSaveas(); 0131 /// Print the current plot 0132 void slotPrint(); 0133 /// For calling print preview functionality 0134 void slotPrintPreview(); 0135 /// Export the current plot as a png, svg or bmp picture 0136 void slotExport(); 0137 /// Implement the Configure KmPlot dialog 0138 void slotSettings(); 0139 /// Calls the common function names dialog. 0140 void slotNames(); 0141 /// Resets the view 0142 void slotResetView(); 0143 /// Tools menu 0144 void calculator(); 0145 void findMinimumValue(); 0146 void findMaximumValue(); 0147 void graphArea(); 0148 0149 private: 0150 /// Settings the standard and non standard actions of the application. 0151 void setupActions(); 0152 /// Sets the printer options and draw the plot with the current options. 0153 void setupPrinter(KPrinterDlg *printDialog, QPrinter *printer); 0154 /// Called when a file is opened. The filename is m_url 0155 bool openFile() Q_DECL_OVERRIDE; 0156 0157 /// Called when a file is saved. The filename is m_url 0158 bool saveFile() Q_DECL_OVERRIDE; 0159 0160 /// The Recent Files action 0161 KRecentFilesAction *m_recentFiles; 0162 /// true == modifications not saved 0163 bool m_modified; 0164 /// An instance of the application config file 0165 KSharedConfigPtr m_config; 0166 /// A Configure KmPlot dialog instance 0167 KConfigDialog *m_settingsDialog; 0168 /// The General page for the Configure KmPlot dialog 0169 SettingsPageGeneral *m_generalSettings; 0170 /// The Colors page for the Configure KmPlot constants 0171 SettingsPageColor *m_colorSettings; 0172 /// The Fonts page for the Configure KmPlot constants 0173 SettingsPageFonts *m_fontsSettings; 0174 /// The diagram config page 0175 SettingsPageDiagram *m_diagramSettings; 0176 0177 /// A dialog used by many tools-menu-items 0178 FunctionTools *m_functionTools; 0179 /// The calculator dialog 0180 Calculator *m_calculator; 0181 /// the popup menu shown when cling with the right mouse button on a graph in the graph widget 0182 QMenu *m_popupmenu; 0183 /// the popup that shows when clicking on the new plot button in the function editor 0184 QMenu *m_newPlotMenu; 0185 /// Loads and saves the user's file. 0186 KmPlotIO *kmplotio; 0187 /// Set to true if the application is readonly 0188 bool m_readonly; 0189 /// MainDlg's parent widget 0190 QWidget *m_parent; 0191 /// Current file 0192 QUrl m_currentfile; 0193 /// The axes config dialogs 0194 CoordsConfigDialog *m_coordsDialog; 0195 /// The constants editor 0196 QPointer<KConstantEditor> m_constantEditor; 0197 /// The function editor 0198 FunctionEditor *m_functionEditor; 0199 /// The undo stack 0200 QStack<QDomDocument> m_undoStack; 0201 /// The reod stack 0202 QStack<QDomDocument> m_redoStack; 0203 /** 0204 * The current document state - this is pushed to the undo stack when a new 0205 * document state is created. 0206 */ 0207 QDomDocument m_currentState; 0208 /// Timer to ensure saveCurrentState() is called only once for a set of simultaneous changes 0209 QTimer *m_saveCurrentStateTimer; 0210 /// The undo action 0211 QAction *m_undoAction; 0212 /// The redo action 0213 QAction *m_redoAction; 0214 0215 /// A pointer to ourselves 0216 static MainDlg *m_self; 0217 0218 /// Root value for copying into clipboard 0219 double m_rootValue; 0220 0221 protected slots: 0222 /** 0223 * When you click on a File->Open Recent file, it'll open 0224 * @param url name of the url to open 0225 */ 0226 void slotOpenRecent(const QUrl &url); 0227 /// @see requestSaveCurrentState 0228 void saveCurrentState(); 0229 /// Used when opening a new file 0230 void resetUndoRedo(); 0231 0232 void setReadOnlyStatusBarText(const QString &); 0233 }; 0234 0235 class BrowserExtension : public KParts::BrowserExtension 0236 { 0237 Q_OBJECT 0238 public: 0239 explicit BrowserExtension(MainDlg *); 0240 0241 public slots: 0242 // Automatically detected by the host. 0243 void print(); 0244 }; 0245 0246 #endif // MainDlg_included