Skip to content

Commit a30d503

Browse files
committed
Version 1.0.12
2 parents 442220f + 755e315 commit a30d503

Some content is hidden

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

62 files changed

+2611
-1590
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ SET(
475475
PageSelectionAccessor.cpp PageSelectionAccessor.h
476476
PageSelectionProvider.h
477477
ContentSpanFinder.cpp ContentSpanFinder.h
478-
PhysicalTransformation.cpp PhysicalTransformation.h
479478
ImageTransformation.cpp ImageTransformation.h
480479
ImagePixmapUnion.h
481480
ImageViewBase.cpp ImageViewBase.h

CommandLine.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,6 @@ page_layout::Alignment CommandLine::fetchAlignment() {
523523
}
524524
}
525525

526-
if (m_options.contains("alignment-tolerance")) {
527-
alignment.setTolerance(m_options["alignment-tolerance"].toFloat());
528-
}
529-
530526
if (m_options.contains("alignment")) {
531527
if (m_options["alignment"] == "original") {
532528
alignment.setVertical(page_layout::Alignment::VORIGINAL);

DefaultParamsDialog.cpp

Lines changed: 141 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ DefaultParamsDialog::DefaultParamsDialog(QWidget* parent)
123123
Alignment(Alignment::BOTTOM, Alignment::RIGHT)
124124
);
125125

126+
alignmentButtonGroup = std::make_unique<QButtonGroup>(this);
127+
for (const auto& buttonAndAlignment : alignmentByButton) {
128+
alignmentButtonGroup->addButton(buttonAndAlignment.first);
129+
}
130+
126131
darkerThresholdLink->setText(
127132
Utils::richTextForLink(darkerThresholdLink->text())
128133
);
@@ -239,21 +244,40 @@ void DefaultParamsDialog::updatePageLayoutDisplay(const DefaultParams::PageLayou
239244
setLinkButtonLinked(leftRightLink, leftRightLinkEnabled);
240245

241246
const Alignment& alignment = params.getAlignment();
242-
if (alignment.vertical() == Alignment::VAUTO) {
247+
if (alignment.isAuto()) {
243248
alignmentMode->setCurrentIndex(0);
244-
alignButtonsWidget->setEnabled(false);
245-
} else if (alignment.vertical() == Alignment::VORIGINAL) {
249+
autoAlignSettingsGroup->setVisible(true);
250+
autoVerticalAligningCB->setChecked(alignment.isAutoVertical());
251+
autoHorizontalAligningCB->setChecked(alignment.isAutoHorizontal());
252+
} else if (alignment.isOriginal()) {
246253
alignmentMode->setCurrentIndex(2);
247-
alignButtonsWidget->setEnabled(false);
254+
autoAlignSettingsGroup->setVisible(true);
255+
autoVerticalAligningCB->setChecked(alignment.isAutoVertical());
256+
autoHorizontalAligningCB->setChecked(alignment.isAutoHorizontal());
248257
} else {
249258
alignmentMode->setCurrentIndex(1);
250-
alignButtonsWidget->setEnabled(!alignment.isNull());
259+
autoAlignSettingsGroup->setVisible(false);
251260
}
261+
updateAlignmentButtonsEnabled();
262+
updateAutoModeButtons();
263+
252264
alignWithOthersCB->setChecked(!alignment.isNull());
253265

254-
for (const auto& value : alignmentByButton) {
255-
if (value.second == alignment) {
256-
value.first->setChecked(true);
266+
for (const auto& kv : alignmentByButton) {
267+
if (alignment.isAuto() || alignment.isOriginal()) {
268+
if (!alignment.isAutoHorizontal()
269+
&& (kv.second.vertical() == Alignment::VCENTER)
270+
&& (kv.second.horizontal() == alignment.horizontal())) {
271+
kv.first->setChecked(true);
272+
break;
273+
} else if (!alignment.isAutoVertical()
274+
&& (kv.second.horizontal() == Alignment::HCENTER)
275+
&& (kv.second.vertical() == alignment.vertical())) {
276+
kv.first->setChecked(true);
277+
break;
278+
}
279+
} else if (kv.second == alignment) {
280+
kv.first->setChecked(true);
257281
break;
258282
}
259283
}
@@ -393,6 +417,8 @@ void DefaultParamsDialog::setupUiConnections() {
393417
connect(profileDeleteButton, SIGNAL(pressed()), this, SLOT(profileDeletePressed()));
394418
connect(colorSegmentationCB, SIGNAL(clicked(bool)), this, SLOT(colorSegmentationToggled(bool)));
395419
connect(posterizeCB, SIGNAL(clicked(bool)), this, SLOT(posterizeToggled(bool)));
420+
connect(autoHorizontalAligningCB, SIGNAL(toggled(bool)), this, SLOT(autoHorizontalAligningToggled(bool)));
421+
connect(autoVerticalAligningCB, SIGNAL(toggled(bool)), this, SLOT(autoVerticalAligningToggled(bool)));
396422
}
397423

398424
void DefaultParamsDialog::removeUiConnections() {
@@ -432,6 +458,8 @@ void DefaultParamsDialog::removeUiConnections() {
432458
disconnect(profileDeleteButton, SIGNAL(pressed()), this, SLOT(profileDeletePressed()));
433459
disconnect(colorSegmentationCB, SIGNAL(clicked(bool)), this, SLOT(colorSegmentationToggled(bool)));
434460
disconnect(posterizeCB, SIGNAL(clicked(bool)), this, SLOT(posterizeToggled(bool)));
461+
disconnect(autoHorizontalAligningCB, SIGNAL(toggled(bool)), this, SLOT(autoHorizontalAligningToggled(bool)));
462+
disconnect(autoVerticalAligningCB, SIGNAL(toggled(bool)), this, SLOT(autoVerticalAligningToggled(bool)));
435463
}
436464

437465
void DefaultParamsDialog::rotateLeft() {
@@ -522,13 +550,13 @@ void DefaultParamsDialog::autoMarginsToggled(const bool checked) {
522550
}
523551

524552
void DefaultParamsDialog::alignmentModeChanged(const int idx) {
525-
const bool enabled = alignWithOthersCB->isChecked() && (idx == 1);
526-
alignButtonsWidget->setEnabled(enabled);
553+
autoAlignSettingsGroup->setVisible((idx == 0) || (idx == 2));
554+
updateAlignmentButtonsEnabled();
555+
updateAutoModeButtons();
527556
}
528557

529-
void DefaultParamsDialog::alignWithOthersToggled(const bool checked) {
530-
const bool enabled = checked && (alignmentMode->currentIndex() == 1);
531-
alignButtonsWidget->setEnabled(enabled);
558+
void DefaultParamsDialog::alignWithOthersToggled(const bool) {
559+
updateAlignmentButtonsEnabled();
532560
}
533561

534562
void DefaultParamsDialog::colorModeChanged(const int idx) {
@@ -664,23 +692,30 @@ std::unique_ptr<DefaultParams> DefaultParamsDialog::buildParams() const {
664692
Alignment alignment;
665693
switch (alignmentMode->currentIndex()) {
666694
case 0:
667-
alignment.setVertical(Alignment::VAUTO);
668-
alignment.setHorizontal(Alignment::HCENTER);
695+
if (autoVerticalAligningCB->isChecked()) {
696+
alignment.setVertical(Alignment::VAUTO);
697+
} else {
698+
alignment.setVertical(alignmentByButton.at(getCheckedAlignmentButton()).vertical());
699+
}
700+
if (autoHorizontalAligningCB->isChecked()) {
701+
alignment.setHorizontal(Alignment::HAUTO);
702+
} else {
703+
alignment.setHorizontal(alignmentByButton.at(getCheckedAlignmentButton()).horizontal());
704+
}
669705
break;
670706
case 1:
671-
for (auto item : alignmentByButton) {
672-
if (item.first->isChecked()) {
673-
alignment = item.second;
674-
break;
675-
}
676-
}
707+
alignment = alignmentByButton.at(getCheckedAlignmentButton());
677708
break;
678709
case 2:
679-
alignment.setVertical(Alignment::VORIGINAL);
680-
if (autoMargins->isChecked()) {
710+
if (autoVerticalAligningCB->isChecked()) {
711+
alignment.setVertical(Alignment::VORIGINAL);
712+
} else {
713+
alignment.setVertical(alignmentByButton.at(getCheckedAlignmentButton()).vertical());
714+
}
715+
if (autoHorizontalAligningCB->isChecked()) {
681716
alignment.setHorizontal(Alignment::HORIGINAL);
682717
} else {
683-
alignment.setHorizontal(Alignment::HCENTER);
718+
alignment.setHorizontal(alignmentByButton.at(getCheckedAlignmentButton()).horizontal());
684719
}
685720
break;
686721
default:
@@ -793,7 +828,7 @@ std::unique_ptr<DefaultParams> DefaultParamsDialog::buildParams() const {
793828

794829
void DefaultParamsDialog::updateUnits(const Units units) {
795830
currentUnits = units;
796-
unitsLabel->setText(unitsToString(units));
831+
unitsLabel->setText(unitsToLocalizedString(units));
797832

798833
{
799834
int decimals;
@@ -1089,3 +1124,84 @@ void DefaultParamsDialog::colorSegmentationToggled(bool checked) {
10891124
void DefaultParamsDialog::posterizeToggled(bool checked) {
10901125
posterizeOptionsWidget->setEnabled(checked);
10911126
}
1127+
1128+
void DefaultParamsDialog::updateAlignmentButtonsEnabled() {
1129+
bool enableHorizontalButtons;
1130+
bool enableVerticalButtons;
1131+
if ((alignmentMode->currentIndex() == 0) || (alignmentMode->currentIndex() == 2)) {
1132+
enableHorizontalButtons = !autoHorizontalAligningCB->isChecked() ? alignWithOthersCB->isChecked()
1133+
: false;
1134+
enableVerticalButtons = !autoVerticalAligningCB->isChecked() ? alignWithOthersCB->isChecked()
1135+
: false;
1136+
} else {
1137+
enableHorizontalButtons = enableVerticalButtons = alignWithOthersCB->isChecked();
1138+
}
1139+
1140+
alignTopLeftBtn->setEnabled(enableHorizontalButtons && enableVerticalButtons);
1141+
alignTopBtn->setEnabled(enableVerticalButtons);
1142+
alignTopRightBtn->setEnabled(enableHorizontalButtons && enableVerticalButtons);
1143+
alignLeftBtn->setEnabled(enableHorizontalButtons);
1144+
alignCenterBtn->setEnabled(enableHorizontalButtons || enableVerticalButtons);
1145+
alignRightBtn->setEnabled(enableHorizontalButtons);
1146+
alignBottomLeftBtn->setEnabled(enableHorizontalButtons && enableVerticalButtons);
1147+
alignBottomBtn->setEnabled(enableVerticalButtons);
1148+
alignBottomRightBtn->setEnabled(enableHorizontalButtons && enableVerticalButtons);
1149+
}
1150+
1151+
void DefaultParamsDialog::updateAutoModeButtons() {
1152+
if ((alignmentMode->currentIndex() == 0) || (alignmentMode->currentIndex() == 2)) {
1153+
if (autoVerticalAligningCB->isChecked() && !autoHorizontalAligningCB->isChecked()) {
1154+
autoVerticalAligningCB->setEnabled(false);
1155+
} else if (autoHorizontalAligningCB->isChecked() && !autoVerticalAligningCB->isChecked()) {
1156+
autoHorizontalAligningCB->setEnabled(false);
1157+
} else {
1158+
autoVerticalAligningCB->setEnabled(true);
1159+
autoHorizontalAligningCB->setEnabled(true);
1160+
}
1161+
}
1162+
1163+
if (autoVerticalAligningCB->isChecked() && !autoHorizontalAligningCB->isChecked()) {
1164+
switch (alignmentByButton.at(getCheckedAlignmentButton()).horizontal()) {
1165+
case Alignment::LEFT:
1166+
alignLeftBtn->setChecked(true);
1167+
break;
1168+
case Alignment::RIGHT:
1169+
alignRightBtn->setChecked(true);
1170+
break;
1171+
default:
1172+
alignCenterBtn->setChecked(true);
1173+
break;
1174+
}
1175+
} else if (autoHorizontalAligningCB->isChecked() && !autoVerticalAligningCB->isChecked()) {
1176+
switch (alignmentByButton.at(getCheckedAlignmentButton()).vertical()) {
1177+
case Alignment::TOP:
1178+
alignTopBtn->setChecked(true);
1179+
break;
1180+
case Alignment::BOTTOM:
1181+
alignBottomBtn->setChecked(true);
1182+
break;
1183+
default:
1184+
alignCenterBtn->setChecked(true);
1185+
break;
1186+
}
1187+
}
1188+
}
1189+
1190+
QToolButton* DefaultParamsDialog::getCheckedAlignmentButton() const {
1191+
auto* checkedButton = dynamic_cast<QToolButton*>(alignmentButtonGroup->checkedButton());
1192+
if (!checkedButton) {
1193+
checkedButton = alignCenterBtn;
1194+
}
1195+
1196+
return checkedButton;
1197+
}
1198+
1199+
void DefaultParamsDialog::autoHorizontalAligningToggled(bool) {
1200+
updateAlignmentButtonsEnabled();
1201+
updateAutoModeButtons();
1202+
}
1203+
1204+
void DefaultParamsDialog::autoVerticalAligningToggled(bool) {
1205+
updateAlignmentButtonsEnabled();
1206+
updateAutoModeButtons();
1207+
}

DefaultParamsDialog.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Q_OBJECT
2020
int ignoreMarginChanges;
2121
OrthogonalRotation orthogonalRotation;
2222
std::unordered_map<QToolButton*, page_layout::Alignment> alignmentByButton;
23+
std::unique_ptr<QButtonGroup> alignmentButtonGroup;
2324
DefaultParamsProfileManager profileManager;
2425
int customDpiItemIdx;
2526
QString customDpiValue;
@@ -55,7 +56,11 @@ private slots:
5556

5657
void alignmentModeChanged(int idx);
5758

58-
void alignWithOthersToggled(bool checked);
59+
void alignWithOthersToggled(bool);
60+
61+
void autoHorizontalAligningToggled(bool);
62+
63+
void autoVerticalAligningToggled(bool);
5964

6065
void topBottomLinkClicked();
6166

@@ -128,6 +133,12 @@ private slots:
128133

129134
void setRotationPixmap();
130135

136+
void updateAlignmentButtonsEnabled();
137+
138+
void updateAutoModeButtons();
139+
140+
QToolButton* getCheckedAlignmentButton() const;
141+
131142
void setLinkButtonLinked(QToolButton* button, bool linked);
132143

133144
void loadParams(const DefaultParams& params);

ImageId.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define IMAGEID_H_
2121

2222
#include <QString>
23+
#include <foundation/Hashes.h>
2324

2425
class QFileInfo;
2526

@@ -84,7 +85,7 @@ namespace std {
8485
template<>
8586
struct hash<ImageId> {
8687
size_t operator()(const ImageId& imageId) const noexcept {
87-
return (hash<string>()(imageId.filePath().toStdString())
88+
return (hashes::hash<QString>()(imageId.filePath())
8889
^ hash<int>()(imageId.page()) << 1);
8990
}
9091
};

ImageViewBase.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ void ImageViewBase::mousePressEvent(QMouseEvent* event) {
508508
m_rootInteractionHandler.mousePressEvent(event, m_interactionState);
509509
event->setAccepted(true);
510510
updateStatusTipAndCursor();
511-
void maybeQueueRedraw();
511+
maybeQueueRedraw();
512512
}
513513

514514
void ImageViewBase::mouseReleaseEvent(QMouseEvent* event) {
@@ -526,6 +526,21 @@ void ImageViewBase::mouseReleaseEvent(QMouseEvent* event) {
526526
maybeQueueRedraw();
527527
}
528528

529+
void ImageViewBase::mouseDoubleClickEvent(QMouseEvent* event) {
530+
m_interactionState.resetProximity();
531+
if (!m_interactionState.captured()) {
532+
m_rootInteractionHandler.proximityUpdate(
533+
QPointF(0.5, 0.5) + event->pos(), m_interactionState
534+
);
535+
}
536+
537+
event->setAccepted(false);
538+
m_rootInteractionHandler.mouseDoubleClickEvent(event, m_interactionState);
539+
event->setAccepted(true);
540+
updateStatusTipAndCursor();
541+
maybeQueueRedraw();
542+
}
543+
529544
void ImageViewBase::mouseMoveEvent(QMouseEvent* event) {
530545
m_interactionState.resetProximity();
531546
if (!m_interactionState.captured()) {

ImageViewBase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ Q_OBJECT
275275

276276
void mouseReleaseEvent(QMouseEvent* event) override;
277277

278+
void mouseDoubleClickEvent(QMouseEvent* event) override;
279+
278280
void mouseMoveEvent(QMouseEvent* event) override;
279281

280282
void wheelEvent(QWheelEvent* event) override;

0 commit comments

Comments
 (0)