2025-11-21 20:42:44 +08:00
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
2022-06-19 16:17:38 +08:00
//
// SPDX-License-Identifier: MIT
2025-07-23 21:20:34 +08:00
2020-09-28 20:10:33 +08:00
#include "aboutdialog.h"
2026-07-06 09:44:38 +08:00
#include "ui_aboutdialog.h"
2025-07-23 21:20:34 +08:00
2020-09-28 20:10:33 +08:00
#include <QApplication>
2020-12-25 13:36:34 +08:00
#include <QFile>
2025-07-23 21:20:34 +08:00
2025-05-31 13:10:21 +08:00
using namespace Qt :: Literals :: StringLiterals ;
2025-07-23 21:20:34 +08:00
2026-07-06 20:34:41 +08:00
static QString loadEmbeddedHtml ( QString && path ) {
QFile htmlFile ( path );
bool canOpenFile = htmlFile . open ( QIODevice :: ReadOnly );
QByteArray htmlRawContent = canOpenFile ? htmlFile . readAll () : QByteArrayLiteral ( "" );
return QString :: fromUtf8 ( htmlRawContent );
}
2020-09-28 20:10:33 +08:00
AboutDialog :: AboutDialog ( QWidget * parent )
2026-07-07 12:16:36 +08:00
: QDialog ( parent ), ui ( new QT_PREPEND_NAMESPACE ( Ui :: AboutDialog ))
2020-09-28 20:10:33 +08:00
{
2026-07-06 09:44:38 +08:00
ui -> setupUi ( this );
setWindowFlag ( Qt :: WindowContextHelpButtonHint , false );
2025-07-23 21:20:34 +08:00
2026-07-06 20:34:41 +08:00
// blumia: Chain two arg() here since it seems lupdate will remove one of them if we use
// the old `arg(QCoreApp::translate(), tr())` way, but it's worth to mention
// `arg(QCoreApp::translate(), this->tr())` works, but lupdate will complain about the usage.
const QString HELP_HTML = loadEmbeddedHtml ( u ":/plain/help.html" _s )
. arg ( tr ( "General Help" ))
. arg ( tr ( "Launch application with image file path as argument to load the file." ))
. arg ( tr ( "Passing in a single image file will load all the images in that directory and start viewing from that image." ))
. arg ( tr ( "Passing in multiple image files lets you view them one by one." ))
. arg ( tr ( "Drag and drop image file onto the window is also supported." ))
. arg ( tr ( "None of the operations in this application will alter the pictures on disk." ))
. arg ( tr ( "Context Menu Help" ))
. arg ( tr ( "Keep transformation" , "The same meaning of MainWindow's Keep transformation." ))
2026-07-09 13:06:14 +08:00
. arg ( tr ( "Avoid resetting the zoom/rotation/flip state that was applied to the image view when switching between images." ))
2026-07-12 19:53:36 +08:00
. arg ( tr ( "Checkerboard" , "The same meaning of MainWindow's Checkerboard." ))
2026-07-09 13:06:14 +08:00
. arg ( tr ( "Checkerboard light and dark theme can be adjusted in the configuration window, or easily switch it by holding Shift and clicking the button." ));
2025-07-23 21:20:34 +08:00
2026-07-06 20:34:41 +08:00
const QString APP_NAME_ARG = qApp -> applicationDisplayName ();
const QString APP_VERSION_ARG =
2020-09-29 09:45:07 +08:00
#ifdef GIT_DESCRIBE_VERSION_STRING
2026-07-06 20:34:41 +08:00
GIT_DESCRIBE_VERSION_STRING ;
2024-09-17 19:28:05 +08:00
#else
2026-07-06 20:34:41 +08:00
qApp -> applicationVersion ();
2020-09-29 09:45:07 +08:00
#endif // GIT_DESCRIBE_VERSION_STRING
2026-07-06 20:34:41 +08:00
const QString QT_VERSION_ARG = QT_VERSION_STR ;
const QString QT_ARCH_ARG = QSysInfo :: buildCpuArchitecture ();
const QString ABOUT_HTML = loadEmbeddedHtml ( u ":/plain/about.html" _s )
. arg ( APP_NAME_ARG )
. arg ( tr ( "Version: %1" ). arg ( APP_VERSION_ARG ))
. arg ( tr ( "Upstream author" ))
. arg ( tr ( "Hard fork author" ))
. arg ( tr ( "Logo designer" ))
. arg ( tr ( "Built with Qt %1 (%2)" ). arg ( QT_VERSION_ARG ). arg ( QT_ARCH_ARG ))
. arg ( tr ( "Source code" ));
2025-07-23 21:20:34 +08:00
2026-07-06 20:34:41 +08:00
const QString SPECIAL_THANKS_HTML = loadEmbeddedHtml ( u ":/plain/special-thanks.html" _s )
. arg ( tr ( "Contributors" ))
. arg ( tr ( "List of contributors on GitHub" ))
. arg ( tr ( "Thanks to all people who contributed to this project." ))
. arg ( tr ( "Translators" ))
. arg ( tr ( "I would like to thank the following people who volunteered to translate this application." ));
2025-07-23 21:20:34 +08:00
2026-07-06 20:34:41 +08:00
const QString LICENSE_HTML = loadEmbeddedHtml ( u ":/plain/license.html" _s )
. arg ( tr ( "License" ))
. arg ( tr ( "This application is released under the MIT License." ))
. arg ( tr ( "License Verbatim Copy" ));
2025-07-23 21:20:34 +08:00
2026-07-06 20:34:41 +08:00
const QString THIRD_PARTY_LIBS_HTML = loadEmbeddedHtml ( u ":/plain/third-party-libs.html" _s )
. arg ( tr ( "Third-party Libraries" ))
. arg ( tr ( "This application is built on the following free software libraries." , "Free as in freedom" ))
. arg ( tr ( "Some of them are optional and might not be included with this distribution depending on the build environment." ));
2025-07-23 21:20:34 +08:00
2026-07-06 20:34:41 +08:00
ui -> m_helpTextEdit -> setHtml ( HELP_HTML );
ui -> m_aboutTextEdit -> setHtml ( ABOUT_HTML );
ui -> m_specialThanksTextEdit -> setHtml ( SPECIAL_THANKS_HTML );
ui -> m_licenseTextEdit -> setHtml ( LICENSE_HTML );
ui -> m_3rdPartyLibsTextEdit -> setHtml ( THIRD_PARTY_LIBS_HTML );
2025-07-23 21:20:34 +08:00
2026-07-06 09:44:38 +08:00
connect ( ui -> m_buttonBox , QOverload < QAbstractButton *>:: of ( & QDialogButtonBox :: clicked ), this , [ this ]( QAbstractButton * btn ){
Q_UNUSED ( btn )
2020-09-28 20:10:33 +08:00
this -> close ();
});
2025-07-23 21:20:34 +08:00
2020-10-08 22:24:54 +08:00
setMinimumSize ( 361 , 161 ); // not sure why it complain "Unable to set geometry"
2020-09-28 20:10:33 +08:00
}
2025-07-23 21:20:34 +08:00
2020-09-28 20:10:33 +08:00
AboutDialog ::~ AboutDialog ()
{
2026-07-06 09:44:38 +08:00
delete ui ;
2020-09-28 20:10:33 +08:00
}
2025-07-23 21:20:34 +08:00
2020-10-08 22:24:54 +08:00
QSize AboutDialog :: sizeHint () const
{
return QSize ( 520 , 350 );
}