23 #include "ip2cupdatebox.h"
24 #include "ui_ip2cupdatebox.h"
26 #include "doomseekerfilepaths.h"
27 #include "gui/commongui.h"
29 #include "ip2c/ip2cupdater.h"
32 #include <QPushButton>
34 DClass<IP2CUpdateBox> :
public Ui::IP2CUpdateBox
37 QPushButton *btnCancel;
38 QPushButton *btnClose;
39 QPushButton *btnUpdate;
50 d->btnUpdate = d->buttonBox->button(QDialogButtonBox::Ok);
51 d->btnCancel = d->buttonBox->button(QDialogButtonBox::Cancel);
52 d->btnClose = d->buttonBox->button(QDialogButtonBox::Close);
56 this->connect(d->ip2cUpdater, SIGNAL(updateNeeded(
int)), SLOT(updateInfo(
int)));
62 IP2CUpdateBox::~IP2CUpdateBox()
66 void IP2CUpdateBox::start()
70 d->lblIP2CFileLocation->setText(!filePath.isEmpty() ? filePath : tr(
"N/A"));
73 d->lblIP2CDownloadLocation->setText(downloadPath);
74 QFileInfo downloadedFileInfo(downloadPath);
75 d->lblDownloadIcon->setPixmap(downloadedFileInfo.isFile() ?
76 QPixmap(
":/icons/edit-redo.png") :
77 QPixmap(
":/icons/edit-redo-red.png"));
78 d->lblDownloadIcon->setToolTip(downloadedFileInfo.isFile() ?
79 tr(
"File is already downloaded.") :
80 tr(
"File doesn't exist yet or location doesn't point to a file."));
82 QFileInfo fileInfo(filePath);
83 if (!filePath.isEmpty() && fileInfo.exists())
85 d->lblFileIcon->setPixmap(QPixmap(
":/icons/edit-redo.png"));
86 d->lblDatabaseStatus->setText(tr(
"Verifying checksum ..."));
87 d->updateInfoPanel->hide();
89 d->ip2cUpdater->needsUpdate(filePath);
93 d->lblFileIcon->setPixmap(QPixmap(
":/icons/edit-redo-red.png"));
94 d->lblDatabaseStatus->setText(tr(
"The IP2C database file was not found. "
95 "Use the \"Download\" button if you want to download the newest database."));
96 d->btnUpdate->setText(tr(
"Download"));
97 d->progressBar->hide();
101 void IP2CUpdateBox::updateInfo(
int status)
103 bool canUpdate =
true;
104 d->progressBar->hide();
107 case IP2CUpdater::UpdateNeeded:
108 d->lblStatusIcon->setPixmap(QPixmap(
":/icons/edit-redo-red.png"));
109 d->lblDatabaseStatus->setText(tr(
"Update available."));
111 case IP2CUpdater::UpToDate:
112 d->lblStatusIcon->setPixmap(QPixmap(
":/icons/edit-redo.png"));
113 d->lblDatabaseStatus->setText(tr(
"Database is up-to-date."));
116 case IP2CUpdater::UpdateCheckError:
117 d->lblStatusIcon->setPixmap(QPixmap(
":/icons/x.png"));
118 d->lblDatabaseStatus->setText(tr(
"Database status check failed. See the log for details."));
121 d->lblStatusIcon->setPixmap(QPixmap(
":/icons/x.png"));
122 d->lblDatabaseStatus->setText(tr(
"Unhandled update check status."));
125 d->updateInfoPanel->setVisible(canUpdate);
126 d->btnUpdate->setVisible(canUpdate);
127 d->btnUpdate->setText(tr(
"Update"));
128 d->btnCancel->setVisible(canUpdate);
129 d->btnClose->setVisible(!canUpdate);
130 (canUpdate ? d->btnUpdate : d->btnClose)->setFocus();