Commit 12ec41fe authored by Adrian Chaves's avatar Adrian Chaves
Browse files

Warn before opening 5+ translation files

Summary:
The context menu of a folder node in th Summary view of Lokalize
allows openning all the container files.

While this can be useful, accidentally selecting this option on the root
node of a large project (e.g. KDE translations) can be troublesome.

I’ve ripped off Dolphin’s approach for the same issue here: if more than
5 items are about to be opened, ask for user confirmation first.

I’ve used Dolphin’s limit (5), but I’m open to using a higher value for
Lokalize.

Test Plan: I tested the changes manually.

Reviewers: ppeter, huftis, shaforostoff, sdepiets

Reviewed By: ppeter, sdepiets

Subscribers: #localization, huftis, ppeter

Tags: #localization

Differential Revision: https://phabricator.kde.org/D23953
parent 43e8b5c3
......@@ -31,13 +31,15 @@
#include "catalog.h"
#include "lokalize_debug.h"
#include <KLocalizedString>
#include <KActionCategory>
#include <KActionCollection>
#include <KGuiItem>
#include <KLocalizedString>
#include <KMessageBox>
#include <KProcess>
#include <KStandardAction>
#include <KStandardGuiItem>
#include <KXMLGUIFactory>
#include <KProcess>
#include <KMessageBox>
#include <QLineEdit>
#include <QIcon>
......@@ -353,6 +355,24 @@ void ProjectTab::openFile()
{
QStringList files = m_browser->selectedItems();
int i = files.size();
if (i > 50) {
QString caption = i18np("You are about to open %1 file", "You are about to open %1 files", i);
QString text = i18n("Opening a large number of files at the same time can make Lokalize unresponsive.")
+ QStringLiteral("\n\n")
+ i18n("Are you sure you want to open this many files?");
auto yes = KGuiItem(
i18np("&Open %1 File", "&Open %1 Files", i),
QStringLiteral("document-open")
);
const int answer = KMessageBox::warningYesNo(
this, text, caption, yes, KStandardGuiItem::cancel()
);
if (answer != KMessageBox::Yes) {
return;
}
}
while (--i >= 0) {
if (Catalog::extIsSupported(files.at(i))) {
emit fileOpenRequested(files.at(i), true);
......
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