generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwindow.cpp
95 lines (80 loc) · 3.03 KB
/
window.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
Copyright 2022 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "window.h"
#include "paths.h"
#include "fonts.h"
#include "constants.h"
#include "serviceview.h"
#ifndef QT_NO_SYSTEMTRAYICON
#include <QCloseEvent>
#include <QDialogButtonBox>
#include <QMessageBox>
#include <QStandardPaths>
#ifndef QT_NO_TERMWIDGET
#include "qtermwidget.h"
#include <QApplication>
#include <QMainWindow>
#endif
const QVersionNumber version = QVersionNumber::fromString("0.4.0");
Window::Window()
{
trayIconIcon = new QIcon(":/resources/images/minikube.png");
Fonts::initFonts();
stackedWidget = new QStackedWidget;
logger = new Logger();
settings = new Settings();
commandRunner = new CommandRunner(this, logger, settings);
basicView = new BasicView(*trayIconIcon, version);
serviceView = new ServiceView(this, *trayIconIcon, commandRunner, settings);
addonsView = new AddonsView(*trayIconIcon);
advancedView = new AdvancedView(*trayIconIcon);
errorMessage = new ErrorMessage(this, *trayIconIcon);
progressWindow = new ProgressWindow(this, *trayIconIcon);
tray = new Tray(*trayIconIcon);
hyperKit = new HyperKit(*trayIconIcon);
updater = new Updater(this, version, *trayIconIcon);
op = new Operator(advancedView, basicView, serviceView, addonsView, commandRunner, errorMessage,
progressWindow, tray, hyperKit, updater, settings, stackedWidget, this);
stackedWidget->addWidget(basicView->basicView);
stackedWidget->addWidget(advancedView->advancedView);
layout = new QVBoxLayout;
layout->addWidget(stackedWidget);
setLayout(layout);
resize(Constants::basicViewWidth, Constants::basicViewHeight);
setWindowTitle("minikube");
setWindowIcon(*trayIconIcon);
}
void Window::setVisible(bool visible)
{
tray->setVisible(visible);
QDialog::setVisible(visible);
}
void Window::closeEvent(QCloseEvent *event)
{
#if __APPLE__
if (!event->spontaneous() || !isVisible()) {
return;
}
#endif
bool skipWarning = settings->getSettings().skipWarningOnClose();
if (QSystemTrayIcon::isSystemTrayAvailable() && tray->isVisible() && !skipWarning) {
QMessageBox::information(this, "minikube",
tr("minikube will minimize to the "
"system tray. To terminate the program, "
"choose <b>Quit</b> in the context menu "
"of the system tray entry."));
hide();
event->ignore();
}
}
#endif