Folder %1 is not empty.
", fileString) + (moveToTrash ? i18n("Skip this one or trash all?
Skip this one or delete all?
")), QString(), KGuiItem(i18n("&Skip")), KGuiItem(moveToTrash ? i18n("&Trash All") : i18n("&Delete All"))); if (result == KMessageBox::Yes) { confirmedFiles.remove(fileUrl); // skip this dir } else if (result == KMessageBox::No) { break; // accept all remaining } else { return QListThe archive %1.%2 already exists. Do you want to overwrite it?
All data in the previous archive will be lost.
The archive %1.%2 already exists. Do you want to overwrite it?
Zip will replace identically named entries in the zip archive or add entries for new names.
Furthermore, running UI applications as root is insecure and can "
"allow attackers to gain root access."),
QString(), KStandardGuiItem::cont(), KStandardGuiItem::cancel(), "Confirm Root Mode",
KMessageBox::Notify | KMessageBox::Dangerous) != KMessageBox::Continue)
return;
if (!KrServices::isExecutable(KDESU_PATH)) {
KMessageBox::sorry(krApp,
i18n("Cannot start root mode Krusader, %1 not found or not executable. "
"Please verify that kde-cli-tools are installed.", QString(KDESU_PATH)));
return;
}
KProcess proc;
proc << KDESU_PATH << "-c" << QApplication::instance()->applicationFilePath()
+ " --left=" + KrServices::quote(LEFT_PANEL->virtualPath().toDisplayString(QUrl::PreferLocalFile))
+ " --right=" + KrServices::quote(RIGHT_PANEL->virtualPath().toDisplayString(QUrl::PreferLocalFile));
if (!proc.startDetached())
KMessageBox::error(nullptr, i18n("Error executing %1.", proc.program()[0]));
}
void KRslots::slotSplit()
{
const QStringList list = ACTIVE_PANEL->gui->getSelectedNames();
QString name;
// first, see if we've got exactly 1 selected file, if not, try the current one
if (list.count() == 1) name = list[0];
if (name.isEmpty()) {
// if we got here, then one of the panel can't be sure what file to diff
KMessageBox::error(nullptr, i18n("Do not know which file to split."));
return;
}
QUrl fileURL = ACTIVE_FUNC->files()->getUrl(name);
if (fileURL.isEmpty())
return;
if (ACTIVE_FUNC->files()->getFileItem(name)->isDir()) {
KMessageBox::sorry(krApp, i18n("You cannot split a folder."));
return;
}
const QUrl destDir = ACTIVE_PANEL->otherPanel()->virtualPath();
SplitterGUI splitterGUI(MAIN_VIEW, fileURL, destDir);
if (splitterGUI.exec() == QDialog::Accepted) {
bool splitToOtherPanel = splitterGUI.getDestinationDir().matches(ACTIVE_PANEL->otherPanel()->virtualPath(),
QUrl::StripTrailingSlash);
Splitter split(MAIN_VIEW, fileURL, splitterGUI.getDestinationDir(), splitterGUI.overWriteFiles());
split.split(splitterGUI.getSplitSize());
if (splitToOtherPanel)
ACTIVE_PANEL->otherPanel()->func->refresh();
}
}
void KRslots::slotCombine()
{
const QStringList list = ACTIVE_PANEL->gui->getSelectedNames();
if (list.isEmpty()) {
KMessageBox::error(nullptr, i18n("Do not know which files to combine."));
return;
}
QUrl baseURL;
bool unixStyle = false;
bool windowsStyle = false;
QString commonName;
int commonLength = 0;
/* checking splitter names */
for (const auto & it : list) {
QUrl url = ACTIVE_FUNC->files()->getUrl(it);
if (url.isEmpty())
return;
if (ACTIVE_FUNC->files()->getFileItem(it)->isDir()) {
KMessageBox::sorry(krApp, i18n("You cannot combine a folder."));
return;
}
if (!unixStyle) {
QString name = url.fileName();
int extPos = name.lastIndexOf('.');
QString ext = name.mid(extPos + 1);
name.truncate(extPos);
url = url.adjusted(QUrl::RemoveFilename);
url.setPath(url.path() + name);
bool isExtInt;
ext.toInt(&isExtInt, 10);
if (extPos < 1 || ext.isEmpty() || (ext != "crc" && !isExtInt)) {
if (windowsStyle) {
KMessageBox::error(nullptr, i18n("Not a split file: %1.", url.toDisplayString(QUrl::PreferLocalFile)));
return;
}
unixStyle = true;
} else {
if (ext != "crc")
windowsStyle = true;
if (baseURL.isEmpty())
baseURL = url;
else if (baseURL != url) {
KMessageBox::error(nullptr, i18n("Select only one split file."));
return;
}
}
}
if (unixStyle) {
bool error = true;
do {
const QString& shortName = it;
QChar lastChar = shortName.at(shortName.length() - 1);
if (lastChar.isLetter()) {
char fillLetter = (lastChar.toUpper() == lastChar) ? 'A' : 'a';
if (commonName.isNull()) {
commonLength = shortName.length();
commonName = shortName;
while (commonName.length()) {
QString shorter = commonName.left(commonName.length() - 1);
QString testFile = shorter.leftJustified(commonLength, fillLetter);
if (ACTIVE_FUNC->files()->getFileItem(testFile) == nullptr)
break;
else {
commonName = shorter;
baseURL = ACTIVE_PANEL->virtualPath().adjusted(QUrl::StripTrailingSlash);
baseURL.setPath(baseURL.path() + '/' + (testFile));
}
}
error = (commonName == shortName);
} else if (commonLength == shortName.length() && shortName.startsWith(commonName))
error = false;
}
} while (false);
if (error) {
KMessageBox::error(nullptr, i18n("Not a split file: %1.", url.toDisplayString(QUrl::PreferLocalFile)));
return;
}
}
}
// ask the user for the copy dest
QUrl dest = KChooseDir::getDir(i18n("Combining %1.* to folder:", baseURL.toDisplayString(QUrl::PreferLocalFile)),
ACTIVE_PANEL->otherPanel()->virtualPath(), ACTIVE_PANEL->virtualPath());
if (dest.isEmpty()) return ; // the user canceled
bool combineToOtherPanel = (dest.matches(ACTIVE_PANEL->otherPanel()->virtualPath(), QUrl::StripTrailingSlash));
Combiner combine(MAIN_VIEW, baseURL, dest, unixStyle);
combine.combine();
if (combineToOtherPanel)
ACTIVE_PANEL->otherPanel()->func->refresh();
}
void KRslots::manageUseractions()
{
ActionMan actionMan(MAIN_VIEW);
}
#ifdef SYNCHRONIZER_ENABLED
void KRslots::slotSynchronizeDirs(QStringList selected)
{
SynchronizerGUI *synchronizerDialog = new SynchronizerGUI(MAIN_VIEW, LEFT_PANEL->virtualPath(),
RIGHT_PANEL->virtualPath(), std::move(selected));
synchronizerDialog->show(); // destroyed on close
}
#endif
void KRslots::compareSetup()
{
for (int i = 0; KrActions::compareArray[i] != nullptr; i++)
if ((*KrActions::compareArray[i])->isChecked()) {
KConfigGroup group(krConfig, "Private");
group.writeEntry("Compare Mode", i);
break;
}
}
/** called by actions actExec* to choose the built-in command line mode */
void KRslots::execTypeSetup()
{
for (int i = 0; KrActions::execTypeArray[i] != nullptr; i++)
if ((*KrActions::execTypeArray[i])->isChecked()) {
if (*KrActions::execTypeArray[i] == KrActions::actExecTerminalEmbedded) {
// if commands are to be executed in the TE, it must be loaded
MAIN_VIEW->terminalDock()->initialise();
}
KConfigGroup grp(krConfig, "Private");
grp.writeEntry("Command Execution Mode", i);
break;
}
}
void KRslots::slotDiskUsage()
{
DiskUsageGUI *diskUsageDialog = new DiskUsageGUI(ACTIVE_PANEL->virtualPath());
diskUsageDialog->askDirAndShow();
}
void KRslots::applicationStateChanged()
{
if (MAIN_VIEW == nullptr) { /* CRASH FIX: it's possible that the method is called after destroying the main view */
return;
}
if(qApp->applicationState() == Qt::ApplicationActive ||
qApp->applicationState() == Qt::ApplicationInactive) {
LEFT_PANEL->panelVisible();
RIGHT_PANEL->panelVisible();
} else {
LEFT_PANEL->panelHidden();
RIGHT_PANEL->panelHidden();
}
}
void KRslots::emptyTrash()
{
KrTrashHandler::emptyTrash();
}
#define OPEN_ID 100001
#define EMPTY_TRASH_ID 100002
void KRslots::trashPopupMenu()
{
QMenu trashMenu(krApp);
QAction * act = trashMenu.addAction(Icon("document-open"), i18n("Open trash bin"));
act->setData(QVariant(OPEN_ID));
act = trashMenu.addAction(Icon("trash-empty"), i18n("Empty trash bin"));
act->setData(QVariant(EMPTY_TRASH_ID));
int result = -1;
QAction *res = trashMenu.exec(QCursor::pos());
if (res && res->data().canConvert