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 | |
Alexander Afanasyev | 81509f3 | 2016-03-21 17:02:38 -0700 | [diff] [blame] | 39 | class Face; |
| 40 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 41 | class TrayMenu : public QWidget |
| 42 | { |
| 43 | Q_OBJECT |
| 44 | |
| 45 | signals: |
| 46 | void |
| 47 | showApp(); |
| 48 | |
| 49 | void |
| 50 | nfdActivityUpdate(bool isActive); |
| 51 | |
| 52 | public: |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 53 | explicit |
Alexander Afanasyev | 81509f3 | 2016-03-21 17:02:38 -0700 | [diff] [blame] | 54 | TrayMenu(QQmlContext* context, Face& face); |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 55 | |
| 56 | ~TrayMenu(); |
| 57 | |
| 58 | Q_INVOKABLE void |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 59 | autoConfig(); |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 60 | |
| 61 | Q_INVOKABLE void |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 62 | startStopNfd(); |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 63 | |
susmit | 4fe3cb9 | 2016-03-20 17:08:41 -0700 | [diff] [blame] | 64 | Q_INVOKABLE void |
| 65 | addDeleteRoute(); |
| 66 | |
| 67 | Q_INVOKABLE void |
| 68 | addRoute(); |
| 69 | |
| 70 | Q_INVOKABLE void |
| 71 | deleteRoute(); |
| 72 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 73 | private slots: |
| 74 | |
| 75 | void |
| 76 | quitApp(); |
| 77 | |
| 78 | void |
| 79 | iconActivated(QSystemTrayIcon::ActivationReason reason); |
| 80 | |
| 81 | void |
| 82 | startNfd(); |
| 83 | |
| 84 | void |
| 85 | stopNfd(); |
| 86 | |
| 87 | void |
| 88 | updateNfdActivityIcon(bool isActive); |
| 89 | |
Alexander Afanasyev | 11ae34d | 2016-03-21 11:55:16 -0700 | [diff] [blame] | 90 | void |
| 91 | enableCli(); |
| 92 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 93 | private: |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 94 | QQmlContext* m_context; |
| 95 | bool m_isNfdRunning; |
Yingdi Yu | 53c11c1 | 2016-03-20 12:56:49 -0700 | [diff] [blame] | 96 | QSystemTrayIcon* m_tray; |
| 97 | QMenu* m_menu; |
| 98 | QAction* m_entryPref; |
| 99 | QAction* m_entrySec; |
Alexander Afanasyev | 11ae34d | 2016-03-21 11:55:16 -0700 | [diff] [blame] | 100 | #ifdef OSX_BUILD |
| 101 | QAction* m_entryEnableCli; |
| 102 | #endif |
| 103 | |
Yingdi Yu | 53c11c1 | 2016-03-20 12:56:49 -0700 | [diff] [blame] | 104 | QAction* m_entryQuit; |
Yingdi Yu | 1f82464 | 2016-03-20 17:07:22 -0700 | [diff] [blame] | 105 | |
| 106 | ncc::KeyViewerDialog* m_keyViewerDialog; |
Alexander Afanasyev | 81509f3 | 2016-03-21 17:02:38 -0700 | [diff] [blame] | 107 | Face& m_face; |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | } // namespace ndn |
| 111 | |
| 112 | #endif // NCC_TRAY_MENU_HPP |