Debian Codegraph @

core/dplugins/generic/tools/jalbum/wizard/jalbumintropage.cpp

raw
1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2006-04-04
7 * Description : a tool to generate jAlbum image galleries
8 *
9 * SPDX-FileCopyrightText: 2013-2019 by Andrew Goodbody <ajg zero two at elfringham dot co dot uk>
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 *
13 * ============================================================ */
14
15 #include "jalbumintropage.h"
16
17 // Qt includes
18
19 #include <QLabel>
20 #include <QPixmap>
21 #include <QComboBox>
22 #include <QGroupBox>
23 #include <QIcon>
24
25 // KDE includes
26
27 #include <klocalizedstring.h>
28
29 // Local includes
30
31 #include "digikam_debug.h"
32 #include "digikam_config.h"
33 #include "dbinarysearch.h"
34 #include "jalbumjar.h"
35 #include "jalbumjava.h"
36 #include "jalbumwizard.h"
37 #include "jalbumsettings.h"
38 #include "dlayoutbox.h"
39
40 namespace DigikamGenericJAlbumPlugin
41 {
42
43 class Q_DECL_HIDDEN JAlbumIntroPage::Private
44 {
45 public:
46
47 explicit Private(QWizard* const dialog)
48 {
49 wizard = dynamic_cast<JAlbumWizard*>(dialog);
50
51 if (wizard)
52 {
53 settings = wizard->settings();
54 iface = settings->m_iface;
55 }
56 }
57
58 public:
59
60 QComboBox* imageGetOption = nullptr;
61 DHBox* hbox = nullptr;
62 JAlbumWizard* wizard = nullptr;
63 JAlbumSettings* settings = nullptr;
64 DInfoInterface* iface = nullptr;
65 DBinarySearch* binSearch = nullptr;
66 JalbumJar jalbumBin;
67 JalbumJava jalbumJava;
68 };
69
70 JAlbumIntroPage::JAlbumIntroPage(QWizard* const dialog, const QString& title)
71 : DWizardPage(dialog, title),
72 d (new Private(dialog))
73 {
74 DVBox* const vbox = new DVBox(this);
75 QLabel* const desc = new QLabel(vbox);
76
77 desc->setWordWrap(true);
78 desc->setOpenExternalLinks(true);
79 desc->setText(i18n("<qt>"
80 "<p><h1><b>Welcome to jAlbum export tool</b></h1></p>"
81 "<p>This assistant will guide you to export quickly</p><p></p>"
82 "<p>your images as a jAlbum project.</p>"
83 "</qt>"));
84
85 // ComboBox for image selection method
86
87 d->hbox = new DHBox(vbox);
88 QLabel* const getImageLabel = new QLabel(i18n("&Choose image selection method:"), d->hbox);
89 d->imageGetOption = new QComboBox(d->hbox);
90 d->imageGetOption->insertItem(JAlbumSettings::ALBUMS, i18n("Albums"));
91 d->imageGetOption->insertItem(JAlbumSettings::IMAGES, i18n("Images"));
92 getImageLabel->setBuddy(d->imageGetOption);
93
94 // --------------------
95
96 QGroupBox* const binaryBox = new QGroupBox(vbox);
97 QGridLayout* const binaryLayout = new QGridLayout;
98 binaryBox->setLayout(binaryLayout);
99 binaryBox->setTitle(i18nc("@title:group", "jAlbum Binaries"));
100 d->binSearch = new DBinarySearch(binaryBox);
101 d->binSearch->addBinary(d->jalbumBin);
102 d->binSearch->addBinary(d->jalbumJava);
103
104 vbox->setStretchFactor(desc, 2);
105 vbox->setStretchFactor(d->hbox, 1);
106 vbox->setStretchFactor(binaryBox, 3);
107
108 setPageWidget(vbox);
109 setLeftBottomPix(QIcon::fromTheme(QLatin1String("text-html")));
110
111 #ifdef Q_OS_WIN
112
113 d->binSearch->addDirectory(QLatin1String(qgetenv("ProgramFiles").constData()) + QLatin1String("\\jAlbum\\"));
114
115 #else
116
117 d->binSearch->addDirectory(QLatin1String("/usr/share/"));
118 d->binSearch->addDirectory(QLatin1String("/usr/share/jAlbum/"));
119 d->binSearch->addDirectory(QLatin1String("/usr/share/jalbum/"));
120 d->binSearch->addDirectory(QLatin1String("/usr/lib/jalbum/"));
121
122 #endif
123
124 connect(d->binSearch, SIGNAL(signalBinariesFound(bool)),
125 this, SLOT(slotBinariesFound()));
126 }
127
128 JAlbumIntroPage::~JAlbumIntroPage()
129 {
130 delete d;
131 }
132
133 void JAlbumIntroPage::initializePage()
134 {
135 bool albumSupport = (d->iface && d->iface->supportAlbums());
136
137 if (!albumSupport)
138 {
139 d->imageGetOption->setCurrentIndex(JAlbumSettings::IMAGES);
140 d->hbox->setEnabled(false);
141 }
142 else
143 {
144 d->imageGetOption->setCurrentIndex(d->settings->m_getOption);
145 }
146
147 d->binSearch->allBinariesFound();
148 slotBinariesFound();
149 }
150
151 bool JAlbumIntroPage::validatePage()
152 {
153 d->settings->m_getOption = (JAlbumSettings::ImageGetOption)d->imageGetOption->currentIndex();
154
155 return true;
156 }
157
158 void JAlbumIntroPage::slotBinariesFound()
159 {
160 d->settings->m_jalbumPath = d->jalbumBin.path();
161 d->settings->m_javaPath = d->jalbumJava.path();
162
163 Q_EMIT completeChanged();
164 }
165
166 bool JAlbumIntroPage::isComplete() const
167 {
168 QString val = d->wizard->settings()->m_javaPath + d->wizard->settings()->m_jalbumPath;
169 qCDebug(DIGIKAM_DPLUGIN_GENERIC_LOG) << val;
170
171 return (!val.isEmpty());
172 }
173
174 } // namespace DigikamGenericJAlbumPlugin
175
176 #include "moc_jalbumintropage.cpp"