Skip to content

Commit

Permalink
Version 1.0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
4lex4 committed Mar 2, 2018
2 parents 442220f + 755e315 commit a30d503
Show file tree
Hide file tree
Showing 62 changed files with 2,611 additions and 1,590 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ SET(
PageSelectionAccessor.cpp PageSelectionAccessor.h
PageSelectionProvider.h
ContentSpanFinder.cpp ContentSpanFinder.h
PhysicalTransformation.cpp PhysicalTransformation.h
ImageTransformation.cpp ImageTransformation.h
ImagePixmapUnion.h
ImageViewBase.cpp ImageViewBase.h
Expand Down
4 changes: 0 additions & 4 deletions CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,6 @@ page_layout::Alignment CommandLine::fetchAlignment() {
}
}

if (m_options.contains("alignment-tolerance")) {
alignment.setTolerance(m_options["alignment-tolerance"].toFloat());
}

if (m_options.contains("alignment")) {
if (m_options["alignment"] == "original") {
alignment.setVertical(page_layout::Alignment::VORIGINAL);
Expand Down
166 changes: 141 additions & 25 deletions DefaultParamsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ DefaultParamsDialog::DefaultParamsDialog(QWidget* parent)
Alignment(Alignment::BOTTOM, Alignment::RIGHT)
);

alignmentButtonGroup = std::make_unique<QButtonGroup>(this);
for (const auto& buttonAndAlignment : alignmentByButton) {
alignmentButtonGroup->addButton(buttonAndAlignment.first);
}

darkerThresholdLink->setText(
Utils::richTextForLink(darkerThresholdLink->text())
);
Expand Down Expand Up @@ -239,21 +244,40 @@ void DefaultParamsDialog::updatePageLayoutDisplay(const DefaultParams::PageLayou
setLinkButtonLinked(leftRightLink, leftRightLinkEnabled);

const Alignment& alignment = params.getAlignment();
if (alignment.vertical() == Alignment::VAUTO) {
if (alignment.isAuto()) {
alignmentMode->setCurrentIndex(0);
alignButtonsWidget->setEnabled(false);
} else if (alignment.vertical() == Alignment::VORIGINAL) {
autoAlignSettingsGroup->setVisible(true);
autoVerticalAligningCB->setChecked(alignment.isAutoVertical());
autoHorizontalAligningCB->setChecked(alignment.isAutoHorizontal());
} else if (alignment.isOriginal()) {
alignmentMode->setCurrentIndex(2);
alignButtonsWidget->setEnabled(false);
autoAlignSettingsGroup->setVisible(true);
autoVerticalAligningCB->setChecked(alignment.isAutoVertical());
autoHorizontalAligningCB->setChecked(alignment.isAutoHorizontal());
} else {
alignmentMode->setCurrentIndex(1);
alignButtonsWidget->setEnabled(!alignment.isNull());
autoAlignSettingsGroup->setVisible(false);
}
updateAlignmentButtonsEnabled();
updateAutoModeButtons();

alignWithOthersCB->setChecked(!alignment.isNull());

for (const auto& value : alignmentByButton) {
if (value.second == alignment) {
value.first->setChecked(true);
for (const auto& kv : alignmentByButton) {
if (alignment.isAuto() || alignment.isOriginal()) {
if (!alignment.isAutoHorizontal()
&& (kv.second.vertical() == Alignment::VCENTER)
&& (kv.second.horizontal() == alignment.horizontal())) {
kv.first->setChecked(true);
break;
} else if (!alignment.isAutoVertical()
&& (kv.second.horizontal() == Alignment::HCENTER)
&& (kv.second.vertical() == alignment.vertical())) {
kv.first->setChecked(true);
break;
}
} else if (kv.second == alignment) {
kv.first->setChecked(true);
break;
}
}
Expand Down Expand Up @@ -393,6 +417,8 @@ void DefaultParamsDialog::setupUiConnections() {
connect(profileDeleteButton, SIGNAL(pressed()), this, SLOT(profileDeletePressed()));
connect(colorSegmentationCB, SIGNAL(clicked(bool)), this, SLOT(colorSegmentationToggled(bool)));
connect(posterizeCB, SIGNAL(clicked(bool)), this, SLOT(posterizeToggled(bool)));
connect(autoHorizontalAligningCB, SIGNAL(toggled(bool)), this, SLOT(autoHorizontalAligningToggled(bool)));
connect(autoVerticalAligningCB, SIGNAL(toggled(bool)), this, SLOT(autoVerticalAligningToggled(bool)));
}

void DefaultParamsDialog::removeUiConnections() {
Expand Down Expand Up @@ -432,6 +458,8 @@ void DefaultParamsDialog::removeUiConnections() {
disconnect(profileDeleteButton, SIGNAL(pressed()), this, SLOT(profileDeletePressed()));
disconnect(colorSegmentationCB, SIGNAL(clicked(bool)), this, SLOT(colorSegmentationToggled(bool)));
disconnect(posterizeCB, SIGNAL(clicked(bool)), this, SLOT(posterizeToggled(bool)));
disconnect(autoHorizontalAligningCB, SIGNAL(toggled(bool)), this, SLOT(autoHorizontalAligningToggled(bool)));
disconnect(autoVerticalAligningCB, SIGNAL(toggled(bool)), this, SLOT(autoVerticalAligningToggled(bool)));
}

void DefaultParamsDialog::rotateLeft() {
Expand Down Expand Up @@ -522,13 +550,13 @@ void DefaultParamsDialog::autoMarginsToggled(const bool checked) {
}

void DefaultParamsDialog::alignmentModeChanged(const int idx) {
const bool enabled = alignWithOthersCB->isChecked() && (idx == 1);
alignButtonsWidget->setEnabled(enabled);
autoAlignSettingsGroup->setVisible((idx == 0) || (idx == 2));
updateAlignmentButtonsEnabled();
updateAutoModeButtons();
}

void DefaultParamsDialog::alignWithOthersToggled(const bool checked) {
const bool enabled = checked && (alignmentMode->currentIndex() == 1);
alignButtonsWidget->setEnabled(enabled);
void DefaultParamsDialog::alignWithOthersToggled(const bool) {
updateAlignmentButtonsEnabled();
}

void DefaultParamsDialog::colorModeChanged(const int idx) {
Expand Down Expand Up @@ -664,23 +692,30 @@ std::unique_ptr<DefaultParams> DefaultParamsDialog::buildParams() const {
Alignment alignment;
switch (alignmentMode->currentIndex()) {
case 0:
alignment.setVertical(Alignment::VAUTO);
alignment.setHorizontal(Alignment::HCENTER);
if (autoVerticalAligningCB->isChecked()) {
alignment.setVertical(Alignment::VAUTO);
} else {
alignment.setVertical(alignmentByButton.at(getCheckedAlignmentButton()).vertical());
}
if (autoHorizontalAligningCB->isChecked()) {
alignment.setHorizontal(Alignment::HAUTO);
} else {
alignment.setHorizontal(alignmentByButton.at(getCheckedAlignmentButton()).horizontal());
}
break;
case 1:
for (auto item : alignmentByButton) {
if (item.first->isChecked()) {
alignment = item.second;
break;
}
}
alignment = alignmentByButton.at(getCheckedAlignmentButton());
break;
case 2:
alignment.setVertical(Alignment::VORIGINAL);
if (autoMargins->isChecked()) {
if (autoVerticalAligningCB->isChecked()) {
alignment.setVertical(Alignment::VORIGINAL);
} else {
alignment.setVertical(alignmentByButton.at(getCheckedAlignmentButton()).vertical());
}
if (autoHorizontalAligningCB->isChecked()) {
alignment.setHorizontal(Alignment::HORIGINAL);
} else {
alignment.setHorizontal(Alignment::HCENTER);
alignment.setHorizontal(alignmentByButton.at(getCheckedAlignmentButton()).horizontal());
}
break;
default:
Expand Down Expand Up @@ -793,7 +828,7 @@ std::unique_ptr<DefaultParams> DefaultParamsDialog::buildParams() const {

void DefaultParamsDialog::updateUnits(const Units units) {
currentUnits = units;
unitsLabel->setText(unitsToString(units));
unitsLabel->setText(unitsToLocalizedString(units));

{
int decimals;
Expand Down Expand Up @@ -1089,3 +1124,84 @@ void DefaultParamsDialog::colorSegmentationToggled(bool checked) {
void DefaultParamsDialog::posterizeToggled(bool checked) {
posterizeOptionsWidget->setEnabled(checked);
}

void DefaultParamsDialog::updateAlignmentButtonsEnabled() {
bool enableHorizontalButtons;
bool enableVerticalButtons;
if ((alignmentMode->currentIndex() == 0) || (alignmentMode->currentIndex() == 2)) {
enableHorizontalButtons = !autoHorizontalAligningCB->isChecked() ? alignWithOthersCB->isChecked()
: false;
enableVerticalButtons = !autoVerticalAligningCB->isChecked() ? alignWithOthersCB->isChecked()
: false;
} else {
enableHorizontalButtons = enableVerticalButtons = alignWithOthersCB->isChecked();
}

alignTopLeftBtn->setEnabled(enableHorizontalButtons && enableVerticalButtons);
alignTopBtn->setEnabled(enableVerticalButtons);
alignTopRightBtn->setEnabled(enableHorizontalButtons && enableVerticalButtons);
alignLeftBtn->setEnabled(enableHorizontalButtons);
alignCenterBtn->setEnabled(enableHorizontalButtons || enableVerticalButtons);
alignRightBtn->setEnabled(enableHorizontalButtons);
alignBottomLeftBtn->setEnabled(enableHorizontalButtons && enableVerticalButtons);
alignBottomBtn->setEnabled(enableVerticalButtons);
alignBottomRightBtn->setEnabled(enableHorizontalButtons && enableVerticalButtons);
}

void DefaultParamsDialog::updateAutoModeButtons() {
if ((alignmentMode->currentIndex() == 0) || (alignmentMode->currentIndex() == 2)) {
if (autoVerticalAligningCB->isChecked() && !autoHorizontalAligningCB->isChecked()) {
autoVerticalAligningCB->setEnabled(false);
} else if (autoHorizontalAligningCB->isChecked() && !autoVerticalAligningCB->isChecked()) {
autoHorizontalAligningCB->setEnabled(false);
} else {
autoVerticalAligningCB->setEnabled(true);
autoHorizontalAligningCB->setEnabled(true);
}
}

if (autoVerticalAligningCB->isChecked() && !autoHorizontalAligningCB->isChecked()) {
switch (alignmentByButton.at(getCheckedAlignmentButton()).horizontal()) {
case Alignment::LEFT:
alignLeftBtn->setChecked(true);
break;
case Alignment::RIGHT:
alignRightBtn->setChecked(true);
break;
default:
alignCenterBtn->setChecked(true);
break;
}
} else if (autoHorizontalAligningCB->isChecked() && !autoVerticalAligningCB->isChecked()) {
switch (alignmentByButton.at(getCheckedAlignmentButton()).vertical()) {
case Alignment::TOP:
alignTopBtn->setChecked(true);
break;
case Alignment::BOTTOM:
alignBottomBtn->setChecked(true);
break;
default:
alignCenterBtn->setChecked(true);
break;
}
}
}

QToolButton* DefaultParamsDialog::getCheckedAlignmentButton() const {
auto* checkedButton = dynamic_cast<QToolButton*>(alignmentButtonGroup->checkedButton());
if (!checkedButton) {
checkedButton = alignCenterBtn;
}

return checkedButton;
}

void DefaultParamsDialog::autoHorizontalAligningToggled(bool) {
updateAlignmentButtonsEnabled();
updateAutoModeButtons();
}

void DefaultParamsDialog::autoVerticalAligningToggled(bool) {
updateAlignmentButtonsEnabled();
updateAutoModeButtons();
}
13 changes: 12 additions & 1 deletion DefaultParamsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Q_OBJECT
int ignoreMarginChanges;
OrthogonalRotation orthogonalRotation;
std::unordered_map<QToolButton*, page_layout::Alignment> alignmentByButton;
std::unique_ptr<QButtonGroup> alignmentButtonGroup;
DefaultParamsProfileManager profileManager;
int customDpiItemIdx;
QString customDpiValue;
Expand Down Expand Up @@ -55,7 +56,11 @@ private slots:

void alignmentModeChanged(int idx);

void alignWithOthersToggled(bool checked);
void alignWithOthersToggled(bool);

void autoHorizontalAligningToggled(bool);

void autoVerticalAligningToggled(bool);

void topBottomLinkClicked();

Expand Down Expand Up @@ -128,6 +133,12 @@ private slots:

void setRotationPixmap();

void updateAlignmentButtonsEnabled();

void updateAutoModeButtons();

QToolButton* getCheckedAlignmentButton() const;

void setLinkButtonLinked(QToolButton* button, bool linked);

void loadParams(const DefaultParams& params);
Expand Down
3 changes: 2 additions & 1 deletion ImageId.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define IMAGEID_H_

#include <QString>
#include <foundation/Hashes.h>

class QFileInfo;

Expand Down Expand Up @@ -84,7 +85,7 @@ namespace std {
template<>
struct hash<ImageId> {
size_t operator()(const ImageId& imageId) const noexcept {
return (hash<string>()(imageId.filePath().toStdString())
return (hashes::hash<QString>()(imageId.filePath())
^ hash<int>()(imageId.page()) << 1);
}
};
Expand Down
17 changes: 16 additions & 1 deletion ImageViewBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ void ImageViewBase::mousePressEvent(QMouseEvent* event) {
m_rootInteractionHandler.mousePressEvent(event, m_interactionState);
event->setAccepted(true);
updateStatusTipAndCursor();
void maybeQueueRedraw();
maybeQueueRedraw();
}

void ImageViewBase::mouseReleaseEvent(QMouseEvent* event) {
Expand All @@ -526,6 +526,21 @@ void ImageViewBase::mouseReleaseEvent(QMouseEvent* event) {
maybeQueueRedraw();
}

void ImageViewBase::mouseDoubleClickEvent(QMouseEvent* event) {
m_interactionState.resetProximity();
if (!m_interactionState.captured()) {
m_rootInteractionHandler.proximityUpdate(
QPointF(0.5, 0.5) + event->pos(), m_interactionState
);
}

event->setAccepted(false);
m_rootInteractionHandler.mouseDoubleClickEvent(event, m_interactionState);
event->setAccepted(true);
updateStatusTipAndCursor();
maybeQueueRedraw();
}

void ImageViewBase::mouseMoveEvent(QMouseEvent* event) {
m_interactionState.resetProximity();
if (!m_interactionState.captured()) {
Expand Down
2 changes: 2 additions & 0 deletions ImageViewBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ Q_OBJECT

void mouseReleaseEvent(QMouseEvent* event) override;

void mouseDoubleClickEvent(QMouseEvent* event) override;

void mouseMoveEvent(QMouseEvent* event) override;

void wheelEvent(QWheelEvent* event) override;
Expand Down
Loading

0 comments on commit a30d503

Please sign in to comment.