diff --git a/CMakeLists.txt b/CMakeLists.txt index 94e53cb..2246c62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ set (PPIC_CPP_FILES toolbutton.cpp settings.cpp settingsdialog.cpp + aboutdialog.cpp ) set (PPIC_HEADER_FILES @@ -34,6 +35,7 @@ set (PPIC_HEADER_FILES toolbutton.h settings.h settingsdialog.h + aboutdialog.h ) set (PPIC_QRC_FILES diff --git a/LICENSE b/LICENSE index 79bfe44..07c2392 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 BLumia +Copyright (c) 2020 BLumia Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/aboutdialog.cpp b/aboutdialog.cpp new file mode 100644 index 0000000..ef1af18 --- /dev/null +++ b/aboutdialog.cpp @@ -0,0 +1,111 @@ +#include "aboutdialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +AboutDialog::AboutDialog(QWidget *parent) + : QDialog(parent) + , m_tabWidget(new QTabWidget) + , m_buttonBox(new QDialogButtonBox) + , m_helpTextEdit(new QTextBrowser) + , m_aboutTextEdit(new QTextBrowser) + , m_licenseTextEdit(new QTextBrowser) +{ + this->setWindowTitle(tr("About")); + + QStringList helpStr { + tr("Launch application with image file path as argument to load the file."), + tr("Drag and drop image file onto the window is also supported."), + "", + tr("Context menu option explanation:"), + ("* " + QCoreApplication::translate("MainWindow", "Stay on top") + " : " + tr("Make window stay on top of all other windows.")), + ("* " + QCoreApplication::translate("MainWindow", "Protected mode") + " : " + tr("Avoid close window accidentally. (eg. by double clicking the window)")) + }; + + QStringList aboutStr { + QStringLiteral("

"), + qApp->applicationDisplayName(), + "
", + tr("Built with Qt %1 (%2)").arg(QT_VERSION_STR, QSysInfo::buildCpuArchitecture()), + QStringLiteral("
%2").arg("https://github.com/BLumia/pineapple-pictures", tr("Source code")), + "
" + }; + + QString licenseDescStr(tr( + "

%1 is released under the MIT License.

" + "

This license grants people a number of freedoms:

" + "
    " + "
  • You are free to use %1, for any purpose
  • " + "
  • You are free to distribute %1
  • " + "
  • You can study how %1 works and change it
  • " + "
  • You can distribute changed versions of %1
  • " + "
" + "

The MIT license guarantees you this freedom. Nobody is ever permitted to take it away.

" + )); + + QStringList licenseStr { + QStringLiteral("

%1

").arg(tr("Your Rights")), + licenseDescStr, + QStringLiteral("
%2
") + }; + + QString mitLicense(QStringLiteral(R"(Expat/MIT License + +Copyright (c) 2020 BLumia + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +)")); + + m_helpTextEdit->setText(helpStr.join('\n')); + + m_aboutTextEdit->setText(aboutStr.join('\n')); + m_aboutTextEdit->setOpenExternalLinks(true); + + m_licenseTextEdit->setText(licenseStr.join('\n').arg(qApp->applicationDisplayName(), mitLicense)); + + m_tabWidget->addTab(m_helpTextEdit, tr("&Help")); + m_tabWidget->addTab(m_aboutTextEdit, tr("&About")); + m_tabWidget->addTab(m_licenseTextEdit, tr("&License")); + + m_buttonBox->setStandardButtons(QDialogButtonBox::Close); + connect(m_buttonBox, QOverload::of(&QDialogButtonBox::clicked), this, [this](){ + this->close(); + }); + + QVBoxLayout * mainLayout = new QVBoxLayout; + + mainLayout->addWidget(m_tabWidget); + mainLayout->addWidget(m_buttonBox); + + this->setLayout(mainLayout); + this->setMinimumSize(361, 161); // not sure why it complain "Unable to set geometry" + this->resize(520, 320); + setWindowFlag(Qt::WindowContextHelpButtonHint, false); +} + +AboutDialog::~AboutDialog() +{ + +} diff --git a/aboutdialog.h b/aboutdialog.h new file mode 100644 index 0000000..447bef8 --- /dev/null +++ b/aboutdialog.h @@ -0,0 +1,28 @@ +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include + +QT_BEGIN_NAMESPACE +class QTextBrowser; +class QTabWidget; +class QDialogButtonBox; +QT_END_NAMESPACE + +class AboutDialog : public QDialog +{ + Q_OBJECT +public: + explicit AboutDialog(QWidget *parent = nullptr); + ~AboutDialog(); + +private: + QTabWidget * m_tabWidget = nullptr; + QDialogButtonBox * m_buttonBox = nullptr; + + QTextBrowser * m_helpTextEdit = nullptr; + QTextBrowser * m_aboutTextEdit = nullptr; + QTextBrowser * m_licenseTextEdit = nullptr; +}; + +#endif // ABOUTDIALOG_H diff --git a/languages/PineapplePictures.ts b/languages/PineapplePictures.ts index 35e9524..ebef332 100644 --- a/languages/PineapplePictures.ts +++ b/languages/PineapplePictures.ts @@ -1,6 +1,64 @@ + + AboutDialog + + + About + + + + + Launch application with image file path as argument to load the file. + + + + + Drag and drop image file onto the window is also supported. + + + + + Context menu option explanation: + + + + + Built with Qt %1 (%2) + + + + + Source code + + + + + <p><i>%1</i> is released under the MIT License.</p><p>This license grants people a number of freedoms:</p><ul><li>You are free to use <i>%1</i>, for any purpose</li><li>You are free to distribute <i>%1</i></li><li>You can study how <i>%1</i> works and change it</li><li>You can distribute changed versions of <i>%1</i></li></ul><p>The MIT license guarantees you this freedom. Nobody is ever permitted to take it away.</p> + + + + + Your Rights + + + + + &Help + + + + + &About + + + + + &License + + + GraphicsScene @@ -12,22 +70,22 @@ GraphicsView - + File url list is empty - + File is not a valid image - + Image data is invalid - + Not supported mimedata: %1 @@ -35,79 +93,67 @@ MainWindow - + File url list is empty - + &Copy - + Copy P&ixmap - + Copy &File Path - + &Paste Image - + &Paste Image File - - + + Stay on top - - + + Protected mode - + Configure... - + Help + + + QCoreApplication - - Launch application with image file path as argument to load the file. - - - - - Drag and drop image file onto the window is also supported. - - - - - Context menu option explanation: - - - - + Make window stay on top of all other windows. - + Avoid close window accidentally. (eg. by double clicking the window) diff --git a/languages/PineapplePictures_zh_CN.ts b/languages/PineapplePictures_zh_CN.ts index ffa707f..0739286 100644 --- a/languages/PineapplePictures_zh_CN.ts +++ b/languages/PineapplePictures_zh_CN.ts @@ -1,6 +1,64 @@ + + AboutDialog + + + About + 关于 + + + + Launch application with image file path as argument to load the file. + 以图片文件的路径作为参数运行程序即可直接打开图片文件。 + + + + Drag and drop image file onto the window is also supported. + 也支持拖放图片文件到窗口内来加载图片。 + + + + Context menu option explanation: + 菜单项说明: + + + + Built with Qt %1 (%2) + 使用 Qt %1 (%2) 进行构建 + + + + Source code + 源代码 + + + + <p><i>%1</i> is released under the MIT License.</p><p>This license grants people a number of freedoms:</p><ul><li>You are free to use <i>%1</i>, for any purpose</li><li>You are free to distribute <i>%1</i></li><li>You can study how <i>%1</i> works and change it</li><li>You can distribute changed versions of <i>%1</i></li></ul><p>The MIT license guarantees you this freedom. Nobody is ever permitted to take it away.</p> + <p><i>%1</i> 是在 MIT 许可协议下发布的。</p><p>此许可证赋予人们以下自由的权利:</p><ul><li>任何人都可以为了任何目的自由地使用 <i>%1</i></li><li>任何人都可以自由地分发 <i>%1</i></li><li>任何人都可以自由地研究 <i>%1</i> 的工作原理并对其进行修改</li><li>任何人都可以自由地分发修改过的 <i>%1</i> 版本</li></ul><p>此软件通过 MIT 许可证赋予用户上述自由,任何人无权剥夺。</p> + + + + Your Rights + 用户的权利 + + + + &Help + 帮助(&H) + + + + &About + 关于(&A) + + + + &License + 软件许可证(&L) + + GraphicsScene @@ -12,22 +70,22 @@ GraphicsView - + File url list is empty 文件 URL 列表为空 - + File is not a valid image 文件不是有效的图片文件 - + Image data is invalid 图片数据无效 - + Not supported mimedata: %1 不受支持的 MimeData 格式:%1 @@ -35,12 +93,12 @@ MainWindow - + File url list is empty 文件 URL 列表为空 - + &Copy 复制(&C) @@ -49,69 +107,77 @@ 复制位图(&P) - + Copy P&ixmap 复制位图(&I) - + Copy &File Path 复制文件路径(&F) - + &Paste Image 粘贴图像(&P) - + &Paste Image File 粘贴图像文件(&P) - - + + Stay on top 总在最前 - - + + Protected mode 保护模式 - + Configure... 设置... - + Help 帮助 - Launch application with image file path as argument to load the file. - 以图片文件的路径作为参数运行程序即可直接打开图片文件。 + 以图片文件的路径作为参数运行程序即可直接打开图片文件。 - Drag and drop image file onto the window is also supported. - 也支持拖放图片文件到窗口内来加载图片。 + 也支持拖放图片文件到窗口内来加载图片。 - Context menu option explanation: - 菜单项说明: + 菜单项说明: - + Make window stay on top of all other windows. + 使窗口始终至于其它非置顶窗口上方。 + + + Avoid close window accidentally. (eg. by double clicking the window) + 避免窗口意外关闭。(如:不小心双击了窗口触发了关闭窗口行为) + + + + QCoreApplication + + Make window stay on top of all other windows. 使窗口始终至于其它非置顶窗口上方。 - + Avoid close window accidentally. (eg. by double clicking the window) 避免窗口意外关闭。(如:不小心双击了窗口触发了关闭窗口行为) diff --git a/mainwindow.cpp b/mainwindow.cpp index f5868ae..1c203d2 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -7,6 +7,7 @@ #include "navigatorview.h" #include "graphicsscene.h" #include "settingsdialog.h" +#include "aboutdialog.h" #include #include @@ -474,15 +475,9 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event) QAction * helpAction = new QAction(tr("Help")); connect(helpAction, &QAction::triggered, this, [ = ](){ - QStringList sl { - tr("Launch application with image file path as argument to load the file."), - tr("Drag and drop image file onto the window is also supported."), - "", - tr("Context menu option explanation:"), - (tr("Stay on top") + " : " + tr("Make window stay on top of all other windows.")), - (tr("Protected mode") + " : " + tr("Avoid close window accidentally. (eg. by double clicking the window)")) - }; - m_graphicsView->showText(sl.join('\n')); + AboutDialog * ad = new AboutDialog(this); + ad->exec(); + ad->deleteLater(); }); if (copyMenu->actions().count() == 1) { diff --git a/pineapple-pictures.pro b/pineapple-pictures.pro index a413e41..0a6dd42 100644 --- a/pineapple-pictures.pro +++ b/pineapple-pictures.pro @@ -23,6 +23,7 @@ DEFINES += QT_DEPRECATED_WARNINGS CONFIG += c++11 lrelease embed_translations SOURCES += \ + aboutdialog.cpp \ main.cpp \ mainwindow.cpp \ graphicsview.cpp \ @@ -35,6 +36,7 @@ SOURCES += \ settingsdialog.cpp HEADERS += \ + aboutdialog.h \ mainwindow.h \ graphicsview.h \ bottombuttongroup.h \ diff --git a/settingsdialog.h b/settingsdialog.h index 03cbca1..5fb043e 100644 --- a/settingsdialog.h +++ b/settingsdialog.h @@ -2,7 +2,6 @@ #define SETTINGSDIALOG_H #include -#include #include class QCheckBox;