Changeset View
Changeset View
Standalone View
Standalone View
app/kookapref.cpp
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | 92 | { | |||
---|---|---|---|---|---|
94 | if (top != nullptr) { | 94 | if (top != nullptr) { | ||
95 | top->addStretch(1); | 95 | top->addStretch(1); | ||
96 | } | 96 | } | ||
97 | 97 | | |||
98 | KPageWidgetItem *item = addPage(page, name); | 98 | KPageWidgetItem *item = addPage(page, name); | ||
99 | item->setHeader(header); | 99 | item->setHeader(header); | ||
100 | item->setIcon(QIcon::fromTheme(icon)); | 100 | item->setIcon(QIcon::fromTheme(icon)); | ||
101 | 101 | | |||
102 | int idx = mPages.count(); // index of new item | 102 | int idx = mPages.count(); // index of new item | ||
103 | mPages.append(item); | 103 | mPages.append(item); | ||
104 | return (idx); // index of item added | 104 | return (idx); // index of item added | ||
105 | } | 105 | } | ||
106 | 106 | | |||
107 | void KookaPref::slotSaveSettings() | 107 | void KookaPref::slotSaveSettings() | ||
108 | { | 108 | { | ||
109 | for (int i = 0; i < mPages.size(); ++i) { | 109 | for (int i = 0; i < mPages.size(); ++i) { | ||
110 | KookaPrefsPage *page = static_cast<KookaPrefsPage *>(mPages[i]->widget()); | 110 | KookaPrefsPage *page = static_cast<KookaPrefsPage *>(mPages[i]->widget()); | ||
111 | page->saveSettings(); | 111 | page->saveSettings(); | ||
112 | } | 112 | } | ||
Show All 19 Lines | |||||
132 | 132 | | |||
133 | int KookaPref::currentPageIndex() | 133 | int KookaPref::currentPageIndex() | ||
134 | { | 134 | { | ||
135 | return (mPages.indexOf(currentPage())); | 135 | return (mPages.indexOf(currentPage())); | ||
136 | } | 136 | } | ||
137 | 137 | | |||
138 | // Support for the gallery location - moved here from Previewer class in libkscan | 138 | // Support for the gallery location - moved here from Previewer class in libkscan | ||
139 | 139 | | |||
140 | QString KookaPref::sGalleryRoot = QString::null; // global resolved location | 140 | QString KookaPref::sGalleryRoot; // global resolved location | ||
141 | 141 | | |||
142 | // The static variable above ensures that the user is only asked | 142 | // The static variable above ensures that the user is only asked | ||
143 | // at most once in an application run. | 143 | // at most once in an application run. | ||
144 | 144 | | |||
145 | QString KookaPref::galleryRoot() | 145 | QString KookaPref::galleryRoot() | ||
146 | { | 146 | { | ||
147 | if (sGalleryRoot.isNull()) { | 147 | if (sGalleryRoot.isNull()) { | ||
148 | sGalleryRoot = findGalleryRoot(); | 148 | sGalleryRoot = findGalleryRoot(); | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | |||||
206 | } | 206 | } | ||
207 | 207 | | |||
208 | QString KookaPref::findGalleryRoot() | 208 | QString KookaPref::findGalleryRoot() | ||
209 | { | 209 | { | ||
210 | QString galleryName = KookaSettings::galleryName(); // may be base name or absolute path | 210 | QString galleryName = KookaSettings::galleryName(); // may be base name or absolute path | ||
211 | if (galleryName.isEmpty()) | 211 | if (galleryName.isEmpty()) | ||
212 | { | 212 | { | ||
213 | qWarning() << "Gallery name not configured"; | 213 | qWarning() << "Gallery name not configured"; | ||
214 | return (QString::null); | 214 | return (QString()); | ||
215 | } | 215 | } | ||
216 | 216 | | |||
217 | QString oldpath = QStandardPaths::locate(QStandardPaths::AppDataLocation, "ScanImages", QStandardPaths::LocateDirectory); | 217 | QString oldpath = QStandardPaths::locate(QStandardPaths::AppDataLocation, "ScanImages", QStandardPaths::LocateDirectory); | ||
218 | bool oldexists = !oldpath.isEmpty(); | 218 | bool oldexists = !oldpath.isEmpty(); | ||
219 | 219 | | |||
220 | QString newpath(galleryName); | 220 | QString newpath(galleryName); | ||
221 | if (!QDir::isAbsolutePath(galleryName)) | 221 | if (!QDir::isAbsolutePath(galleryName)) | ||
222 | { | 222 | { | ||
Show All 29 Lines | 240 | if (KMessageBox::questionYesNo(nullptr, | |||
252 | if (created) { // new created OK | 252 | if (created) { // new created OK | ||
253 | KMessageBox::information(nullptr, | 253 | KMessageBox::information(nullptr, | ||
254 | xi18nc("@info", | 254 | xi18nc("@info", | ||
255 | "Kooka will use the new gallery, <link url=\"file:%1\"><filename>%1</filename></link>." | 255 | "Kooka will use the new gallery, <link url=\"file:%1\"><filename>%1</filename></link>." | ||
256 | "<nl/><nl/>If you wish to add the images from your old gallery <link url=\"file:%2\"><filename>%2</filename></link>," | 256 | "<nl/><nl/>If you wish to add the images from your old gallery <link url=\"file:%2\"><filename>%2</filename></link>," | ||
257 | "<nl/>then you may do so by simply copying or moving the files.", | 257 | "<nl/>then you may do so by simply copying or moving the files.", | ||
258 | newpath, oldpath), | 258 | newpath, oldpath), | ||
259 | i18n("New Gallery Created"), | 259 | i18n("New Gallery Created"), | ||
260 | QString::null, | 260 | QString(), | ||
261 | KMessageBox::Notify | KMessageBox::AllowLink); | 261 | KMessageBox::Notify | KMessageBox::AllowLink); | ||
262 | } | 262 | } | ||
263 | } else { // no, don't create | 263 | } else { // no, don't create | ||
264 | dir = oldpath; // stay with old location | 264 | dir = oldpath; // stay with old location | ||
265 | } | 265 | } | ||
266 | } else { // both exist | 266 | } else { // both exist | ||
267 | KMessageBox::information(nullptr, | 267 | KMessageBox::information(nullptr, | ||
268 | xi18nc("@info", | 268 | xi18nc("@info", | ||
Show All 14 Lines |