blob: cda18b82d2c5f30b1a28973008278928f7d4159b [file] [log] [blame]
taylorchuc27dd482014-05-17 20:06:49 -07001/* -*- 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 Afanasyev11ae34d2016-03-21 11:55:16 -070023#include "config.hpp"
24
taylorchuc27dd482014-05-17 20:06:49 -070025#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 Afanasyev4086d512014-07-11 15:56:33 -070033#include <QtQml/QQmlContext>
34
Yingdi Yu1f824642016-03-20 17:07:22 -070035#include "key-viewer-dialog.hpp"
36
taylorchuc27dd482014-05-17 20:06:49 -070037namespace ndn {
38
Alexander Afanasyev81509f32016-03-21 17:02:38 -070039class Face;
40
taylorchuc27dd482014-05-17 20:06:49 -070041class TrayMenu : public QWidget
42{
43 Q_OBJECT
44
45signals:
46 void
47 showApp();
48
49 void
50 nfdActivityUpdate(bool isActive);
51
52public:
Alexander Afanasyev4086d512014-07-11 15:56:33 -070053 explicit
Alexander Afanasyev81509f32016-03-21 17:02:38 -070054 TrayMenu(QQmlContext* context, Face& face);
taylorchuc27dd482014-05-17 20:06:49 -070055
56 ~TrayMenu();
57
58 Q_INVOKABLE void
Alexander Afanasyev4086d512014-07-11 15:56:33 -070059 autoConfig();
taylorchuc27dd482014-05-17 20:06:49 -070060
61 Q_INVOKABLE void
Alexander Afanasyev4086d512014-07-11 15:56:33 -070062 startStopNfd();
taylorchuc27dd482014-05-17 20:06:49 -070063
susmit4fe3cb92016-03-20 17:08:41 -070064 Q_INVOKABLE void
65 addDeleteRoute();
66
67 Q_INVOKABLE void
68 addRoute();
69
70 Q_INVOKABLE void
71 deleteRoute();
72
taylorchuc27dd482014-05-17 20:06:49 -070073private 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 Afanasyev11ae34d2016-03-21 11:55:16 -070090 void
91 enableCli();
92
taylorchuc27dd482014-05-17 20:06:49 -070093private:
Alexander Afanasyev4086d512014-07-11 15:56:33 -070094 QQmlContext* m_context;
95 bool m_isNfdRunning;
Yingdi Yu53c11c12016-03-20 12:56:49 -070096 QSystemTrayIcon* m_tray;
97 QMenu* m_menu;
98 QAction* m_entryPref;
99 QAction* m_entrySec;
Alexander Afanasyev11ae34d2016-03-21 11:55:16 -0700100#ifdef OSX_BUILD
101 QAction* m_entryEnableCli;
102#endif
103
Yingdi Yu53c11c12016-03-20 12:56:49 -0700104 QAction* m_entryQuit;
Yingdi Yu1f824642016-03-20 17:07:22 -0700105
106 ncc::KeyViewerDialog* m_keyViewerDialog;
Alexander Afanasyev81509f32016-03-21 17:02:38 -0700107 Face& m_face;
taylorchuc27dd482014-05-17 20:06:49 -0700108};
109
110} // namespace ndn
111
112#endif // NCC_TRAY_MENU_HPP