blob: 0c09cb0dc56afb82628d5a2044b2b6113102d298 [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
39class TrayMenu : public QWidget
40{
41 Q_OBJECT
42
43signals:
44 void
45 showApp();
46
47 void
48 nfdActivityUpdate(bool isActive);
49
50public:
Alexander Afanasyev4086d512014-07-11 15:56:33 -070051 explicit
52 TrayMenu(QQmlContext* context);
taylorchuc27dd482014-05-17 20:06:49 -070053
54 ~TrayMenu();
55
56 Q_INVOKABLE void
Alexander Afanasyev4086d512014-07-11 15:56:33 -070057 autoConfig();
taylorchuc27dd482014-05-17 20:06:49 -070058
59 Q_INVOKABLE void
Alexander Afanasyev4086d512014-07-11 15:56:33 -070060 startStopNfd();
taylorchuc27dd482014-05-17 20:06:49 -070061
susmit4fe3cb92016-03-20 17:08:41 -070062 Q_INVOKABLE void
63 addDeleteRoute();
64
65 Q_INVOKABLE void
66 addRoute();
67
68 Q_INVOKABLE void
69 deleteRoute();
70
taylorchuc27dd482014-05-17 20:06:49 -070071private 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 Afanasyev11ae34d2016-03-21 11:55:16 -070088 void
89 enableCli();
90
taylorchuc27dd482014-05-17 20:06:49 -070091private:
Alexander Afanasyev4086d512014-07-11 15:56:33 -070092 QQmlContext* m_context;
93 bool m_isNfdRunning;
Yingdi Yu53c11c12016-03-20 12:56:49 -070094 QSystemTrayIcon* m_tray;
95 QMenu* m_menu;
96 QAction* m_entryPref;
97 QAction* m_entrySec;
Alexander Afanasyev11ae34d2016-03-21 11:55:16 -070098#ifdef OSX_BUILD
99 QAction* m_entryEnableCli;
100#endif
101
Yingdi Yu53c11c12016-03-20 12:56:49 -0700102 QAction* m_entryQuit;
Yingdi Yu1f824642016-03-20 17:07:22 -0700103
104 ncc::KeyViewerDialog* m_keyViewerDialog;
taylorchuc27dd482014-05-17 20:06:49 -0700105};
106
107} // namespace ndn
108
109#endif // NCC_TRAY_MENU_HPP