Skip to content

Commit 3608139

Browse files
gui: strip VICE encryption/decryption from main program in preparation for context menu plugin
1 parent 79c2af9 commit 3608139

File tree

9 files changed

+0
-284
lines changed

9 files changed

+0
-284
lines changed

src/gui/EntryContextMenuData.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ EntryContextMenuData::EntryContextMenuData(bool useRoot, QWidget* parent)
66
this->extractFileAction = this->contextMenuFile->addAction(parent->style()->standardIcon(QStyle::SP_DialogSaveButton), tr("Extract File..."));
77
this->contextMenuFile->addSeparator();
88
this->editFileAction = this->contextMenuFile->addAction(parent->style()->standardIcon(QStyle::SP_DialogResetButton), tr("Rename/Move File..."));
9-
this->encryptFileAction = this->contextMenuFile->addAction(parent->style()->standardIcon(QStyle::SP_TitleBarUnshadeButton), tr("Encrypt File..."));
10-
this->decryptFileAction = this->contextMenuFile->addAction(parent->style()->standardIcon(QStyle::SP_TitleBarShadeButton), tr("Decrypt File..."));
119
this->copyFilePathAction = this->contextMenuFile->addAction(parent->style()->standardIcon(QStyle::SP_FileDialogDetailedView), tr("Copy Path"));
1210
this->contextMenuFile->addSeparator();
1311
this->removeFileAction = this->contextMenuFile->addAction(parent->style()->standardIcon(QStyle::SP_TrashIcon), tr("Remove File"));
@@ -55,8 +53,3 @@ void EntryContextMenuData::setReadOnly(bool readOnly) const {
5553
this->addDirToRootAction->setDisabled(readOnly);
5654
}
5755
}
58-
59-
void EntryContextMenuData::setEncryptDecryptVisible(bool encrypt, bool decrypt) const {
60-
this->encryptFileAction->setVisible(encrypt);
61-
this->decryptFileAction->setVisible(decrypt);
62-
}

src/gui/EntryContextMenuData.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@ struct EntryContextMenuData : public QObject {
1212

1313
void setReadOnly(bool readOnly) const;
1414

15-
void setEncryptDecryptVisible(bool encrypt, bool decrypt) const;
16-
1715
QMenu* contextMenuFile = nullptr;
1816
QAction* extractFileAction = nullptr;
1917
QAction* editFileAction = nullptr;
20-
QAction* encryptFileAction = nullptr;
21-
QAction* decryptFileAction = nullptr;
2218
QAction* copyFilePathAction = nullptr;
2319
QAction* removeFileAction = nullptr;
2420

src/gui/EntryTree.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ EntryTree::EntryTree(Window* window_, QWidget* parent)
355355

356356
QObject::connect(this, &QWidget::customContextMenuRequested, this, [this, contextMenuData](const QPoint& pos) {
357357
contextMenuData->setReadOnly(this->window->isReadOnly());
358-
contextMenuData->setEncryptDecryptVisible(false, false); // todo: remove me
359358
if (const auto selectedIndexes = this->selectedIndexes(); selectedIndexes.length() > 1) {
360359
// Handle the selected action
361360
if (const auto* selectedSelectionAction = contextMenuData->contextMenuSelection->exec(this->mapToGlobal(pos)); selectedSelectionAction == contextMenuData->extractSelectedAction) {

src/gui/Window.cpp

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "dialogs/NewUpdateDialog.h"
4545
#include "dialogs/VerifyChecksumsDialog.h"
4646
#include "dialogs/VerifySignatureDialog.h"
47-
#include "dialogs/VICEDialog.h"
4847
#include "extensions/Folder.h"
4948
#include "utility/DiscordPresence.h"
5049
#include "utility/ImageLoader.h"
@@ -1081,92 +1080,6 @@ void Window::editFileContents(const QString& path, const QString& data) {
10811080
this->markModified(true);
10821081
}
10831082

1084-
void Window::encryptFile(const QString& path) {
1085-
auto entry = this->packFile->findEntry(path.toLocal8Bit().constData());
1086-
if (!entry) {
1087-
return;
1088-
}
1089-
1090-
auto data = VICEDialog::encrypt(this, path, this);
1091-
if (!data) {
1092-
return;
1093-
}
1094-
1095-
// Load existing properties
1096-
EntryCompressionType compressionType = EntryCompressionType::NO_COMPRESS;
1097-
int16_t compressionStrength = 5;
1098-
if (this->packFile->isInstanceOf<BSP>() || this->packFile->isInstanceOf<ZIP>()) {
1099-
if (auto* zip = dynamic_cast<ZIP*>(this->packFile.get())) {
1100-
compressionType = zip->getEntryCompressionType(path.toLocal8Bit().constData());
1101-
compressionStrength = zip->getEntryCompressionStrength(path.toLocal8Bit().constData());
1102-
}
1103-
}
1104-
1105-
QString newPath;
1106-
if (path.endsWith(".kv")) {
1107-
newPath = path.sliced(0, path.length() - 2) + "ekv";
1108-
} else if (path.endsWith(".nut")) {
1109-
newPath = path.sliced(0, path.length() - 3) + "nuc";
1110-
} else if (path.endsWith(".txt")) {
1111-
newPath = path.sliced(0, path.length() - 3) + "ctx";
1112-
}
1113-
this->requestEntryRemoval(path);
1114-
this->requestEntryRemoval(newPath);
1115-
1116-
this->packFile->addEntry(newPath.toLocal8Bit().constData(), std::move(data.value()), {
1117-
.zip_compressionType = compressionType,
1118-
.zip_compressionStrength = compressionStrength,
1119-
.vpk_preloadBytes = static_cast<uint16_t>(entry->extraData.size()),
1120-
.vpk_saveToDirectory = entry->archiveIndex == VPK_DIR_INDEX,
1121-
});
1122-
this->entryTree->addEntry(newPath);
1123-
this->fileViewer->addEntry(*this->packFile, newPath);
1124-
this->markModified(true);
1125-
}
1126-
1127-
void Window::decryptFile(const QString& path) {
1128-
auto entry = this->packFile->findEntry(path.toLocal8Bit().constData());
1129-
if (!entry) {
1130-
return;
1131-
}
1132-
1133-
auto data = VICEDialog::decrypt(this, path, this);
1134-
if (!data) {
1135-
return;
1136-
}
1137-
1138-
// Load existing properties
1139-
EntryCompressionType compressionType = EntryCompressionType::NO_COMPRESS;
1140-
int16_t compressionStrength = 5;
1141-
if (this->packFile->isInstanceOf<BSP>() || this->packFile->isInstanceOf<ZIP>()) {
1142-
if (auto* zip = dynamic_cast<ZIP*>(this->packFile.get())) {
1143-
compressionType = zip->getEntryCompressionType(path.toLocal8Bit().constData());
1144-
compressionStrength = zip->getEntryCompressionStrength(path.toLocal8Bit().constData());
1145-
}
1146-
}
1147-
1148-
QString newPath;
1149-
if (path.endsWith(".ekv")) {
1150-
newPath = path.sliced(0, path.length() - 3) + "kv";
1151-
} else if (path.endsWith(".nuc")) {
1152-
newPath = path.sliced(0, path.length() - 3) + "nut";
1153-
} else if (path.endsWith(".ctx")) {
1154-
newPath = path.sliced(0, path.length() - 3) + "txt";
1155-
}
1156-
this->requestEntryRemoval(path);
1157-
this->requestEntryRemoval(newPath);
1158-
1159-
this->packFile->addEntry(newPath.toLocal8Bit().constData(), std::move(data.value()), {
1160-
.zip_compressionType = compressionType,
1161-
.zip_compressionStrength = compressionStrength,
1162-
.vpk_preloadBytes = static_cast<uint16_t>(entry->extraData.size()),
1163-
.vpk_saveToDirectory = entry->archiveIndex == VPK_DIR_INDEX,
1164-
});
1165-
this->entryTree->addEntry(newPath);
1166-
this->fileViewer->addEntry(*this->packFile, newPath);
1167-
this->markModified(true);
1168-
}
1169-
11701083
void Window::renameDir(const QString& oldPath, const QString& newPath_) {
11711084
// Get new path
11721085
QString newPath = newPath_;

src/gui/Window.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ class Window : public QMainWindow {
8383

8484
void editFileContents(const QString& path, const QString& data);
8585

86-
void encryptFile(const QString& path);
87-
88-
void decryptFile(const QString& path);
89-
9086
void renameDir(const QString& oldPath, const QString& newPath_ = QString());
9187

9288
void generateKeyPairFiles(const QString& name = QString());

src/gui/_gui.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE
1414
"${CMAKE_CURRENT_LIST_DIR}/dialogs/VerifyChecksumsDialog.h"
1515
"${CMAKE_CURRENT_LIST_DIR}/dialogs/VerifySignatureDialog.cpp"
1616
"${CMAKE_CURRENT_LIST_DIR}/dialogs/VerifySignatureDialog.h"
17-
"${CMAKE_CURRENT_LIST_DIR}/dialogs/VICEDialog.cpp"
18-
"${CMAKE_CURRENT_LIST_DIR}/dialogs/VICEDialog.h"
1917

2018
"${CMAKE_CURRENT_LIST_DIR}/extensions/Folder.cpp"
2119
"${CMAKE_CURRENT_LIST_DIR}/extensions/Folder.h"

src/gui/dialogs/VICEDialog.cpp

Lines changed: 0 additions & 125 deletions
This file was deleted.

src/gui/dialogs/VICEDialog.h

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/gui/previews/DirPreview.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,6 @@ DirPreview::DirPreview(FileViewer* fileViewer_, Window* window_, QWidget* parent
101101
auto* contextMenuData = new EntryContextMenuData{false, this};
102102
QObject::connect(this, &QTableWidget::customContextMenuRequested, this, [this, contextMenuData](const QPoint& pos) {
103103
contextMenuData->setReadOnly(this->window->isReadOnly());
104-
if (this->selectedItems().length() == 1) {
105-
auto path = this->getItemPath(this->selectedItems()[0]);
106-
if (path.endsWith(".nuc") || path.endsWith(".ctx") || path.endsWith(".ekv")) {
107-
contextMenuData->setEncryptDecryptVisible(false, true);
108-
} else if (path.endsWith(".nut") || path.endsWith(".txt") || path.endsWith(".kv")) {
109-
contextMenuData->setEncryptDecryptVisible(true, false);
110-
} else {
111-
contextMenuData->setEncryptDecryptVisible(false, false);
112-
}
113-
} else {
114-
contextMenuData->setEncryptDecryptVisible(false, false);
115-
}
116-
117104
if (this->selectedItems().length() > this->columnCount()) {
118105
// Show the selection context menu at the requested position
119106
auto* selectedSelectionAction = contextMenuData->contextMenuSelection->exec(this->mapToGlobal(pos));
@@ -158,10 +145,6 @@ DirPreview::DirPreview(FileViewer* fileViewer_, Window* window_, QWidget* parent
158145
this->window->extractFile(path);
159146
} else if (selectedFileAction == contextMenuData->editFileAction) {
160147
this->window->editFile(path);
161-
} else if (selectedFileAction == contextMenuData->encryptFileAction) {
162-
this->window->encryptFile(path);
163-
} else if (selectedFileAction == contextMenuData->decryptFileAction) {
164-
this->window->decryptFile(path);
165148
} else if (selectedFileAction == contextMenuData->copyFilePathAction) {
166149
QGuiApplication::clipboard()->setText(path);
167150
} else if (selectedFileAction == contextMenuData->removeFileAction) {

0 commit comments

Comments
 (0)