Qt6 Readiness (#470)
Make it possible to build GUI with Qt 6 while keeping compatibility with 5.6.3.
This commit is contained in:
parent
eabd0f2168
commit
c2de3db345
13
.github/workflows/qt6_test.sh
vendored
Executable file
13
.github/workflows/qt6_test.sh
vendored
Executable file
@ -0,0 +1,13 @@
|
||||
cd tsMuxerGUI
|
||||
|
||||
mkdir qmake_build
|
||||
cd qmake_build
|
||||
qmake ..
|
||||
make -j$(nproc --all)
|
||||
|
||||
cd ../..
|
||||
|
||||
mkdir cmake_build
|
||||
cd cmake_build
|
||||
cmake -DTSMUXER_GUI=TRUE -DQT_VERSION=6 ..
|
||||
make -j$(nproc --all) tsMuxerGUI
|
28
.github/workflows/qt6_test.yml
vendored
Normal file
28
.github/workflows/qt6_test.yml
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
name: Qt6 test build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
paths:
|
||||
- 'tsMuxerGUI/**'
|
||||
pull_request:
|
||||
branches: [master]
|
||||
paths:
|
||||
- 'tsMuxerGUI/**'
|
||||
|
||||
jobs:
|
||||
build-qt6-test:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
name: checkout
|
||||
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v2
|
||||
with:
|
||||
version: '6.2.0'
|
||||
|
||||
- run: ./.github/workflows/qt6_test.sh
|
||||
name: build-qt6-linux
|
@ -9,12 +9,40 @@ if(CMAKE_VERSION VERSION_LESS "3.7.0")
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
endif()
|
||||
|
||||
find_package(Qt5 COMPONENTS Widgets Multimedia LinguistTools REQUIRED)
|
||||
set(QT_VERSION 5 CACHE STRING "Qt version to use")
|
||||
set_property(CACHE QT_VERSION PROPERTY STRINGS 5 6)
|
||||
|
||||
set(qt_ver_pfx "Qt${QT_VERSION}")
|
||||
|
||||
find_package(${qt_ver_pfx}
|
||||
REQUIRED COMPONENTS Widgets LinguistTools
|
||||
OPTIONAL_COMPONENTS Multimedia)
|
||||
set(tsmuxer_gui_libs ${qt_ver_pfx}::Widgets)
|
||||
|
||||
if(${${qt_ver_pfx}Multimedia_FOUND})
|
||||
list(APPEND tsmuxer_gui_libs ${qt_ver_pfx}::Multimedia)
|
||||
endif()
|
||||
|
||||
set(tsmuxer_ts_files
|
||||
translations/tsmuxergui_en.ts
|
||||
translations/tsmuxergui_ru.ts
|
||||
translations/tsmuxergui_fr.ts
|
||||
translations/tsmuxergui_zh.ts
|
||||
)
|
||||
|
||||
set(lang_qrc "translations.qrc")
|
||||
configure_file(${lang_qrc} ${lang_qrc} COPYONLY)
|
||||
# create_translation is not used due to QTBUG-41736
|
||||
qt5_add_translation(QM_FILES translations/tsmuxergui_en.ts translations/tsmuxergui_ru.ts translations/tsmuxergui_fr.ts translations/tsmuxergui_zh.ts)
|
||||
|
||||
if(${QT_VERSION} EQUAL 5)
|
||||
# create_translation is not used due to QTBUG-41736
|
||||
qt5_add_translation(QM_FILES ${tsmuxer_ts_files})
|
||||
elseif(${QT_VERSION} EQUAL 6)
|
||||
# should use qt6_add_translations once Qt6 is the only supported version.
|
||||
# this will also make ${lang_qrc} and all QM_FILES shenanigans unnecessary as
|
||||
# that command turns the compiled qrcs into resources automatically, and adds
|
||||
# them to the target's sources so they're embedded in the final binary.
|
||||
qt6_add_translation(QM_FILES ${tsmuxer_ts_files})
|
||||
endif()
|
||||
|
||||
set(tsmuxer_gui_sources
|
||||
main.cpp
|
||||
@ -40,14 +68,14 @@ elseif(APPLE)
|
||||
endif()
|
||||
|
||||
add_executable(tsMuxerGUI ${GUI_OPTIONS} ${tsmuxer_gui_sources})
|
||||
target_link_libraries(tsMuxerGUI Qt5::Widgets Qt5::Multimedia)
|
||||
target_link_libraries(tsMuxerGUI ${tsmuxer_gui_libs})
|
||||
|
||||
if(NOT MSVC)
|
||||
install(TARGETS tsMuxerGUI DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(FILES tsMuxerGUI.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
|
||||
install(FILES images/icon.png
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps/
|
||||
RENAME tsMuxerGUI.png)
|
||||
RENAME tsMuxerGUI.png)
|
||||
endif(NOT MSVC)
|
||||
|
||||
if (WIN32)
|
||||
|
@ -6,7 +6,10 @@
|
||||
|
||||
TEMPLATE = app
|
||||
TARGET = tsMuxerGUI
|
||||
QT = core gui widgets multimedia
|
||||
QT = core gui widgets
|
||||
qtHaveModule(multimedia) {
|
||||
QT += multimedia
|
||||
}
|
||||
CONFIG += c++17 strict_c++ lrelease embed_translations
|
||||
|
||||
HEADERS += tsmuxerwindow.h lang_codes.h muxForm.h checkboxedheaderview.h \
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QMimeData>
|
||||
#include <QSettings>
|
||||
#include <QSound>
|
||||
#include <QStandardPaths>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTime>
|
||||
|
||||
@ -20,6 +20,11 @@
|
||||
#include "fontsettingstablemodel.h"
|
||||
#include "lang_codes.h"
|
||||
#include "muxForm.h"
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
||||
#define setTabStopDistance setTabStopWidth
|
||||
#endif
|
||||
|
||||
#include "ui_tsmuxerwindow.h"
|
||||
|
||||
namespace
|
||||
@ -304,7 +309,9 @@ TsMuxerWindow::TsMuxerWindow()
|
||||
{
|
||||
delete settings;
|
||||
settings = new QSettings(iniName, QSettings::IniFormat);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
settings->setIniCodec("UTF-8");
|
||||
#endif
|
||||
if (!readSettings())
|
||||
writeSettings(); // copy current registry settings to the ini file
|
||||
}
|
||||
@ -432,7 +439,7 @@ TsMuxerWindow::TsMuxerWindow()
|
||||
connect(&proc, &QProcess::readyReadStandardError, this, &TsMuxerWindow::readFromStderr);
|
||||
void (QProcess::*processFinished)(int, QProcess::ExitStatus) = &QProcess::finished;
|
||||
connect(&proc, processFinished, this, &TsMuxerWindow::onProcessFinished);
|
||||
void (QProcess::*processError)(QProcess::ProcessError) = &QProcess::error;
|
||||
void (QProcess::*processError)(QProcess::ProcessError) = &QProcess::errorOccurred;
|
||||
connect(&proc, processError, this, &TsMuxerWindow::onProcessError);
|
||||
|
||||
ui->DiskLabel->setVisible(false);
|
||||
@ -698,7 +705,7 @@ void TsMuxerWindow::updateCurrentColor(int dr, int dg, int db, int row)
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
QModelIndex index = ui->trackLV->model()->index(row, i);
|
||||
ui->trackLV->model()->setData(index, QBrush(color), Qt::BackgroundColorRole);
|
||||
ui->trackLV->model()->setData(index, QBrush(color), Qt::BackgroundRole);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1241,9 +1248,7 @@ void TsMuxerWindow::continueAddFile()
|
||||
if (!mplsFileList.empty())
|
||||
fileItem->setData(MplsItemRole, MPLS_PRIMARY);
|
||||
fileItem->setData(FileNameRole, newFileName);
|
||||
QVariant v;
|
||||
v.setValue<ChapterList>(chapters);
|
||||
fileItem->setData(ChaptersRole, v);
|
||||
fileItem->setData(ChaptersRole, QVariant::fromValue(chapters));
|
||||
fileItem->setData(FileDurationRole, fileDuration);
|
||||
chapters.clear();
|
||||
fileDuration = 0.0;
|
||||
@ -1293,7 +1298,7 @@ void TsMuxerWindow::updateCustomChapters()
|
||||
}
|
||||
|
||||
ui->memoChapters->clear();
|
||||
QList<qint64> mergedChapterList = chaptersSet.toList();
|
||||
QList<qint64> mergedChapterList = chaptersSet.values();
|
||||
std::sort(std::begin(mergedChapterList), std::end(mergedChapterList));
|
||||
for (auto chapter : mergedChapterList)
|
||||
ui->memoChapters->insertPlainText(floatToTime(chapter / 1000000.0) + QString('\n'));
|
||||
@ -1369,8 +1374,12 @@ void TsMuxerWindow::readFromStderr()
|
||||
|
||||
void TsMuxerWindow::myPlaySound(const QString &fileName)
|
||||
{
|
||||
#if QT_MULTIMEDIA_LIB
|
||||
sound.setSource(QUrl(QString("qrc%1").arg(fileName)));
|
||||
sound.play();
|
||||
#else
|
||||
QApplication::beep();
|
||||
#endif
|
||||
}
|
||||
|
||||
void TsMuxerWindow::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
@ -1482,9 +1491,7 @@ void TsMuxerWindow::doAppendInt(const QString &fileName, const QString &parentFi
|
||||
item->setData(FileNameRole, fileName);
|
||||
if (duration > 0)
|
||||
item->setData(FileDurationRole, duration);
|
||||
QVariant v;
|
||||
v.setValue<ChapterList>(chapters);
|
||||
item->setData(ChaptersRole, v);
|
||||
item->setData(ChaptersRole, QVariant::fromValue(chapters));
|
||||
|
||||
ui->inputFilesLV->setCurrentItem(item);
|
||||
|
||||
|
@ -3,11 +3,14 @@
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QProcess>
|
||||
#include <QSoundEffect>
|
||||
#include <QTimer>
|
||||
#include <QTranslator>
|
||||
#include <QWidget>
|
||||
|
||||
#if QT_MULTIMEDIA_LIB
|
||||
#include <QSoundEffect>
|
||||
#endif
|
||||
|
||||
#include "codecinfo.h"
|
||||
|
||||
class QFileDialog;
|
||||
@ -194,7 +197,9 @@ class TsMuxerWindow : public QWidget
|
||||
void dragMoveEvent(QDragMoveEvent* event) override;
|
||||
void dragLeaveEvent(QDragLeaveEvent* event) override;
|
||||
|
||||
#if QT_MULTIMEDIA_LIB
|
||||
QSoundEffect sound;
|
||||
#endif
|
||||
void myPlaySound(const QString& fileName);
|
||||
bool isVideoCropped();
|
||||
|
||||
|
@ -1233,7 +1233,7 @@
|
||||
<property name="tabChangesFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabStopWidth">
|
||||
<property name="tabStopDistance">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
|
Loading…
x
Reference in New Issue
Block a user