VBoxProgressDialog.h revision e014c798932e7f4d57bca099271c938da5eddfd9
79cb65616bd94eb1616b17f8a75ac5e973469e56Matthias Tristl/** @file
4b3769ce483ece06f60f983193712492b920144fJake Feasel *
4b3769ce483ece06f60f983193712492b920144fJake Feasel * VBox frontends: Qt4 GUI ("VirtualBox"):
4b3769ce483ece06f60f983193712492b920144fJake Feasel * VBoxProgressDialog class declaration
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel */
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel/*
4b3769ce483ece06f60f983193712492b920144fJake Feasel * Copyright (C) 2009 Sun Microsystems, Inc.
4b3769ce483ece06f60f983193712492b920144fJake Feasel *
4b3769ce483ece06f60f983193712492b920144fJake Feasel * This file is part of VirtualBox Open Source Edition (OSE), as
4b3769ce483ece06f60f983193712492b920144fJake Feasel * available from http://www.virtualbox.org. This file is free software;
4b3769ce483ece06f60f983193712492b920144fJake Feasel * you can redistribute it and/or modify it under the terms of the GNU
4b3769ce483ece06f60f983193712492b920144fJake Feasel * General Public License (GPL) as published by the Free Software
4b3769ce483ece06f60f983193712492b920144fJake Feasel * Foundation, in version 2 as it comes in the "COPYING" file of the
4b3769ce483ece06f60f983193712492b920144fJake Feasel * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
4b3769ce483ece06f60f983193712492b920144fJake Feasel * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4b3769ce483ece06f60f983193712492b920144fJake Feasel *
4b3769ce483ece06f60f983193712492b920144fJake Feasel * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
4b3769ce483ece06f60f983193712492b920144fJake Feasel * Clara, CA 95054 USA or visit http://www.sun.com if you need
4b3769ce483ece06f60f983193712492b920144fJake Feasel * additional information or have any questions.
4b3769ce483ece06f60f983193712492b920144fJake Feasel */
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel#ifndef __VBoxProgressDialog_h__
4b3769ce483ece06f60f983193712492b920144fJake Feasel#define __VBoxProgressDialog_h__
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel/* Qt includes */
185941104719f48494a107996e17a23aad237c7dJon Branch#include "QIDialog.h"
185941104719f48494a107996e17a23aad237c7dJon Branch
185941104719f48494a107996e17a23aad237c7dJon Branch/* VBox forward declarations */
185941104719f48494a107996e17a23aad237c7dJon Branchclass CProgress;
4b3769ce483ece06f60f983193712492b920144fJake Feaselclass QILabel;
4b3769ce483ece06f60f983193712492b920144fJake Feaselclass VBoxMiniCancelButton;
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel/* Qt forward declarations */
4b3769ce483ece06f60f983193712492b920144fJake Feaselclass QProgressBar;
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel/**
4b3769ce483ece06f60f983193712492b920144fJake Feasel * A QProgressDialog enhancement that allows to:
4b3769ce483ece06f60f983193712492b920144fJake Feasel *
4b3769ce483ece06f60f983193712492b920144fJake Feasel * 1) prevent closing the dialog when it has no cancel button;
4b3769ce483ece06f60f983193712492b920144fJake Feasel * 2) effectively track the IProgress object completion (w/o using
4b3769ce483ece06f60f983193712492b920144fJake Feasel * IProgress::waitForCompletion() and w/o blocking the UI thread in any other
4b3769ce483ece06f60f983193712492b920144fJake Feasel * way for too long).
4b3769ce483ece06f60f983193712492b920144fJake Feasel *
4b3769ce483ece06f60f983193712492b920144fJake Feasel * @note The CProgress instance is passed as a non-const reference to the
4b3769ce483ece06f60f983193712492b920144fJake Feasel * constructor (to memorize COM errors if they happen), and therefore must
4b3769ce483ece06f60f983193712492b920144fJake Feasel * not be destroyed before the created VBoxProgressDialog instance is
4b3769ce483ece06f60f983193712492b920144fJake Feasel * destroyed.
4b3769ce483ece06f60f983193712492b920144fJake Feasel */
4b3769ce483ece06f60f983193712492b920144fJake Feaselclass VBoxProgressDialog: protected QIDialog
4b3769ce483ece06f60f983193712492b920144fJake Feasel{
4b3769ce483ece06f60f983193712492b920144fJake Feasel Q_OBJECT;
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feaselpublic:
4b3769ce483ece06f60f983193712492b920144fJake Feasel VBoxProgressDialog (CProgress &aProgress, const QString &aTitle,
4b3769ce483ece06f60f983193712492b920144fJake Feasel int aMinDuration = 2000, QWidget *aParent = 0);
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel int run (int aRefreshInterval);
4b3769ce483ece06f60f983193712492b920144fJake Feasel bool cancelEnabled() const { return mCancelEnabled; }
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feaselprotected:
4b3769ce483ece06f60f983193712492b920144fJake Feasel virtual void retranslateUi();
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel virtual void reject();
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel virtual void timerEvent (QTimerEvent *aEvent);
4b3769ce483ece06f60f983193712492b920144fJake Feasel virtual void closeEvent (QCloseEvent *aEvent);
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feaselprivate slots:
4b3769ce483ece06f60f983193712492b920144fJake Feasel void showDialog();
7d83b6a03bd7b63f2eb6404d6cc1e4c074391ea7Jake Feasel void cancelOperation();
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feaselprivate:
4b3769ce483ece06f60f983193712492b920144fJake Feasel /* Private member vars */
39d358fb2513d1778bf553a72f93aa46b3e417fcJake Feasel CProgress &mProgress;
4b3769ce483ece06f60f983193712492b920144fJake Feasel QILabel *mLabel;
185941104719f48494a107996e17a23aad237c7dJon Branch QILabel *mETA;
185941104719f48494a107996e17a23aad237c7dJon Branch QString mCancelText;
185941104719f48494a107996e17a23aad237c7dJon Branch QProgressBar *mProgressBar;
185941104719f48494a107996e17a23aad237c7dJon Branch VBoxMiniCancelButton *mCancelBtn;
185941104719f48494a107996e17a23aad237c7dJon Branch bool mCancelEnabled;
185941104719f48494a107996e17a23aad237c7dJon Branch const ulong mOpCount;
185941104719f48494a107996e17a23aad237c7dJon Branch ulong mCurOp;
185941104719f48494a107996e17a23aad237c7dJon Branch bool mEnded;
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel static const char *sOpDescTpl;
4b3769ce483ece06f60f983193712492b920144fJake Feasel};
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel#endif /* __VBoxProgressDialog_h__ */
4b3769ce483ece06f60f983193712492b920144fJake Feasel
4b3769ce483ece06f60f983193712492b920144fJake Feasel