Commit 6b413bfa authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Rename group

parent f1429b4f
Pipeline #45301 passed with stage
in 9 minutes and 46 seconds
......@@ -27,6 +27,7 @@
#include <QDir>
#include <QListWidget>
#include <QVBoxLayout>
#include <QInputDialog>
GroupManagementWidget::GroupManagementWidget(QWidget *parent)
: QWidget(parent)
......@@ -54,6 +55,24 @@ void GroupManagementWidget::slotCustomContextMenu()
const auto items = mListWidget->selectedItems();
if (!items.isEmpty()) {
QMenu menu(this);
if (mListWidget->selectedItems().count() == 1) {
const auto item = items.at(0);
menu.addAction(QIcon::fromTheme(QStringLiteral("edit")), i18n("Rename Groups"), this, [this, item]() {
const QString fullPath = item->data(FullPathRole).toString();
QFile f(fullPath);
QFileInfo fileInfo(f);
const QString filePath = fileInfo.path();
const QString newName = QInputDialog::getText(this, i18n("Rename Group"), i18n("New Name:"));
const QString newNameTrimmed = newName.trimmed();
if (!newNameTrimmed.isEmpty()) {
if (!f.rename(filePath + QLatin1Char('/') + newNameTrimmed)) {
KMessageBox::error(this, i18n("Impossible to rename group as \'%1\'", newNameTrimmed), i18n("Rename Group"));
}
}
});
menu.addSeparator();
}
menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Remove Groups"), this, [this, items]() {
for (auto item : items) {
const QString fullPath = item->data(FullPathRole).toString();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment