UIWarningPane.cpp revision b40b3662dc06fdc995315e89ecef4a9d7098fbd8
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync * VBox frontends: Qt4 GUI ("VirtualBox"):
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync * UIWarningPane class implementation
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync * Copyright (C) 2009-2013 Oracle Corporation
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync * available from http://www.virtualbox.org. This file is free software;
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync * you can redistribute it and/or modify it under the terms of the GNU
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync * General Public License (GPL) as published by the Free Software
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync/* Qt includes: */
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync/* GUI includes: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync/* Other VBox includes: */
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync /* Prepare: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsyncvoid UIWarningPane::setWarningLabel(const QString &strWarningLabel)
b885f23e839880e918ddbcd8c135b7023d97ba09vboxsync /* Assign passed text directly to warning-label: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsyncvoid UIWarningPane::registerValidator(UIPageValidator *pValidator)
b885f23e839880e918ddbcd8c135b7023d97ba09vboxsync /* Make sure validator exists: */
b885f23e839880e918ddbcd8c135b7023d97ba09vboxsync /* Make sure validator is not registered yet: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync AssertMsgFailed(("Validator is registered already!\n"));
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Register validator: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Create icon-label for newly registered validator: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Add icon-label into list: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Add icon-label into layout: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Configure icon-label: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync pIconLabel->setPixmap(pValidator->warningPixmap());
d67a5f90076d3e208810415abb792f5c42081c97vboxsync connect(pValidator, SIGNAL(sigShowWarningIcon()), pIconLabel, SLOT(show()));
d67a5f90076d3e208810415abb792f5c42081c97vboxsync connect(pValidator, SIGNAL(sigHideWarningIcon()), pIconLabel, SLOT(hide()));
b885f23e839880e918ddbcd8c135b7023d97ba09vboxsync /* Mark icon as 'unhovered': */
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync /* Prepare content: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Create main-layout: */
235d3bea31bdca1dd7f555821eacfd0dd36bd6f5vboxsync /* Configure layout: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Add left stretch: */
b885f23e839880e918ddbcd8c135b7023d97ba09vboxsync /* Create text-label: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Add into main-layout: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Create layout: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Configure layout: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Add into main-layout: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Add right stretch: */
1548538a86bdf3de84605db9c0ae03e000a55c6fvboxsyncbool UIWarningPane::eventFilter(QObject *pWatched, QEvent *pEvent)
1548538a86bdf3de84605db9c0ae03e000a55c6fvboxsync /* Depending on event-type: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* One of icons hovered: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Cast object to label: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync if (QLabel *pIconLabel = qobject_cast<QLabel*>(pWatched))
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Search for the corresponding icon: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Mark icon-label hovered if not yet: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync int iIconLabelPosition = m_icons.indexOf(pIconLabel);
d67a5f90076d3e208810415abb792f5c42081c97vboxsync emit sigHoverEnter(m_validators[iIconLabelPosition]);
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* One of icons unhovered: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Cast object to label: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync if (QLabel *pIconLabel = qobject_cast<QLabel*>(pWatched))
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Search for the corresponding icon: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync /* Mark icon-label unhovered if not yet: */
d67a5f90076d3e208810415abb792f5c42081c97vboxsync int iIconLabelPosition = m_icons.indexOf(pIconLabel);
d67a5f90076d3e208810415abb792f5c42081c97vboxsync emit sigHoverLeave(m_validators[iIconLabelPosition]);
1548538a86bdf3de84605db9c0ae03e000a55c6fvboxsync /* Default case: */
1548538a86bdf3de84605db9c0ae03e000a55c6fvboxsync default: break;
1548538a86bdf3de84605db9c0ae03e000a55c6fvboxsync /* Call to base-class: */