diff --git a/app/fileopscontextmanageritem.cpp b/app/fileopscontextmanageritem.cpp index 688ff3cb..20d60458 100644 --- a/app/fileopscontextmanageritem.cpp +++ b/app/fileopscontextmanageritem.cpp @@ -1,491 +1,490 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Self #include "fileopscontextmanageritem.h" // Qt #include #include #include #include #include #include #include // KDE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include #include #include #include #include // Local #include #include #include #include "fileoperations.h" #include "sidebar.h" namespace Gwenview { struct FileOpsContextManagerItemPrivate { FileOpsContextManagerItem* q; QListView* mThumbnailView; KXMLGUIClient* mXMLGUIClient; SideBarGroup* mGroup; QAction * mCutAction; QAction * mCopyAction; QAction * mPasteAction; QAction * mCopyToAction; QAction * mMoveToAction; QAction * mLinkToAction; QAction * mRenameAction; QAction * mTrashAction; QAction * mDelAction; QAction * mRestoreAction; QAction * mShowPropertiesAction; QAction * mCreateFolderAction; QAction * mOpenWithAction; QList mRegularFileActionList; QList mTrashFileActionList; KService::List mServiceList; KNewFileMenu * mNewFileMenu; bool mInTrash; QPair pasteInfo(const QUrl& targetUrl) { QPair ret; QClipboard* clipboard = QApplication::clipboard(); const QMimeData* mimeData = clipboard->mimeData(); bool canPasteData = false; QList urls; // mimeData can be 0 according to https://bugs.kde.org/show_bug.cgi?id=335053 if (mimeData) { canPasteData = KIO::canPasteMimeData(mimeData); urls = KUrlMimeData::urlsFromMimeData(mimeData); } else { qWarning() << "QApplication::clipboard()->mimeData() is 0!"; } if (!urls.isEmpty() || canPasteData) { // disable the paste action if no writing is supported KFileItem item(KFileItem::Unknown, KFileItem::Unknown, targetUrl); ret.first = KFileItemListProperties(KFileItemList() << item).supportsWriting(); if (urls.count() == 1) { const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, urls.first(), true); ret.second = item.isDir() ? i18nc("@action:inmenu", "Paste One Folder") : i18nc("@action:inmenu", "Paste One File"); } else if (!urls.isEmpty()) { ret.second = i18ncp("@action:inmenu", "Paste One Item", "Paste %1 Items", urls.count()); } else { ret.second = i18nc("@action:inmenu", "Paste Clipboard Contents..."); } } else { ret.first = false; ret.second = i18nc("@action:inmenu", "Paste"); } return ret; } QList urlList() const { QList urlList; KFileItemList list = q->contextManager()->selectedFileItemList(); if (list.count() > 0) { urlList = list.urlList(); } else { QUrl url = q->contextManager()->currentUrl(); Q_ASSERT(url.isValid()); urlList << url; } return urlList; } void updateServiceList() { // This code is inspired from // kdebase/apps/lib/konq/konq_menuactions.cpp // Get list of all distinct mimetypes in selection QStringList mimeTypes; Q_FOREACH(const KFileItem & item, q->contextManager()->selectedFileItemList()) { const QString mimeType = item.mimetype(); if (!mimeTypes.contains(mimeType)) { mimeTypes << mimeType; } } // Query trader mServiceList = KFileItemActions::associatedApplications(mimeTypes, QString()); } QMimeData* selectionMimeData() { QMimeData* mimeData = new QMimeData; KFileItemList list = q->contextManager()->selectedFileItemList(); mimeData->setUrls(list.urlList()); return mimeData; } QUrl pasteTargetUrl() const { // If only one folder is selected, paste inside it, otherwise paste in // current KFileItemList list = q->contextManager()->selectedFileItemList(); if (list.count() == 1 && list.first().isDir()) { return list.first().url(); } else { return q->contextManager()->currentDirUrl(); } } }; static QAction* createSeparator(QObject* parent) { QAction* action = new QAction(parent); action->setSeparator(true); return action; } FileOpsContextManagerItem::FileOpsContextManagerItem(ContextManager* manager, QListView* thumbnailView, KActionCollection* actionCollection, KXMLGUIClient* client) : AbstractContextManagerItem(manager) , d(new FileOpsContextManagerItemPrivate) { d->q = this; d->mThumbnailView = thumbnailView; d->mXMLGUIClient = client; d->mGroup = new SideBarGroup(i18n("File Operations")); setWidget(d->mGroup); EventWatcher::install(d->mGroup, QEvent::Show, this, SLOT(updateSideBarContent())); d->mInTrash = false; d->mNewFileMenu = new KNewFileMenu(Q_NULLPTR, QString(), this); connect(contextManager(), SIGNAL(selectionChanged()), SLOT(updateActions())); connect(contextManager(), SIGNAL(currentDirUrlChanged(QUrl)), SLOT(updateActions())); KActionCategory* file = new KActionCategory(i18nc("@title actions category", "File"), actionCollection); KActionCategory* edit = new KActionCategory(i18nc("@title actions category", "Edit"), actionCollection); d->mCutAction = edit->addAction(KStandardAction::Cut, this, SLOT(cut())); // Copied from Dolphin: // need to remove shift+del from cut action, else the shortcut for deletejob // doesn't work //KF5TODO // d->mCopyAction->setShortcut(QKeySequence()); d->mCopyAction = edit->addAction(KStandardAction::Copy, this, SLOT(copy())); d->mPasteAction = edit->addAction(KStandardAction::Paste, this, SLOT(paste())); d->mCopyToAction = file->addAction("file_copy_to", this, SLOT(copyTo())); d->mCopyToAction->setText(i18nc("Verb", "Copy To...")); actionCollection->setDefaultShortcut(d->mCopyAction, Qt::Key_F7); d->mMoveToAction = file->addAction("file_move_to", this, SLOT(moveTo())); d->mMoveToAction->setText(i18nc("Verb", "Move To...")); actionCollection->setDefaultShortcut(d->mMoveToAction, Qt::Key_F8); d->mLinkToAction = file->addAction("file_link_to", this, SLOT(linkTo())); d->mLinkToAction->setText(i18nc("Verb: create link to the file where user wants", "Link To...")); actionCollection->setDefaultShortcut(d->mLinkToAction, Qt::Key_F9); d->mRenameAction = file->addAction("file_rename", this, SLOT(rename())); d->mRenameAction->setText(i18nc("Verb", "Rename...")); actionCollection->setDefaultShortcut(d->mRenameAction, Qt::Key_F2); d->mTrashAction = file->addAction("file_trash", this, SLOT(trash())); d->mTrashAction->setText(i18nc("Verb", "Trash")); d->mTrashAction->setIcon(QIcon::fromTheme("user-trash")); actionCollection->setDefaultShortcut(d->mTrashAction, Qt::Key_Delete); d->mDelAction = file->addAction("file_delete", this, SLOT(del())); d->mDelAction->setText(i18n("Delete")); d->mDelAction->setIcon(QIcon::fromTheme("edit-delete")); actionCollection->setDefaultShortcut(d->mDelAction, QKeySequence(Qt::ShiftModifier | Qt::Key_Delete)); d->mRestoreAction = file->addAction("file_restore", this, SLOT(restore())); d->mRestoreAction->setText(i18n("Restore")); d->mShowPropertiesAction = file->addAction("file_show_properties", this, SLOT(showProperties())); d->mShowPropertiesAction->setText(i18n("Properties")); d->mShowPropertiesAction->setIcon(QIcon::fromTheme("document-properties")); d->mCreateFolderAction = file->addAction("file_create_folder", this, SLOT(createFolder())); d->mCreateFolderAction->setText(i18n("Create Folder...")); d->mCreateFolderAction->setIcon(QIcon::fromTheme("folder-new")); d->mOpenWithAction = file->addAction("file_open_with"); d->mOpenWithAction->setText(i18n("Open With")); QMenu* menu = new QMenu; d->mOpenWithAction->setMenu(menu); connect(menu, &QMenu::aboutToShow, this, &FileOpsContextManagerItem::populateOpenMenu); connect(menu, &QMenu::triggered, this, &FileOpsContextManagerItem::openWith); d->mRegularFileActionList << d->mRenameAction << d->mTrashAction << d->mDelAction << createSeparator(this) << d->mCopyToAction << d->mMoveToAction << d->mLinkToAction << createSeparator(this) << d->mOpenWithAction << d->mShowPropertiesAction << createSeparator(this) << d->mCreateFolderAction ; d->mTrashFileActionList << d->mRestoreAction << d->mDelAction << createSeparator(this) << d->mShowPropertiesAction ; connect(QApplication::clipboard(), SIGNAL(dataChanged()), SLOT(updatePasteAction())); updatePasteAction(); // Delay action update because it must happen *after* main window has called // createGUI(), otherwise calling d->mXMLGUIClient->plugActionList() will // fail. QMetaObject::invokeMethod(this, "updateActions", Qt::QueuedConnection); } FileOpsContextManagerItem::~FileOpsContextManagerItem() { delete d->mOpenWithAction->menu(); delete d; } void FileOpsContextManagerItem::updateActions() { const int count = contextManager()->selectedFileItemList().count(); const bool selectionNotEmpty = count > 0; const bool urlIsValid = contextManager()->currentUrl().isValid(); const bool dirUrlIsValid = contextManager()->currentDirUrl().isValid(); d->mInTrash = contextManager()->currentDirUrl().scheme() == "trash"; d->mCutAction->setEnabled(selectionNotEmpty); d->mCopyAction->setEnabled(selectionNotEmpty); d->mCopyToAction->setEnabled(selectionNotEmpty); d->mMoveToAction->setEnabled(selectionNotEmpty); d->mLinkToAction->setEnabled(selectionNotEmpty); d->mTrashAction->setEnabled(selectionNotEmpty); d->mRestoreAction->setEnabled(selectionNotEmpty); d->mDelAction->setEnabled(selectionNotEmpty); d->mOpenWithAction->setEnabled(selectionNotEmpty); d->mRenameAction->setEnabled(count == 1); d->mCreateFolderAction->setEnabled(dirUrlIsValid); d->mShowPropertiesAction->setEnabled(dirUrlIsValid || urlIsValid); d->mXMLGUIClient->unplugActionList("file_action_list"); QList& list = d->mInTrash ? d->mTrashFileActionList : d->mRegularFileActionList; d->mXMLGUIClient->plugActionList("file_action_list", list); updateSideBarContent(); } void FileOpsContextManagerItem::updatePasteAction() { QPair info = d->pasteInfo(d->pasteTargetUrl()); d->mPasteAction->setEnabled(info.first); d->mPasteAction->setText(info.second); } void FileOpsContextManagerItem::updateSideBarContent() { if (!d->mGroup->isVisible()) { return; } d->mGroup->clear(); QList& list = d->mInTrash ? d->mTrashFileActionList : d->mRegularFileActionList; Q_FOREACH(QAction * action, list) { if (action->isEnabled() && !action->isSeparator()) { d->mGroup->addAction(action); } } } void FileOpsContextManagerItem::showProperties() { KFileItemList list = contextManager()->selectedFileItemList(); if (list.count() > 0) { KPropertiesDialog::showDialog(list, d->mGroup); } else { QUrl url = contextManager()->currentDirUrl(); KPropertiesDialog::showDialog(url, d->mGroup); } } void FileOpsContextManagerItem::cut() { QMimeData* mimeData = d->selectionMimeData(); KIO::setClipboardDataCut(mimeData, true); QApplication::clipboard()->setMimeData(mimeData); } void FileOpsContextManagerItem::copy() { QMimeData* mimeData = d->selectionMimeData(); KIO::setClipboardDataCut(mimeData, false); QApplication::clipboard()->setMimeData(mimeData); } void FileOpsContextManagerItem::paste() { const bool move = KIO::isClipboardDataCut(QApplication::clipboard()->mimeData()); KIO::pasteClipboard(d->pasteTargetUrl(), d->mGroup, move); } void FileOpsContextManagerItem::trash() { FileOperations::trash(d->urlList(), d->mGroup); } void FileOpsContextManagerItem::del() { FileOperations::del(d->urlList(), d->mGroup); } void FileOpsContextManagerItem::restore() { KIO::RestoreJob *job = KIO::restoreFromTrash(d->urlList()); KJobWidgets::setWindow(job, d->mGroup); job->uiDelegate()->setAutoErrorHandlingEnabled(true); } void FileOpsContextManagerItem::copyTo() { FileOperations::copyTo(d->urlList(), d->mGroup); } void FileOpsContextManagerItem::moveTo() { FileOperations::moveTo(d->urlList(), d->mGroup); } void FileOpsContextManagerItem::linkTo() { FileOperations::linkTo(d->urlList(), d->mGroup); } void FileOpsContextManagerItem::rename() { if (d->mThumbnailView->isVisible()) { QModelIndex index = d->mThumbnailView->currentIndex(); d->mThumbnailView->edit(index); } else { FileOperations::rename(d->urlList().first(), d->mGroup); } } void FileOpsContextManagerItem::createFolder() { QUrl url = contextManager()->currentDirUrl(); d->mNewFileMenu->setParentWidget(d->mGroup); d->mNewFileMenu->setPopupFiles(QList() << url); d->mNewFileMenu->createDirectory(); } void FileOpsContextManagerItem::populateOpenMenu() { QMenu* openMenu = d->mOpenWithAction->menu(); qDeleteAll(openMenu->actions()); d->updateServiceList(); int idx = 0; Q_FOREACH(const KService::Ptr & service, d->mServiceList) { QString text = service->name().replace('&', "&&"); QAction* action = openMenu->addAction(text); action->setIcon(QIcon::fromTheme(service->icon())); action->setData(idx); ++idx; } openMenu->addSeparator(); QAction* action = openMenu->addAction(i18n("Other Application...")); action->setData(-1); } void FileOpsContextManagerItem::openWith(QAction* action) { Q_ASSERT(action); KService::Ptr service; QList list = d->urlList(); bool ok; int idx = action->data().toInt(&ok); GV_RETURN_IF_FAIL(ok); if (idx == -1) { // Other Application... KOpenWithDialog dlg(list, d->mGroup); if (!dlg.exec()) { return; } service = dlg.service(); if (!service) { // User entered a custom command Q_ASSERT(!dlg.text().isEmpty()); KRun::run(dlg.text(), list, d->mGroup); return; } } else { service = d->mServiceList.at(idx); } Q_ASSERT(service); KRun::run(*service, list, d->mGroup); } } // namespace diff --git a/lib/crop/cropwidget.cpp b/lib/crop/cropwidget.cpp index c7085ed5..aaf257da 100644 --- a/lib/crop/cropwidget.cpp +++ b/lib/crop/cropwidget.cpp @@ -1,320 +1,320 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2007 Aurélien Gâteau This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Self // Qt #include #include #include #include #include // KDE #include #include #include #include // Local #include #include "croptool.h" #include "signalblocker.h" #include "ui_cropwidget.h" #include "cropwidget.h" namespace Gwenview { // Euclidean algorithm to compute the greatest common divisor of two integers. // Found at: // http://en.wikipedia.org/wiki/Euclidean_algorithm static int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } static QSize screenRatio() { const QRect rect = QApplication::desktop()->screenGeometry(); const int width = rect.width(); const int height = rect.height(); const int divisor = gcd(width, height); return QSize(width / divisor, height / divisor); } struct CropWidgetPrivate : public Ui_CropWidget { CropWidget* q; Document::Ptr mDocument; CropTool* mCropTool; bool mUpdatingFromCropTool; bool ratioIsConstrained() const { return cropRatio() > 0; } double cropRatio() const { int index = ratioComboBox->currentIndex(); if (index != -1 && ratioComboBox->currentText() == ratioComboBox->itemText(index)) { // Get ratio from predefined value // Note: We check currentText is itemText(currentIndex) because // currentIndex is not reset to -1 when text is edited by hand. QSizeF size = ratioComboBox->itemData(index).toSizeF(); return size.height() / size.width(); } // Not a predefined value, extract ratio from the combobox text const QStringList lst = ratioComboBox->currentText().split(':'); if (lst.size() != 2) { return 0; } bool ok; const double width = lst[0].toDouble(&ok); if (!ok) { return 0; } const double height = lst[1].toDouble(&ok); if (!ok) { return 0; } return height / width; } void addRatioToComboBox(const QSizeF& size, const QString& label = QString()) { QString text = label.isEmpty() ? QString("%1:%2").arg(size.width()).arg(size.height()) : label; ratioComboBox->addItem(text, QVariant(size)); } void addSectionHeaderToComboBox(const QString& title) { // Insert a line ratioComboBox->insertSeparator(ratioComboBox->count()); // Insert our section header // This header is made of a separator with a text. We reset // Qt::AccessibleDescriptionRole to the header text otherwise QComboBox // delegate will draw a separator line instead of our text. int index = ratioComboBox->count(); ratioComboBox->insertSeparator(index); ratioComboBox->setItemText(index, title); ratioComboBox->setItemData(index, title, Qt::AccessibleDescriptionRole); ratioComboBox->setItemData(index, Qt::AlignHCenter, Qt::TextAlignmentRole); } void initRatioComboBox() { QList ratioList; const qreal sqrt2 = qSqrt(2.); ratioList << QSizeF(7, 5) << QSizeF(3, 2) << QSizeF(4, 3) << QSizeF(5, 4); addRatioToComboBox(QSizeF(1, 1), i18n("Square")); addRatioToComboBox(screenRatio(), i18n("This Screen")); addSectionHeaderToComboBox(i18n("Landscape")); Q_FOREACH(const QSizeF& size, ratioList) { addRatioToComboBox(size); } addRatioToComboBox(QSizeF(sqrt2, 1), i18n("ISO Size (A4, A3...)")); addRatioToComboBox(QSizeF(11, 8.5), i18n("US Letter")); addSectionHeaderToComboBox(i18n("Portrait")); Q_FOREACH(QSizeF size, ratioList) { size.transpose(); addRatioToComboBox(size); } addRatioToComboBox(QSizeF(1, sqrt2), i18n("ISO Size (A4, A3...)")); addRatioToComboBox(QSizeF(8.5, 11), i18n("US Letter")); ratioComboBox->setMaxVisibleItems(ratioComboBox->count()); ratioComboBox->setEditText(QString()); KLineEdit* edit = qobject_cast(ratioComboBox->lineEdit()); Q_ASSERT(edit); // Do not use i18n("%1:%2") because ':' should not be translated, it is // used to parse the ratio string. edit->setClickMessage(QString("%1:%2").arg(i18n("Width")).arg(i18n("Height"))); } QRect cropRect() const { QRect rect( leftSpinBox->value(), topSpinBox->value(), widthSpinBox->value(), heightSpinBox->value() ); return rect; } void initSpinBoxes() { QSize size = mDocument->size(); leftSpinBox->setMaximum(size.width()); widthSpinBox->setMaximum(size.width()); topSpinBox->setMaximum(size.height()); heightSpinBox->setMaximum(size.height()); } void initDialogButtonBox() { QPushButton* cropButton = dialogButtonBox->button(QDialogButtonBox::Ok); cropButton->setIcon(QIcon::fromTheme("transform-crop-and-resize")); cropButton->setText(i18n("Crop")); QObject::connect(dialogButtonBox, &KDialogButtonBox::accepted, q, &CropWidget::cropRequested); QObject::connect(dialogButtonBox, &KDialogButtonBox::rejected, q, &CropWidget::done); } }; CropWidget::CropWidget(QWidget* parent, RasterImageView* imageView, CropTool* cropTool) : QWidget(parent) , d(new CropWidgetPrivate) { setWindowFlags(Qt::Tool); d->q = this; d->mDocument = imageView->document(); d->mUpdatingFromCropTool = false; d->mCropTool = cropTool; d->setupUi(this); setFont(KGlobalSettings::smallestReadableFont()); layout()->setMargin(KDialog::marginHint()); layout()->setSizeConstraint(QLayout::SetFixedSize); connect(d->advancedCheckBox, SIGNAL(toggled(bool)), d->advancedWidget, SLOT(setVisible(bool))); d->advancedWidget->setVisible(false); d->advancedWidget->layout()->setMargin(0); d->initRatioComboBox(); connect(d->mCropTool, &CropTool::rectUpdated, this, &CropWidget::setCropRect); - connect(d->leftSpinBox, static_cast(&KIntSpinBox::valueChanged), this, &CropWidget::slotPositionChanged); - connect(d->topSpinBox, static_cast(&KIntSpinBox::valueChanged), this, &CropWidget::slotPositionChanged); - connect(d->widthSpinBox, static_cast(&KIntSpinBox::valueChanged), this, &CropWidget::slotWidthChanged); - connect(d->heightSpinBox, static_cast(&KIntSpinBox::valueChanged), this, &CropWidget::slotHeightChanged); + connect(d->leftSpinBox, static_cast(&QSpinBox::valueChanged), this, &CropWidget::slotPositionChanged); + connect(d->topSpinBox, static_cast(&QSpinBox::valueChanged), this, &CropWidget::slotPositionChanged); + connect(d->widthSpinBox, static_cast(&QSpinBox::valueChanged), this, &CropWidget::slotWidthChanged); + connect(d->heightSpinBox, static_cast(&QSpinBox::valueChanged), this, &CropWidget::slotHeightChanged); d->initDialogButtonBox(); connect(d->ratioComboBox, &KComboBox::editTextChanged, this, &CropWidget::slotRatioComboBoxEditTextChanged); // Don't do this before signals are connected, otherwise the tool won't get // initialized d->initSpinBoxes(); setCropRect(d->mCropTool->rect()); } CropWidget::~CropWidget() { delete d; } void CropWidget::setAdvancedSettingsEnabled(bool enable) { d->advancedCheckBox->setChecked(enable); } bool CropWidget::advancedSettingsEnabled() const { return d->advancedCheckBox->isChecked(); } void CropWidget::setCropRect(const QRect& rect) { d->mUpdatingFromCropTool = true; d->leftSpinBox->setValue(rect.left()); d->topSpinBox->setValue(rect.top()); d->widthSpinBox->setValue(rect.width()); d->heightSpinBox->setValue(rect.height()); d->mUpdatingFromCropTool = false; } void CropWidget::slotPositionChanged() { const QSize size = d->mDocument->size(); d->widthSpinBox->setMaximum(size.width() - d->leftSpinBox->value()); d->heightSpinBox->setMaximum(size.height() - d->topSpinBox->value()); if (d->mUpdatingFromCropTool) { return; } d->mCropTool->setRect(d->cropRect()); } void CropWidget::slotWidthChanged() { d->leftSpinBox->setMaximum(d->mDocument->width() - d->widthSpinBox->value()); if (d->mUpdatingFromCropTool) { return; } if (d->ratioIsConstrained()) { int height = int(d->widthSpinBox->value() * d->cropRatio()); d->heightSpinBox->setValue(height); } d->mCropTool->setRect(d->cropRect()); } void CropWidget::slotHeightChanged() { d->topSpinBox->setMaximum(d->mDocument->height() - d->heightSpinBox->value()); if (d->mUpdatingFromCropTool) { return; } if (d->ratioIsConstrained()) { int width = int(d->heightSpinBox->value() / d->cropRatio()); d->widthSpinBox->setValue(width); } d->mCropTool->setRect(d->cropRect()); } void CropWidget::applyRatioConstraint() { double ratio = d->cropRatio(); d->mCropTool->setCropRatio(ratio); if (!d->ratioIsConstrained()) { return; } QRect rect = d->cropRect(); rect.setHeight(int(rect.width() * ratio)); d->mCropTool->setRect(rect); } void CropWidget::slotRatioComboBoxEditTextChanged() { applyRatioConstraint(); } } // namespace diff --git a/lib/crop/cropwidget.ui b/lib/crop/cropwidget.ui index 1d0fed89..efa5cf53 100644 --- a/lib/crop/cropwidget.ui +++ b/lib/crop/cropwidget.ui @@ -1,198 +1,193 @@ CropWidget 0 0 - 790 + 824 66 0 0 Crop Qt::NoFocus Advanced settings Qt::Horizontal QSizePolicy::Fixed 12 20 Ratio: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter ratioComboBox true QComboBox::NoInsert 0 0 Position: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter leftSpinBox - + 1 0 - + 1 0 - Size: + Si&ze: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter widthSpinBox - + 1 0 - + 1 0 Qt::Horizontal 0 20 QDialogButtonBox::Cancel|QDialogButtonBox::Ok KDialogButtonBox QDialogButtonBox
kdialogbuttonbox.h
KComboBox QComboBox
kcombobox.h
- - KIntSpinBox - QSpinBox -
knuminput.h
-
ratioComboBox leftSpinBox topSpinBox widthSpinBox heightSpinBox
diff --git a/lib/redeyereduction/redeyereductionwidget.ui b/lib/redeyereduction/redeyereductionwidget.ui index 151e4e77..04645b1f 100644 --- a/lib/redeyereduction/redeyereductionwidget.ui +++ b/lib/redeyereduction/redeyereductionwidget.ui @@ -1,127 +1,87 @@ RedEyeReductionWidget 0 0 - 372 - 51 + 405 + 56 0 - Size + Si&ze diameterSlider 2 40 Qt::Horizontal - + 2 diameterSpinBox - diameterSlider - diameterSpinBox label diameterSlider Click on the red eye you want to fix QDialogButtonBox::Close|QDialogButtonBox::Ok KDialogButtonBox QDialogButtonBox
kdialogbuttonbox.h
- - KIntSpinBox - QSpinBox -
knuminput.h
-
- - - diameterSlider - sliderMoved(int) - diameterSpinBox - setValue(int) - - - 120 - 22 - - - 175 - 21 - - - - - diameterSpinBox - valueChanged(int) - diameterSlider - setValue(int) - - - 153 - 7 - - - 124 - 7 - - - - +
diff --git a/lib/resize/resizeimagedialog.cpp b/lib/resize/resizeimagedialog.cpp index 15c501c5..fb1d17e6 100644 --- a/lib/resize/resizeimagedialog.cpp +++ b/lib/resize/resizeimagedialog.cpp @@ -1,128 +1,128 @@ // vim: set tabstop=4 shiftwidth=4 expandtab: /* Gwenview: an image viewer Copyright 2010 Aurélien Gâteau This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. */ // Self #include "resizeimagedialog.h" // Qt #include #include // KDE #include #include // Local #include namespace Gwenview { struct ResizeImageDialogPrivate : public Ui_ResizeImageWidget { bool mUpdateFromRatio; QSize mOriginalSize; }; ResizeImageDialog::ResizeImageDialog(QWidget* parent) : QDialog(parent) , d(new ResizeImageDialogPrivate) { d->mUpdateFromRatio = false; QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); QWidget* content = new QWidget(this); d->setupUi(content); mainLayout->addWidget(content); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); connect(buttonBox, &QDialogButtonBox::accepted, this, &ResizeImageDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &ResizeImageDialog::reject); mainLayout->addWidget(buttonBox); content->layout()->setMargin(0); KGuiItem::assign(okButton, KGuiItem(i18n("Resize"), "transform-scale")); setWindowTitle(content->windowTitle()); d->mWidthSpinBox->setFocus(); - connect(d->mWidthSpinBox, static_cast(&KIntSpinBox::valueChanged), this, &ResizeImageDialog::slotWidthChanged); - connect(d->mHeightSpinBox, static_cast(&KIntSpinBox::valueChanged), this, &ResizeImageDialog::slotHeightChanged); + connect(d->mWidthSpinBox, static_cast(&QSpinBox::valueChanged), this, &ResizeImageDialog::slotWidthChanged); + connect(d->mHeightSpinBox, static_cast(&QSpinBox::valueChanged), this, &ResizeImageDialog::slotHeightChanged); connect(d->mKeepAspectCheckBox, &QCheckBox::toggled, this, &ResizeImageDialog::slotKeepAspectChanged); } ResizeImageDialog::~ResizeImageDialog() { delete d; } void ResizeImageDialog::setOriginalSize(const QSize& size) { d->mOriginalSize = size; d->mOriginalWidthLabel->setText(QString::number(size.width())); d->mOriginalHeightLabel->setText(QString::number(size.height())); d->mWidthSpinBox->setValue(size.width()); d->mHeightSpinBox->setValue(size.height()); } QSize ResizeImageDialog::size() const { return QSize( d->mWidthSpinBox->value(), d->mHeightSpinBox->value() ); } void ResizeImageDialog::slotWidthChanged(int width) { if (!d->mKeepAspectCheckBox->isChecked()) { return; } if (d->mUpdateFromRatio) { return; } d->mUpdateFromRatio = true; d->mHeightSpinBox->setValue(d->mOriginalSize.height() * width / d->mOriginalSize.width()); d->mUpdateFromRatio = false; } void ResizeImageDialog::slotHeightChanged(int height) { if (!d->mKeepAspectCheckBox->isChecked()) { return; } if (d->mUpdateFromRatio) { return; } d->mUpdateFromRatio = true; d->mWidthSpinBox->setValue(d->mOriginalSize.width() * height / d->mOriginalSize.height()); d->mUpdateFromRatio = false; } void ResizeImageDialog::slotKeepAspectChanged(bool value) { if (value) { slotWidthChanged(d->mWidthSpinBox->value()); } } } // namespace diff --git a/lib/resize/resizeimagewidget.ui b/lib/resize/resizeimagewidget.ui index 21ea19a4..2ebe526d 100644 --- a/lib/resize/resizeimagewidget.ui +++ b/lib/resize/resizeimagewidget.ui @@ -1,153 +1,140 @@ ResizeImageWidget 0 0 - 248 + 269 155 Image Resizing Enter the new size for this image. true Current size: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter true Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse true true Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - New Size: + New Si&ze: mWidthSpinBox - - - false - - - QAbstractSpinBox::UpDownArrows - + 1 100000 - + 1 100000 Keep aspect ratio true - - - KIntSpinBox - QSpinBox -
knuminput.h
-
-