blob: 3c7b0f03d2893045b1b8cff16dadba76e6cf45d3 [file] [log] [blame]
taylorchuc27dd482014-05-17 20:06:49 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Qi Zhao86f2b212016-12-06 12:44:16 -08003 * Copyright (c) 2013-2017, Regents of the University of California,
taylorchuc27dd482014-05-17 20:06:49 -07004 *
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>
Qi Zhao86f2b212016-12-06 12:44:16 -080028#include <QtCore/QSettings>
taylorchuc27dd482014-05-17 20:06:49 -070029
Qi Zhao86f2b212016-12-06 12:44:16 -080030#include <QtWidgets/QWidget>
taylorchuc27dd482014-05-17 20:06:49 -070031#include <QtWidgets/QSystemTrayIcon>
32#include <QtWidgets/QAction>
33#include <QtWidgets/QMenu>
Qi Zhao86f2b212016-12-06 12:44:16 -080034#include <QtWidgets/QVBoxLayout>
35#include <QtWidgets/QPlainTextEdit>
36#include <QtWidgets/QPushButton>
taylorchuc27dd482014-05-17 20:06:49 -070037
Alexander Afanasyev4086d512014-07-11 15:56:33 -070038#include <QtQml/QQmlContext>
39
Yingdi Yu1f824642016-03-20 17:07:22 -070040#include "key-viewer-dialog.hpp"
41
taylorchuc27dd482014-05-17 20:06:49 -070042namespace ndn {
43
Alexander Afanasyev81509f32016-03-21 17:02:38 -070044class Face;
45
taylorchuc27dd482014-05-17 20:06:49 -070046class TrayMenu : public QWidget
47{
48 Q_OBJECT
49
50signals:
51 void
52 showApp();
53
54 void
55 nfdActivityUpdate(bool isActive);
56
57public:
Alexander Afanasyev4086d512014-07-11 15:56:33 -070058 explicit
Alexander Afanasyev81509f32016-03-21 17:02:38 -070059 TrayMenu(QQmlContext* context, Face& face);
taylorchuc27dd482014-05-17 20:06:49 -070060
61 ~TrayMenu();
62
Qi Zhao86f2b212016-12-06 12:44:16 -080063 Q_INVOKABLE bool
64 isAutoConfigEnabled();
taylorchuc27dd482014-05-17 20:06:49 -070065
66 Q_INVOKABLE void
Qi Zhao86f2b212016-12-06 12:44:16 -080067 startStopAutoConfig(bool autoConfig);
68
69 Q_INVOKABLE void
70 startStopNfd(bool autoConfig);
taylorchuc27dd482014-05-17 20:06:49 -070071
susmit4fe3cb92016-03-20 17:08:41 -070072 Q_INVOKABLE void
73 addDeleteRoute();
74
75 Q_INVOKABLE void
76 addRoute();
77
78 Q_INVOKABLE void
79 deleteRoute();
80
taylorchuc27dd482014-05-17 20:06:49 -070081private slots:
82
83 void
84 quitApp();
85
86 void
87 iconActivated(QSystemTrayIcon::ActivationReason reason);
88
89 void
Qi Zhao86f2b212016-12-06 12:44:16 -080090 startAutoConfig();
91
92 void
93 stopAutoConfig();
94
95 void
taylorchuc27dd482014-05-17 20:06:49 -070096 startNfd();
97
98 void
99 stopNfd();
100
101 void
102 updateNfdActivityIcon(bool isActive);
103
Alexander Afanasyev11ae34d2016-03-21 11:55:16 -0700104 void
105 enableCli();
106
Qi Zhao86f2b212016-12-06 12:44:16 -0800107 void
108 processOutput();
109
110 void
111 showPref();
112
113 static void
114 appendMsg(QString &target, QString source);
115
taylorchuc27dd482014-05-17 20:06:49 -0700116private:
Alexander Afanasyev4086d512014-07-11 15:56:33 -0700117 QQmlContext* m_context;
118 bool m_isNfdRunning;
Yingdi Yu53c11c12016-03-20 12:56:49 -0700119 QSystemTrayIcon* m_tray;
120 QMenu* m_menu;
121 QAction* m_entryPref;
122 QAction* m_entrySec;
Qi Zhao86f2b212016-12-06 12:44:16 -0800123 QProcess* m_acProc;
124 QString m_autoConfigMsg;
125 QSettings m_settings;
Alexander Afanasyev11ae34d2016-03-21 11:55:16 -0700126#ifdef OSX_BUILD
127 QAction* m_entryEnableCli;
128#endif
129
Yingdi Yu53c11c12016-03-20 12:56:49 -0700130 QAction* m_entryQuit;
Yingdi Yu1f824642016-03-20 17:07:22 -0700131
132 ncc::KeyViewerDialog* m_keyViewerDialog;
Alexander Afanasyev81509f32016-03-21 17:02:38 -0700133 Face& m_face;
taylorchuc27dd482014-05-17 20:06:49 -0700134};
135
136} // namespace ndn
137
138#endif // NCC_TRAY_MENU_HPP