[graphics/kooka] app: Rename "Scan Parameters" -> "Scan Presets"
Jonathan Marten
null at kde.org
Fri Jan 29 13:28:25 GMT 2021
Git commit d89f4c6dcd079ee98d3efe27b8102fbe4b26a600 by Jonathan Marten.
Committed on 28/01/2021 at 20:12.
Pushed by marten into branch 'master'.
Rename "Scan Parameters" -> "Scan Presets"
The new name better describes the function, and internally in the code
it will not be confused with ScanParams.
I18N:
GUI:
M +2 -3 app/CMakeLists.txt
M +1 -7 app/kooka.cpp
M +0 -1 app/kooka.h
M +4 -5 app/kookaview.cpp
R +14 -15 app/newscanpresetdialog.cpp [from: app/newscanparams.cpp - 078% similarity]
R +7 -5 app/newscanpresetdialog.h [from: app/newscanparams.h - 084% similarity]
R +57 -43 app/scanpresetsdialog.cpp [from: app/scanparamsdialog.cpp - 076% similarity]
R +9 -8 app/scanpresetsdialog.h [from: app/scanparamsdialog.h - 086% similarity]
https://invent.kde.org/graphics/kooka/commit/d89f4c6dcd079ee98d3efe27b8102fbe4b26a600
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 7282ea5..29b851c 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -97,10 +97,9 @@ set(kooka_SRCS
thumbview.cpp
kookaprint.cpp
imgprintdialog.cpp
- scanparamsdialog.cpp
- newscanparams.cpp # -> newscaparamsdialog
+ scanpresetsdialog.cpp
+ newscanpresetdialog.cpp
ocrresedit.cpp
- #QT5 photocopyprintdialogpage.cpp
${kooka_LOG_SRCS}
)
diff --git a/app/kooka.cpp b/app/kooka.cpp
index 308ab2d..a51f1b2 100644
--- a/app/kooka.cpp
+++ b/app/kooka.cpp
@@ -286,12 +286,7 @@ void Kooka::setupActions()
actionCollection()->setDefaultShortcut(scanAction, Qt::Key_F4);
connect(scanAction, &QAction::triggered, m_view, &KookaView::slotStartFinalScan);
- photocopyAction = new QAction(QIcon::fromTheme("photocopy"), i18n("Photocopy..."), this);
- actionCollection()->addAction("startPhotoCopy", photocopyAction);
- actionCollection()->setDefaultShortcut(photocopyAction, Qt::CTRL + Qt::Key_F);
- connect(photocopyAction, &QAction::triggered, m_view, &KookaView::slotStartPhotoCopy);
-
- paramsAction = new QAction(QIcon::fromTheme("bookmark-new"), i18n("Scan Parameters..."), this);
+ paramsAction = new QAction(QIcon::fromTheme("bookmark-new"), i18n("Scan Presets..."), this);
actionCollection()->addAction("scanparam", paramsAction);
actionCollection()->setDefaultShortcut(paramsAction, Qt::CTRL + Qt::SHIFT + Qt::Key_S);
connect(paramsAction, &QAction::triggered, m_view, &KookaView::slotScanParams);
@@ -401,7 +396,6 @@ void Kooka::slotUpdateScannerActions(bool haveConnection)
scanAction->setEnabled(haveConnection);
previewAction->setEnabled(haveConnection);
- photocopyAction->setEnabled(haveConnection);
paramsAction->setEnabled(haveConnection);
if (!ScanGlobal::self()->available()) {
diff --git a/app/kooka.h b/app/kooka.h
index 4bb3dda..9e4469e 100644
--- a/app/kooka.h
+++ b/app/kooka.h
@@ -124,7 +124,6 @@ private:
QAction *scanAction;
QAction *previewAction;
- QAction *photocopyAction;
QAction *paramsAction;
KToggleAction *autoselAction;
QAction *ocrAction;
diff --git a/app/kookaview.cpp b/app/kookaview.cpp
index f036155..1a5fce3 100644
--- a/app/kookaview.cpp
+++ b/app/kookaview.cpp
@@ -77,7 +77,7 @@
#include "abstractocrengine.h"
#include "pluginmanager.h"
#include "ocrresedit.h"
-#include "scanparamsdialog.h"
+#include "scanpresetsdialog.h"
#include "kookagallery.h"
#include "kookascanparams.h"
#include "scangallery.h"
@@ -952,12 +952,11 @@ void KookaView::slotSaveOcrResult()
}
}
+
void KookaView::slotScanParams()
{
- if (mScanDevice == nullptr) {
- return; // must have a scanner device
- }
- ScanParamsDialog d(this, mScanDevice);
+ if (mScanDevice == nullptr) return; // must have a scanner device
+ ScanPresetsDialog d(mScanDevice, this);
d.exec();
}
diff --git a/app/newscanparams.cpp b/app/newscanpresetdialog.cpp
similarity index 78%
rename from app/newscanparams.cpp
rename to app/newscanpresetdialog.cpp
index dbc5607..4b80a30 100644
--- a/app/newscanparams.cpp
+++ b/app/newscanpresetdialog.cpp
@@ -28,7 +28,7 @@
* *
************************************************************************/
-#include "newscanparams.h"
+#include "newscanpresetdialog.h"
#include <qlabel.h>
#include <qlineedit.h>
@@ -37,11 +37,10 @@
#include <klocalizedstring.h>
-NewScanParams::NewScanParams(QWidget *parent,
- const QString &name, const QString &desc, bool renaming)
- : DialogBase(parent)
+NewScanPresetDialog::NewScanPresetDialog(const QString &name, const QString &desc, bool renaming, QWidget *pnt)
+ : DialogBase(pnt)
{
- setObjectName("NewScanParams");
+ setObjectName("NewScanPresetDialog");
setButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
@@ -51,31 +50,31 @@ NewScanParams::NewScanParams(QWidget *parent,
QLabel *l;
if (renaming)
{
- setWindowTitle(i18n("Edit Scan Parameters"));
- l = new QLabel(i18n("Change the name and/or description of the scan parameter set."), vb);
+ setWindowTitle(i18n("Edit Scan Preset"));
+ l = new QLabel(i18n("Change the name and/or description of the scan preset."), vb);
}
else
{
- setWindowTitle(i18n("Save Scan Parameters"));
- l = new QLabel(i18n("Enter a name and description for the new scan parameter set."), vb);
+ setWindowTitle(i18n("Save Scan Preset"));
+ l = new QLabel(i18n("Enter a name and description for the new scan preset."), vb);
}
vbVBoxLayout->addWidget(l);
l = new QLabel("", vb);
vbVBoxLayout->addWidget(l);
- l = new QLabel(i18n("Set name:"), vb);
+ l = new QLabel(i18n("Preset name:"), vb);
vbVBoxLayout->addWidget(l);
mNameEdit = new QLineEdit(name, vb);
vbVBoxLayout->addWidget(mNameEdit);
- connect(mNameEdit, &QLineEdit::textChanged, this, &NewScanParams::slotTextChanged);
+ connect(mNameEdit, &QLineEdit::textChanged, this, &NewScanPresetDialog::slotTextChanged);
l->setBuddy(mNameEdit);
l = new QLabel(i18n("Description:"), vb);
vbVBoxLayout->addWidget(l);
mDescEdit = new QLineEdit(desc, vb);
vbVBoxLayout->addWidget(mDescEdit);
- connect(mDescEdit, &QLineEdit::textChanged, this, &NewScanParams::slotTextChanged);
+ connect(mDescEdit, &QLineEdit::textChanged, this, &NewScanPresetDialog::slotTextChanged);
l->setBuddy(mDescEdit);
setMainWidget(vb);
@@ -83,18 +82,18 @@ NewScanParams::NewScanParams(QWidget *parent,
mNameEdit->setFocus();
}
-void NewScanParams::slotTextChanged()
+void NewScanPresetDialog::slotTextChanged()
{
setButtonEnabled(QDialogButtonBox::Ok, !mNameEdit->text().trimmed().isEmpty() &&
!mDescEdit->text().trimmed().isEmpty());
}
-QString NewScanParams::getName() const
+QString NewScanPresetDialog::getName() const
{
return (mNameEdit->text());
}
-QString NewScanParams::getDescription() const
+QString NewScanPresetDialog::getDescription() const
{
return (mDescEdit->text());
}
diff --git a/app/newscanparams.h b/app/newscanpresetdialog.h
similarity index 84%
rename from app/newscanparams.h
rename to app/newscanpresetdialog.h
index ff7939f..17f614e 100644
--- a/app/newscanparams.h
+++ b/app/newscanpresetdialog.h
@@ -28,8 +28,8 @@
* *
************************************************************************/
-#ifndef NEWSCANPARAMS_H
-#define NEWSCANPARAMS_H
+#ifndef NEWSCANPRESETDIALOG_H
+#define NEWSCANPRESETDIALOG_H
#include <dialogbase.h>
@@ -41,12 +41,14 @@ class QLineEdit;
* a set of saved scan parameters.
*/
-class NewScanParams : public DialogBase
+class NewScanPresetDialog : public DialogBase
{
Q_OBJECT
public:
- explicit NewScanParams(QWidget *parent, const QString &name, const QString &desc, bool renaming);
+ explicit NewScanPresetDialog(const QString &name, const QString &desc, bool renaming,
+ QWidget *pnt = nullptr);
+ ~NewScanPresetDialog() override = default;
QString getName() const;
QString getDescription() const;
@@ -59,4 +61,4 @@ private:
QLineEdit *mDescEdit;
};
-#endif // NEWSCANPARAMS_H
+#endif // NEWSCANPRESETDIALOG_H
diff --git a/app/scanparamsdialog.cpp b/app/scanpresetsdialog.cpp
similarity index 76%
rename from app/scanparamsdialog.cpp
rename to app/scanpresetsdialog.cpp
index c607c66..e913c0c 100644
--- a/app/scanparamsdialog.cpp
+++ b/app/scanpresetsdialog.cpp
@@ -28,7 +28,7 @@
* *
************************************************************************/
-#include "scanparamsdialog.h"
+#include "scanpresetsdialog.h"
#include <qlabel.h>
#include <qlayout.h>
@@ -46,19 +46,20 @@ extern "C" {
#include "kscandevice.h"
#include "kscanoption.h"
#include "kscanoptset.h"
-#include "newscanparams.h"
+#include "kscancontrols.h"
+#include "newscanpresetdialog.h"
#include "kooka_logging.h"
// TODO: also associate an icon, default the "color"/"grey" etc
-ScanParamsDialog::ScanParamsDialog(QWidget *parent, KScanDevice *scandev)
- : DialogBase(parent)
+ScanPresetsDialog::ScanPresetsDialog(KScanDevice *scandev, QWidget *pnt)
+ : DialogBase(pnt)
{
- setObjectName("ScanParamsDialog");
+ setObjectName("ScanPresetsDialog");
setButtons(QDialogButtonBox::Close);
- setWindowTitle(i18n("Scan Parameters"));
+ setWindowTitle(i18n("Scan Presets"));
QWidget *w = new QWidget(this);
QGridLayout *gl = new QGridLayout(w);
@@ -67,43 +68,43 @@ ScanParamsDialog::ScanParamsDialog(QWidget *parent, KScanDevice *scandev)
paramsList->setSelectionMode(QAbstractItemView::SingleSelection);
paramsList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
paramsList->setMinimumWidth(200);
- connect(paramsList, &QListWidget::itemSelectionChanged, this, &ScanParamsDialog::slotSelectionChanged);
- connect(paramsList, &QListWidget::itemDoubleClicked, this, &ScanParamsDialog::slotLoadAndClose);
+ connect(paramsList, &QListWidget::itemSelectionChanged, this, &ScanPresetsDialog::slotSelectionChanged);
+ connect(paramsList, &QListWidget::itemDoubleClicked, this, &ScanPresetsDialog::slotLoadAndClose);
gl->addWidget(paramsList, 1, 0, 5, 1);
- QLabel *l = new QLabel(i18n("Saved scan parameter sets:"), w);
+ QLabel *l = new QLabel(i18n("Saved scan preset sets:"), w);
gl->addWidget(l, 0, 0, Qt::AlignLeft);
l->setBuddy(paramsList);
buttonLoad = new QPushButton(i18n("Select"), w);
buttonLoad->setIcon(QIcon::fromTheme("dialog-ok-apply"));
- buttonLoad->setToolTip(i18n("Load the selected scan parameter set to use as scanner settings"));
- connect(buttonLoad, &QPushButton::clicked, this, &ScanParamsDialog::slotLoad);
+ buttonLoad->setToolTip(i18n("Load the selected scan preset set to use as scanner settings"));
+ connect(buttonLoad, &QPushButton::clicked, this, &ScanPresetsDialog::slotLoad);
gl->addWidget(buttonLoad, 1, 2);
buttonSave = new QPushButton(i18n("Save..."), w);
buttonSave->setIcon(QIcon::fromTheme("bookmark-new"));
- buttonSave->setToolTip(i18n("Save the current scanner settings as a new scan parameter set"));
- connect(buttonSave, &QPushButton::clicked, this, &ScanParamsDialog::slotSave);
+ buttonSave->setToolTip(i18n("Save the current scanner settings as a new scan preset set"));
+ connect(buttonSave, &QPushButton::clicked, this, &ScanPresetsDialog::slotSave);
gl->addWidget(buttonSave, 2, 2);
buttonDelete = new QPushButton(w);
KGuiItem::assign(buttonDelete, KStandardGuiItem::del());
- buttonDelete->setToolTip(i18n("Delete the selected scan parameter set"));
- connect(buttonDelete, &QPushButton::clicked, this, &ScanParamsDialog::slotDelete);
+ buttonDelete->setToolTip(i18n("Delete the selected scan preset set"));
+ connect(buttonDelete, &QPushButton::clicked, this, &ScanPresetsDialog::slotDelete);
gl->addWidget(buttonDelete, 3, 2);
buttonEdit = new QPushButton(i18n("Edit..."), w);
buttonEdit->setIcon(QIcon::fromTheme("document-edit"));
- buttonEdit->setToolTip(i18n("Change the name or description of the selected scan parameter set"));
- connect(buttonEdit, &QPushButton::clicked, this, &ScanParamsDialog::slotEdit);
+ buttonEdit->setToolTip(i18n("Change the name or description of the selected scan preset set"));
+ connect(buttonEdit, &QPushButton::clicked, this, &ScanPresetsDialog::slotEdit);
gl->addWidget(buttonEdit, 4, 2);
gl->setRowStretch(5, 9);
- gl->setRowMinimumHeight(6, 2*verticalSpacing());
+ gl->setRowMinimumHeight(6, 2*DialogBase::verticalSpacing());
gl->setColumnStretch(0, 9);
- gl->setColumnMinimumWidth(1, 2*horizontalSpacing());
+ gl->setColumnMinimumWidth(1, 2*DialogBase::horizontalSpacing());
descLabel = new QLabel(w);
gl->addWidget(descLabel, 7, 0, 1, 3);
@@ -115,26 +116,29 @@ ScanParamsDialog::ScanParamsDialog(QWidget *parent, KScanDevice *scandev)
slotSelectionChanged();
}
-void ScanParamsDialog::populateList()
+
+void ScanPresetsDialog::populateList()
{
paramsList->clear();
sets = KScanOptSet::readList();
- for (KScanOptSet::StringMap::const_iterator it = sets.constBegin(); it != sets.constEnd(); ++it) {
+ for (KScanOptSet::StringMap::const_iterator it = sets.constBegin(); it != sets.constEnd(); ++it)
+ {
qCDebug(KOOKA_LOG) << "saveset" << it.key();
paramsList->addItem(it.key());
}
}
-void ScanParamsDialog::slotSelectionChanged()
+
+void ScanPresetsDialog::slotSelectionChanged()
{
QString desc;
bool enable = false;
QListWidgetItem *item = paramsList->currentItem();
- if (item == nullptr) {
- desc = i18n("No save set selected.");
- } else { // something getting selected
+ if (item == nullptr) desc = i18n("No preset set selected.");
+ else // something getting selected
+ {
desc = sets[item->text()];
enable = true;
}
@@ -148,7 +152,8 @@ void ScanParamsDialog::slotSelectionChanged()
buttonBox()->button(QDialogButtonBox::Close)->setDefault(!enable);
}
-void ScanParamsDialog::slotLoad()
+
+void ScanPresetsDialog::slotLoad()
{
QListWidgetItem *item = paramsList->currentItem();
if (item == nullptr) return;
@@ -157,7 +162,8 @@ void ScanParamsDialog::slotLoad()
qCDebug(KOOKA_LOG) << "set" << name;
KScanOptSet optSet(name);
- if (!optSet.loadConfig()) {
+ if (!optSet.loadConfig())
+ {
qCWarning(KOOKA_LOG) << "Failed to load set" << name;
return;
}
@@ -166,7 +172,8 @@ void ScanParamsDialog::slotLoad()
sane->reloadAllOptions();
}
-void ScanParamsDialog::slotLoadAndClose(QListWidgetItem *item)
+
+void ScanPresetsDialog::slotLoadAndClose(QListWidgetItem *item)
{
if (item == nullptr) return;
@@ -176,7 +183,8 @@ void ScanParamsDialog::slotLoadAndClose(QListWidgetItem *item)
accept();
}
-void ScanParamsDialog::slotSave()
+
+void ScanPresetsDialog::slotSave()
{
QString name;
QListWidgetItem *item = paramsList->currentItem();
@@ -184,18 +192,24 @@ void ScanParamsDialog::slotSave()
qCDebug(KOOKA_LOG) << "selected set" << name;
QString newdesc;
- if (sets.contains(name)) {
- newdesc = sets[name];
- } else {
+ if (sets.contains(name)) newdesc = sets[name];
+ else
+ {
const KScanOption *sm = sane->getExistingGuiElement(SANE_NAME_SCAN_MODE);
const KScanOption *sr = sane->getExistingGuiElement(SANE_NAME_SCAN_RESOLUTION);
- if (sm != nullptr && sr != nullptr) newdesc = i18n("%1, %2 dpi",
- sm->get().constData(),
- sr->get().constData());
+ if (sm != nullptr && sr != nullptr)
+ {
+ // See KScanCombo::setList() for explanation
+ QString scanMode = ki18n(sm->widget()->text().toLocal8Bit().constData()).toString("sane-backends");
+ if (scanMode.isEmpty()) scanMode = sm->get();
+ newdesc = i18nc("New set name, %1=scan mode, %2=resolution", "%1, %2 dpi",
+ scanMode, sr->get().constData());
+ }
}
- NewScanParams d(this, name, newdesc, false);
- if (d.exec()) {
+ NewScanPresetDialog d(name, newdesc, false, this);
+ if (d.exec())
+ {
QString newName = d.getName();
QString newDesc = d.getDescription();
@@ -222,7 +236,8 @@ void ScanParamsDialog::slotSave()
}
}
-void ScanParamsDialog::slotEdit()
+
+void ScanPresetsDialog::slotEdit()
{
QListWidgetItem *item = paramsList->currentItem();
if (item == nullptr) {
@@ -231,7 +246,7 @@ void ScanParamsDialog::slotEdit()
QString oldName = item->text();
qCDebug(KOOKA_LOG) << "selected set" << oldName;
- NewScanParams d(this, oldName, sets[oldName], true);
+ NewScanPresetDialog d(oldName, sets[oldName], true, this);
if (d.exec()) {
QString newName = d.getName();
QString newDesc = d.getDescription();
@@ -259,7 +274,8 @@ void ScanParamsDialog::slotEdit()
}
}
-void ScanParamsDialog::slotDelete()
+
+void ScanPresetsDialog::slotDelete()
{
QListWidgetItem *item = paramsList->currentItem();
if (item == nullptr) return;
@@ -271,9 +287,7 @@ void ScanParamsDialog::slotDelete()
i18n("Delete Scan Parameter Set"),
KStandardGuiItem::del(),
KStandardGuiItem::cancel(),
- "deleteSaveSet") != KMessageBox::Continue) {
- return;
- }
+ "deleteSaveSet") != KMessageBox::Continue) return;
KScanOptSet::deleteSet(name);
delete paramsList->takeItem(paramsList->row(item));
diff --git a/app/scanparamsdialog.h b/app/scanpresetsdialog.h
similarity index 86%
rename from app/scanparamsdialog.h
rename to app/scanpresetsdialog.h
index 5c4fe02..9230314 100644
--- a/app/scanparamsdialog.h
+++ b/app/scanpresetsdialog.h
@@ -28,8 +28,8 @@
* *
************************************************************************/
-#ifndef SCANPARAMSDIALOG_H
-#define SCANPARAMSDIALOG_H
+#ifndef SCANPRESETSDIALOG_H
+#define SCANPRESETSDIALOG_H
#include <dialogbase.h>
@@ -43,16 +43,16 @@ class KScanDevice;
/**
- * A dialogue to allow the user to enter a name and description for
- * a set of saved scan parameters.
- */
+ * A dialogue to manage sets of saved scan parameters.
+ **/
-class ScanParamsDialog : public DialogBase
+class ScanPresetsDialog : public DialogBase
{
Q_OBJECT
public:
- explicit ScanParamsDialog(QWidget *parent, KScanDevice *scandev);
+ explicit ScanPresetsDialog(KScanDevice *scandev, QWidget *pnt = nullptr);
+ ~ScanPresetsDialog() override = default;
protected slots:
void slotSelectionChanged();
@@ -65,6 +65,7 @@ protected slots:
private:
void populateList();
+private:
QLabel *descLabel;
QListWidget *paramsList;
QPushButton *buttonLoad;
@@ -76,4 +77,4 @@ private:
KScanDevice *sane;
};
-#endif // SCANPARAMSDIALOG_H
+#endif // SCANPRESETSDIALOG_H
More information about the kde-doc-english
mailing list