SSH config UI: use "delete" consistently, avoid Yes/No buttons

"Delete" instead of "Remove" makes it more obvious the data is gone
afterwards, not just removed from a list.

Also use KMessageBox::warningYesNo instead of the helper method
KMessageBox::messageBox.
And fix missing i18n markup of menu entry.

Yes/No buttons in dialogs are discouraged (not only) by KDE HIG in favour
of actions terms.
wilder
Friedrich W. H. Kossebau 4 years ago
parent 7b16bf24fe
commit f4b84a10f6
  1. 42
      src/plugins/SSHManager/sshmanagerpluginwidget.cpp
  2. 2
      src/plugins/SSHManager/sshmanagerpluginwidget.h
  3. 8
      src/plugins/SSHManager/sshwidget.ui

@ -68,7 +68,7 @@ SSHManagerTreeWidget::SSHManagerTreeWidget(QWidget *parent)
connect(ui->newSSHConfig, &QPushButton::clicked, this, &SSHManagerTreeWidget::showInfoPane); connect(ui->newSSHConfig, &QPushButton::clicked, this, &SSHManagerTreeWidget::showInfoPane);
connect(ui->btnCancel, &QPushButton::clicked, this, &SSHManagerTreeWidget::clearSshInfo); connect(ui->btnCancel, &QPushButton::clicked, this, &SSHManagerTreeWidget::clearSshInfo);
connect(ui->btnEdit, &QPushButton::clicked, this, &SSHManagerTreeWidget::editSshInfo); connect(ui->btnEdit, &QPushButton::clicked, this, &SSHManagerTreeWidget::editSshInfo);
connect(ui->btnRemove, &QPushButton::clicked, this, &SSHManagerTreeWidget::triggerRemove); connect(ui->btnDelete, &QPushButton::clicked, this, &SSHManagerTreeWidget::triggerDelete);
connect(ui->btnInvertFilter, &QPushButton::clicked, d->filterModel, &SSHManagerFilterModel::setInvertFilter); connect(ui->btnInvertFilter, &QPushButton::clicked, d->filterModel, &SSHManagerFilterModel::setInvertFilter);
connect(ui->btnFindSshKey, &QPushButton::clicked, this, [this] { connect(ui->btnFindSshKey, &QPushButton::clicked, this, [this] {
@ -111,10 +111,10 @@ SSHManagerTreeWidget::SSHManagerTreeWidget(QWidget *parent)
} }
QMenu *menu = new QMenu(this); QMenu *menu = new QMenu(this);
auto action = new QAction(QStringLiteral("Remove"), ui->treeView); auto action = new QAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18nc("@action:inmenu", "Delete"), ui->treeView);
menu->addAction(action); menu->addAction(action);
connect(action, &QAction::triggered, this, &SSHManagerTreeWidget::triggerRemove); connect(action, &QAction::triggered, this, &SSHManagerTreeWidget::triggerDelete);
menu->popup(ui->treeView->viewport()->mapToGlobal(pos)); menu->popup(ui->treeView->viewport()->mapToGlobal(pos));
}); });
@ -183,7 +183,7 @@ SSHConfigurationData SSHManagerTreeWidget::info() const
return data; return data;
} }
void SSHManagerTreeWidget::triggerRemove() void SSHManagerTreeWidget::triggerDelete()
{ {
auto selection = ui->treeView->selectionModel()->selectedIndexes(); auto selection = ui->treeView->selectionModel()->selectedIndexes();
if (selection.empty()) { if (selection.empty()) {
@ -192,20 +192,18 @@ void SSHManagerTreeWidget::triggerRemove()
const QString text = selection.at(0).data(Qt::DisplayRole).toString(); const QString text = selection.at(0).data(Qt::DisplayRole).toString();
const QString dialogMessage = ui->treeView->model()->rowCount(selection.at(0)) const QString dialogMessage = ui->treeView->model()->rowCount(selection.at(0))
? i18n("You are about to remove the folder %1,\n with multiple SSH Configurations, are you sure?", text) ? i18n("You are about to delete the folder %1,\n with multiple SSH Configurations, are you sure?", text)
: i18n("You are about to remove %1, are you sure?", text); : i18n("You are about to delete %1, are you sure?", text);
const QString dontAskAgainKey = const QString dontAskAgainKey =
ui->treeView->model()->rowCount(selection.at(0)) ? QStringLiteral("remove_ssh_folder") : QStringLiteral("remove_ssh_config"); ui->treeView->model()->rowCount(selection.at(0)) ? QStringLiteral("remove_ssh_folder") : QStringLiteral("remove_ssh_config");
KMessageBox::ButtonCode result = KMessageBox::messageBox(this, int result = KMessageBox::warningYesNo(this,
KMessageBox::DialogType::WarningYesNo, dialogMessage,
dialogMessage, i18nc("@title:window", "Delete SSH Configurations"),
i18n("Remove SSH Configurations"), KStandardGuiItem::del(),
KStandardGuiItem::yes(), KStandardGuiItem::cancel(),
KStandardGuiItem::no(), dontAskAgainKey);
KStandardGuiItem::cancel(),
dontAskAgainKey);
if (result == KMessageBox::ButtonCode::No) { if (result == KMessageBox::ButtonCode::No) {
return; return;
@ -285,7 +283,7 @@ void SSHManagerTreeWidget::clearSshInfo()
void SSHManagerTreeWidget::hideInfoPane() void SSHManagerTreeWidget::hideInfoPane()
{ {
ui->newSSHConfig->show(); ui->newSSHConfig->show();
ui->btnRemove->show(); ui->btnDelete->show();
ui->btnEdit->show(); ui->btnEdit->show();
ui->sshInfoPane->hide(); ui->sshInfoPane->hide();
ui->btnAdd->hide(); ui->btnAdd->hide();
@ -296,7 +294,7 @@ void SSHManagerTreeWidget::hideInfoPane()
void SSHManagerTreeWidget::showInfoPane() void SSHManagerTreeWidget::showInfoPane()
{ {
ui->newSSHConfig->hide(); ui->newSSHConfig->hide();
ui->btnRemove->hide(); ui->btnDelete->hide();
ui->btnEdit->hide(); ui->btnEdit->hide();
ui->sshInfoPane->show(); ui->sshInfoPane->show();
ui->btnAdd->show(); ui->btnAdd->show();
@ -396,11 +394,11 @@ void SSHManagerTreeWidget::handleTreeClick(Qt::MouseButton btn, const QModelInde
if (isParent) { if (isParent) {
setEditComponentsEnabled(false); setEditComponentsEnabled(false);
if (sourceIdx.data(Qt::DisplayRole).toString() == i18n("SSH Config")) { if (sourceIdx.data(Qt::DisplayRole).toString() == i18n("SSH Config")) {
ui->btnRemove->setEnabled(false); ui->btnDelete->setEnabled(false);
ui->btnRemove->setToolTip(i18n("Cannot remove this folder")); ui->btnDelete->setToolTip(i18n("Cannot delete this folder"));
} else { } else {
ui->btnRemove->setEnabled(true); ui->btnDelete->setEnabled(true);
ui->btnRemove->setToolTip(i18n("Remove folder and all of its contents")); ui->btnDelete->setToolTip(i18n("Delete folder and all of its contents"));
} }
ui->btnEdit->setEnabled(false); ui->btnEdit->setEnabled(false);
if (ui->sshInfoPane->isVisible()) { if (ui->sshInfoPane->isVisible()) {
@ -410,8 +408,8 @@ void SSHManagerTreeWidget::handleTreeClick(Qt::MouseButton btn, const QModelInde
const auto item = d->model->itemFromIndex(sourceIdx); const auto item = d->model->itemFromIndex(sourceIdx);
const auto data = item->data(SSHManagerModel::SSHRole).value<SSHConfigurationData>(); const auto data = item->data(SSHManagerModel::SSHRole).value<SSHConfigurationData>();
ui->btnEdit->setEnabled(true); ui->btnEdit->setEnabled(true);
ui->btnRemove->setEnabled(!data.importedFromSshConfig); ui->btnDelete->setEnabled(!data.importedFromSshConfig);
ui->btnRemove->setToolTip(data.importedFromSshConfig ? i18n("You can't remove an automatically added entry.") : i18n("Remove selected entry")); ui->btnDelete->setToolTip(data.importedFromSshConfig ? i18n("You can't delete an automatically added entry.") : i18n("Delete selected entry"));
if (ui->sshInfoPane->isVisible()) { if (ui->sshInfoPane->isVisible()) {
handleImportedData(data.importedFromSshConfig); handleImportedData(data.importedFromSshConfig);
editSshInfo(); editSshInfo();

@ -59,7 +59,7 @@ public:
void setEditComponentsEnabled(bool enabled); void setEditComponentsEnabled(bool enabled);
void setModel(SSHManagerModel *model); void setModel(SSHManagerModel *model);
void triggerRemove(); void triggerDelete();
void setCurrentController(Konsole::SessionController *controller); void setCurrentController(Konsole::SessionController *controller);
void connectRequested(const QModelIndex &idx); void connectRequested(const QModelIndex &idx);
void handleImportedData(bool isImported); void handleImportedData(bool isImported);

@ -240,15 +240,15 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="btnRemove"> <widget class="QPushButton" name="btnDelete">
<property name="toolTip"> <property name="toolTip">
<string>Remove selected SSH entry</string> <string>Delete selected SSH entry</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="list-remove"> <iconset theme="edit-delete">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
</widget> </widget>
@ -313,7 +313,7 @@
<tabstop>btnAdd</tabstop> <tabstop>btnAdd</tabstop>
<tabstop>btnCancel</tabstop> <tabstop>btnCancel</tabstop>
<tabstop>btnEdit</tabstop> <tabstop>btnEdit</tabstop>
<tabstop>btnRemove</tabstop> <tabstop>btnDelete</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>

Loading…
Cancel
Save