1 /*************************************************************************** 2 * * 3 * copyright : (C) 2007 The University of Toronto * 4 * netterfield@astro.utoronto.ca * 5 * * 6 * This program is free software; you can redistribute it and/or modify * 7 * it under the terms of the GNU General Public License as published by * 8 * the Free Software Foundation; either version 2 of the License, or * 9 * (at your option) any later version. * 10 * * 11 ***************************************************************************/ 12 13 #ifndef MAINWINDOW_H 14 #define MAINWINDOW_H 15 16 #include <QMainWindow> 17 #include <QPointer> 18 #include <QLabel> 19 20 #if defined(__QNX__) 21 #include <QDateTime> 22 #endif // defined(__QNX__) 23 24 class QMenu; 25 class QAction; 26 class QProgressBar; 27 class QUndoGroup; 28 class QPrinter; 29 class QSettings; 30 class QSignalMapper; 31 32 namespace Kst { 33 34 class DataManager; 35 class DebugDialog; 36 class Document; 37 class ExportGraphicsDialog; 38 class ExportVectorsDialog; 39 class LogDialog; 40 class DifferentiateCurvesDialog; 41 class FilterMultipleDialog; 42 class ChooseColorDialog; 43 class ChangeDataSampleDialog; 44 class ChangeFileDialog; 45 class BugReportWizard; 46 class ApplicationSettingsDialog; 47 class ThemeDialog; 48 class AboutDialog; 49 class ShortcutDialog; 50 class TabWidget; 51 class View; 52 class ScriptServer; 53 class ViewVectorDialog; 54 55 56 class MainWindow : public QMainWindow 57 { 58 Q_OBJECT 59 public: 60 MainWindow(); 61 ~MainWindow(); 62 63 QUndoGroup *undoGroup() const; 64 TabWidget *tabWidget() const; 65 Document *document() const; 66 QProgressBar *progressBar() const; 67 bool initFromCommandLine(); isHighlightPoint()68 bool isHighlightPoint() { return _highlightPoint; } 69 bool isTiedTabs(); 70 void setStatusMessage(QString message, int timeout=0, bool delayed = false); 71 void updateStatusMessage(); 72 QString statusMessage(); 73 74 static void setWidgetFlags(QWidget*); 75 void updateRecentKstFiles(const QString& newfilename = QString()); 76 77 void setKstWindowTitle(); 78 QString scriptServerName(); 79 bool scriptServerNameSet(); 80 void setScriptServerName(QString server_name); 81 82 public Q_SLOTS: 83 void copyTab(); 84 void showDataManager(); 85 void showDebugDialog(); 86 void showExportGraphicsDialog(); 87 void showExportVectorsDialog(); 88 void showLogDialog(); 89 void showVectorEditor(); 90 void showScalarEditor(); 91 void showMatrixEditor(); 92 void showStringEditor(); 93 void showSettingsDialog(); 94 void showThemeDialog(); 95 void clearDefaults(); 96 void clearDataSourceSettings(); 97 void showDifferentiateCurvesDialog(); 98 void filterMultipleDialog(); 99 void showChooseColorDialog(); 100 void showChangeDataSampleDialog(); 101 void showChangeFileDialog(); 102 void showDataWizard(); 103 void showDataWizard(const QString &dataFile); 104 void showBugReportWizard(); 105 void showPluginDialog(QString &pluginName); 106 107 void readFromEnd(); 108 void readToEnd(); 109 void pause(bool pause); 110 void back(double scale = 1.0); 111 void forward(double scale = 1.0); backSmall()112 void backSmall() {back(0.2);} forwardSmall()113 void forwardSmall() {forward(0.2);} 114 void reload(); 115 116 void updateViewItems(qint64 serial); 117 void updateProgress(int percent, const QString& message); 118 119 void save(); 120 void saveAs(); 121 void open(); 122 void newDoc(bool force=false); 123 void openFile(const QString &file); 124 void cleanUpDataSourceList(); 125 #ifndef KST_NO_PRINTER 126 void print(); 127 void setPrinterDefaults(QPrinter *printer); 128 void savePrinterDefaults(QPrinter *printer); 129 void printToPrinter(QPrinter *printer); 130 void printFromCommandLine(const QString &printFileName); 131 #endif 132 void exportGraphicsFile(const QString &filename, const QString &format, int w, int h, int display, bool export_all, int autosave_period); 133 void exportLog(const QString &imagename, QString &msgfilename, const QString &_format, int x_size, int y_size, 134 int size_option_index, const QString &message); 135 136 137 void clearDrawingMarker(); 138 void tiedZoomRemoved(); 139 void allPlotsTiedZoom(); 140 141 void updateRecentDataFiles(const QString& newfilename = QString()); 142 void videoTutorial(int); 143 144 QStringList recentDataFiles(); 145 146 void cleanupRecentDataFilesList(); 147 148 private Q_SLOTS: 149 void aboutToQuit(); 150 void about(); 151 void showShortcutDialog(); 152 void currentViewChanged(); 153 void currentViewModeChanged(); 154 155 void createBox(); 156 void createEllipse(); 157 void createLabel(); 158 void createCircle(); 159 void createLine(); 160 void createArrow(); 161 void createPicture(); 162 void createPlot(); 163 void insertPlot(); 164 #ifndef KST_NO_SVG 165 void createSvg(); 166 #endif 167 void createSharedAxisBox(); 168 169 void createScalar(); 170 void createVector(); 171 void createMatrix(); 172 void createString(); 173 void createCurve(); 174 void createPSD(); 175 void createEquation(); 176 void createHistogram(); 177 void createImage(); 178 void createSpectogram(); 179 void createEventMonitor(); 180 181 void performHeavyStartupActions(); 182 void cleanup(); 183 184 void setLayoutMode(bool layoutMode); 185 void toggleTiedZoom(); 186 187 void setHighlightPoint(bool); 188 void changeZoomOnlyMode(QAction*); 189 190 void openRecentKstFile(); 191 void openRecentDataFile(); 192 void checkRecentFilesOnExistence(); 193 194 void autoExportImage(); 195 196 protected: 197 void closeEvent(QCloseEvent *e); 198 199 private: 200 void createActions(); 201 void createMenus(); 202 void createStatusBar(); 203 void createToolBars(); 204 205 void readSettings(); 206 void writeSettings(); 207 bool promptSaveDone(); 208 209 QAction* createRecentFileAction(const QString& filename, int idx, const QString& text, const char* openslot); 210 void updateRecentFiles(const QString& key, QMenu *menu, QList<QAction*>& actions, QMenu* submenu, const QString& newfilename, const char* openslot); 211 212 void dragEnterEvent(QDragEnterEvent *event); 213 void dropEvent(QDropEvent *event); 214 #if defined(__QNX__) 215 void keyPressEvent(QKeyEvent *event); 216 bool eventFilter(QObject *obj, QEvent *event); 217 void qnxToggleToolbarVisibility(); 218 #endif // defined(__QNX__) 219 220 private: 221 Document *_doc; 222 TabWidget *_tabWidget; 223 QUndoGroup *_undoGroup; 224 ScriptServer* _scriptServer; 225 QSettings& _settings; 226 227 DataManager *_dataManager; 228 DebugDialog *_debugDialog; 229 ExportGraphicsDialog *_exportGraphics; 230 ExportVectorsDialog *_exportVectors; 231 LogDialog *_logDialog; 232 DifferentiateCurvesDialog *_differentiateCurvesDialog; 233 FilterMultipleDialog *_filterMultipleDialog; 234 ChooseColorDialog *_chooseColorDialog; 235 ChangeDataSampleDialog *_changeDataSampleDialog; 236 ChangeFileDialog *_changeFileDialog; 237 BugReportWizard *_bugReportWizard; 238 ApplicationSettingsDialog *_applicationSettingsDialog; 239 ThemeDialog *_themeDialog; 240 AboutDialog* _aboutDialog; 241 ShortcutDialog* _shortcutDialog; 242 ViewVectorDialog* _viewVectorDialog; 243 QSignalMapper* _videoMapper; 244 QPointer<QProgressBar> _progressBar; 245 QLabel *_messageLabel; 246 247 bool _highlightPoint; 248 249 QMenu *_fileMenu; 250 QMenu *_editMenu; 251 QMenu *_viewMenu; 252 QMenu *_createMenu; 253 QMenu *_pluginsMenu; 254 QMenu *_fitsPluginsMenu; 255 QMenu *_filterPluginsMenu; 256 QMenu *_modeMenu; 257 QMenu *_rangeMenu; 258 QMenu *_toolsMenu; 259 QMenu *_settingsMenu; 260 QMenu *_helpMenu; 261 QMenu* _videoTutorialsMenu; 262 263 QToolBar *_fileToolBar; 264 QToolBar *_editToolBar; 265 QToolBar *_rangeToolBar; 266 QToolBar *_modeToolBar; 267 QToolBar *_plotLayoutToolBar; 268 QToolBar *_toolsToolBar; 269 QToolBar *_annotationToolBar; 270 271 QAction *_undoAct; 272 QAction *_redoAct; 273 QAction *_copyTabAct; 274 275 // FIXME: move these into each object, along with the creation slot? 276 QAction *_createLabelAct; 277 QAction *_createBoxAct; 278 QAction *_createCircleAct; 279 QAction *_createEllipseAct; 280 QAction *_createLineAct; 281 QAction *_createArrowAct; 282 QAction *_createPictureAct; 283 QAction *_createPlotAct; 284 QAction *_insertPlotAct; 285 #ifndef KST_NO_SVG 286 QAction *_createSvgAct; 287 #endif 288 QAction *_createSharedAxisBoxAct; 289 290 QAction *_aboutAct; 291 QAction *_showShortcutAct; 292 QAction *_dataManagerAct; 293 QAction *_debugDialogAct; 294 QAction *_video1Act; 295 QAction *_video2Act; 296 QAction *_video3Act; 297 QAction *_video4Act; 298 QAction *_video5Act; 299 QAction *_video6Act; 300 QAction *_video7Act; 301 QAction *_exitAct; 302 QAction *_exportGraphicsAct; 303 QAction *_exportVectorsAct; 304 QAction *_logAct; 305 QAction *_openAct; 306 QAction *_saveAct; 307 QAction *_saveAsAct; 308 QAction *_closeAct; 309 QAction *_printAct; 310 QAction *_newTabAct; 311 QAction *_closeTabAct; 312 QAction *_scalarEditorAct; 313 QAction *_vectorEditorAct; 314 QAction *_matrixEditorAct; 315 QAction *_stringEditorAct; 316 317 QAction *_layoutModeAct; 318 QAction *_tiedZoomAct; 319 QAction *_tabTiedAct; 320 QAction *_highlightPointAct; 321 QAction *_standardZoomAct; 322 QAction *_xOnlyZoomAct; 323 QAction *_yOnlyZoomAct; 324 325 QAction *_settingsDialogAct; 326 QAction *_themeDialogAct; 327 328 QAction *_clearUISettings; 329 QAction *_clearDataSourceSettings; 330 331 QAction *_differentiateCurvesDialogAct; 332 QAction *_filterMultipleDialogAct; 333 QAction *_chooseColorDialogAct; 334 QAction *_changeDataSampleDialogAct; 335 QAction *_changeFileDialogAct; 336 QAction *_dataWizardAct; 337 QAction *_bugReportWizardAct; 338 339 QAction *_readFromEndAct; 340 QAction *_readToEndAct; 341 QAction *_pauseAct; 342 QAction *_backAct; 343 QAction *_forwardAct; 344 QAction *_backSmallAct; 345 QAction *_forwardSmallAct; 346 QAction *_reloadAct; 347 348 QAction *_newScalarAct; 349 QAction *_newVectorAct; 350 QAction *_newMatrixAct; 351 QAction *_newStringAct; 352 QAction *_newCurveAct; 353 QAction *_newEquationAct; 354 QAction *_newPSDAct; 355 QAction *_newHistogramAct; 356 QAction *_newImageAct; 357 QAction *_newSpectrogramAct; 358 QAction *_newEventMonitorAct; 359 360 QMenu* _recentKstFilesMenu; 361 QMenu* _recentDataFilesMenu; 362 QList<QAction*> _bottomRecentKstActions; 363 QList<QAction*> _bottomRecentDataActions; 364 QString _statusBarMessage; 365 int _statusBarTimeout; 366 #if defined(__QNX__) 367 bool _qnxToolbarsVisible; 368 QDateTime _qnxLastToolbarEvent; 369 #endif // defined(__QNX__) 370 371 // autoExportGraphics fields 372 QString _ae_filename; 373 QString _ae_format; 374 int _ae_width; 375 int _ae_height; 376 int _ae_display; 377 bool _ae_export_all; 378 int _ae_autosave_period; 379 QTimer *_ae_Timer; 380 QString _sessionFileName; 381 382 friend class ScriptServer; 383 }; 384 385 } 386 #endif 387 388 // vim: ts=2 sw=2 et 389