Skip to content

Commit 5e0068f

Browse files
committed
Version 1.0.16
2 parents 275ae37 + 57e5d44 commit 5e0068f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+737
-516
lines changed

Application.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "Application.h"
2020
#include <config.h>
2121
#include <QDir>
22+
#include <QFontDatabase>
2223
#include <QTemporaryDir>
2324
#include "DebugImages.h"
2425
#include "ErrorWidget.h"
@@ -37,6 +38,8 @@
3738
Application::Application(int& argc, char** argv) : QApplication(argc, argv), m_currentLocale("en") {
3839
initTranslations();
3940
initPortableVersion();
41+
42+
QFontDatabase::addApplicationFont(":/fonts/symbols.ttf");
4043
}
4144

4245
bool Application::notify(QObject* receiver, QEvent* e) {

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ set(common_sources
501501
BlackOnWhiteEstimator.cpp BlackOnWhiteEstimator.h
502502
ImageSettings.cpp ImageSettings.h
503503
EmptyTaskStatus.h
504-
OrderByCompleteness.cpp OrderByCompleteness.h
504+
OrderByCompletenessProvider.cpp OrderByCompletenessProvider.h
505505
version.h
506506
config.h.in
507507
${common_ui_files})

ColorScheme.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <QStyle>
66
#include <QtGui/QPalette>
7+
#include <memory>
78
#include <unordered_map>
89

910
class ColorScheme {

DefaultParamsDialog.cpp

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,6 @@ void DefaultParamsDialog::updatePageLayoutDisplay(const DefaultParams::PageLayou
226226
alignmentMode->setCurrentIndex(1);
227227
autoAlignSettingsGroup->setVisible(false);
228228
}
229-
updateAlignmentButtonsEnabled();
230-
updateAutoModeButtons();
231-
232229
alignWithOthersCB->setChecked(!alignment.isNull());
233230

234231
for (const auto& kv : m_alignmentByButton) {
@@ -247,6 +244,10 @@ void DefaultParamsDialog::updatePageLayoutDisplay(const DefaultParams::PageLayou
247244
break;
248245
}
249246
}
247+
248+
updateAlignmentModeEnabled();
249+
updateAlignmentButtonsEnabled();
250+
updateAutoModeButtons();
250251
}
251252

252253
void DefaultParamsDialog::updateOutputDisplay(const DefaultParams::OutputParams& params) {
@@ -479,7 +480,8 @@ void DefaultParamsDialog::alignmentModeChanged(const int idx) {
479480
updateAutoModeButtons();
480481
}
481482

482-
void DefaultParamsDialog::alignWithOthersToggled(const bool) {
483+
void DefaultParamsDialog::alignWithOthersToggled(const bool state) {
484+
updateAlignmentModeEnabled();
483485
updateAlignmentButtonsEnabled();
484486
}
485487

@@ -500,6 +502,7 @@ void DefaultParamsDialog::colorModeChanged(const int idx) {
500502
break;
501503
}
502504
thresholdOptions->setEnabled(threshold_options_visible);
505+
despecklePanel->setEnabled(threshold_options_visible);
503506
pictureShapeOptions->setEnabled(picture_shape_visible);
504507
splittingOptions->setEnabled(splitting_options_visible);
505508

@@ -517,8 +520,7 @@ void DefaultParamsDialog::colorModeChanged(const int idx) {
517520
morphologicalSmoothingCB->setEnabled(colorMode != COLOR_GRAYSCALE);
518521

519522
colorSegmentationCB->setEnabled(threshold_options_visible);
520-
segmenterOptionsWidget->setEnabled(threshold_options_visible);
521-
segmenterOptionsWidget->setEnabled(colorSegmentationCB->isChecked());
523+
segmenterOptionsWidget->setEnabled(threshold_options_visible && colorSegmentationCB->isChecked());
522524
if (threshold_options_visible) {
523525
posterizeCB->setEnabled(colorSegmentationCB->isChecked());
524526
posterizeOptionsWidget->setEnabled(colorSegmentationCB->isChecked() && posterizeCB->isChecked());
@@ -910,15 +912,27 @@ void DefaultParamsDialog::profileChanged(const int index) {
910912
std::unique_ptr<DefaultParams> sourceProfile = m_profileManager.createSourceProfile();
911913
loadParams(*sourceProfile);
912914
} else {
913-
std::unique_ptr<DefaultParams> profile = m_profileManager.readProfile(profileCB->itemData(index).toString());
914-
if (profile != nullptr) {
915+
const QString profileName = profileCB->currentData().toString();
916+
DefaultParamsProfileManager::LoadStatus loadStatus;
917+
918+
std::unique_ptr<DefaultParams> profile = m_profileManager.readProfile(profileName, &loadStatus);
919+
if (loadStatus == DefaultParamsProfileManager::SUCCESS) {
915920
profileSaveButton->setEnabled(true);
916921
profileDeleteButton->setEnabled(true);
917922
setTabWidgetsEnabled(true);
918923

919924
loadParams(*profile);
920925
} else {
921-
QMessageBox::critical(this, tr("Error"), tr("Error loading the profile."));
926+
if (loadStatus == DefaultParamsProfileManager::INCOMPATIBLE_VERSION_ERROR) {
927+
const int result = QMessageBox::warning(
928+
this, tr("Error"), tr("The profile file is not compatible with the current application version. Remove?"),
929+
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
930+
if (result == QMessageBox::Yes) {
931+
m_profileManager.deleteProfile(profileName);
932+
}
933+
} else {
934+
QMessageBox::critical(this, tr("Error"), tr("Error loading the profile."));
935+
}
922936
profileCB->setCurrentIndex(0);
923937
profileCB->removeItem(index);
924938
m_customProfileItemIdx--;
@@ -1107,3 +1121,10 @@ void DefaultParamsDialog::despeckleSliderValueChanged(int value) {
11071121
tooltip_pos = despeckleSlider->mapToGlobal(tooltip_pos);
11081122
QToolTip::showText(tooltip_pos, tooltip_text, despeckleSlider);
11091123
}
1124+
1125+
void DefaultParamsDialog::updateAlignmentModeEnabled() {
1126+
const bool is_alignment_null = !alignWithOthersCB->isChecked();
1127+
1128+
alignmentMode->setEnabled(!is_alignment_null);
1129+
autoAlignSettingsGroup->setEnabled(!is_alignment_null);
1130+
}

DefaultParamsDialog.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class DefaultParamsDialog : public QDialog, private Ui::DefaultParamsDialog {
4141

4242
void alignmentModeChanged(int idx);
4343

44-
void alignWithOthersToggled(bool);
44+
void alignWithOthersToggled(bool state);
4545

4646
void autoHorizontalAligningToggled(bool);
4747

@@ -126,6 +126,8 @@ class DefaultParamsDialog : public QDialog, private Ui::DefaultParamsDialog {
126126

127127
void updateAutoModeButtons();
128128

129+
void updateAlignmentModeEnabled();
130+
129131
QToolButton* getCheckedAlignmentButton() const;
130132

131133
void setLinkButtonLinked(QToolButton* button, bool linked);

DefaultParamsProfileManager.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,40 @@ std::list<QString> DefaultParamsProfileManager::getProfileList() const {
3030
QList<QFileInfo> fileInfoList = dir.entryInfoList();
3131
for (const QFileInfo& fileInfo : fileInfoList) {
3232
if (fileInfo.isFile() && ((fileInfo.suffix() == "stp") || (fileInfo.suffix() == "xml"))) {
33-
profileList.push_back(fileInfo.baseName());
33+
profileList.push_back(fileInfo.completeBaseName());
3434
}
3535
}
3636
}
3737

3838
return profileList;
3939
}
4040

41-
std::unique_ptr<DefaultParams> DefaultParamsProfileManager::readProfile(const QString& name) const {
41+
std::unique_ptr<DefaultParams> DefaultParamsProfileManager::readProfile(const QString& name, LoadStatus* status) const {
4242
QDir dir(m_path);
4343
QFileInfo profile(dir.absoluteFilePath(name + ".stp"));
4444
if (!profile.exists()) {
4545
profile = dir.absoluteFilePath(name + ".xml");
4646
if (!profile.exists()) {
47+
if (status) {
48+
*status = IO_ERROR;
49+
}
4750
return nullptr;
4851
}
4952
}
5053

5154
QFile profileFile(profile.filePath());
5255
if (!profileFile.open(QIODevice::ReadOnly)) {
56+
if (status) {
57+
*status = IO_ERROR;
58+
}
5359
return nullptr;
5460
}
5561

5662
QDomDocument doc;
5763
if (!doc.setContent(&profileFile)) {
64+
if (status) {
65+
*status = IO_ERROR;
66+
}
5867
return nullptr;
5968
}
6069

@@ -63,10 +72,16 @@ std::unique_ptr<DefaultParams> DefaultParamsProfileManager::readProfile(const QS
6372
const QDomElement profileElement(doc.documentElement());
6473
const QString version = profileElement.attribute("version");
6574
if (version.isNull() || (version.toInt() != PROJECT_VERSION)) {
75+
if (status) {
76+
*status = INCOMPATIBLE_VERSION_ERROR;
77+
}
6678
return nullptr;
6779
}
6880
const QDomElement defaultParamsElement(profileElement.namedItem("default-params").toElement());
6981

82+
if (status) {
83+
*status = SUCCESS;
84+
}
7085
return std::make_unique<DefaultParams>(defaultParamsElement);
7186
}
7287

DefaultParamsProfileManager.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ class DefaultParamsProfileManager {
1717

1818
explicit DefaultParamsProfileManager(const QString& path);
1919

20+
enum LoadStatus {
21+
SUCCESS,
22+
IO_ERROR,
23+
INCOMPATIBLE_VERSION_ERROR
24+
};
25+
2026
std::list<QString> getProfileList() const;
2127

22-
std::unique_ptr<DefaultParams> readProfile(const QString& name) const;
28+
std::unique_ptr<DefaultParams> readProfile(const QString& name, LoadStatus* status = nullptr) const;
2329

2430
bool writeProfile(const DefaultParams& params, const QString& name) const;
2531

MainWindow.cpp

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,20 @@ MainWindow::MainWindow()
225225
connect(actionNextSelectedPageW, SIGNAL(triggered(bool)), this, SLOT(goNextSelectedPage()));
226226
connect(actionAbout, SIGNAL(triggered(bool)), this, SLOT(showAboutDialog()));
227227
connect(&OutOfMemoryHandler::instance(), SIGNAL(outOfMemory()), SLOT(handleOutOfMemorySituation()));
228+
connect(prevPageBtn, &QToolButton::clicked, this, [this]() {
229+
if (filterSelectedBtn->isChecked()) {
230+
goPrevSelectedPage();
231+
} else {
232+
goPrevPage();
233+
}
234+
});
235+
connect(nextPageBtn, &QToolButton::clicked, this, [this]() {
236+
if (filterSelectedBtn->isChecked()) {
237+
goNextSelectedPage();
238+
} else {
239+
goNextPage();
240+
}
241+
});
228242

229243
connect(actionSwitchFilter1, SIGNAL(triggered(bool)), SLOT(switchFilter1()));
230244
connect(actionSwitchFilter2, SIGNAL(triggered(bool)), SLOT(switchFilter2()));
@@ -283,6 +297,12 @@ MainWindow::MainWindow()
283297
}
284298
}
285299
m_autoSaveProject = settings.value("settings/auto_save_project").toBool();
300+
301+
m_maxLogicalThumbSizeUpdater.setSingleShot(true);
302+
connect(&m_maxLogicalThumbSizeUpdater, &QTimer::timeout, this, &MainWindow::updateMaxLogicalThumbSize);
303+
304+
m_sceneItemsPosUpdater.setSingleShot(true);
305+
connect(&m_sceneItemsPosUpdater, &QTimer::timeout, m_thumbSequence.get(), &ThumbnailSequence::updateSceneItemsPos);
286306
}
287307

288308
MainWindow::~MainWindow() {
@@ -438,23 +458,27 @@ void MainWindow::createBatchProcessingWidget() {
438458
connect(stop_btn, SIGNAL(clicked()), SLOT(stopBatchProcessing()));
439459
} // MainWindow::createBatchProcessingWidget
440460

441-
void MainWindow::setupThumbView() {
461+
void MainWindow::updateThumbViewMinWidth() {
442462
const int sb = thumbView->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
443463
int inner_width = thumbView->maximumViewportSize().width() - sb;
444464
if (thumbView->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, thumbView)) {
445465
inner_width -= thumbView->frameWidth() * 2;
446466
}
447467
const int delta_x = thumbView->size().width() - inner_width;
448468
thumbView->setMinimumWidth((int) std::ceil(m_maxLogicalThumbSize.width() + delta_x));
469+
}
449470

471+
void MainWindow::setupThumbView() {
472+
updateThumbViewMinWidth();
450473
m_thumbSequence->attachView(thumbView);
451-
452474
thumbView->installEventFilter(this);
453475
}
454476

455477
bool MainWindow::eventFilter(QObject* obj, QEvent* ev) {
456478
if ((obj == thumbView) && (ev->type() == QEvent::Resize)) {
457-
emit invalidateAllThumbnails();
479+
if (!m_sceneItemsPosUpdater.isActive()) {
480+
m_sceneItemsPosUpdater.start(150);
481+
}
458482
}
459483

460484
if ((obj == thumbView || obj == thumbView->verticalScrollBar()) && (ev->type() == QEvent::Wheel)) {
@@ -1385,19 +1409,32 @@ void MainWindow::openDefaultParamsDialog() {
13851409

13861410
void MainWindow::onSettingsChanged() {
13871411
QSettings settings;
1412+
bool need_invalidate = true;
13881413

13891414
m_autoSaveProject = settings.value("settings/auto_save_project").toBool();
13901415

13911416
if (auto* app = dynamic_cast<Application*>(qApp)) {
13921417
app->installLanguage(settings.value("settings/language").toString());
13931418
}
13941419

1420+
if (m_thumbnailCache) {
1421+
const QSize max_thumb_size = settings.value("settings/thumbnail_quality").toSize();
1422+
if (m_thumbnailCache->getMaxThumbSize() != max_thumb_size) {
1423+
m_thumbnailCache->setMaxThumbSize(max_thumb_size);
1424+
need_invalidate = true;
1425+
}
1426+
}
1427+
13951428
const QSizeF max_logical_thumb_size = settings.value("settings/max_logical_thumb_size").toSizeF();
13961429
if (m_maxLogicalThumbSize != max_logical_thumb_size) {
1397-
updateMaxLogicalThumbSize(max_logical_thumb_size);
1430+
m_maxLogicalThumbSize = max_logical_thumb_size;
1431+
updateMaxLogicalThumbSize();
1432+
need_invalidate = false;
13981433
}
13991434

1400-
m_thumbSequence->invalidateAllThumbnails();
1435+
if (need_invalidate) {
1436+
m_thumbSequence->invalidateAllThumbnails();
1437+
}
14011438
}
14021439

14031440
void MainWindow::showAboutDialog() {
@@ -1567,7 +1604,7 @@ void MainWindow::updateWindowTitle() {
15671604
} else if (cli.hasWindowTitle()) {
15681605
project_name = cli.getWindowTitle();
15691606
} else {
1570-
project_name = QFileInfo(m_projectFile).baseName();
1607+
project_name = QFileInfo(m_projectFile).completeBaseName();
15711608
}
15721609
const QString version(QString::fromUtf8(VERSION));
15731610
setWindowTitle(tr("%2 - ScanTailor Advanced [%1bit]").arg(sizeof(void*) * 8).arg(project_name));
@@ -2015,16 +2052,17 @@ void MainWindow::scaleThumbnails(const QWheelEvent* wheel_event) {
20152052
const double dy = std::copysign(16.0, wheel_dist);
20162053
const double width = qBound(100.0, m_maxLogicalThumbSize.width() + dx, 1000.0);
20172054
const double height = qBound(64.0, m_maxLogicalThumbSize.height() + dy, 640.0);
2018-
updateMaxLogicalThumbSize(QSizeF(width, height));
2055+
m_maxLogicalThumbSize = QSizeF(width, height);
2056+
if (!m_maxLogicalThumbSizeUpdater.isActive()) {
2057+
m_maxLogicalThumbSizeUpdater.start(350);
2058+
}
20192059

20202060
QSettings().setValue("settings/max_logical_thumb_size", m_maxLogicalThumbSize);
20212061
}
20222062
}
20232063

2024-
void MainWindow::updateMaxLogicalThumbSize(const QSizeF& size) {
2025-
m_maxLogicalThumbSize = size;
2026-
2064+
void MainWindow::updateMaxLogicalThumbSize() {
20272065
m_thumbSequence->setMaxLogicalThumbSize(m_maxLogicalThumbSize);
2028-
setupThumbView();
2066+
updateThumbViewMinWidth();
20292067
resetThumbSequence(currentPageOrderProvider(), ThumbnailSequence::KEEP_SELECTION);
2030-
}
2068+
}

MainWindow.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ class MainWindow : public QMainWindow, private FilterUiInterface, private Ui::Ma
218218
const QString& project_file_path = QString(),
219219
const ProjectReader* project_reader = nullptr);
220220

221+
void updateThumbViewMinWidth();
222+
221223
void setupThumbView();
222224

223225
void showNewOpenProjectPanel();
@@ -297,7 +299,7 @@ class MainWindow : public QMainWindow, private FilterUiInterface, private Ui::Ma
297299

298300
void scaleThumbnails(const QWheelEvent* wheel_event);
299301

300-
void updateMaxLogicalThumbSize(const QSizeF& size);
302+
void updateMaxLogicalThumbSize();
301303

302304
QSizeF m_maxLogicalThumbSize;
303305
intrusive_ptr<ProjectPages> m_pages;
@@ -332,6 +334,8 @@ class MainWindow : public QMainWindow, private FilterUiInterface, private Ui::Ma
332334
bool m_autoSaveProject;
333335
std::unique_ptr<StatusBarPanel> m_statusBarPanel;
334336
std::unique_ptr<QActionGroup> m_unitsMenuActionGroup;
337+
QTimer m_maxLogicalThumbSizeUpdater;
338+
QTimer m_sceneItemsPosUpdater;
335339
};
336340

337341

NewOpenProjectPanel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ NewOpenProjectPanel::NewOpenProjectPanel(QWidget* parent) : QWidget(parent) {
4949

5050
void NewOpenProjectPanel::addRecentProject(const QString& file_path) {
5151
const QFileInfo file_info(file_path);
52-
QString base_name(file_info.baseName());
52+
QString base_name(file_info.completeBaseName());
5353
if (base_name.isEmpty()) {
5454
base_name = QChar('_');
5555
}

0 commit comments

Comments
 (0)