Skip to content

Commit

Permalink
Prepare the about-dialog for additional content (e.g. list of
Browse files Browse the repository at this point in the history
contributors...)
  • Loading branch information
jahnf committed May 2, 2019
1 parent c458c6a commit 66aa5c9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
45 changes: 34 additions & 11 deletions aboutdlg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <QIcon>
#include <QLabel>
#include <QPushButton>
#include <QTabWidget>
#include <QVBoxLayout>
#include <QDialogButtonBox>

Expand All @@ -22,10 +23,29 @@ AboutDialog::AboutDialog(QWidget* parent)
iconLabel->setPixmap(QIcon(":/icons/projecteur-tray.svg").pixmap(QSize(128,128)));
hbox->addWidget(iconLabel);

auto vbox = new QVBoxLayout();
vbox->addWidget(new QLabel(QString("<b>%1</b><br>Version %2")
auto tabWidget = new QTabWidget(this);
hbox->addWidget(tabWidget, 1);

tabWidget->addTab(createVersionInfoWidget(), tr("Version"));
// tabWidget->addTab(createContributorInfoWidget(), tr("Contributors"));

auto bbox = new QDialogButtonBox(QDialogButtonBox::Ok, this);
connect(bbox, &QDialogButtonBox::clicked, this, &QDialog::accept);

auto mainVbox = new QVBoxLayout(this);
mainVbox->addLayout(hbox);
mainVbox->addSpacing(10);
mainVbox->addWidget(bbox);
}

QWidget* AboutDialog::createVersionInfoWidget()
{
auto versionInfoWidget = new QWidget(this);
auto vbox = new QVBoxLayout(versionInfoWidget);
vbox->addWidget(new QLabel(QString("<b>%1</b><br>%2")
.arg(QCoreApplication::applicationName())
.arg(projecteur::version_string()), this));
.arg(tr("Version %1", "%1=application version number")
.arg(projecteur::version_string()))));

if (QString(projecteur::version_branch()) != "master")
{
Expand All @@ -42,16 +62,19 @@ AboutDialog::AboutDialog(QWidget* parent)
vbox->addWidget(weblinkLabel);

vbox->addSpacing(20);
vbox->addWidget(new QLabel(QString("Qt Version: %1").arg(QT_VERSION_STR), this));
vbox->addWidget(new QLabel(tr("Qt Version: %1", "%1=qt version number").arg(QT_VERSION_STR), this));

vbox->addStretch(1);
hbox->addLayout(vbox);
return versionInfoWidget;
}

auto bbox = new QDialogButtonBox(QDialogButtonBox::Ok, this);
connect(bbox, &QDialogButtonBox::clicked, this, &QDialog::accept);
QWidget* AboutDialog::createContributorInfoWidget()
{
auto contributorWidget = new QWidget(this);
auto vbox = new QVBoxLayout(contributorWidget);

auto mainVbox = new QVBoxLayout(this);
mainVbox->addLayout(hbox);
mainVbox->addSpacing(10);
mainVbox->addWidget(bbox);
// TODO: list contributors (scroll box)

vbox->addStretch(1);
return contributorWidget;
}
4 changes: 4 additions & 0 deletions aboutdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ class AboutDialog : public QDialog
public:
explicit AboutDialog(QWidget* parent = nullptr);
virtual ~AboutDialog() override = default;

private:
QWidget* createVersionInfoWidget();
QWidget* createContributorInfoWidget();
};

0 comments on commit 66aa5c9

Please sign in to comment.