QIMainDialog.cpp revision a9b62afc62b28da7a1a77f34259f8013892d9664
/* $Id$ */
/** @file
* VBox Qt GUI - VirtualBox Qt extensions: QIMainDialog class implementation.
*/
/*
* Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* 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.
*/
# include <precomp.h>
#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
# include "QIMainDialog.h"
# include "VBoxUtils.h"
# include "VBoxGlobal.h"
/* Qt includes */
# include <QProcess>
# include <QEventLoop>
# include <QApplication>
# include <QDir>
# include <QUrl>
# include <QMenu>
# include <QSizeGrip>
# include <QPushButton>
# include <QDialogButtonBox>
#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
, mPolished (false)
, mIsAutoCentering (true)
, mCenterWidget (aParent)
{
qApp->installEventFilter (this);
}
{
/* Check for the recursive run: */
/* Reset the result code: */
/* Tune some attributes: */
/* Create a local event-loop: */
mEventLoop = &eventLoop;
/* Show the window: */
show();
/* A guard to ourself for the case we destroy ourself: */
/* Start the event-loop: */
/* Check if dialog is still valid: */
mEventLoop = 0;
/* Prepare result: */
/* Restore old show-modal attribute: */
/* Return the final result: */
return res;
}
{
return mRescode;
}
{
{
}
delete mSizeGrip;
}
bool QIMainDialog::isSizeGripEnabled() const
{
return mSizeGrip;
}
{
}
{
return mDefaultButton;
}
{
}
{
/* Exit from the event loop if there is any and we are changing our state
* from visible to invisible. */
if (mEventLoop && !aVisible)
mEventLoop->exit();
}
{
{
{
/* Initially search for the default button. */
break;
}
default:
break;
}
}
{
/* Polishing border */
if (mPolished)
return;
mPolished = true;
/* Explicit widget centering relatively to it's centering
* widget if any or desktop if centering widget is missed. */
if (mIsAutoCentering)
}
{
/* Adjust the size-grip location for the current resize event */
if (mSizeGrip)
{
if (isRightToLeft())
else
}
}
{
/* Make sure that we only proceed if no
* popup or other modal widgets are open. */
if (qApp->activePopupWidget() ||
{
/* Call to base-class: */
}
/* Special handling for some keys: */
{
/* Special handling for Escape key: */
case Qt::Key_Escape:
{
{
reject();
return;
}
break;
}
#ifdef Q_WS_MAC
/* Special handling for Period key: */
case Qt::Key_Period:
{
{
reject();
return;
}
break;
}
#endif /* Q_WS_MAC */
case Qt::Key_Return:
{
{
{
return;
}
}
break;
}
/* Default handling for others: */
default: break;
}
/* Call to base-class: */
}
{
if (!isActiveWindow())
{
/* Auto-default button focus-in processor used to move the "default"
* button property into the currently focused button. */
{
{
if (mDefaultButton)
}
break;
}
/* Auto-default button focus-out processor used to remove the "default"
* button property from the previously focused button. */
{
{
if (mDefaultButton)
}
break;
}
default:
break;
}
}
{
/* Search for the first default button in the dialog. */
return button;
return NULL;
}
void QIMainDialog::accept()
{
}
void QIMainDialog::reject()
{
}
{
/* Set the final result */
/* Hide this window */
hide();
/* And close the window */
close();
}
{
}