Skip to content

Commit

Permalink
inital commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Aryxile committed Sep 25, 2023
1 parent 50c6f3c commit 3d7c6a1
Show file tree
Hide file tree
Showing 49 changed files with 2,589 additions and 0 deletions.
117 changes: 117 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,117 @@
cmake_minimum_required(VERSION 3.5)

project(SubPar VERSION 1.0 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Network)

set(TS_FILES SubPar_en_IE.ts)

set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
assets.qrc
optionsdialog.h optionsdialog.cpp optionsdialog.ui
opensubtitlesapi.h opensubtitlesapi.cpp
aboutdialog.h aboutdialog.cpp aboutdialog.ui

filelistmodel.h filelistmodel.cpp
qfileitem.h qfileitem.cpp
qlistviewdrawdelegate.h qlistviewdrawdelegate.cpp
listview.h listview.cpp
${TS_FILES}
)

if (WIN32)
set(app_icon_resource "${CMAKE_CURRENT_SOURCE_DIR}/resources/app_icon.rc")
qt_add_executable(SubPar
MANUAL_FINALIZATION
${PROJECT_SOURCES}
${app_icon_resource}
)
# qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
elseif (APPLE)
# The MACOSX_BUNDLE_ICON_FILE variable is added to the Info.plist
# generated by CMake. This variable contains the .icns file name,
# without the path.
# set(MACOSX_BUNDLE_ICON_FILE subpar.icns)

# # And the following tells CMake where to find and install the file itself.
# set(app_icon_resource "${CMAKE_CURRENT_SOURCE_DIR}/resources/subpar.icns")
# set_source_files_properties(${app_icon_resource} PROPERTIES
# MACOSX_PACKAGE_LOCATION "Resources")

# qt_add_executable(SubPar
# MACOSX_BUNDLE
# MANUAL_FINALIZATION
# ${PROJECT_SOURCES}
# ${app_icon_resource})

# The MACOSX_BUNDLE_ICON_FILE variable is added to the Info.plist
# generated by CMake. This variable contains the .icns file name,
# without the path.
set(MACOSX_BUNDLE_ICON_FILE subpar.icns)

# And the following tells CMake where to find and install the file itself.
set(app_icon_macos "${CMAKE_CURRENT_SOURCE_DIR}/resources/subpar.icns")
set_source_files_properties(${app_icon_macos} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")

qt_add_executable(SubPar MACOSX_BUNDLE ${PROJECT_SOURCES} ${app_icon_macos})
else()
qt_add_executable(SubPar ${PROJECT_SOURCES})
endif()


if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)


#################
# Define target properties for Android with Qt 6 as:
# set_property(TARGET SubPar APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation

# qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
if(ANDROID)
add_library(SubPar SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(SubPar
${PROJECT_SOURCES}
)
endif()

qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()

target_link_libraries(SubPar PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network)

set_target_properties(SubPar PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER subpar.arcanespire.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)

install(TARGETS SubPar
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(SubPar)
endif()
3 changes: 3 additions & 0 deletions SubPar_en_IE.ts
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_IE"></TS>
19 changes: 19 additions & 0 deletions aboutdialog.cpp
@@ -0,0 +1,19 @@
#include "aboutdialog.h"
#include "ui_aboutdialog.h"
#include <QDesktopServices>
#include <QLabel>

AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDialog) {

ui->setupUi(this);
connect( findChild<QLabel*>("linkLabel"), &QLabel::linkActivated, this, &AboutDialog::OpenLink );
}

AboutDialog::~AboutDialog() {
delete ui;
}

void AboutDialog::OpenLink(const QString &link) {
QDesktopServices::openUrl( QUrl("https://www.arcanespire.com/subpar", QUrl::TolerantMode) );
}

26 changes: 26 additions & 0 deletions aboutdialog.h
@@ -0,0 +1,26 @@
#ifndef ABOUTDIALOG_H
#define ABOUTDIALOG_H

#include <QDialog>

namespace Ui {
class AboutDialog;
}

class AboutDialog : public QDialog
{
Q_OBJECT

public:
explicit AboutDialog(QWidget *parent = nullptr);
~AboutDialog();

private slots:

void OpenLink(const QString &link);

private:
Ui::AboutDialog *ui;
};

#endif // ABOUTDIALOG_H
138 changes: 138 additions & 0 deletions aboutdialog.ui
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>411</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>256</width>
<height>256</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>256</width>
<height>256</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="assets.qrc">:/icon/images/Icon.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>16</pointsize>
</font>
</property>
<property name="text">
<string>SubPar</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>version 1.0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="linkLabel">
<property name="font">
<font>
<underline>true</underline>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(0, 0, 255)</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;
&lt;a href=&quot;www.arcanespire.com/subpar&quot;&gt;www.arcanespire.com/subpar&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="assets.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AboutDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AboutDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
14 changes: 14 additions & 0 deletions assets.qrc
@@ -0,0 +1,14 @@
<RCC>
<qresource prefix="/images">
<file>images/cog.png</file>
<file>images/logo.gif</file>
<file>images/downloading.png</file>
<file>images/not_found.png</file>
<file>images/searching.png</file>
<file>images/success.png</file>
<file>images/about.png</file>
</qresource>
<qresource prefix="/icon">
<file>images/Icon.png</file>
</qresource>
</RCC>

0 comments on commit 3d7c6a1

Please sign in to comment.