feat: new about dialog

This commit is contained in:
Gary Wang
2020-09-28 20:10:33 +08:00
parent 5ff49f4885
commit f7aaa76985
9 changed files with 317 additions and 68 deletions
+2
View File
@@ -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
+1 -1
View File
@@ -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
+111
View File
@@ -0,0 +1,111 @@
#include "aboutdialog.h"
#include <QAbstractButton>
#include <QDialogButtonBox>
#include <QTextBrowser>
#include <QTabWidget>
#include <QVBoxLayout>
#include <QApplication>
#include <QLabel>
#include <QPushButton>
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("<center><img width='128' height='128' src=':/icons/app-icon.svg'/><br/>"),
qApp->applicationDisplayName(),
"<hr/>",
tr("Built with Qt %1 (%2)").arg(QT_VERSION_STR, QSysInfo::buildCpuArchitecture()),
QStringLiteral("<br/><a href='%1'>%2</a>").arg("https://github.com/BLumia/pineapple-pictures", tr("Source code")),
"</center>"
};
QString licenseDescStr(tr(
"<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>"
));
QStringList licenseStr {
QStringLiteral("<h1 align='center'><b>%1</b></h1>").arg(tr("Your Rights")),
licenseDescStr,
QStringLiteral("<hr/><pre>%2</pre>")
};
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<QAbstractButton *>::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()
{
}
+28
View File
@@ -0,0 +1,28 @@
#ifndef ABOUTDIALOG_H
#define ABOUTDIALOG_H
#include <QDialog>
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
+79 -33
View File
@@ -1,6 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>AboutDialog</name>
<message>
<location filename="../aboutdialog.cpp" line="20"/>
<source>About</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="23"/>
<source>Launch application with image file path as argument to load the file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="24"/>
<source>Drag and drop image file onto the window is also supported.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="26"/>
<source>Context menu option explanation:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="35"/>
<source>Built with Qt %1 (%2)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="36"/>
<source>Source code</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="40"/>
<source>&lt;p&gt;&lt;i&gt;%1&lt;/i&gt; is released under the MIT License.&lt;/p&gt;&lt;p&gt;This license grants people a number of freedoms:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You are free to use &lt;i&gt;%1&lt;/i&gt;, for any purpose&lt;/li&gt;&lt;li&gt;You are free to distribute &lt;i&gt;%1&lt;/i&gt;&lt;/li&gt;&lt;li&gt;You can study how &lt;i&gt;%1&lt;/i&gt; works and change it&lt;/li&gt;&lt;li&gt;You can distribute changed versions of &lt;i&gt;%1&lt;/i&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The MIT license guarantees you this freedom. Nobody is ever permitted to take it away.&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="53"/>
<source>Your Rights</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="88"/>
<source>&amp;Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="89"/>
<source>&amp;About</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="90"/>
<source>&amp;License</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>GraphicsScene</name>
<message>
@@ -12,22 +70,22 @@
<context>
<name>GraphicsView</name>
<message>
<location filename="../graphicsview.cpp" line="247"/>
<location filename="../graphicsview.cpp" line="254"/>
<source>File url list is empty</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../graphicsview.cpp" line="46"/>
<location filename="../graphicsview.cpp" line="53"/>
<source>File is not a valid image</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../graphicsview.cpp" line="255"/>
<location filename="../graphicsview.cpp" line="262"/>
<source>Image data is invalid</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../graphicsview.cpp" line="262"/>
<location filename="../graphicsview.cpp" line="269"/>
<source>Not supported mimedata: %1</source>
<translation type="unfinished"></translation>
</message>
@@ -35,79 +93,67 @@
<context>
<name>MainWindow</name>
<message>
<location filename="../mainwindow.cpp" line="174"/>
<location filename="../mainwindow.cpp" line="175"/>
<source>File url list is empty</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="396"/>
<location filename="../mainwindow.cpp" line="408"/>
<source>&amp;Copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="417"/>
<location filename="../mainwindow.cpp" line="429"/>
<source>Copy P&amp;ixmap</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="422"/>
<location filename="../mainwindow.cpp" line="434"/>
<source>Copy &amp;File Path</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="432"/>
<location filename="../mainwindow.cpp" line="444"/>
<source>&amp;Paste Image</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="438"/>
<location filename="../mainwindow.cpp" line="450"/>
<source>&amp;Paste Image File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="443"/>
<location filename="../mainwindow.cpp" line="471"/>
<location filename="../aboutdialog.cpp" line="27"/>
<location filename="../mainwindow.cpp" line="455"/>
<source>Stay on top</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="450"/>
<location filename="../mainwindow.cpp" line="472"/>
<location filename="../aboutdialog.cpp" line="28"/>
<location filename="../mainwindow.cpp" line="462"/>
<source>Protected mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="457"/>
<location filename="../mainwindow.cpp" line="469"/>
<source>Configure...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="464"/>
<location filename="../mainwindow.cpp" line="476"/>
<source>Help</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QCoreApplication</name>
<message>
<location filename="../mainwindow.cpp" line="467"/>
<source>Launch application with image file path as argument to load the file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="468"/>
<source>Drag and drop image file onto the window is also supported.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="470"/>
<source>Context menu option explanation:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="471"/>
<location filename="../aboutdialog.cpp" line="27"/>
<source>Make window stay on top of all other windows.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="472"/>
<location filename="../aboutdialog.cpp" line="28"/>
<source>Avoid close window accidentally. (eg. by double clicking the window)</source>
<translation type="unfinished"></translation>
</message>
+90 -24
View File
@@ -1,6 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>AboutDialog</name>
<message>
<location filename="../aboutdialog.cpp" line="20"/>
<source>About</source>
<translation>关于</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="23"/>
<source>Launch application with image file path as argument to load the file.</source>
<translation>以图片文件的路径作为参数运行程序即可直接打开图片文件。</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="24"/>
<source>Drag and drop image file onto the window is also supported.</source>
<translation>也支持拖放图片文件到窗口内来加载图片。</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="26"/>
<source>Context menu option explanation:</source>
<translation>菜单项说明:</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="35"/>
<source>Built with Qt %1 (%2)</source>
<translation>使用 Qt %1 (%2) 进行构建</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="36"/>
<source>Source code</source>
<translation>源代码</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="40"/>
<source>&lt;p&gt;&lt;i&gt;%1&lt;/i&gt; is released under the MIT License.&lt;/p&gt;&lt;p&gt;This license grants people a number of freedoms:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You are free to use &lt;i&gt;%1&lt;/i&gt;, for any purpose&lt;/li&gt;&lt;li&gt;You are free to distribute &lt;i&gt;%1&lt;/i&gt;&lt;/li&gt;&lt;li&gt;You can study how &lt;i&gt;%1&lt;/i&gt; works and change it&lt;/li&gt;&lt;li&gt;You can distribute changed versions of &lt;i&gt;%1&lt;/i&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The MIT license guarantees you this freedom. Nobody is ever permitted to take it away.&lt;/p&gt;</source>
<translation>&lt;p&gt;&lt;i&gt;%1&lt;/i&gt; 是在 MIT 许可协议下发布的。&lt;/p&gt;&lt;p&gt;此许可证赋予人们以下自由的权利:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;任何人都可以为了任何目的自由地使用 &lt;i&gt;%1&lt;/i&gt;&lt;/li&gt;&lt;li&gt;任何人都可以自由地分发 &lt;i&gt;%1&lt;/i&gt;&lt;/li&gt;&lt;li&gt;任何人都可以自由地研究 &lt;i&gt;%1&lt;/i&gt; 的工作原理并对其进行修改&lt;/li&gt;&lt;li&gt;任何人都可以自由地分发修改过的 &lt;i&gt;%1&lt;/i&gt; 版本&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;此软件通过 MIT 许可证赋予用户上述自由,任何人无权剥夺。&lt;/p&gt;</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="53"/>
<source>Your Rights</source>
<translation>用户的权利</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="88"/>
<source>&amp;Help</source>
<translation>帮助(&amp;H)</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="89"/>
<source>&amp;About</source>
<translation>关于(&amp;A)</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="90"/>
<source>&amp;License</source>
<translation>软件许可证(&amp;L)</translation>
</message>
</context>
<context>
<name>GraphicsScene</name>
<message>
@@ -12,22 +70,22 @@
<context>
<name>GraphicsView</name>
<message>
<location filename="../graphicsview.cpp" line="247"/>
<location filename="../graphicsview.cpp" line="254"/>
<source>File url list is empty</source>
<translation>文件 URL 列表为空</translation>
</message>
<message>
<location filename="../graphicsview.cpp" line="46"/>
<location filename="../graphicsview.cpp" line="53"/>
<source>File is not a valid image</source>
<translation>文件不是有效的图片文件</translation>
</message>
<message>
<location filename="../graphicsview.cpp" line="255"/>
<location filename="../graphicsview.cpp" line="262"/>
<source>Image data is invalid</source>
<translation>图片数据无效</translation>
</message>
<message>
<location filename="../graphicsview.cpp" line="262"/>
<location filename="../graphicsview.cpp" line="269"/>
<source>Not supported mimedata: %1</source>
<translation>不受支持的 MimeData 格式:%1</translation>
</message>
@@ -35,12 +93,12 @@
<context>
<name>MainWindow</name>
<message>
<location filename="../mainwindow.cpp" line="174"/>
<location filename="../mainwindow.cpp" line="175"/>
<source>File url list is empty</source>
<translation>文件 URL 列表为空</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="396"/>
<location filename="../mainwindow.cpp" line="408"/>
<source>&amp;Copy</source>
<translation>复制(&amp;C)</translation>
</message>
@@ -49,69 +107,77 @@
<translation type="vanished">复制位图(&amp;P)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="417"/>
<location filename="../mainwindow.cpp" line="429"/>
<source>Copy P&amp;ixmap</source>
<translation>复制位图(&amp;I)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="422"/>
<location filename="../mainwindow.cpp" line="434"/>
<source>Copy &amp;File Path</source>
<translation>复制文件路径(&amp;F)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="432"/>
<location filename="../mainwindow.cpp" line="444"/>
<source>&amp;Paste Image</source>
<translation>粘贴图像(&amp;P)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="438"/>
<location filename="../mainwindow.cpp" line="450"/>
<source>&amp;Paste Image File</source>
<translation>粘贴图像文件(&amp;P)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="443"/>
<location filename="../mainwindow.cpp" line="471"/>
<location filename="../aboutdialog.cpp" line="27"/>
<location filename="../mainwindow.cpp" line="455"/>
<source>Stay on top</source>
<translation>总在最前</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="450"/>
<location filename="../mainwindow.cpp" line="472"/>
<location filename="../aboutdialog.cpp" line="28"/>
<location filename="../mainwindow.cpp" line="462"/>
<source>Protected mode</source>
<translation>保护模式</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="457"/>
<location filename="../mainwindow.cpp" line="469"/>
<source>Configure...</source>
<translation>设置...</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="464"/>
<location filename="../mainwindow.cpp" line="476"/>
<source>Help</source>
<translation>帮助</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="467"/>
<source>Launch application with image file path as argument to load the file.</source>
<translation>以图片文件的路径作为参数运行程序即可直接打开图片文件。</translation>
<translation type="vanished">以图片文件的路径作为参数运行程序即可直接打开图片文件。</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="468"/>
<source>Drag and drop image file onto the window is also supported.</source>
<translation>也支持拖放图片文件到窗口内来加载图片。</translation>
<translation type="vanished">也支持拖放图片文件到窗口内来加载图片。</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="470"/>
<source>Context menu option explanation:</source>
<translation>菜单项说明:</translation>
<translation type="vanished">菜单项说明:</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="471"/>
<source>Make window stay on top of all other windows.</source>
<translation type="vanished">使窗口始终至于其它非置顶窗口上方。</translation>
</message>
<message>
<source>Avoid close window accidentally. (eg. by double clicking the window)</source>
<translation type="vanished">避免窗口意外关闭。(如:不小心双击了窗口触发了关闭窗口行为)</translation>
</message>
</context>
<context>
<name>QCoreApplication</name>
<message>
<location filename="../aboutdialog.cpp" line="27"/>
<source>Make window stay on top of all other windows.</source>
<translation>使窗口始终至于其它非置顶窗口上方。</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="472"/>
<location filename="../aboutdialog.cpp" line="28"/>
<source>Avoid close window accidentally. (eg. by double clicking the window)</source>
<translation>避免窗口意外关闭。(如:不小心双击了窗口触发了关闭窗口行为)</translation>
</message>
+4 -9
View File
@@ -7,6 +7,7 @@
#include "navigatorview.h"
#include "graphicsscene.h"
#include "settingsdialog.h"
#include "aboutdialog.h"
#include <QMouseEvent>
#include <QMovie>
@@ -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) {
+2
View File
@@ -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 \
-1
View File
@@ -2,7 +2,6 @@
#define SETTINGSDIALOG_H
#include <QObject>
#include <QWidget>
#include <QDialog>
class QCheckBox;