VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsPageValidator.cpp@ 103977

Last change on this file since 103977 was 103538, checked in by vboxsync, 10 months ago

FE/Qt: Moving out logging stuff from UIDefs.h to separate UILoggingDefs.h; This breaks dependency of UIDefs/UICommon headers from VBox/log.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/* $Id: UISettingsPageValidator.cpp 103538 2024-02-22 17:06:26Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: UISettingsPageValidator class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-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/* GUI includes: */
29#include "UILoggingDefs.h"
30#include "UISettingsPage.h"
31#include "UISettingsPageValidator.h"
32
33
34UISettingsPageValidator::UISettingsPageValidator(QObject *pParent, UISettingsPage *pPage)
35 : QObject(pParent)
36 , m_pPage(pPage)
37 , m_fIsValid(true)
38{
39}
40
41QPixmap UISettingsPageValidator::warningPixmap() const
42{
43 return m_pPage->warningPixmap();
44}
45
46QString UISettingsPageValidator::internalName() const
47{
48 return m_pPage->internalName();
49}
50
51void UISettingsPageValidator::setTitlePrefix(const QString &strPrefix)
52{
53 /* Assign new prefix: */
54 m_strPrefix = strPrefix;
55
56 /* Revalidate if we had errors previously: */
57 if (!lastMessage().isEmpty())
58 revalidate();
59}
60
61void UISettingsPageValidator::setLastMessage(const QString &strLastMessage)
62{
63 /* Remember new message: */
64 m_strLastMessage = strLastMessage;
65
66 /* Should we show corresponding warning icon? */
67 if (m_strLastMessage.isEmpty())
68 emit sigHideWarningIcon();
69 else
70 emit sigShowWarningIcon();
71}
72
73void UISettingsPageValidator::invalidate()
74{
75 /* Notify listener(s) about validity change: */
76 emit sigValidityChanged(this);
77}
78
79void UISettingsPageValidator::revalidate()
80{
81 /* Perform page revalidation: */
82 QList<UIValidationMessage> messages;
83 setValid(m_pPage->validate(messages));
84
85 /* Remember warning/error message: */
86 if (messages.isEmpty())
87 setLastMessage(QString());
88 else
89 {
90 /* Prepare text: */
91 QStringList text;
92 foreach (const UIValidationMessage &message, messages)
93 {
94 /* Prepare title: */
95 const QString strTitle(message.first.isNull() ? tr("<b>%1</b> page:").arg(m_strPrefix) :
96 tr("<b>%1: %2</b> page:").arg(m_strPrefix, message.first));
97
98 /* Prepare paragraph: */
99 QStringList paragraph(message.second);
100 paragraph.prepend(strTitle);
101
102 /* Format text for iterated message: */
103 text << paragraph.join("<br>");
104 }
105
106 /* Remember text: */
107 setLastMessage(text.join("<br><br>"));
108 LogRelFlow(("Settings Dialog: Page validation FAILED: {%s}\n",
109 lastMessage().toUtf8().constData()));
110 }
111}
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