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
96
97
98
99
100
|
/* $Id$ */
/** @file
* VBox Qt GUI - UIMachineSettingsPortForwardingDlg class implementation.
*/
/*
* Copyright (C) 2010-2022 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/* Qt includes: */
#include <QVBoxLayout>
#include <QPushButton>
/* GUI includes: */
#include "UIDesktopWidgetWatchdog.h"
#include "UIMachineSettingsPortForwardingDlg.h"
#include "UIIconPool.h"
#include "UIMessageCenter.h"
#include "QIDialogButtonBox.h"
UIMachineSettingsPortForwardingDlg::UIMachineSettingsPortForwardingDlg(QWidget *pParent,
const UIPortForwardingDataList &rules)
: QIWithRetranslateUI<QIDialog>(pParent)
, m_pTable(0)
, m_pButtonBox(0)
{
/* Set dialog icon: */
setWindowIcon(UIIconPool::iconSetFull(":/nw_32px.png", ":/nw_16px.png"));
/* Create layout: */
QVBoxLayout *pMainLayout = new QVBoxLayout(this);
{
/* Create table: */
m_pTable = new UIPortForwardingTable(rules, false, true);
{
/* Configure table: */
m_pTable->layout()->setContentsMargins(0, 0, 0, 0);
}
/* Create button-box: */
m_pButtonBox = new QIDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal);
{
/* Configure button-box: */
connect(m_pButtonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked,
this, &UIMachineSettingsPortForwardingDlg::accept);
connect(m_pButtonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
this, &UIMachineSettingsPortForwardingDlg::reject);
}
/* Add widgets into layout: */
pMainLayout->addWidget(m_pTable);
pMainLayout->addWidget(m_pButtonBox);
}
/* Retranslate dialog: */
retranslateUi();
/* Limit the minimum size to 33% of screen size: */
setMinimumSize(gpDesktop->screenGeometry(this).size() / 3);
}
const UIPortForwardingDataList UIMachineSettingsPortForwardingDlg::rules() const
{
return m_pTable->rules();
}
void UIMachineSettingsPortForwardingDlg::accept()
{
/* Make sure table has own data committed: */
m_pTable->makeSureEditorDataCommitted();
/* Validate table: */
bool fPassed = m_pTable->validate();
if (!fPassed)
return;
/* Call to base-class: */
QIWithRetranslateUI<QIDialog>::accept();
}
void UIMachineSettingsPortForwardingDlg::reject()
{
/* Ask user to discard table changes if necessary: */
if ( m_pTable->isChanged()
&& !msgCenter().confirmCancelingPortForwardingDialog(window()))
return;
/* Call to base-class: */
QIWithRetranslateUI<QIDialog>::reject();
}
void UIMachineSettingsPortForwardingDlg::retranslateUi()
{
/* Set window title: */
setWindowTitle(tr("Port Forwarding Rules"));
}
|