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 | |
| 23 | #include <QtCore/QObject> |
| 24 | #include <QtCore/QProcess> |
| 25 | #include <QtCore/QCoreApplication> |
| 26 | |
| 27 | #include <QtWidgets/QSystemTrayIcon> |
| 28 | #include <QtWidgets/QAction> |
| 29 | #include <QtWidgets/QMenu> |
| 30 | |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 31 | #include <QtQml/QQmlContext> |
| 32 | |
Yingdi Yu | 1f82464 | 2016-03-20 17:07:22 -0700 | [diff] [blame] | 33 | #include "key-viewer-dialog.hpp" |
| 34 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 35 | namespace ndn { |
| 36 | |
| 37 | class TrayMenu : public QWidget |
| 38 | { |
| 39 | Q_OBJECT |
| 40 | |
| 41 | signals: |
| 42 | void |
| 43 | showApp(); |
| 44 | |
| 45 | void |
| 46 | nfdActivityUpdate(bool isActive); |
| 47 | |
| 48 | public: |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 49 | explicit |
| 50 | TrayMenu(QQmlContext* context); |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 51 | |
| 52 | ~TrayMenu(); |
| 53 | |
| 54 | Q_INVOKABLE void |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 55 | autoConfig(); |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 56 | |
| 57 | Q_INVOKABLE void |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 58 | startStopNfd(); |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 59 | |
susmit | 4fe3cb9 | 2016-03-20 17:08:41 -0700 | [diff] [blame] | 60 | Q_INVOKABLE void |
| 61 | addDeleteRoute(); |
| 62 | |
| 63 | Q_INVOKABLE void |
| 64 | addRoute(); |
| 65 | |
| 66 | Q_INVOKABLE void |
| 67 | deleteRoute(); |
| 68 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 69 | private slots: |
| 70 | |
| 71 | void |
| 72 | quitApp(); |
| 73 | |
| 74 | void |
| 75 | iconActivated(QSystemTrayIcon::ActivationReason reason); |
| 76 | |
| 77 | void |
| 78 | startNfd(); |
| 79 | |
| 80 | void |
| 81 | stopNfd(); |
| 82 | |
susmit | 4fe3cb9 | 2016-03-20 17:08:41 -0700 | [diff] [blame] | 83 | |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 84 | void |
| 85 | updateNfdActivityIcon(bool isActive); |
| 86 | |
| 87 | private: |
Alexander Afanasyev | 4086d51 | 2014-07-11 15:56:33 -0700 | [diff] [blame] | 88 | QQmlContext* m_context; |
| 89 | bool m_isNfdRunning; |
Yingdi Yu | 53c11c1 | 2016-03-20 12:56:49 -0700 | [diff] [blame] | 90 | QSystemTrayIcon* m_tray; |
| 91 | QMenu* m_menu; |
| 92 | QAction* m_entryPref; |
| 93 | QAction* m_entrySec; |
| 94 | QAction* m_entryQuit; |
Yingdi Yu | 1f82464 | 2016-03-20 17:07:22 -0700 | [diff] [blame] | 95 | |
| 96 | ncc::KeyViewerDialog* m_keyViewerDialog; |
taylorchu | c27dd48 | 2014-05-17 20:06:49 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | } // namespace ndn |
| 100 | |
| 101 | #endif // NCC_TRAY_MENU_HPP |