|
|
@ -4,56 +4,161 @@ |
|
|
|
#include "UBUpdateDlg.h" |
|
|
|
#include "UBUpdateDlg.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "core/memcheck.h" |
|
|
|
#include "core/memcheck.h" |
|
|
|
|
|
|
|
#include <../Trolltech/Qt-4.7.0/include/QtWebKit/qwebpage.h> |
|
|
|
|
|
|
|
|
|
|
|
UBUpdateDlg::UBUpdateDlg(QWidget *parent, int nbFiles, const QString& bkpPath) |
|
|
|
UBUpdateDlg::UBUpdateDlg(QWidget *parent, int nbFiles, const QString& bkpPath) |
|
|
|
: QDialog(parent) |
|
|
|
: QDialog(parent) |
|
|
|
, mpDlgBttn(NULL) |
|
|
|
, mMainLayout(NULL) |
|
|
|
|
|
|
|
, mNbFilesLabel(NULL) |
|
|
|
|
|
|
|
, mBkpLabel(NULL) |
|
|
|
|
|
|
|
, mBkpPath(NULL) |
|
|
|
|
|
|
|
, mBrowseBttn(NULL) |
|
|
|
|
|
|
|
, mpDlgBttn(NULL) |
|
|
|
|
|
|
|
, mLayout(NULL) |
|
|
|
|
|
|
|
, mHLayout(NULL) |
|
|
|
|
|
|
|
, mStackedWidget(NULL) |
|
|
|
|
|
|
|
, mDialogWidget(NULL) |
|
|
|
|
|
|
|
, mProgressWidget(NULL) |
|
|
|
|
|
|
|
, mProgressLayout(NULL) |
|
|
|
|
|
|
|
, mProgressLabel(NULL) |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
setFixedSize(400, 110); |
|
|
|
mDialogWidget = new QWidget(this); |
|
|
|
|
|
|
|
mProgressWidget = new QWidget(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mStackedWidget = new QStackedWidget(this); |
|
|
|
|
|
|
|
mStackedWidget->addWidget(mDialogWidget); |
|
|
|
|
|
|
|
mStackedWidget->addWidget(mProgressWidget); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setFixedSize(450, 110); |
|
|
|
setModal(true); |
|
|
|
setModal(true); |
|
|
|
setWindowTitle(tr("Document updater")); |
|
|
|
setWindowTitle(tr("Document updater")); |
|
|
|
setLayout(&mLayout); |
|
|
|
mLayout = new QVBoxLayout(); |
|
|
|
|
|
|
|
setLayout(mLayout); |
|
|
|
|
|
|
|
|
|
|
|
QString str = QString::number(nbFiles); |
|
|
|
QString str = QString::number(nbFiles); |
|
|
|
str.append(tr(" files require an update.")); |
|
|
|
str.append(tr(" files require an update.")); |
|
|
|
mNbFilesLabel.setText(str); |
|
|
|
mNbFilesLabel = new QLabel(mDialogWidget); |
|
|
|
mLayout.addWidget(&mNbFilesLabel); |
|
|
|
mNbFilesLabel->setText(str); |
|
|
|
mBkpLabel.setText(tr("Backup path: ")); |
|
|
|
|
|
|
|
mBkpPath.setText(bkpPath); |
|
|
|
mLayout->addWidget(mNbFilesLabel); |
|
|
|
mBrowseBttn.setText(tr("Browse")); |
|
|
|
|
|
|
|
mHLayout.addWidget(&mBkpLabel); |
|
|
|
mBkpLabel = new QLabel(mDialogWidget); |
|
|
|
mHLayout.addWidget(&mBkpPath, 1); |
|
|
|
mBkpLabel->setText(tr("Backup path: ")); |
|
|
|
mHLayout.addWidget(&mBrowseBttn); |
|
|
|
|
|
|
|
mLayout.addLayout(&mHLayout); |
|
|
|
mBkpPath = new QLineEdit(mDialogWidget); |
|
|
|
|
|
|
|
mBkpPath->setText(bkpPath); |
|
|
|
mpDlgBttn = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); |
|
|
|
|
|
|
|
mLayout.addWidget(mpDlgBttn); |
|
|
|
mBrowseBttn = new QPushButton(mDialogWidget); |
|
|
|
|
|
|
|
mBrowseBttn->setText(tr("Browse")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mHLayout = new QHBoxLayout(); |
|
|
|
|
|
|
|
mHLayout->addWidget(mBkpLabel); |
|
|
|
|
|
|
|
mHLayout->addWidget(mBkpPath, 1); |
|
|
|
|
|
|
|
mHLayout->addWidget(mBrowseBttn); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mLayout->addLayout(mHLayout); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mpDlgBttn = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, mDialogWidget); |
|
|
|
|
|
|
|
mLayout->addWidget(mpDlgBttn); |
|
|
|
|
|
|
|
|
|
|
|
mpDlgBttn->button(QDialogButtonBox::Ok)->setText(tr("Update")); |
|
|
|
mpDlgBttn->button(QDialogButtonBox::Ok)->setText(tr("Update")); |
|
|
|
mpDlgBttn->button(QDialogButtonBox::Cancel)->setText("Remind me later"); |
|
|
|
mpDlgBttn->button(QDialogButtonBox::Cancel)->setText("Remind me later"); |
|
|
|
|
|
|
|
|
|
|
|
QObject::connect(&mBrowseBttn, SIGNAL(clicked()), this, SLOT(onBrowse())); |
|
|
|
QObject::connect(mBrowseBttn, SIGNAL(clicked()), this, SLOT(onBrowse())); |
|
|
|
QObject::connect(mpDlgBttn, SIGNAL(accepted()), this, SLOT(onUpdate())); |
|
|
|
QObject::connect(mpDlgBttn, SIGNAL(accepted()), this, SLOT(onUpdate())); |
|
|
|
QObject::connect(mpDlgBttn, SIGNAL(rejected()), this, SLOT(reject())); |
|
|
|
QObject::connect(mpDlgBttn, SIGNAL(rejected()), this, SLOT(reject())); |
|
|
|
|
|
|
|
mDialogWidget->setLayout(mLayout); |
|
|
|
|
|
|
|
mStackedWidget->setCurrentWidget(mDialogWidget); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mMainLayout = new QVBoxLayout(); |
|
|
|
|
|
|
|
this->setLayout(mMainLayout); |
|
|
|
|
|
|
|
mMainLayout->addWidget(mStackedWidget); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBUpdateDlg::~UBUpdateDlg() |
|
|
|
UBUpdateDlg::~UBUpdateDlg() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(NULL != mpDlgBttn) |
|
|
|
if (NULL != mpDlgBttn) |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete mpDlgBttn; |
|
|
|
delete mpDlgBttn; |
|
|
|
mpDlgBttn = NULL; |
|
|
|
mpDlgBttn = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mNbFilesLabel) { |
|
|
|
|
|
|
|
delete mNbFilesLabel; |
|
|
|
|
|
|
|
mNbFilesLabel = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mBkpLabel) { |
|
|
|
|
|
|
|
delete mBkpLabel; |
|
|
|
|
|
|
|
mBkpLabel = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mBkpPath) { |
|
|
|
|
|
|
|
delete mBkpPath; |
|
|
|
|
|
|
|
mBkpPath = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mBrowseBttn) { |
|
|
|
|
|
|
|
delete mBrowseBttn; |
|
|
|
|
|
|
|
mBrowseBttn = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mProgressLabel) { |
|
|
|
|
|
|
|
delete mProgressLabel; |
|
|
|
|
|
|
|
mProgressLabel = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mHLayout) { |
|
|
|
|
|
|
|
delete mHLayout; |
|
|
|
|
|
|
|
mHLayout = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mLayout) { |
|
|
|
|
|
|
|
delete mLayout; |
|
|
|
|
|
|
|
mLayout = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mProgressLayout) { |
|
|
|
|
|
|
|
delete mProgressLayout; |
|
|
|
|
|
|
|
mProgressLayout = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mDialogWidget) { |
|
|
|
|
|
|
|
delete mDialogWidget; |
|
|
|
|
|
|
|
mDialogWidget = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mProgressWidget) { |
|
|
|
|
|
|
|
delete mProgressWidget; |
|
|
|
|
|
|
|
mProgressWidget = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mStackedWidget) { |
|
|
|
|
|
|
|
delete mStackedWidget; |
|
|
|
|
|
|
|
mStackedWidget = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mMainLayout) { |
|
|
|
|
|
|
|
delete mMainLayout; |
|
|
|
|
|
|
|
mMainLayout = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBUpdateDlg::onBrowse() |
|
|
|
void UBUpdateDlg::onBrowse() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString qsSelectedDir; |
|
|
|
QString qsSelectedDir; |
|
|
|
qsSelectedDir = QFileDialog::getExistingDirectory(this, tr("Select a backup folder"), mBkpPath.text()); |
|
|
|
qsSelectedDir = QFileDialog::getExistingDirectory(this, tr("Select a backup folder"), mBkpPath->text()); |
|
|
|
mBkpPath.setText(qsSelectedDir); |
|
|
|
mBkpPath->setText(qsSelectedDir); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBUpdateDlg::onUpdate() |
|
|
|
void UBUpdateDlg::onUpdate() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
mProgressLabel = new QLabel(mProgressWidget); |
|
|
|
|
|
|
|
mProgressLayout = new QHBoxLayout(); |
|
|
|
|
|
|
|
mProgressLayout->addWidget(mProgressLabel); |
|
|
|
|
|
|
|
mProgressWidget->setLayout(mProgressLayout); |
|
|
|
|
|
|
|
mStackedWidget->setCurrentWidget(mProgressWidget); |
|
|
|
emit updateFiles(); |
|
|
|
emit updateFiles(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -61,7 +166,7 @@ void UBUpdateDlg::onFilesUpdated(bool bResult) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString qsMsg; |
|
|
|
QString qsMsg; |
|
|
|
|
|
|
|
|
|
|
|
if(bResult) |
|
|
|
if (bResult) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qsMsg = tr("Files update successful!\nPlease reboot the application to access the updated documents."); |
|
|
|
qsMsg = tr("Files update successful!\nPlease reboot the application to access the updated documents."); |
|
|
|
} |
|
|
|
} |
|
|
@ -74,5 +179,11 @@ void UBUpdateDlg::onFilesUpdated(bool bResult) |
|
|
|
|
|
|
|
|
|
|
|
QString UBUpdateDlg::backupPath() |
|
|
|
QString UBUpdateDlg::backupPath() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return mBkpPath.text(); |
|
|
|
return mBkpPath->text(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBUpdateDlg::transitioningFile(QString fileName) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mProgressLabel->setText(tr("Updating file ") + fileName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|