VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsPortForwardingDlg.cpp@ 104158

Last change on this file since 104158 was 100896, checked in by vboxsync, 18 months ago

FE/Qt: bugref:10506: Suitable HiDPI icon sets for all dialogs using QWidget::setWindowIcon.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1/* $Id: UIMachineSettingsPortForwardingDlg.cpp 100896 2023-08-17 12:18:19Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMachineSettingsPortForwardingDlg class implementation.
4 */
5
6/*
7 * Copyright (C) 2010-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QVBoxLayout>
30#include <QPushButton>
31
32/* GUI includes: */
33#include "UIDesktopWidgetWatchdog.h"
34#include "UIMachineSettingsPortForwardingDlg.h"
35#include "UIIconPool.h"
36#include "UIMessageCenter.h"
37#include "QIDialogButtonBox.h"
38
39
40UIMachineSettingsPortForwardingDlg::UIMachineSettingsPortForwardingDlg(QWidget *pParent,
41 const UIPortForwardingDataList &rules)
42 : QIWithRetranslateUI<QIDialog>(pParent)
43 , m_pTable(0)
44 , m_pButtonBox(0)
45{
46#ifndef VBOX_WS_MAC
47 /* Assign window icon: */
48 setWindowIcon(UIIconPool::iconSetFull(":/nw_32px.png", ":/nw_16px.png"));
49#endif
50
51 /* Create layout: */
52 QVBoxLayout *pMainLayout = new QVBoxLayout(this);
53 {
54 /* Create table: */
55 m_pTable = new UIPortForwardingTable(rules, false, true);
56 {
57 /* Configure table: */
58 m_pTable->layout()->setContentsMargins(0, 0, 0, 0);
59 }
60 /* Create button-box: */
61 m_pButtonBox = new QIDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal);
62 {
63 /* Configure button-box: */
64 connect(m_pButtonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked,
65 this, &UIMachineSettingsPortForwardingDlg::accept);
66 connect(m_pButtonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
67 this, &UIMachineSettingsPortForwardingDlg::reject);
68 }
69 /* Add widgets into layout: */
70 pMainLayout->addWidget(m_pTable);
71 pMainLayout->addWidget(m_pButtonBox);
72 }
73
74 /* Retranslate dialog: */
75 retranslateUi();
76
77 /* Limit the minimum size to 33% of screen size: */
78 setMinimumSize(gpDesktop->screenGeometry(this).size() / 3);
79}
80
81const UIPortForwardingDataList UIMachineSettingsPortForwardingDlg::rules() const
82{
83 return m_pTable->rules();
84}
85
86void UIMachineSettingsPortForwardingDlg::accept()
87{
88 /* Make sure table has own data committed: */
89 m_pTable->makeSureEditorDataCommitted();
90 /* Validate table: */
91 bool fPassed = m_pTable->validate();
92 if (!fPassed)
93 return;
94 /* Call to base-class: */
95 QIWithRetranslateUI<QIDialog>::accept();
96}
97
98void UIMachineSettingsPortForwardingDlg::reject()
99{
100 /* Ask user to discard table changes if necessary: */
101 if ( m_pTable->isChanged()
102 && !msgCenter().confirmCancelingPortForwardingDialog(window()))
103 return;
104 /* Call to base-class: */
105 QIWithRetranslateUI<QIDialog>::reject();
106}
107
108void UIMachineSettingsPortForwardingDlg::retranslateUi()
109{
110 /* Set window title: */
111 setWindowTitle(tr("Port Forwarding Rules"));
112}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette