31 #include "gui/formnewproject.h"
33 #include "core/templateentrypoint.h"
34 #include "core/templatefactory.h"
35 #include "miscellaneous/iconfactory.h"
40 FormNewProject::FormNewProject(
TemplateFactory *template_manager, QWidget *parent)
45 m_ui->m_lblThumbnail->setFixedSize(200, 213);
46 m_ui->m_listTemplates->setFixedWidth(200);
48 QMargins description_margins = m_ui->m_lblDescription->contentsMargins();
50 description_margins.setTop(20);
52 m_ui->m_lblDescription->setContentsMargins(description_margins);
54 connect(m_ui->m_listTemplates, SIGNAL(currentRowChanged(
int)),
this, SLOT(templateSelected(
int)));
55 connect(m_ui->m_listTemplates, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(accept()));
58 setAttribute(Qt::WA_DeleteOnClose,
false);
60 setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | (windowFlags() & ~Qt::WindowContextHelpButtonHint));
65 FormNewProject::~FormNewProject() {
70 if (exec() == QDialog::Accepted && m_ui->m_listTemplates->currentRow() >= 0) {
71 return static_cast<TemplateEntryPoint*
>(m_ui->m_listTemplates->currentItem()->data(Qt::UserRole).value<
void*>());
78 void FormNewProject::showEvent(QShowEvent *e) {
81 adjustPosition(parentWidget());
89 void FormNewProject::templateSelected(
int index) {
93 m_ui->m_lblDescription->setText(entry_point->
description());
94 m_ui->m_lblThumbnail->setPixmap(QPixmap(APP_TEMPLATES_PATH + QDir::separator() +
95 entry_point->
baseFolder() + QDir::separator() +
100 void FormNewProject::loadTemplates(
const QList<TemplateEntryPoint*> &entry_points) {
103 (
new QListWidgetItem(entry_point->
humanName(),
104 m_ui->m_listTemplates))->setData(Qt::UserRole,
105 QVariant::fromValue((
void*) entry_point));
108 if (m_ui->m_listTemplates->count() > 0) {
109 m_ui->m_listTemplates->setCurrentRow(0);
virtual QString description() const
Description of template.
virtual QString humanName() const
Human-readable name of template.
The top-level manager of templates.
QList< TemplateEntryPoint * > availableTemplates()
Access to available templates.
The entry point for a template.
virtual QString baseFolder() const
Base folder of template.
virtual QString thumbnailImage() const
Relative path to thumbnail image.
static IconFactory * instance()
Singleton getter.