File indexing completed on 2024-04-28 04:33:57
0001 /******************************************************************************** 0002 * Copyright (C) 2011-2015 by Stephen Allewell * 0003 * steve.allewell@gmail.com * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ********************************************************************************/ 0010 0011 0012 /** 0013 * @file 0014 * Header file for the MainWindow class. 0015 */ 0016 0017 0018 #ifndef MainWindow_H 0019 #define MainWindow_H 0020 0021 0022 #include <QUndoGroup> 0023 #include <QUrl> 0024 0025 #include <KXmlGuiWindow> 0026 0027 class QListWidgetItem; 0028 0029 class QTabWidget; 0030 0031 class Editor; 0032 class Symbol; 0033 class SymbolLibrary; 0034 class SymbolListWidget; 0035 0036 0037 /** 0038 * @brief Manages the main window of the application. 0039 * 0040 * The MainWindow class is based on the KXmlGuiWindow class which provides the basis for KDE applications. 0041 * It creates instances of the Editor class and the QListWidget class that is used to show the existing 0042 * symbols in the library. 0043 * 0044 * It creates all the actions that are associated with the application connecting various signals to the 0045 * relevant slots to allow the interaction between the gui elements. 0046 */ 0047 class MainWindow : public KXmlGuiWindow 0048 { 0049 Q_OBJECT 0050 0051 public: 0052 MainWindow(); 0053 ~MainWindow(); 0054 0055 protected: 0056 virtual bool queryClose() Q_DECL_OVERRIDE; 0057 0058 protected slots: 0059 // File menu 0060 void fileOpen(); 0061 void fileOpen(const QUrl &url); 0062 void save(); 0063 void saveAs(); 0064 void newSymbol(); 0065 void saveSymbol(); 0066 void saveSymbolAsNew(); 0067 void importLibrary(); 0068 void close(); 0069 void quit(); 0070 0071 // Edit menu 0072 void undo(); 0073 void redo(); 0074 void undoTextChanged(const QString &text); 0075 void redoTextChanged(const QString &text); 0076 void cleanChanged(bool clean); 0077 0078 void currentChanged(int index); 0079 void itemSelected(QListWidgetItem *item); 0080 void listWidgetContextMenuRequested(const QPoint &pos); 0081 void deleteSymbol(); 0082 0083 // Settings menu 0084 void preferences(); 0085 0086 private: 0087 bool editorClean(); 0088 bool libraryClean(); 0089 void setupActions(); 0090 void setActionsFromSymbol(const Symbol &symbol); 0091 0092 QUrl m_url; /**< url of the loaded library */ 0093 0094 QTabWidget *m_tabWidget; /**< pointer to the QTabWidget containing the editor and library tabs */ 0095 Editor *m_editor; /**< pointer to the Editor */ 0096 SymbolListWidget *m_listWidget; /**< pointer to the SymbolListWidget containing icons for the library symbols */ 0097 0098 SymbolLibrary *m_symbolLibrary; /**< pointer to a SymbolLibrary */ 0099 0100 QListWidgetItem *m_item; /**< pointer to a QListWidgetItem in m_listWidget found for the context menu */ 0101 QMenu *m_menu; /**< pointer to a popup context menu */ 0102 0103 QUndoGroup m_undoGroup; /**< the QUndoGroup has the QUndoStacks for the Editor and the SymbolLibrary added to it */ 0104 }; 0105 0106 0107 #endif 0108