taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2013-2014, Regents of the University of California, |
| 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> |
| 28 | |
| 29 | #include <QtWidgets/QSystemTrayIcon> |
| 30 | #include <QtWidgets/QAction> |
| 31 | #include <QtWidgets/QMenu> |
| 32 | |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 33 | #include <QtQml/QQmlContext> |
| 34 | |
Yingdi Yu | 1f82464 | 2016-03-20 17:07:22 -0700 | [diff] [blame] | 35 | #include "key-viewer-dialog.hpp" |
| 36 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 37 | namespace ndn { |
| 38 | |
| 39 | class TrayMenu : public QWidget |
| 40 | { |
| 41 | Q_OBJECT |
| 42 | |
| 43 | signals: |
| 44 | void |
| 45 | showApp(); |
| 46 | |
| 47 | void |
| 48 | nfdActivityUpdate(bool isActive); |
| 49 | |
| 50 | public: |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 51 | explicit |
| 52 | TrayMenu(QQmlContext* context); |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 53 | |
| 54 | ~TrayMenu(); |
| 55 | |
| 56 | Q_INVOKABLE void |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 57 | autoConfig(); |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 58 | |
| 59 | Q_INVOKABLE void |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 60 | startStopNfd(); |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 61 | |
susmit | 4fe3cb9 | 2016-03-20 17:08:41 -0700 | [diff] [blame] | 62 | Q_INVOKABLE void |
| 63 | addDeleteRoute(); |
| 64 | |
| 65 | Q_INVOKABLE void |
| 66 | addRoute(); |
| 67 | |
| 68 | Q_INVOKABLE void |
| 69 | deleteRoute(); |
| 70 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 71 | private slots: |
| 72 | |
| 73 | void |
| 74 | quitApp(); |
| 75 | |
| 76 | void |
| 77 | iconActivated(QSystemTrayIcon::ActivationReason reason); |
| 78 | |
| 79 | void |
| 80 | startNfd(); |
| 81 | |
| 82 | void |
| 83 | stopNfd(); |
| 84 | |
| 85 | void |
| 86 | updateNfdActivityIcon(bool isActive); |
| 87 | |
Alexander Afanasyev | 11ae34d | 2016-03-21 11:55:16 -0700 | [diff] [blame] | 88 | void |
| 89 | enableCli(); |
| 90 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 91 | private: |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 92 | QQmlContext* m_context; |
| 93 | bool m_isNfdRunning; |
Yingdi Yu | 53c11c1 | 2016-03-20 12:56:49 -0700 | [diff] [blame] | 94 | QSystemTrayIcon* m_tray; |
| 95 | QMenu* m_menu; |
| 96 | QAction* m_entryPref; |
| 97 | QAction* m_entrySec; |
Alexander Afanasyev | 11ae34d | 2016-03-21 11:55:16 -0700 | [diff] [blame] | 98 | #ifdef OSX_BUILD |
| 99 | QAction* m_entryEnableCli; |
| 100 | #endif |
| 101 | |
Yingdi Yu | 53c11c1 | 2016-03-20 12:56:49 -0700 | [diff] [blame] | 102 | QAction* m_entryQuit; |
Yingdi Yu | 1f82464 | 2016-03-20 17:07:22 -0700 | [diff] [blame] | 103 | |
| 104 | ncc::KeyViewerDialog* m_keyViewerDialog; |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | } // namespace ndn |
| 108 | |
| 109 | #endif // NCC_TRAY_MENU_HPP |