File indexing completed on 2025-03-16 13:13:04
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(); 0057 virtual bool queryExit(); 0058 0059 protected slots: 0060 // File menu 0061 void fileOpen(); 0062 void fileOpen(const QUrl &url); 0063 void save(); 0064 void saveAs(); 0065 void newSymbol(); 0066 void saveSymbol(); 0067 void saveSymbolAsNew(); 0068 void importLibrary(); 0069 void close(); 0070 void quit(); 0071 0072 // Edit menu 0073 void undo(); 0074 void redo(); 0075 void undoTextChanged(const QString &text); 0076 void redoTextChanged(const QString &text); 0077 void cleanChanged(bool clean); 0078 0079 void currentChanged(int index); 0080 void itemSelected(QListWidgetItem *item); 0081 void listWidgetContextMenuRequested(const QPoint &pos); 0082 void deleteSymbol(); 0083 0084 // Settings menu 0085 void preferences(); 0086 0087 private: 0088 bool editorClean(); 0089 bool libraryClean(); 0090 void setupActions(); 0091 void setActionsFromSymbol(const Symbol &symbol); 0092 0093 QUrl m_url; /**< url of the loaded library */ 0094 0095 QTabWidget *m_tabWidget; /**< pointer to the QTabWidget containing the editor and library tabs */ 0096 Editor *m_editor; /**< pointer to the Editor */ 0097 SymbolListWidget *m_listWidget; /**< pointer to the SymbolListWidget containing icons for the library symbols */ 0098 0099 SymbolLibrary *m_symbolLibrary; /**< pointer to a SymbolLibrary */ 0100 0101 QListWidgetItem *m_item; /**< pointer to a QListWidgetItem in m_listWidget found for the context menu */ 0102 QMenu *m_menu; /**< pointer to a popup context menu */ 0103 0104 QUndoGroup m_undoGroup; /**< the QUndoGroup has the QUndoStacks for the Editor and the SymbolLibrary added to it */ 0105 }; 0106 0107 0108 #endif 0109