File indexing completed on 2024-05-05 16:27:23

0001 /* This file is part of KGraphViewer.
0002    Copyright (C) 2005-2007 Gael de Chalendar <kleag@free.fr>
0003 
0004    KGraphViewer is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU General Public
0006    License as published by the Free Software Foundation, version 2.
0007 
0008    This program is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011    General Public License for more details.
0012 
0013    You should have received a copy of the GNU General Public License
0014    along with this program; if not, write to the Free Software
0015    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0016    02110-1301, USA
0017 */
0018 
0019 #ifndef _KGRAPHVIEWER_H_
0020 #define _KGRAPHVIEWER_H_
0021 
0022 //#include <config-kgraphviewer.h>
0023 
0024 #include <KParts/MainWindow>
0025 #include <KRecentFilesAction>
0026 #include <QAction>
0027 #include <QDir>
0028 #include <QTabWidget>
0029 
0030 class KToggleAction;
0031 
0032 /**
0033  * This is the application "Shell".  It has a menubar, toolbar, and
0034  * statusbar but relies on the "Part" to do all the real work.
0035  *
0036  * @short Application Shell
0037  * @author Gael de Chalendar <kleag@free.fr>
0038  */
0039 class KGraphViewerWindow : public KParts::MainWindow
0040 {
0041     Q_OBJECT
0042 public:
0043     /**
0044      * Default Constructor
0045      */
0046     KGraphViewerWindow();
0047 
0048     /**
0049      * Default Destructor
0050      */
0051     ~KGraphViewerWindow() override;
0052 
0053     /**
0054      * Use this method to load whatever file/URL you have
0055      */
0056     void openUrl(const QUrl &url);
0057 
0058     void reloadPreviousFiles();
0059 
0060 protected:
0061     void closeEvent(QCloseEvent *event) override;
0062 
0063 Q_SIGNALS:
0064     void hide(KParts::Part *part);
0065 
0066 public Q_SLOTS:
0067     /**
0068      * Use this method to load whatever file/URL you have
0069      */
0070     void openUrl(const QString &url)
0071     {
0072         openUrl(QUrl::fromUserInput(url, QDir::currentPath(), QUrl::AssumeLocalFile));
0073     }
0074 
0075     void close();
0076 
0077     void slotReloadOnChangeModeYesToggled(bool value);
0078     void slotReloadOnChangeModeNoToggled(bool value);
0079     void slotReloadOnChangeModeAskToggled(bool value);
0080     void slotOpenInExistingWindowModeYesToggled(bool value);
0081     void slotOpenInExistingWindowModeNoToggled(bool value);
0082     void slotOpenInExistingWindowModeAskToggled(bool value);
0083     void slotReopenPreviouslyOpenedFilesModeYesToggled(bool value);
0084     void slotReopenPreviouslyOpenedFilesModeNoToggled(bool value);
0085     void slotReopenPreviouslyOpenedFilesModeAskToggled(bool value);
0086     void slotParsingModeExternalToggled(bool value);
0087     void slotParsingModeInternalToggled(bool value);
0088 
0089 private Q_SLOTS:
0090     void fileNew();
0091     void fileOpen();
0092     void close(int index);
0093     void slotURLSelected(const QUrl &);
0094     void optionsShowToolbar();
0095     void optionsShowStatusbar();
0096     void optionsConfigureToolbars();
0097     void optionsConfigure();
0098     void newTabSelectedSlot(int index);
0099 
0100     void applyNewToolbarConfig();
0101 
0102     void slotHoverEnter(const QString &);
0103     void slotHoverLeave(const QString &);
0104     void slotBackgroundColorChanged(const QColor &);
0105 
0106 private:
0107     void setupAccel();
0108     void setupActions();
0109 
0110 private:
0111     QTabWidget *m_widget;
0112     KRecentFilesAction *m_rfa;
0113     KParts::PartManager *m_manager;
0114 
0115     KToggleAction *m_toolbarAction;
0116     KToggleAction *m_statusbarAction;
0117     QAction *m_closeAction;
0118 
0119     QStringList m_openedFiles;
0120 
0121     QMap<QWidget *, KParts::Part *> m_tabsPartsMap;
0122     QMap<QWidget *, QString> m_tabsFilesMap;
0123 };
0124 
0125 #endif // _KGRAPHVIEWER_H_