1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
/* ============================================================
*
* This file is a part of KDE project
*
*
* Date : 2009-11-13
* Description : a template to create wizzard page.
*
* Copyright (C) 2009-2018 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "kpwizardpage.h"
// Qt includes
#include <QHBoxLayout>
#include <QLabel>
#include <QVBoxLayout>
#include <QStandardPaths>
#include <QApplication>
#include <QStyle>
#include <QScrollArea>
// Local includes
#include "kptooldialog.h"
namespace KIPIPlugins
{
class KPWizardPage::Private
{
public:
Private()
{
hlay = nullptr;
logo = nullptr;
leftBottomPix = nullptr;
leftView = nullptr;
isComplete = true;
id = -1;
dlg = nullptr;
}
bool isComplete;
int id;
QWidget* leftView;
QLabel* logo;
QLabel* leftBottomPix;
QHBoxLayout* hlay;
KPWizardDialog* dlg;
};
KPWizardPage::KPWizardPage(KPWizardDialog* const dlg, const QString& title)
: QWizardPage(dlg),
d(new Private)
{
setTitle(title);
const int spacing = QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
QScrollArea* const sv = new QScrollArea(this);
QWidget* const panel = new QWidget(sv->viewport());
sv->setWidget(panel);
sv->setWidgetResizable(true);
d->hlay = new QHBoxLayout(panel);
d->leftView = new QWidget(panel);
QVBoxLayout* const vboxLay = new QVBoxLayout(d->leftView);
d->logo = new QLabel(d->leftView);
d->logo->setAlignment(Qt::AlignTop);
d->logo->setPixmap(QPixmap(QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QString::fromLatin1(":/images/kipi-logo.svg")))
.scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation));
QWidget* const space = new QLabel(d->leftView);
d->leftBottomPix = new QLabel(d->leftView);
d->leftBottomPix->setAlignment(Qt::AlignBottom);
vboxLay->addWidget(d->logo);
vboxLay->addWidget(space);
vboxLay->addWidget(d->leftBottomPix);
vboxLay->setStretchFactor(space, 10);
vboxLay->setContentsMargins(spacing, spacing, spacing, spacing);
vboxLay->setSpacing(spacing);
QFrame* const vline = new QFrame(panel);
vline->setLineWidth(1);
vline->setMidLineWidth(0);
vline->setFrameShape(QFrame::VLine);
vline->setFrameShadow(QFrame::Sunken);
vline->setMinimumSize(2, 0);
vline->updateGeometry();
d->hlay->addWidget(d->leftView);
d->hlay->addWidget(vline);
d->hlay->setContentsMargins(QMargins());
d->hlay->setSpacing(spacing);
QVBoxLayout* const layout = new QVBoxLayout;
layout->addWidget(sv);
setLayout(layout);
d->dlg = dlg;
d->id = d->dlg->addPage(this);
}
KPWizardPage::~KPWizardPage()
{
delete d;
}
void KPWizardPage::setComplete(bool b)
{
d->isComplete = b;
Q_EMIT completeChanged();
}
bool KPWizardPage::isComplete() const
{
return d->isComplete;
}
int KPWizardPage::id() const
{
return d->id;
}
void KPWizardPage::setShowLeftView(bool v)
{
d->leftView->setVisible(v);
}
void KPWizardPage::setPageWidget(QWidget* const w)
{
d->hlay->addWidget(w);
d->hlay->setStretchFactor(w, 10);
}
void KPWizardPage::removePageWidget(QWidget* const w)
{
d->hlay->removeWidget(w);
}
void KPWizardPage::setLeftBottomPix(const QPixmap& pix)
{
d->leftBottomPix->setPixmap(pix);
}
KPWizardDialog* KPWizardPage::assistant() const
{
return d->dlg;
}
} // namespace KIPIPlugins
|