127 lines
4.7 KiB
C++
127 lines
4.7 KiB
C++
|
#include "albumwizard.h"
|
||
|
|
||
|
AlbumWizard::AlbumWizard(QWidget *parent) :
|
||
|
QWizard(parent)
|
||
|
{
|
||
|
addPage(new IntroPage);
|
||
|
addPage(new SettingsPage);
|
||
|
addPage(new ConclusionPage);
|
||
|
|
||
|
setPixmap(QWizard::BannerPixmap, QPixmap(":/images/banner.png"));
|
||
|
setPixmap(QWizard::BackgroundPixmap, QPixmap(":/images/background.png"));
|
||
|
|
||
|
this->setButtonText(QWizard::FinishButton, tr("Finish"));
|
||
|
|
||
|
setWindowTitle(tr("Import Album"));
|
||
|
}
|
||
|
|
||
|
IntroPage::IntroPage(QWidget *parent)
|
||
|
: QWizardPage(parent)
|
||
|
{
|
||
|
setTitle(tr("Introduction"));
|
||
|
setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark1.png"));
|
||
|
|
||
|
label = new QLabel(tr("This wizard allows you to import a folder, "
|
||
|
"along with its subfolders, directly into Caesium. "
|
||
|
"You simply need to set an input folder, choose where "
|
||
|
"compress your pictures and Caesium will keep the same "
|
||
|
"(sub)folder structure, name and format. You can set the compression level "
|
||
|
"and compress your pictures right after the wizard end."));
|
||
|
label->setWordWrap(true);
|
||
|
|
||
|
QVBoxLayout *layout = new QVBoxLayout;
|
||
|
layout->addWidget(label);
|
||
|
setLayout(layout);
|
||
|
}
|
||
|
|
||
|
SettingsPage::SettingsPage(QWidget *parent)
|
||
|
: QWizardPage(parent)
|
||
|
{
|
||
|
setTitle(tr("Settings"));
|
||
|
|
||
|
label = new QLabel(tr("In this page you can set your pictures folder, "
|
||
|
"where to compress them and the compression level."));
|
||
|
label->setWordWrap(true);
|
||
|
|
||
|
inputLineEdit = new QLineEdit(this);
|
||
|
inputLineEdit->setPlaceholderText(tr("Choose your pictures folder..."));
|
||
|
inputLineEdit->setReadOnly(true);
|
||
|
inputButton = new QPushButton(tr("Browse..."));
|
||
|
|
||
|
outputLineEdit = new QLineEdit(this);
|
||
|
outputLineEdit->setPlaceholderText(tr("Choose where to compress..."));
|
||
|
outputLineEdit->setReadOnly(true);
|
||
|
outputButton = new QPushButton(tr("Browse..."));
|
||
|
|
||
|
spacer = new QSpacerItem(1, 20);
|
||
|
|
||
|
compressionLabel = new QLabel(tr("Quality: "));
|
||
|
compressionSlider = new QSlider(Qt::Horizontal);
|
||
|
compressionSlider->setMaximum(100);
|
||
|
compressionSlider->setMinimum(1);
|
||
|
compressionSlider->setSingleStep(5);
|
||
|
compressionSlider->setValue(80);
|
||
|
compressionSlider->setTickInterval(10);
|
||
|
compressionSlider->setTickPosition(QSlider::TicksBelow);
|
||
|
compressionSpinBox = new QSpinBox();
|
||
|
compressionSpinBox->setValue(80);
|
||
|
compressionSpinBox->setMaximum(100);
|
||
|
compressionSpinBox->setMinimum(1);
|
||
|
connect(compressionSlider, SIGNAL(valueChanged(int)), compressionSpinBox, SLOT(setValue(int)));
|
||
|
connect(compressionSpinBox, SIGNAL(valueChanged(int)), compressionSlider, SLOT(setValue(int)));
|
||
|
|
||
|
testSpacer = new QSpacerItem(300, 1, QSizePolicy::Expanding, QSizePolicy::Maximum);
|
||
|
testButton = new QPushButton(tr("Run test"));
|
||
|
|
||
|
QVBoxLayout *layout = new QVBoxLayout;
|
||
|
layout->addWidget(label);
|
||
|
QHBoxLayout *inputLayout = new QHBoxLayout;
|
||
|
inputLayout->addWidget(inputLineEdit);
|
||
|
inputLayout->addWidget(inputButton);
|
||
|
layout->addLayout(inputLayout);
|
||
|
QHBoxLayout *outputLayout = new QHBoxLayout;
|
||
|
outputLayout->addWidget(outputLineEdit);
|
||
|
outputLayout->addWidget(outputButton);
|
||
|
layout->addLayout(outputLayout);
|
||
|
layout->addSpacerItem(spacer);
|
||
|
QHBoxLayout *compressionLayout = new QHBoxLayout;
|
||
|
compressionLayout->addWidget(compressionLabel);
|
||
|
compressionLayout->addWidget(compressionSlider);
|
||
|
compressionLayout->addWidget(compressionSpinBox);
|
||
|
layout->addLayout(compressionLayout);
|
||
|
QHBoxLayout *testLayout = new QHBoxLayout;
|
||
|
testLayout->addSpacerItem(testSpacer);
|
||
|
testLayout->addWidget(testButton);
|
||
|
layout->addLayout(testLayout);
|
||
|
setLayout(layout);
|
||
|
inputLineEdit->setFocusPolicy(Qt::NoFocus);
|
||
|
outputLineEdit->setFocusPolicy(Qt::NoFocus);
|
||
|
}
|
||
|
|
||
|
ConclusionPage::ConclusionPage(QWidget *parent)
|
||
|
: QWizardPage(parent)
|
||
|
{
|
||
|
setTitle(tr("Conclusion"));
|
||
|
setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark2.png"));
|
||
|
|
||
|
label = new QLabel;
|
||
|
label->setWordWrap(true);
|
||
|
|
||
|
compressCheckBox = new QCheckBox(tr("Compress now"), this);
|
||
|
compressCheckBox->setChecked(true);
|
||
|
|
||
|
QVBoxLayout *layout = new QVBoxLayout;
|
||
|
layout->addWidget(label);
|
||
|
layout->addWidget(compressCheckBox);
|
||
|
setLayout(layout);
|
||
|
}
|
||
|
|
||
|
void ConclusionPage::initializePage()
|
||
|
{
|
||
|
QString finishText = wizard()->buttonText(QWizard::FinishButton);
|
||
|
finishText.remove('&');
|
||
|
label->setText(tr("You can choose to compress now you pictures or click %1 to exit the wizard "
|
||
|
"and go to Caesium main page to set other compression options.")
|
||
|
.arg(finishText));
|
||
|
}
|