Switched the method of how the Designer UI file is used in the AboutDialog class to "The Single Inheritance Approach" (with "Using a Pointer Member Variable"). This is the method which Qt recommends for large projects.
This commit is contained in:
parent
7c5ccbe417
commit
a812aa28fa
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "Dialog_About.h"
|
#include "Dialog_About.h"
|
||||||
|
|
||||||
|
#include "../tmp/UIC_AboutDialog.h"
|
||||||
|
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Resource.h"
|
#include "Resource.h"
|
||||||
#include "Model_Settings.h"
|
#include "Model_Settings.h"
|
||||||
@ -91,6 +93,7 @@ g_lamexp_translators[] =
|
|||||||
AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
|
AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
|
||||||
:
|
:
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
ui(new Ui::AboutDialog),
|
||||||
m_settings(settings),
|
m_settings(settings),
|
||||||
m_initFlags(new QMap<QWidget*,bool>),
|
m_initFlags(new QMap<QWidget*,bool>),
|
||||||
m_disque(NULL),
|
m_disque(NULL),
|
||||||
@ -100,7 +103,7 @@ AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstSta
|
|||||||
m_lastTab(0)
|
m_lastTab(0)
|
||||||
{
|
{
|
||||||
//Init the dialog, from the .ui file
|
//Init the dialog, from the .ui file
|
||||||
setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||||
resize(this->minimumSize());
|
resize(this->minimumSize());
|
||||||
|
|
||||||
@ -120,16 +123,16 @@ AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstSta
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Init tab widget
|
//Init tab widget
|
||||||
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
|
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
|
||||||
|
|
||||||
//Make transparent
|
//Make transparent
|
||||||
QStyle *style = qApp->style();
|
QStyle *style = qApp->style();
|
||||||
if((dynamic_cast<QWindowsVistaStyle*>(style)) || (dynamic_cast<QWindowsXPStyle*>(style)))
|
if((dynamic_cast<QWindowsVistaStyle*>(style)) || (dynamic_cast<QWindowsXPStyle*>(style)))
|
||||||
{
|
{
|
||||||
MAKE_TRANSPARENT(infoScrollArea);
|
MAKE_TRANSPARENT(ui->infoScrollArea);
|
||||||
MAKE_TRANSPARENT(contributorsScrollArea);
|
MAKE_TRANSPARENT(ui->contributorsScrollArea);
|
||||||
MAKE_TRANSPARENT(softwareScrollArea);
|
MAKE_TRANSPARENT(ui->softwareScrollArea);
|
||||||
MAKE_TRANSPARENT(licenseScrollArea);
|
MAKE_TRANSPARENT(ui->licenseScrollArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Show about dialog for the first time?
|
//Show about dialog for the first time?
|
||||||
@ -137,10 +140,10 @@ AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstSta
|
|||||||
{
|
{
|
||||||
lamexp_seed_rand();
|
lamexp_seed_rand();
|
||||||
|
|
||||||
acceptButton->hide();
|
ui->acceptButton->hide();
|
||||||
declineButton->hide();
|
ui->declineButton->hide();
|
||||||
aboutQtButton->show();
|
ui->aboutQtButton->show();
|
||||||
closeButton->show();
|
ui->closeButton->show();
|
||||||
|
|
||||||
QPixmap disque(":/images/Disque.png");
|
QPixmap disque(":/images/Disque.png");
|
||||||
QRect screenGeometry = QApplication::desktop()->availableGeometry();
|
QRect screenGeometry = QApplication::desktop()->availableGeometry();
|
||||||
@ -159,19 +162,19 @@ AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstSta
|
|||||||
m_disqueTimer->setInterval(10);
|
m_disqueTimer->setInterval(10);
|
||||||
m_disqueTimer->start();
|
m_disqueTimer->start();
|
||||||
|
|
||||||
connect(aboutQtButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
|
connect(ui->aboutQtButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
acceptButton->show();
|
ui->acceptButton->show();
|
||||||
declineButton->show();
|
ui->declineButton->show();
|
||||||
aboutQtButton->hide();
|
ui->aboutQtButton->hide();
|
||||||
closeButton->hide();
|
ui->closeButton->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Activate "show license" button
|
//Activate "show license" button
|
||||||
showLicenseButton->show();
|
ui->showLicenseButton->show();
|
||||||
connect(showLicenseButton, SIGNAL(clicked()), this, SLOT(gotoLicenseTab()));
|
connect(ui->showLicenseButton, SIGNAL(clicked()), this, SLOT(gotoLicenseTab()));
|
||||||
|
|
||||||
m_firstShow = firstStart;
|
m_firstShow = firstStart;
|
||||||
}
|
}
|
||||||
@ -193,6 +196,7 @@ AboutDialog::~AboutDialog(void)
|
|||||||
LAMEXP_DELETE(m_cartoon[i]);
|
LAMEXP_DELETE(m_cartoon[i]);
|
||||||
}
|
}
|
||||||
LAMEXP_DELETE(m_initFlags);
|
LAMEXP_DELETE(m_initFlags);
|
||||||
|
LAMEXP_DELETE(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -239,20 +243,20 @@ if(m_disque) { bool _tmp = m_disque->isVisible(); if(_tmp) m_disque->hide(); {CM
|
|||||||
|
|
||||||
void AboutDialog::tabChanged(int index)
|
void AboutDialog::tabChanged(int index)
|
||||||
{
|
{
|
||||||
bool bInitialized = m_initFlags->value(tabWidget->widget(index), false);
|
bool bInitialized = m_initFlags->value(ui->tabWidget->widget(index), false);
|
||||||
|
|
||||||
if(!bInitialized)
|
if(!bInitialized)
|
||||||
{
|
{
|
||||||
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
|
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||||
|
|
||||||
if(QWidget *tab = tabWidget->widget(index))
|
if(QWidget *tab = ui->tabWidget->widget(index))
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
|
|
||||||
if(tab == infoTab) { initInformationTab(); ok = true; }
|
if(tab == ui->infoTab) { initInformationTab(); ok = true; }
|
||||||
if(tab == contributorsTab) { initContributorsTab(); ok = true; }
|
if(tab == ui->contributorsTab) { initContributorsTab(); ok = true; }
|
||||||
if(tab == softwareTab) { initSoftwareTab(); ok = true; }
|
if(tab == ui->softwareTab) { initSoftwareTab(); ok = true; }
|
||||||
if(tab == licenseTab) { initLicenseTab(); ok = true; }
|
if(tab == ui->licenseTab) { initLicenseTab(); ok = true; }
|
||||||
|
|
||||||
if(ok)
|
if(ok)
|
||||||
{
|
{
|
||||||
@ -265,29 +269,29 @@ void AboutDialog::tabChanged(int index)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tabWidget->widget(index)->update();
|
ui->tabWidget->widget(index)->update();
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
qApp->restoreOverrideCursor();
|
qApp->restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Scroll to the top
|
//Scroll to the top
|
||||||
if(QWidget *tab = tabWidget->widget(index))
|
if(QWidget *tab = ui->tabWidget->widget(index))
|
||||||
{
|
{
|
||||||
if(tab == infoTab) infoScrollArea->verticalScrollBar()->setSliderPosition(0);
|
if(tab == ui->infoTab) ui->infoScrollArea->verticalScrollBar()->setSliderPosition(0);
|
||||||
if(tab == contributorsTab) contributorsScrollArea->verticalScrollBar()->setSliderPosition(0);
|
if(tab == ui->contributorsTab) ui->contributorsScrollArea->verticalScrollBar()->setSliderPosition(0);
|
||||||
if(tab == softwareTab) softwareScrollArea->verticalScrollBar()->setSliderPosition(0);
|
if(tab == ui->softwareTab) ui->softwareScrollArea->verticalScrollBar()->setSliderPosition(0);
|
||||||
if(tab == licenseTab) licenseScrollArea->verticalScrollBar()->setSliderPosition(0);
|
if(tab == ui->licenseTab) ui->licenseScrollArea->verticalScrollBar()->setSliderPosition(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update license button
|
//Update license button
|
||||||
showLicenseButton->setChecked(tabWidget->widget(index) == licenseTab);
|
ui->showLicenseButton->setChecked(ui->tabWidget->widget(index) == ui->licenseTab);
|
||||||
if(tabWidget->widget(index) != licenseTab) m_lastTab = index;
|
if(ui->tabWidget->widget(index) != ui->licenseTab) m_lastTab = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutDialog::enableButtons(void)
|
void AboutDialog::enableButtons(void)
|
||||||
{
|
{
|
||||||
acceptButton->setEnabled(true);
|
ui->acceptButton->setEnabled(true);
|
||||||
declineButton->setEnabled(true);
|
ui->declineButton->setEnabled(true);
|
||||||
setCursor(QCursor(Qt::ArrowCursor));
|
setCursor(QCursor(Qt::ArrowCursor));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +313,7 @@ void AboutDialog::showAboutQt(void)
|
|||||||
|
|
||||||
void AboutDialog::gotoLicenseTab(void)
|
void AboutDialog::gotoLicenseTab(void)
|
||||||
{
|
{
|
||||||
tabWidget->setCurrentIndex(tabWidget->indexOf(showLicenseButton->isChecked() ? licenseTab : tabWidget->widget(m_lastTab)));
|
ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->showLicenseButton->isChecked() ? ui->licenseTab : ui->tabWidget->widget(m_lastTab)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutDialog::moveDisque(void)
|
void AboutDialog::moveDisque(void)
|
||||||
@ -392,7 +396,7 @@ void AboutDialog::adjustSize(void)
|
|||||||
{
|
{
|
||||||
int maximumHeight = QApplication::desktop()->availableGeometry().height();
|
int maximumHeight = QApplication::desktop()->availableGeometry().height();
|
||||||
|
|
||||||
int delta = infoScrollArea->widget()->height() - infoScrollArea->viewport()->height();
|
int delta = ui->infoScrollArea->widget()->height() - ui->infoScrollArea->viewport()->height();
|
||||||
if(delta > 0)
|
if(delta > 0)
|
||||||
{
|
{
|
||||||
this->resize(this->width(), qMin(this->height() + delta, maximumHeight));
|
this->resize(this->width(), qMin(this->height() + delta, maximumHeight));
|
||||||
@ -409,13 +413,13 @@ void AboutDialog::showEvent(QShowEvent *e)
|
|||||||
{
|
{
|
||||||
QDialog::showEvent(e);
|
QDialog::showEvent(e);
|
||||||
|
|
||||||
tabWidget->setCurrentIndex(tabWidget->indexOf(infoTab));
|
ui->tabWidget->setCurrentIndex(ui->tabWidget->indexOf(ui->infoTab));
|
||||||
tabChanged(m_lastTab = tabWidget->currentIndex());
|
tabChanged(m_lastTab = ui->tabWidget->currentIndex());
|
||||||
|
|
||||||
if(m_firstShow)
|
if(m_firstShow)
|
||||||
{
|
{
|
||||||
acceptButton->setEnabled(false);
|
ui->acceptButton->setEnabled(false);
|
||||||
declineButton->setEnabled(false);
|
ui->declineButton->setEnabled(false);
|
||||||
QTimer::singleShot(5000, this, SLOT(enableButtons()));
|
QTimer::singleShot(5000, this, SLOT(enableButtons()));
|
||||||
setCursor(QCursor(Qt::WaitCursor));
|
setCursor(QCursor(Qt::WaitCursor));
|
||||||
}
|
}
|
||||||
@ -521,9 +525,9 @@ void AboutDialog::initInformationTab(void)
|
|||||||
aboutText += "</tr></table>";
|
aboutText += "</tr></table>";
|
||||||
//aboutText += QString("%1<br>").arg(NOBR(tr("Special thanks go out to \"John33\" from %1 for his continuous support.")).arg(LINK("http://www.rarewares.org/")));
|
//aboutText += QString("%1<br>").arg(NOBR(tr("Special thanks go out to \"John33\" from %1 for his continuous support.")).arg(LINK("http://www.rarewares.org/")));
|
||||||
|
|
||||||
infoLabel->setText(aboutText);
|
ui->infoLabel->setText(aboutText);
|
||||||
infoIcon->setPixmap(lamexp_app_icon().pixmap(QSize(72,72)));
|
ui->infoIcon->setPixmap(lamexp_app_icon().pixmap(QSize(72,72)));
|
||||||
connect(infoLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
|
connect(ui->infoLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutDialog::initContributorsTab(void)
|
void AboutDialog::initContributorsTab(void)
|
||||||
@ -575,9 +579,9 @@ void AboutDialog::initContributorsTab(void)
|
|||||||
contributorsAboutText += "</table><br><br><br>";
|
contributorsAboutText += "</table><br><br><br>";
|
||||||
contributorsAboutText += QString("<i>%1</i><br>").arg(NOBR(tr("If you are willing to contribute a LameXP translation, feel free to contact us!")));
|
contributorsAboutText += QString("<i>%1</i><br>").arg(NOBR(tr("If you are willing to contribute a LameXP translation, feel free to contact us!")));
|
||||||
|
|
||||||
contributorsLabel->setText(contributorsAboutText);
|
ui->contributorsLabel->setText(contributorsAboutText);
|
||||||
contributorsIcon->setPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(72,84)));
|
ui->contributorsIcon->setPixmap(QIcon(":/images/Logo_Contributors.png").pixmap(QSize(72,84)));
|
||||||
connect(contributorsLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
|
connect(ui->contributorsLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutDialog::initSoftwareTab(void)
|
void AboutDialog::initSoftwareTab(void)
|
||||||
@ -775,9 +779,9 @@ void AboutDialog::initSoftwareTab(void)
|
|||||||
tr("The copyright of LameXP as a whole belongs to LoRd_MuldeR. The copyright of third-party software used in LameXP belongs to the individual authors.")
|
tr("The copyright of LameXP as a whole belongs to LoRd_MuldeR. The copyright of third-party software used in LameXP belongs to the individual authors.")
|
||||||
);
|
);
|
||||||
|
|
||||||
softwareLabel->setText(moreAboutText);
|
ui->softwareLabel->setText(moreAboutText);
|
||||||
softwareIcon->setPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(72,65)));
|
ui->softwareIcon->setPixmap(QIcon(":/images/Logo_Software.png").pixmap(QSize(72,65)));
|
||||||
connect(softwareLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
|
connect(ui->softwareLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutDialog::initLicenseTab(void)
|
void AboutDialog::initLicenseTab(void)
|
||||||
@ -823,9 +827,9 @@ void AboutDialog::initLicenseTab(void)
|
|||||||
|
|
||||||
licenseText += ("</tt>");
|
licenseText += ("</tt>");
|
||||||
|
|
||||||
licenseLabel->setText(licenseText);
|
ui->licenseLabel->setText(licenseText);
|
||||||
licenseIcon->setPixmap(QIcon(":/images/Logo_GNU.png").pixmap(QSize(72,65)));
|
ui->licenseIcon->setPixmap(QIcon(":/images/Logo_GNU.png").pixmap(QSize(72,65)));
|
||||||
connect(licenseLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
|
connect(ui->licenseLabel, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,11 +21,21 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../tmp/UIC_AboutDialog.h"
|
#include <QDialog>
|
||||||
|
|
||||||
|
//UIC forward declartion
|
||||||
|
namespace Ui {
|
||||||
|
class AboutDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Class declarations
|
||||||
|
class QLabel;
|
||||||
|
class QPixmap;
|
||||||
|
class QTimer;
|
||||||
class SettingsModel;
|
class SettingsModel;
|
||||||
|
|
||||||
class AboutDialog : public QDialog, private Ui::AboutDialog
|
//AboutDialog class
|
||||||
|
class AboutDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -51,6 +61,8 @@ protected:
|
|||||||
bool eventFilter(QObject *obj, QEvent *event);
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Ui::AboutDialog *ui; //for Qt UIC
|
||||||
|
|
||||||
bool m_firstShow;
|
bool m_firstShow;
|
||||||
SettingsModel *m_settings;
|
SettingsModel *m_settings;
|
||||||
QMap<QWidget*,bool> *m_initFlags;
|
QMap<QWidget*,bool> *m_initFlags;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user