From 56fb9c19dc0ab23d7b4457ee450ac82c091fd176 Mon Sep 17 00:00:00 2001 From: Kitteh Date: Mon, 29 Oct 2018 14:19:12 +0000 Subject: [PATCH] [UI] Minor tweaks, fixes and better screenshot handling. --- CMakeLists.txt | 8 +- KittehPlayer.pro | 9 +- src/fileopendialog.cpp | 226 +++++++++++++++++++++++++++++++++++++ src/fileopendialog.h | 86 ++++++++++++++ src/filesavedialog.cpp | 208 ++++++++++++++++++++++++++++++++++ src/filesavedialog.h | 74 ++++++++++++ src/main.cpp | 10 +- src/mpvobject.cpp | 9 ++ src/mpvobject.h | 1 + src/qml/CustomMenuItem.qml | 1 + src/qml/main.qml | 77 ++++++++----- 11 files changed, 674 insertions(+), 35 deletions(-) create mode 100644 src/fileopendialog.cpp create mode 100644 src/fileopendialog.h create mode 100644 src/filesavedialog.cpp create mode 100644 src/filesavedialog.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c1a7b2..07cae5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -fstrict-aliasing -Wno-dep option(DEVELOP "Enable runtime QML reloading for developing." OFF) - find_package(Qt5Core REQUIRED) +find_package(Qt5Gui REQUIRED) find_package(Qt5 REQUIRED Qml Quick Gui Widgets Core) find_package(Qt5QuickCompiler) @@ -18,14 +18,20 @@ qtquick_compiler_add_resources(qml_QRC src/qml/qml.qrc) find_package(PkgConfig) pkg_check_modules(MPV REQUIRED mpv) + +include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) + set(SOURCES src/main.cpp src/mpvobject.cpp + src/filesavedialog.cpp + src/fileopendialog.cpp ) if(DEVELOP) set(SOURCES ${SOURCES} runtimeqml/runtimeqml.cpp) add_definitions(-DQRC_SOURCE_PATH="${PROJECT_SOURCE_DIR}/src/qml") +add_definitions(-DQT_QML_DEBUG) endif(DEVELOP) add_executable(KittehPlayer ${SOURCES} ${qml_QRC}) diff --git a/KittehPlayer.pro b/KittehPlayer.pro index 2d0044e..065a6df 100644 --- a/KittehPlayer.pro +++ b/KittehPlayer.pro @@ -1,9 +1,8 @@ TARGET = KittehPlayer TEMPLATE = app -QT += qml quickcontrols2 widgets - -SOURCES += src/main.cpp src/mpvobject.cpp +QT += qml quickcontrols2 widgets core-private gui-private +SOURCES += src/main.cpp src/mpvobject.cpp src/filesavedialog.cpp src/fileopendialog.cpp CONFIG += release CONFIG+=qtquickcompiler @@ -13,7 +12,7 @@ PKGCONFIG += mpv RESOURCES += src/qml/qml.qrc unix { - isEmpty(PREFIX) { + isEmpty { PREFIX = /usr } @@ -30,7 +29,7 @@ unix { INSTALLS += target -HEADERS += src/mpvobject.h src/config.h +HEADERS += src/mpvobject.h src/config.h src/filesavedialog.h src/fileopendialog.h DISTFILES += KittehPlayer.desktop KittehPlayer.png README.md LICENSE.txt diff --git a/src/fileopendialog.cpp b/src/fileopendialog.cpp new file mode 100644 index 0000000..d5a9b82 --- /dev/null +++ b/src/fileopendialog.cpp @@ -0,0 +1,226 @@ +/* Copyright 2013–2017 Kullo GmbH. All rights reserved. */ +#include "fileopendialog.h" + +#include +#include +#include + +FileOpenDialog::FileOpenDialog(QQuickItem *parent) + : QQuickItem(parent) + , m_dlgHelper(init_helper()) + , m_modality(Qt::WindowModal) + #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) + , m_options(QFileDialogOptions::create()) + #else + , m_options(QSharedPointer(new QFileDialogOptions())) + #endif +{ + /* + * Qt Widgets support must be present, i.e. the main app is a QApplication. + * The following line break at compile time, if the main app is a QGuiApplication + */ + QApplication *appHasQtWidgetsSupport = qobject_cast(QCoreApplication::instance()); + Q_ASSERT(appHasQtWidgetsSupport); + Q_UNUSED(appHasQtWidgetsSupport); + + if (valid()) + { + connect(m_dlgHelper, &QPlatformFileDialogHelper::accept, + this, &FileOpenDialog::accept); + connect(m_dlgHelper, &QPlatformFileDialogHelper::reject, + this, &FileOpenDialog::reject); + } +} + +FileOpenDialog::~FileOpenDialog() +{ + if (m_dlgHelper) + m_dlgHelper->hide(); + delete m_dlgHelper; +} + +bool FileOpenDialog::valid() const +{ + if (m_dlgHelper) return true; + else return false; +} + +QUrl FileOpenDialog::fileUrl() const +{ + return fileUrl_; +} + +QList FileOpenDialog::fileUrls() const +{ + return fileUrls_; +} + +void FileOpenDialog::setFileUrl(QUrl fileUrl) +{ + if (fileUrl_ != fileUrl) + { + fileUrl_ = fileUrl; + emit fileUrlChanged(); + } +} + +void FileOpenDialog::setFileUrls(QList fileUrls) +{ + if (fileUrls_ != fileUrls) + { + fileUrls_ = fileUrls; + emit fileUrlsChanged(); + } +} + +QString FileOpenDialog::filename() const +{ + return filename_; +} + +void FileOpenDialog::setFilename(QString filename) +{ + if (filename_ != filename) + { + filename_ = filename; + emit filenameChanged(); + } +} + +QString FileOpenDialog::title() const +{ + return title_; +} + +void FileOpenDialog::setTitle(QString title) +{ + if (title_ != title) + { + title_ = title; + emit titleChanged(); + } +} + +QStringList FileOpenDialog::nameFilters() const +{ + return nameFilters_; +} + +void FileOpenDialog::setNameFilters(QStringList nameFilters) +{ + if (nameFilters_ != nameFilters) + { + nameFilters_ = nameFilters; + emit nameFiltersChanged(); + } +} + +bool FileOpenDialog::selectMultiple() const +{ + return selectMultiple_; +} + +void FileOpenDialog::setSelectMultiple(bool selectMultiple) +{ + if (selectMultiple_ != selectMultiple) + { + selectMultiple_ = selectMultiple; + emit selectMultipleChanged(); + } +} + +QPlatformFileDialogHelper* FileOpenDialog::init_helper() +{ + return static_cast( + QGuiApplicationPrivate::platformTheme()->createPlatformDialogHelper(QPlatformTheme::FileDialog) + ); +} + +void FileOpenDialog::open() +{ + if (!valid()) return; + + QQuickItem *parent = this->parentItem(); + Q_ASSERT(parent); + + QQuickWindow *window = parent->window(); + Q_ASSERT(window); + + m_parentWindow = window; + + m_options->setFileMode(selectMultiple_ ? QFileDialogOptions::ExistingFiles : QFileDialogOptions::ExistingFile); + m_options->setAcceptMode(QFileDialogOptions::AcceptOpen); + m_options->setWindowTitle(title()); + m_options->setNameFilters(nameFilters()); + + /* + * Mac: + * Set filename incl. directory via setInitiallySelectedFiles() + * + * Windows: + * Set filename via setInitiallySelectedFiles() and let Windows choose the directory. + * Default directory: C:\\Users\XYZ\Downloads + * + * Gnome: + * Set directory via QPlatformFileDialogHelper::setDirectory() and leave + * filename empty, since QGtk2FileDialogHelper can not set non-existing filenames. + * + */ +#ifdef Q_OS_OSX + QString initialSelection = QFileInfo(QDir::homePath(), filename()).absoluteFilePath(); + //qDebug() << "Initial file:" << initialSelection; + m_options->setInitiallySelectedFiles(QList() << QUrl::fromLocalFile(initialSelection)); +#endif +#ifdef Q_OS_WIN + //qDebug() << "Initial filename:" << filename(); + m_options->setInitiallySelectedFiles(QList() << QUrl::fromLocalFile(filename())); +#endif +#ifdef Q_OS_LINUX + //qDebug() << "Initial directory:" << QDir::homePath(); + m_dlgHelper->setDirectory(QUrl::fromLocalFile(QDir::homePath())); +#endif + + m_dlgHelper->setOptions(m_options); + m_dlgHelper->setFilter(); // applyOptions(); + + Qt::WindowFlags flags = Qt::Dialog; + if (!title().isEmpty()) flags |= Qt::WindowTitleHint; + + m_visible = m_dlgHelper->show(flags, m_modality, m_parentWindow); +} + +void FileOpenDialog::close() +{ + if (!valid()) return; + + m_dlgHelper->hide(); + m_visible = false; +} + +void FileOpenDialog::accept() +{ + if (!valid()) return; + + m_dlgHelper->hide(); + + QList selectedUrls = m_dlgHelper->selectedFiles(); + if (!selectedUrls.empty()) + { + if (selectedUrls.size() == 1) + setFileUrl(selectedUrls.at(0)); + else + setFileUrl(); + + setFileUrls(selectedUrls); + } + + emit accepted(); +} + +void FileOpenDialog::reject() +{ + if (!valid()) return; + + m_dlgHelper->hide(); + emit rejected(); +} diff --git a/src/fileopendialog.h b/src/fileopendialog.h new file mode 100644 index 0000000..e6790a0 --- /dev/null +++ b/src/fileopendialog.h @@ -0,0 +1,86 @@ +/* Copyright 2013–2017 Kullo GmbH. All rights reserved. */ +#pragma once + +#include +#include +#include +#include +#include +#include + +class FileOpenDialog : public QQuickItem +{ + Q_OBJECT + +public: + explicit FileOpenDialog(QQuickItem *parent = 0); + ~FileOpenDialog(); + + Q_PROPERTY(bool valid READ valid NOTIFY validChanged) + bool valid() const; + + Q_PROPERTY(QUrl fileUrl READ fileUrl NOTIFY fileUrlChanged) + QUrl fileUrl() const; + + Q_PROPERTY(QList fileUrls READ fileUrls NOTIFY fileUrlsChanged) + QList fileUrls() const; + + Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged) + QString filename() const; + void setFilename(QString filename); + + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + QString title() const; + void setTitle(QString title); + + Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters NOTIFY nameFiltersChanged) + QStringList nameFilters() const; + void setNameFilters(QStringList nameFilters); + + Q_PROPERTY(bool selectMultiple READ selectMultiple WRITE setSelectMultiple NOTIFY selectMultipleChanged) + bool selectMultiple() const; + void setSelectMultiple(bool selectMultiple); + + Q_INVOKABLE void open(); + Q_INVOKABLE void close(); + +signals: + void fileUrlChanged(); + void fileUrlsChanged(); + void filenameChanged(); + void titleChanged(); + void nameFiltersChanged(); + void accepted(); + void rejected(); + void selectMultipleChanged(); + + // unused + void validChanged(); + +protected: + QPlatformFileDialogHelper* init_helper(); + +protected: + QPlatformFileDialogHelper *m_dlgHelper; + QQuickWindow *m_parentWindow; + Qt::WindowModality m_modality; + bool m_visible; + QSharedPointer m_options; + +protected Q_SLOTS: + virtual void accept(); + virtual void reject(); + +private: + void setFileUrl(QUrl fileUrl = QUrl()); + void setFileUrls(QList fileUrls = QList()); + + QUrl fileUrl_; + QList fileUrls_; + QString filename_; + QString title_; + QStringList nameFilters_; + bool selectMultiple_ = false; + + Q_DISABLE_COPY(FileOpenDialog) +}; diff --git a/src/filesavedialog.cpp b/src/filesavedialog.cpp new file mode 100644 index 0000000..a2bd692 --- /dev/null +++ b/src/filesavedialog.cpp @@ -0,0 +1,208 @@ +/* Copyright 2013–2017 Kullo GmbH. All rights reserved. */ +#include "filesavedialog.h" + +#include +#include +#include +#include + +FileSaveDialog::FileSaveDialog(QQuickItem *parent) + : QQuickItem(parent) + , m_dlgHelper(init_helper()) + , m_modality(Qt::WindowModal) + #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) + , m_options(QFileDialogOptions::create()) + #else + , m_options(QSharedPointer(new QFileDialogOptions())) + #endif +{ + /* + * Qt Widgets support must be present, i.e. the main app is a QApplication. + * The following line break at compile time, if the main app is a QGuiApplication + */ + QApplication *appHasQtWidgetsSupport = qobject_cast(QCoreApplication::instance()); + Q_ASSERT(appHasQtWidgetsSupport); + Q_UNUSED(appHasQtWidgetsSupport); + + if (valid()) + { + connect(m_dlgHelper, &QPlatformFileDialogHelper::accept, + this, &FileSaveDialog::accept); + connect(m_dlgHelper, &QPlatformFileDialogHelper::reject, + this, &FileSaveDialog::reject); + }else{ + qDebug() << "ERROR: You need the gtk3 platform plugin to use the file save dialog."; + qDebug() << "To automatically set gtk3 to QT_QPA_PLATFORMTHEME run the following at the command line"; + qDebug() << "echo \"export QT_QPA_PLATFORMTHEME=gtk3\">> ~/.profile && source ~/.profile"; + } +} + +FileSaveDialog::~FileSaveDialog() +{ + if (m_dlgHelper) + m_dlgHelper->hide(); + delete m_dlgHelper; +} + +bool FileSaveDialog::valid() const +{ + if (m_dlgHelper) return true; + else return false; +} + +QUrl FileSaveDialog::fileUrl() const +{ + return fileUrl_; +} + +void FileSaveDialog::setFileUrl(QUrl fileUrl) +{ + if (fileUrl_ != fileUrl) + { + fileUrl_ = fileUrl; + emit fileUrlChanged(); + } +} + +QString FileSaveDialog::filename() const +{ + return filename_; +} + +void FileSaveDialog::setFilename(QString filename) +{ + if (filename_ != filename) + { + filename_ = filename; + emit filenameChanged(); + } +} + +QString FileSaveDialog::title() const +{ + return title_; +} + +void FileSaveDialog::setTitle(QString title) +{ + if (title_ != title) + { + title_ = title; + emit titleChanged(); + } +} + +QStringList FileSaveDialog::nameFilters() const +{ + return nameFilters_; +} + +void FileSaveDialog::setNameFilters(QStringList nameFilters) +{ + if (nameFilters_ != nameFilters) + { + nameFilters_ = nameFilters; + emit nameFiltersChanged(); + } +} + +QPlatformFileDialogHelper* FileSaveDialog::init_helper() +{ + return static_cast( + QGuiApplicationPrivate::platformTheme()->createPlatformDialogHelper(QPlatformTheme::FileDialog) + ); +} + +void FileSaveDialog::open() +{ + if (!valid()) return; + + QQuickItem *parent = this->parentItem(); + Q_ASSERT(parent); + + QQuickWindow *window = parent->window(); + Q_ASSERT(window); + + m_parentWindow = window; + + m_options->setFileMode(QFileDialogOptions::AnyFile); + m_options->setAcceptMode(QFileDialogOptions::AcceptSave); + m_options->setWindowTitle(title()); + m_options->setNameFilters(nameFilters()); + + /* + * Mac: + * Set filename incl. directory via setInitiallySelectedFiles() + * + * Windows: + * Set filename via setInitiallySelectedFiles() and let Windows choose the directory. + * Default directory: C:\\Users\XYZ\Downloads + * + * Gnome: + * Set directory via QPlatformFileDialogHelper::setDirectory() and leave + * filename empty, since QGtk2FileDialogHelper can not set non-existing filenames. + * + */ + const QString folder = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); + const QString name = filename(); + +#ifdef Q_OS_OSX + QUrl initialSelection = QUrl::fromLocalFile(QFileInfo(folder, name).absoluteFilePath()); + //qDebug() << "Initial file:" << initialSelection; + m_options->setInitiallySelectedFiles(QList() << initialSelection); +#endif +#ifdef Q_OS_WIN + //qDebug() << "Initial filename:" << name; + m_options->setInitiallySelectedFiles(QList() << QUrl::fromLocalFile(name)); +#endif +#ifdef Q_OS_LINUX + #if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 2)) + // Wohoo, big fix! https://codereview.qt-project.org/91501 + QUrl initialSelection = QUrl::fromLocalFile(QFileInfo(folder, name).absoluteFilePath()); + //qDebug() << "Initial file:" << initialSelection; + m_options->setInitiallySelectedFiles(QList() << initialSelection); + #else + //qDebug() << "Initial directory:" << folder; + m_dlgHelper->setDirectory(QUrl::fromLocalFile(folder)); + #endif +#endif + + m_dlgHelper->setOptions(m_options); + m_dlgHelper->setFilter(); // applyOptions(); + + Qt::WindowFlags flags = Qt::Dialog; + if (!title().isEmpty()) flags |= Qt::WindowTitleHint; + + m_visible = m_dlgHelper->show(flags, m_modality, m_parentWindow); +} + +void FileSaveDialog::close() +{ + if (!valid()) return; + + m_dlgHelper->hide(); + m_visible = false; +} + +void FileSaveDialog::accept() +{ + if (!valid()) return; + + m_dlgHelper->hide(); + + QList selectedUrls = m_dlgHelper->selectedFiles(); + if (!selectedUrls.empty()) + { + setFileUrl(selectedUrls.at(0)); + } + + emit accepted(); +} + +void FileSaveDialog::reject() +{ + if (!valid()) return; + + m_dlgHelper->hide(); + emit rejected(); +} diff --git a/src/filesavedialog.h b/src/filesavedialog.h new file mode 100644 index 0000000..7577d21 --- /dev/null +++ b/src/filesavedialog.h @@ -0,0 +1,74 @@ +/* Copyright 2013–2017 Kullo GmbH. All rights reserved. */ +#pragma once + +#include +#include +#include +#include +#include +#include + +class FileSaveDialog : public QQuickItem +{ + Q_OBJECT + +public: + explicit FileSaveDialog(QQuickItem *parent = 0); + ~FileSaveDialog(); + + Q_PROPERTY(bool valid READ valid NOTIFY validChanged) + bool valid() const; + + Q_PROPERTY(QUrl fileUrl READ fileUrl NOTIFY fileUrlChanged) + QUrl fileUrl() const; + + Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged) + QString filename() const; + void setFilename(QString filename); + + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + QString title() const; + void setTitle(QString title); + + Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters NOTIFY nameFiltersChanged) + QStringList nameFilters() const; + void setNameFilters(QStringList nameFilters); + + Q_INVOKABLE void open(); + Q_INVOKABLE void close(); + +signals: + void fileUrlChanged(); + void filenameChanged(); + void titleChanged(); + void nameFiltersChanged(); + void accepted(); + void rejected(); + + // unused + void validChanged(); + +protected: + QPlatformFileDialogHelper* init_helper(); + +protected: + QPlatformFileDialogHelper *m_dlgHelper; + QQuickWindow *m_parentWindow; + Qt::WindowModality m_modality; + bool m_visible; + QSharedPointer m_options; + +protected Q_SLOTS: + virtual void accept(); + virtual void reject(); + +private: + void setFileUrl(QUrl fileUrl); + + QUrl fileUrl_; + QString filename_; + QString title_; + QStringList nameFilters_; + + Q_DISABLE_COPY(FileSaveDialog) +}; diff --git a/src/main.cpp b/src/main.cpp index 1b1fe2e..373b92e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,9 @@ #include "runtimeqml/runtimeqml.h" #endif +#include "fileopendialog.h" +#include "filesavedialog.h" + #include #include @@ -25,6 +28,7 @@ int main( int argc, char *argv[] ) { + setenv("QT_QPA_PLATFORMTHEME", "gtk3", 0); setenv("QT_QUICK_CONTROLS_STYLE","Desktop",1); QApplication app(argc, argv); app.setOrganizationName("KittehPlayer"); @@ -51,9 +55,11 @@ int main( int argc, char *argv[] ) qDebug() << newpath; setenv("Path", newpath.toUtf8().constData(), 1); - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL ); qmlRegisterType("player", 1, 0, "MpvObject"); - + qmlRegisterType("player", 1, 0, "FileOpenDialog"); + qmlRegisterType("player", 1, 0, "FileSaveDialog"); std::setlocale(LC_NUMERIC, "C"); diff --git a/src/mpvobject.cpp b/src/mpvobject.cpp index 39c2eb7..b1eb81d 100644 --- a/src/mpvobject.cpp +++ b/src/mpvobject.cpp @@ -8,6 +8,9 @@ #include #include +#include +#include + #include #include @@ -211,6 +214,12 @@ void MpvObject::setOption(const QString& name, const QVariant& value) mpv::qt::set_option_variant(mpv, name, value); } +void MpvObject::launchAboutQt() +{ + QApplication *qapp = qobject_cast(QCoreApplication::instance()); + qapp->aboutQt(); +} + void MpvObject::on_mpv_events() { while (mpv) { diff --git a/src/mpvobject.h b/src/mpvobject.h index 30e4fdc..3ceca71 100644 --- a/src/mpvobject.h +++ b/src/mpvobject.h @@ -39,6 +39,7 @@ public: public slots: + void launchAboutQt(); void command(const QVariant& params); void setProperty(const QString& name, const QVariant& value); void setOption(const QString& name, const QVariant& value); diff --git a/src/qml/CustomMenuItem.qml b/src/qml/CustomMenuItem.qml index 99594fa..4b8e5e2 100644 --- a/src/qml/CustomMenuItem.qml +++ b/src/qml/CustomMenuItem.qml @@ -17,6 +17,7 @@ MenuItem { rightPadding: menuItem.indicator.width text: menuItem.text font.family: notoFont.name + font.bold: menuItem.highlighted opacity: 1 color: menuItem.highlighted ? "#5a50da" : "white" horizontalAlignment: Text.AlignLeft diff --git a/src/qml/main.qml b/src/qml/main.qml index 2baefc7..a6277bb 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -212,7 +212,7 @@ ApplicationWindow { || fileMenuBarItem.opened || playbackMenuBarItem.opened || viewMenuBarItem.opened || audioMenuBarItem.opened || screenshotSaveDialog.visible || videoMenuBarItem.opened - || subsMenuBarItem.opened + || subsMenuBarItem.opened || aboutMenuBarItem.opened } function hideControls(force) { @@ -256,26 +256,26 @@ ApplicationWindow { property bool nyanCat: false } - Dialog { + FileSaveDialog { id: screenshotSaveDialog title: "Save Screenshot To" - standardButtons: StandardButton.Cancel | StandardButton.Open + filename: "screenshot.png" + nameFilters: ["Images (*.png)", "All files (*)"] onAccepted: { player.grabToImage(function (result) { - result.saveToFile(screenshotFile.text) + var filepath = String(screenshotSaveDialog.fileUrl).replace( + "file://", '') + console.log("Saving screenshot to: " + filepath) + result.saveToFile(filepath) nativeSubs.visible = true }) } - TextField { - id: screenshotFile - placeholderText: "~/screenshot.jpg" - } } - FileDialog { + FileOpenDialog { id: fileDialog title: "Please choose a file" - folder: shortcuts.home + nameFilters: ["All files (*)"] onAccepted: { player.command(["loadfile", String(fileDialog.fileUrl)]) fileDialog.close() @@ -327,7 +327,9 @@ ApplicationWindow { hoverEnabled: true cursorShape: controlsBar.visible ? Qt.ArrowCursor : Qt.BlankCursor onClicked: { - if (clickToPause) { player.command(["cycle", "pause"]) } + if (appearance.clickToPause) { + player.command(["cycle", "pause"]) + } } Timer { id: mouseAreaPlayerTimer @@ -381,15 +383,22 @@ ApplicationWindow { MenuBar { id: menuBar //width: parent.width - height: Screen.height / 24 + height: Screen.height / 32 delegate: MenuBarItem { id: menuBarItem + padding: 4 + topPadding: padding + leftPadding: padding + rightPadding: padding + bottomPadding: padding + contentItem: Text { + id: menuBarItemText text: menuBarItem.text font.family: notoFont.name font.pixelSize: 14 - renderType: Text.NativeRendering + font.bold: menuBarItem.highlighted opacity: 1 color: menuBarItem.highlighted ? "#5a50da" : "white" horizontalAlignment: Text.AlignLeft @@ -700,6 +709,27 @@ ApplicationWindow { shortcut: keybinds.nyanCat } } + Menu { + id: aboutMenuBarItem + title: "About" + width: 120 + background: Rectangle { + implicitWidth: parent.width + implicitHeight: 10 + color: "black" + opacity: 0.6 + } + delegate: CustomMenuItem { + width: parent.width + } + + Action { + text: "Fullscreen" + onTriggered: { + player.launchAboutQt() + } + } + } Action { onTriggered: player.skipToNinth(parseInt(shortcut)) @@ -771,7 +801,6 @@ ApplicationWindow { color: "white" font.family: notoFont.name font.pixelSize: 14 - renderType: Text.NativeRendering horizontalAlignment: Text.AlignHCenter opacity: 1 } @@ -797,7 +826,6 @@ ApplicationWindow { font.family: notoFont.name font.pixelSize: 14 anchors.top: audioList.bottom - renderType: Text.NativeRendering horizontalAlignment: Text.AlignHCenter opacity: 1 } @@ -823,7 +851,6 @@ ApplicationWindow { font.family: notoFont.name font.pixelSize: 14 anchors.top: subList.bottom - renderType: Text.NativeRendering horizontalAlignment: Text.AlignHCenter opacity: 1 } @@ -873,15 +900,12 @@ ApplicationWindow { anchors.left: parent.left anchors.leftMargin: 10 anchors.bottom: parent.bottom - anchors.bottomMargin: 4 - anchors.topMargin: 4 + topPadding: 4 + bottomPadding: 4 anchors.top: parent.top font.family: notoFont.name - fontSizeMode: Text.Fit - minimumPixelSize: 10 - font.pixelSize: 72 - verticalAlignment: Text.AlignVCenter - renderType: Text.NativeRendering + font.pixelSize: 14 + font.bold: true opacity: 1 } } @@ -912,7 +936,7 @@ ApplicationWindow { radius: 5 color: "transparent" TextMetrics { - id: t_metrics + id: subTextMetrics font.family: notoFont.name font.pixelSize: nativeSubs.fontInfo.pixelSize text: nativeSubs.text @@ -925,7 +949,6 @@ ApplicationWindow { color: "white" font.family: notoFont.name font.pixelSize: Screen.height / 24 - renderType: Text.NativeRendering horizontalAlignment: Text.AlignHCenter anchors.bottom: parent.top opacity: 1 @@ -934,10 +957,10 @@ ApplicationWindow { background: Rectangle { id: subsBackground color: Qt.rgba(0, 0, 0, 0.6) - width: t_metrics.tightBoundingRect.width + 8 + width: subTextMetrics.tightBoundingRect.width + 8 anchors.left: parent.left anchors.leftMargin: (nativeSubtitles.width - - t_metrics.tightBoundingRect.width) / 2 + - subTextMetrics.tightBoundingRect.width) / 2 anchors.right: parent.right anchors.rightMargin: anchors.leftMargin }