Some bs zentry changes.
This commit is contained in:
parent
23827f4ffa
commit
6cc3d71acf
11
tools/zentry/main.cpp
Normal file
11
tools/zentry/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
120
tools/zentry/mainwindow.cpp
Normal file
120
tools/zentry/mainwindow.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include "compression.h"
|
||||
#include "qfiledialog.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QLabel>
|
||||
#include <QFile>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow{parent} {
|
||||
setWindowTitle("Zentry Tool");
|
||||
setMinimumSize(250, 150);
|
||||
setMaximumSize(250, 150);
|
||||
setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
|
||||
|
||||
QLabel *dragLabel = new QLabel(this);
|
||||
dragLabel->setText("Drop file here...");
|
||||
dragLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
dragLabel->setStyleSheet("QLabel {"
|
||||
" color: white;"
|
||||
" background-color: grey;"
|
||||
"}"
|
||||
"QLabel::hover "
|
||||
"{"
|
||||
" background-color: black;"
|
||||
"}");
|
||||
|
||||
setCentralWidget(dragLabel);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::dragEnterEvent(QDragEnterEvent *event) {
|
||||
const QMimeData *mimeData = event->mimeData();
|
||||
bool goodDrag = true;
|
||||
if (mimeData->hasUrls()) {
|
||||
qDebug() << mimeData->urls();
|
||||
} else {
|
||||
goodDrag = false;
|
||||
}
|
||||
if (goodDrag) {
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::dragMoveEvent(QDragMoveEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
void MainWindow::dragLeaveEvent(QDragLeaveEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
void MainWindow::dropEvent(QDropEvent *event) {
|
||||
const QMimeData *mimeData = event->mimeData();
|
||||
if (mimeData->hasUrls()) {
|
||||
foreach (const QUrl &url, mimeData->urls()) {
|
||||
const QString fileName = url.toString().split('/').last();
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("Handle File");
|
||||
msgBox.setText("Choose how to handle " + fileName);
|
||||
|
||||
QPushButton *compressButton = msgBox.addButton(tr("Compress"), QMessageBox::AcceptRole);
|
||||
QPushButton *decompressButton = msgBox.addButton(tr("Decompress"), QMessageBox::RejectRole);
|
||||
QPushButton *cancelButton = msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
|
||||
msgBox.exec();
|
||||
|
||||
if ((QPushButton*)msgBox.clickedButton() == compressButton) {
|
||||
// Compress
|
||||
} else if ((QPushButton*)msgBox.clickedButton() == decompressButton) {
|
||||
// Decompress
|
||||
QFile compressedFile(url.toLocalFile());
|
||||
if (!compressedFile.open(QIODevice::ReadOnly)) {
|
||||
qDebug() << QString("Failed to open %1!").arg(fileName);
|
||||
continue;
|
||||
}
|
||||
|
||||
const QByteArray compressedData = compressedFile.readAll();
|
||||
QByteArray decompressedData;
|
||||
if (compressedData.left(2).toHex() == "7801") {
|
||||
qDebug() << "Detected zlib data! (No Compression/low)";
|
||||
decompressedData = Compression::DecompressZLIB(compressedData);
|
||||
} else if (compressedData.left(2).toHex() == "785e") {
|
||||
qDebug() << "Detected zlib data! (Fast Compression)";
|
||||
decompressedData = Compression::DecompressZLIB(compressedData);
|
||||
} else if (compressedData.left(2).toHex() == "789c") {
|
||||
qDebug() << "Detected zlib data! (Default Compression)";
|
||||
decompressedData = Compression::DecompressZLIB(compressedData);
|
||||
} else if (compressedData.left(2).toHex() == "78da") {
|
||||
qDebug() << "Detected zlib data! (Best Compression)";
|
||||
decompressedData = Compression::DecompressZLIB(compressedData);
|
||||
} else {
|
||||
qDebug() << "Invalid zlib header!";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (decompressedData.isEmpty()) {
|
||||
qDebug() << "Zlib output was empty!";
|
||||
continue;
|
||||
}
|
||||
|
||||
const QString decompressedPath = QFileDialog::getSaveFileName(this, "Choose save name");
|
||||
QFile decompressedFile(decompressedPath);
|
||||
if (!decompressedFile.open(QIODevice::WriteOnly)) {
|
||||
qDebug() << QString("Failed to open %1!").arg(decompressedPath.split('/').last());
|
||||
continue;
|
||||
}
|
||||
decompressedFile.write(decompressedData);
|
||||
decompressedFile.close();
|
||||
} else if ((QPushButton*)msgBox.clickedButton() == cancelButton) {
|
||||
// Cancel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
tools/zentry/mainwindow.h
Normal file
32
tools/zentry/mainwindow.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QDebug>
|
||||
#include <QMimeData>
|
||||
#include <QDragEnterEvent>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent *event) override;
|
||||
void dragMoveEvent(QDragMoveEvent *event) override;
|
||||
void dragLeaveEvent(QDragLeaveEvent *event) override;
|
||||
void dropEvent(QDropEvent *event) override;
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
22
tools/zentry/mainwindow.ui
Normal file
22
tools/zentry/mainwindow.ui
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1006</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout"/>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -2,26 +2,29 @@ QT += core widgets gui multimedia
|
||||
|
||||
RC_ICONS = zentry.ico
|
||||
|
||||
SUBDIRS += zentry
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
SOURCES += \
|
||||
zentrymain.cpp \
|
||||
zentrywindow.cpp
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
zentrywindow.h
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
LIBS += \
|
||||
-L$$OUT_PWD/../../libs/ -lcore \
|
||||
-L$$OUT_PWD/../../libs/ -lcompression \
|
||||
-L$$PWD/../../third_party/xbox_sdk/lib -lxcompress64
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$PWD/../../libs/core \
|
||||
$$PWD/../../libs/compression \
|
||||
$$PWD/../../third_party/xbox_sdk/include
|
||||
|
||||
DEPENDPATH += \
|
||||
$$PWD/../../libs/core \
|
||||
$$PWD/../../libs/compression \
|
||||
$$PWD/../../third_party/xbox_sdk/include
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user