Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to Qt6, Botan 3, make it work on macOS #105

Merged
merged 31 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
31eeb34
fix: switch to qmake
jlopez Jun 12, 2024
a4dc27e
fix: seek_dir -> seekdir
jlopez Jun 12, 2024
1e5096e
fix: botan 3 include/lib locations
jlopez Jun 12, 2024
0912f12
fix: ensure c++20 std
jlopez Jun 12, 2024
a52ea4d
fix: migrate to botan-3
jlopez Jun 12, 2024
40c85ef
fix: ensure c++20 std
jlopez Jun 12, 2024
6fdf17b
fix: remove softkeys from mainwindow.ui
jlopez Jun 12, 2024
0cb52f6
fix: case insensitive issue on top Makefile
jlopez Jun 12, 2024
bd8ae25
fix: remove unnecessary botan initialization
jlopez Jun 12, 2024
6bd3a29
fix: add .qmake.stash to .gitignore
jlopez Jun 12, 2024
fccdff0
fix: pixmap is no longer a pointer
jlopez Jun 12, 2024
ad362c1
fix: QRegExp to QRegularExpression
jlopez Jun 12, 2024
e8c5ada
fix: switch to UTF-8 encoding
jlopez Jun 12, 2024
c5d8b6a
fix: update QDate methods
jlopez Jun 12, 2024
7815195
fix: setItemHidden -> setHidden
jlopez Jun 12, 2024
493184f
fix: add include for QStandardPaths
jlopez Jun 12, 2024
d52b97a
fix: implicit QChar assignment from int
jlopez Jun 12, 2024
e619675
fix: QNetworkInformation reachability
jlopez Jun 12, 2024
c458fd2
fix: QRegularExpression new API
jlopez Jun 12, 2024
7d2ba73
fix: use std::sort instead of qSort
jlopez Jun 12, 2024
f5c7e9a
fix: QByteArray and QString interactions
jlopez Jun 12, 2024
33bad42
fix: QString sprintf deprecation
jlopez Jun 12, 2024
14e0663
fix: rename of QPalette::background() -> window()
jlopez Jun 12, 2024
4cfe13f
fix: update QDate methods (tbs)
jlopez Jun 12, 2024
13b3b87
fix: missing imports
jlopez Jun 12, 2024
a91c398
fix: QFontMetrics::width -> horizontalAdvance
jlopez Jun 12, 2024
e4e12d9
fix: QPainter::drawRoundRect -> drawRoundedRect
jlopez Jun 12, 2024
45aee02
fix: ensure unix botan libs not used on mac
jlopez Jun 12, 2024
60e1cbe
fix: init QNetworkInformation to avoid crash
jlopez Jun 12, 2024
cea6629
chore: add vscode config files
jlopez Jun 12, 2024
19341e6
doc: update COMPILING.md
jlopez Jul 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ moc_*.h
moc_*.cpp
ui_*.h
qrc_Resources.cpp
.qmake.stash

# Velocity #
############
Expand Down
35 changes: 35 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include",
"/opt/homebrew/include",
"/opt/homebrew/opt/qt/Frameworks/QtWidgets.framework/Versions/Current/Headers",
"/opt/homebrew/opt/qt/Frameworks/QtGui.framework/Versions/Current/Headers",
"/opt/homebrew/opt/qt/Frameworks/QtCore.framework/Versions/Current/Headers",
"/opt/homebrew/opt/qt/Frameworks/QtNetwork.framework/Versions/Current/Headers",
"/opt/homebrew/include/botan-3"
],
"defines": [
"XBOXINTERNALS_LIBRARY",
"QT_CORE_LIB",
"Q_OS_MAC",
"QT_WIDGETS_LIB",
"QT_GUI_LIB"
],
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks",
"/opt/homebrew/opt/qt/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++20",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Velocity.app",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/Velocity/Velocity.app/Contents/MacOS/Velocity",
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "build",
}
]
}
18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "make",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always"
},
"problemMatcher": "$gcc",
}
]
}
30 changes: 15 additions & 15 deletions COMPILING.md
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! Could you update this COMPILING.md to include updated instructions? Seems it's referencing Qt 4.8.1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed a new commit updating COMPILING.md

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed a new commit updating COMPILING.md

The link for the precompiled Botan library in that readme is still for the old version.

Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
The Qt Creator IDE is used to build/debug Velocity. Velocity currently depends on Qt4 and Botan 1.10.
The Qt Creator IDE is used to build/debug Velocity. Velocity currently depends on Qt6 and Botan 3.4

==========

- WINDOWS
While debugging, Velocity is compiled with 'Qt 4.8.1 for Desktop - MingGW (Qt SDK) Debug'.
While compiling for release mode, Velocity is compiled with 'Qt 4.8.1 for Desktop - MingGW (Qt SDK) Release'.

While debugging, Velocity is compiled with 'Qt 6.7 for Desktop - MingGW (Qt SDK) Debug'.
While compiling for release mode, Velocity is compiled with 'Qt 6.7 for Desktop - MingGW (Qt SDK) Release'.

Tool Chain: 'Mingw as a GCC for Windows targets'

WARNING: Botan must be found in the working directory of Velocity.exe for Velocity to successfully run. To obtain the Botan libraries, you have 2 options:

1. Download the Botan sources from http://botan.randombit.net/download.html.
2. Download the Botan binary (.a) from http://www.mediafire.com/?o5zhbb4leufk8d7, if available.

- MAC

Botan can be installed using Homebrew by typing `brew install botan` into your terminal.

- LINUX

The installation process differs depending on distribution. For example:
Ubuntu: `apt-get install libbotan-1.10-0`

Ubuntu: `apt-get install libbotan-3-0`
Arch Linux: `pacman -S botan`

==========

If you do not want to use Qt Creator IDE, you can use Makefile in the root directory of the project.
The Makefile builds Velocity with debug configuration by default, but one can explicitly set desired configuration as the parameter like this:
If you do not want to use Qt Creator IDE, you can use Makefile in the root directory of the project.
The Makefile builds Velocity with debug configuration by default, but one can explicitly set desired configuration as the parameter like this:
`make debug` or `make release`
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QMAKE = qmake-qt4
QMAKE = qmake
UNAME = $(shell uname -s)

ifeq ($(UNAME), Linux)
Expand All @@ -17,11 +17,11 @@ libXboxInternals: XboxInternals/
mkdir -p XboxInternals-$(OS)/$(CONFIG)
cp XboxInternals/libXboxInternals.* XboxInternals-$(OS)/$(CONFIG)

velocity: Velocity/
velocity_target: Velocity/
$(QMAKE) Velocity/Velocity.pro -o Velocity/Makefile CONFIG+=$(CONFIG)
make -C Velocity

modules: libXboxInternals velocity
modules: libXboxInternals velocity_target

debug: CONFIG = debug
debug: modules
Expand Down
12 changes: 7 additions & 5 deletions Velocity/Velocity.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ QT += core gui network xml widgets
TARGET = Velocity
TEMPLATE = app

CONFIG += c++20

win32:UI_DIR = ../Velocity

# application version
Expand All @@ -22,12 +24,12 @@ win32 {
INCLUDEPATH += C:/botan/include
}
macx {
INCLUDEPATH += /usr/local/include/botan-1.10
LIBS += /usr/local/lib/libbotan-1.10.a
INCLUDEPATH += /opt/homebrew/include/botan-3
LIBS += /opt/homebrew/lib/libbotan-3.a
}
unix {
INCLUDEPATH += /usr/include/botan-1.10
LIBS += /usr/lib/libbotan-1.10.so.0
else:unix {
INCLUDEPATH += /usr/include/botan-3
LIBS += /usr/lib/libbotan-3.so.0
}

# phonon, icon
Expand Down
2 changes: 1 addition & 1 deletion Velocity/achievementcreationwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void AchievementCreationWizard::onFinished(int result)
achievement->structSize = 0x1C;

// set the thumbnail image
*achThumbnail = ui->imgThumbnail->pixmap()->toImage();
*achThumbnail = ui->imgThumbnail->pixmap().toImage();
}
}

Expand Down
4 changes: 2 additions & 2 deletions Velocity/creationwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,14 @@ void CreationWizard::onFinished(int status)
QByteArray ba1;
QBuffer buffer1(&ba1);
buffer1.open(QIODevice::WriteOnly);
ui->imgThumbnail->pixmap()->save(&buffer1, "PNG");
ui->imgThumbnail->pixmap().save(&buffer1, "PNG");
package.metaData->thumbnailImage = (BYTE*)ba1.data();
package.metaData->thumbnailImageSize = ba1.length();

QByteArray ba2;
QBuffer buffer2(&ba2);
buffer2.open(QIODevice::WriteOnly);
ui->imgTitleThumbnail->pixmap()->save(&buffer2, "PNG");
ui->imgTitleThumbnail->pixmap().save(&buffer2, "PNG");
package.metaData->titleThumbnailImage = (BYTE*)ba2.data();
package.metaData->titleThumbnailImageSize = ba2.length();

Expand Down
6 changes: 3 additions & 3 deletions Velocity/deviceviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void DeviceViewer::DrawMemoryGraph()

// draw the insano piechart
QPixmap chart(750, 500);
chart.fill(ui->imgPiechart->palette().background().color());
chart.fill(ui->imgPiechart->palette().window().color());
QPainter painter(&chart);
Nightcharts pieChart;
pieChart.setType(Nightcharts::Dpie);
Expand Down Expand Up @@ -273,7 +273,7 @@ void DeviceViewer::showContextMenu(QPoint point)
QDate date;
date.setDate(createdtime.year, createdtime.month, createdtime.monthDay);

entryItem->setText(2, date.toString(Qt::DefaultLocaleShortDate));
entryItem->setText(2, date.toString(QLocale::system().dateFormat(QLocale::ShortFormat)));
}
}
}
Expand Down Expand Up @@ -553,7 +553,7 @@ void DeviceViewer::LoadFolderAll(FatxFileEntry *folder)
QDate date;
date.setDate(createdtime.year, createdtime.month, createdtime.monthDay);

entryItem->setText(2, date.toString(Qt::DefaultLocaleShortDate));
entryItem->setText(2, date.toString(QLocale::system().dateFormat(QLocale::ShortFormat)));

if (i % 25 == 0)
QApplication::processEvents();
Expand Down
4 changes: 2 additions & 2 deletions Velocity/fatxpathgendialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ FATXPathGenDialog::FATXPathGenDialog(StfsPackage *package, QWidget *parent) :
// the general path for packages is: Data\Content\ProfileID\TitleID\ContentType
ui->txtPath->setText("Data\\Content\\" +
QtHelpers::ByteArrayToString(package->metaData->profileID, 8, false) + "\\" +
QString().sprintf("%8X", package->metaData->titleID).replace(" ", "0") + "\\" +
QString().sprintf("%8X", package->metaData->contentType).replace(" ", "0") + "\\");
QString("%1").arg(package->metaData->titleID, 8, 16, QChar('0')).toUpper() + "\\" +
QString("%1").arg(package->metaData->contentType, 8, 16, QChar('0')).toUpper() + "\\");
}

FATXPathGenDialog::~FATXPathGenDialog()
Expand Down
10 changes: 5 additions & 5 deletions Velocity/gameadderdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ GameAdderDialog::GameAdderDialog(StfsPackage *package, QWidget *parent, bool dis
manager = new QNetworkAccessManager(this);

// check for a connection
if (manager->networkAccessible() == QNetworkAccessManager::NotAccessible)
if (QNetworkInformation::instance()->reachability() != QNetworkInformation::Reachability::Online)
{
QMessageBox::warning(this, "Listing Error",
"The listing could not be parsed. Try again later, as the servers may be down and make sure Velocity has access to the internet.");
Expand Down Expand Up @@ -148,7 +148,7 @@ void GameAdderDialog::gameReplyFinished(QNetworkReply *aReply)
.femaleAvatarAwardsEarned = 0,
.femaleAvatarAwardCount = (BYTE)femaleAwardCount.toInt(),
.flags = 0,
.lastPlayed = QDateTime::currentDateTime().toTime_t(),
.lastPlayed = QDateTime::currentDateTime().currentSecsSinceEpoch(),
.gameName = gameName.toStdWString()
};

Expand Down Expand Up @@ -637,7 +637,7 @@ void GameAdderDialog::on_txtSearch_textChanged(const QString & /* arg1 */)

// hide all the items
for (int i = 0; i < ui->treeWidgetAllGames->topLevelItemCount(); i++)
ui->treeWidgetAllGames->setItemHidden(ui->treeWidgetAllGames->topLevelItem(i), true);
ui->treeWidgetAllGames->topLevelItem(i)->setHidden(true);

if (itemsMatched.count() == 0)
{
Expand All @@ -654,13 +654,13 @@ void GameAdderDialog::on_txtSearch_textChanged(const QString & /* arg1 */)
QTreeWidgetItem *parent = itemsMatched.at(i)->parent();
while (parent != NULL)
{
ui->treeWidgetAllGames->setItemHidden(parent, false);
parent->setHidden(false);
parent->setExpanded(true);
parent = parent->parent();
}

// show the item itself
ui->treeWidgetAllGames->setItemHidden(itemsMatched.at(i), false);
itemsMatched.at(i)->setHidden(false);
}
}

Expand Down
1 change: 1 addition & 0 deletions Velocity/gameadderdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QDialog>
#include <QNetworkRequest>
#include <QNetworkAccessManager>
#include <QNetworkInformation>
#include <QNetworkReply>
#include <QTreeWidgetItem>
#include <QDateTime>
Expand Down
16 changes: 9 additions & 7 deletions Velocity/gamerpicturepackdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,22 @@ void GamerPicturePackDialog::gamercardNetworkReply(QNetworkReply *reply)
{
// setup
QString pageSource(reply->readAll());
QRegExp exp("<title>([^<]*).*<img id=\"Gamerpic\" src=\"([^\"]*)");
QRegularExpression exp("<title>([^<]*).*<img id=\"Gamerpic\" src=\"([^\"]*)");

exp.indexIn(pageSource, 0);
QRegularExpressionMatch match = exp.match(pageSource);
if (!match.hasMatch())
return;

// request image
QString gamertag = exp.cap(1);
QString gamertag = match.captured(1);
ui->txtSearch->setText(gamertag);

if (searchedGamertags.contains(gamertag))
return;

searchedGamertags.push_back(gamertag);

QString urlStr = exp.cap(2);
QString urlStr = match.captured(2);
QUrl url(urlStr);

if (url.host() == "avatar.xboxlive.com")
Expand Down Expand Up @@ -180,8 +182,8 @@ void GamerPicturePackDialog::onTitleIDSearchReturn(QList<TitleData> titlesFound)
// display all the titles found in the widget
for (int i = 0; i < titlesFound.size(); i++)
{
QString newStr = ((QString*)&titlesFound.at(i).titleName)->replace("&#174;", "").replace("&#39;",
"'").replace("&amp;","&").replace("&gt;",">").replace("&lt;","<").replace("", "").replace("", "");
QString newStr = ((QString*)&titlesFound.at(i).titleName)->replace("&#174;", "®").replace("&#39;",
"'").replace("&amp;","&").replace("&gt;",">").replace("&lt;","<").replace("â", "").replace("¢", "");
ui->listGameNames->addItem(newStr);
}
}
Expand Down Expand Up @@ -493,7 +495,7 @@ bool GamerPicturePackDialog::verifyGamertag(QString gamertag)
if (gamertag.length() == 0 || gamertag.length() > 15 || !gamertag.at(0).isLetter())
return false;

QChar prevChar = 0;
QChar prevChar(0);
for (int i = 1; i < gamertag.length(); i++)
{
if (gamertag.at(i) == ' ' && prevChar == ' ')
Expand Down
4 changes: 2 additions & 2 deletions Velocity/githubcommitsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GitHubCommitsDialog::GitHubCommitsDialog(QWidget *parent) :
label->setWordWrap(true);

// make sure we can connect to the internet
if (commitsManager->networkAccessible() == QNetworkAccessManager::NotAccessible)
if (QNetworkInformation::instance()->reachability() != QNetworkInformation::Reachability::Online)
{
label->setText("<center>Error connecting to GitHub...</center>");
return;
Expand Down Expand Up @@ -103,7 +103,7 @@ void GitHubCommitsDialog::onCommitsReply(QNetworkReply *reply)

if (++retrievedCount == branchCount)
{
qSort(allCommits.begin(), allCommits.end(), commitCompare);
std::sort(allCommits.begin(), allCommits.end(), commitCompare);

int iterations = (allCommits.size() > 20) ? 20 : allCommits.size();
for (int i = 0; i < iterations; i++)
Expand Down
1 change: 1 addition & 0 deletions Velocity/githubcommitsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QDialog>
#include <QLabel>
#include <QNetworkAccessManager>
#include <QNetworkInformation>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QDateTime>
Expand Down
Loading