VBoxSettingsDialog.cpp revision 40f695842c55df1cec4c816e5b40c1a436f02ed6
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* VBoxSettingsDialog class implementation
*/
/*
* Copyright (C) 2006-2008 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include "VBoxSettingsDialog.h"
#include "VBoxSettingsUtils.h"
#include "VBoxGlobal.h"
#include "VBoxProblemReporter.h"
#include "QIWidgetValidator.h"
#include "VBoxSettingsSelector.h"
#include "VBoxSettingsPage.h"
#include "VBoxToolBar.h"
#ifdef Q_WS_MAC
# include "VBoxUtils.h"
#endif /* Q_WS_MAC */
/* Qt includes */
#include <QPushButton>
#include <QStackedWidget>
#include <QTimer>
# define VBOX_GUI_WITH_TOOLBAR_SETTINGS
#endif /* MAC_LEOPARD_STYLE */
, mPolished (false)
, mValid (true)
, mSilent (true)
, mIconLabel (new VBoxWarnIconLabel (this))
, mWhatsThisTimer (new QTimer (this))
, mWhatsThisCandidate (0)
{
/* Apply UI decorations */
// setToolbar (new VBoxToolBar (this));
#ifdef Q_WS_MAC
// VBoxGlobal::setLayoutMargin (centralWidget()->layout(), 0);
/* No status bar on the mac */
setSizeGripEnabled (false);
setStatusBar (NULL);
#endif
/* Page title font is derived from the system font */
f.setBold (true);
mLbWhatsThis->hide();
mSelector = new VBoxSettingsToolBarSelector (this);
/* No title in this mode, we change the title of the window. */
mainLayout->setColumnMinimumWidth (0, 0);
#else
/* Create the classical tree view selector */
mSelector = new VBoxSettingsTreeViewSelector (this);
#endif
/* Creating stack of pages */
layout->setContentsMargins (0, 0, 0, 0);
/* Setup whatsthis stuff */
setWhatsThis (tr ("<i>Select a settings category from the list on the left-hand side and move the mouse over a settings item to get more information</i>."));
qApp->installEventFilter (this);
mWhatsThisTimer->setSingleShot (true);
mLbWhatsThis->setAutoFillBackground (true);
/* Setup error & warning stuff */
/* Set the default button */
/* Setup connections */
this, SLOT (categoryChanged (int)));
/* Applying language settings */
}
{
delete mSelector;
}
{
/* Perform validations for particular page */
}
{
#ifndef Q_WS_MAC
#else /* Q_WS_MAC */
/* First make all fully resizeable */
{
/* Switch to the new page first if we are shrinking */
/* Do the animation */
::darwinWindowAnimateResize (this, QRect (x(), y(),
/* Switch to the new page last if we are zooming */
/* Make the widget fixed size */
setFixedSize (ss);
}
::darwinSetShowsResizeIndicator (this, false);
#endif /* !Q_WS_MAC */
# ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS
# endif
}
void VBoxSettingsDialog::retranslateUi()
{
/* Translate uic generated strings */
if (!mValid)
else if (!mSilent)
/* Rename all validators to make them feat new language. */
/* Revalidate all pages to retranslate the warning messages also. */
revalidate (wval);
}
{
#else
return tr ("Settings");
#endif
}
{
/* Not touching QILabel until dialog is polished otherwise
* it can change its size to undefined */
if (!mPolished)
return;
if (!mErrorString.isEmpty())
else
updateWhatsThis (true);
}
{
/* Not touching QILabel until dialog is polished otherwise
* it can change its size to undefined */
if (!mPolished)
return;
if (!mWarnString.isEmpty())
else
updateWhatsThis (true);
}
const QString &aBigIconDisabled,
const QString &aSmallIcon,
const QString &aSmallIconDisabled,
int aId,
int aParentId /* = -1 */)
{
if (page)
if (aPrefPage)
}
{
return true;
}
{
/* Detect ERROR presence */
{
bool newValid = true;
{
if (!newValid)
{
break;
}
}
/* Try to set the generic error message when invalid
* but no specific message is provided */
#ifdef Q_WS_MAC
#endif /* Q_WS_MAC */
if (!mValid) return;
}
/* Detect WARNING presence */
{
bool newSilent = true;
{
{
newSilent = false;
if (wvalWarning.isNull())
break;
}
}
/* Try to set the generic error message when invalid
* but no specific message is provided */
#ifdef Q_WS_MAC
#endif /* Q_WS_MAC */
}
}
{
if (!aGotFocus)
{
if (mWhatsThisCandidate && mWhatsThisCandidate != this)
}
else
{
}
/* If the given widget lacks the whats'this text, look at its parent */
{
break;
}
#ifndef Q_WS_MAC
text = mErrorString;
text = mWarnString;
#else /* Q_WS_MAC */
#endif /* Q_WS_MAC */
}
{
if (mWhatsThisCandidate == aObj)
mWhatsThisCandidate = 0;
}
{
if (!aObject->isWidgetType())
{
{
{
/* What if Qt sends Enter w/o Leave... */
if (mWhatsThisCandidate)
/* Make sure we don't reference a deleted object after the
* timer is shot */
}
else
{
/* Cleanup */
if (mWhatsThisCandidate)
}
break;
}
{
updateWhatsThis (true /* aGotFocus */);
break;
}
default:
break;
}
}
{
/* One may think that QWidget::polish() is the right place to do things
* below, but apparently, by the time when QWidget::polish() is called,
* the widget style & layout are not fully done, at least the minimum
* size hint is not properly calculated. Since this is sometimes necessary,
* we provide our own "polish" implementation. */
if (mPolished)
return;
mPolished = true;
#ifdef Q_WS_MAC
/* Remove all title bar buttons (Buggy Qt) */
::darwinSetHidesAllTitleButtons (this);
/* Set all size policies to ignored */
/* Activate every single page to get the optimal size */
{
mStack->setCurrentIndex (i);
QSize s = minimumSize();
}
#else /* Q_WS_MAC */
/* Resize to the minimum possible size */
QSize s = minimumSize();
resize (s);
#endif /* Q_WS_MAC */
}
{
aPage, this);
return aPage;
}