taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Qi Zhao | 86f2b21 | 2016-12-06 12:44:16 -0800 | [diff] [blame^] | 3 | * Copyright (c) 2013-2017, Regents of the University of California, |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of NFD Control Center. See AUTHORS.md for complete list of NFD |
| 6 | * authors and contributors. |
| 7 | * |
| 8 | * NFD Control Center is free software: you can redistribute it and/or modify it under the |
| 9 | * terms of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * NFD Control Center is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 14 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with NFD |
| 17 | * Control Center, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #ifndef NCC_TRAY_MENU_HPP |
| 21 | #define NCC_TRAY_MENU_HPP |
| 22 | |
Alexander Afanasyev | 11ae34d | 2016-03-21 11:55:16 -0700 | [diff] [blame] | 23 | #include "config.hpp" |
| 24 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 25 | #include <QtCore/QObject> |
| 26 | #include <QtCore/QProcess> |
| 27 | #include <QtCore/QCoreApplication> |
Qi Zhao | 86f2b21 | 2016-12-06 12:44:16 -0800 | [diff] [blame^] | 28 | #include <QtCore/QSettings> |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 29 | |
Qi Zhao | 86f2b21 | 2016-12-06 12:44:16 -0800 | [diff] [blame^] | 30 | #include <QtWidgets/QWidget> |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 31 | #include <QtWidgets/QSystemTrayIcon> |
| 32 | #include <QtWidgets/QAction> |
| 33 | #include <QtWidgets/QMenu> |
Qi Zhao | 86f2b21 | 2016-12-06 12:44:16 -0800 | [diff] [blame^] | 34 | #include <QtWidgets/QVBoxLayout> |
| 35 | #include <QtWidgets/QPlainTextEdit> |
| 36 | #include <QtWidgets/QPushButton> |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 37 | |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 38 | #include <QtQml/QQmlContext> |
| 39 | |
Yingdi Yu | 1f82464 | 2016-03-20 17:07:22 -0700 | [diff] [blame] | 40 | #include "key-viewer-dialog.hpp" |
| 41 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 42 | namespace ndn { |
| 43 | |
Alexander Afanasyev | 81509f3 | 2016-03-21 17:02:38 -0700 | [diff] [blame] | 44 | class Face; |
| 45 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 46 | class TrayMenu : public QWidget |
| 47 | { |
| 48 | Q_OBJECT |
| 49 | |
| 50 | signals: |
| 51 | void |
| 52 | showApp(); |
| 53 | |
| 54 | void |
| 55 | nfdActivityUpdate(bool isActive); |
| 56 | |
| 57 | public: |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 58 | explicit |
Alexander Afanasyev | 81509f3 | 2016-03-21 17:02:38 -0700 | [diff] [blame] | 59 | TrayMenu(QQmlContext* context, Face& face); |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 60 | |
| 61 | ~TrayMenu(); |
| 62 | |
Qi Zhao | 86f2b21 | 2016-12-06 12:44:16 -0800 | [diff] [blame^] | 63 | Q_INVOKABLE bool |
| 64 | isAutoConfigEnabled(); |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 65 | |
| 66 | Q_INVOKABLE void |
Qi Zhao | 86f2b21 | 2016-12-06 12:44:16 -0800 | [diff] [blame^] | 67 | startStopAutoConfig(bool autoConfig); |
| 68 | |
| 69 | Q_INVOKABLE void |
| 70 | startStopNfd(bool autoConfig); |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 71 | |
susmit | 4fe3cb9 | 2016-03-20 17:08:41 -0700 | [diff] [blame] | 72 | Q_INVOKABLE void |
| 73 | addDeleteRoute(); |
| 74 | |
| 75 | Q_INVOKABLE void |
| 76 | addRoute(); |
| 77 | |
| 78 | Q_INVOKABLE void |
| 79 | deleteRoute(); |
| 80 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 81 | private slots: |
| 82 | |
| 83 | void |
| 84 | quitApp(); |
| 85 | |
| 86 | void |
| 87 | iconActivated(QSystemTrayIcon::ActivationReason reason); |
| 88 | |
| 89 | void |
Qi Zhao | 86f2b21 | 2016-12-06 12:44:16 -0800 | [diff] [blame^] | 90 | startAutoConfig(); |
| 91 | |
| 92 | void |
| 93 | stopAutoConfig(); |
| 94 | |
| 95 | void |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 96 | startNfd(); |
| 97 | |
| 98 | void |
| 99 | stopNfd(); |
| 100 | |
| 101 | void |
| 102 | updateNfdActivityIcon(bool isActive); |
| 103 | |
Alexander Afanasyev | 11ae34d | 2016-03-21 11:55:16 -0700 | [diff] [blame] | 104 | void |
| 105 | enableCli(); |
| 106 | |
Qi Zhao | 86f2b21 | 2016-12-06 12:44:16 -0800 | [diff] [blame^] | 107 | void |
| 108 | processOutput(); |
| 109 | |
| 110 | void |
| 111 | showPref(); |
| 112 | |
| 113 | static void |
| 114 | appendMsg(QString &target, QString source); |
| 115 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 116 | private: |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 117 | QQmlContext* m_context; |
| 118 | bool m_isNfdRunning; |
Yingdi Yu | 53c11c1 | 2016-03-20 12:56:49 -0700 | [diff] [blame] | 119 | QSystemTrayIcon* m_tray; |
| 120 | QMenu* m_menu; |
| 121 | QAction* m_entryPref; |
| 122 | QAction* m_entrySec; |
Qi Zhao | 86f2b21 | 2016-12-06 12:44:16 -0800 | [diff] [blame^] | 123 | QProcess* m_acProc; |
| 124 | QString m_autoConfigMsg; |
| 125 | QSettings m_settings; |
Alexander Afanasyev | 11ae34d | 2016-03-21 11:55:16 -0700 | [diff] [blame] | 126 | #ifdef OSX_BUILD |
| 127 | QAction* m_entryEnableCli; |
| 128 | #endif |
| 129 | |
Yingdi Yu | 53c11c1 | 2016-03-20 12:56:49 -0700 | [diff] [blame] | 130 | QAction* m_entryQuit; |
Yingdi Yu | 1f82464 | 2016-03-20 17:07:22 -0700 | [diff] [blame] | 131 | |
| 132 | ncc::KeyViewerDialog* m_keyViewerDialog; |
Alexander Afanasyev | 81509f3 | 2016-03-21 17:02:38 -0700 | [diff] [blame] | 133 | Face& m_face; |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | } // namespace ndn |
| 137 | |
| 138 | #endif // NCC_TRAY_MENU_HPP |