Add "copy info" buttons to about dialog

This commit is contained in:
shenleban tongying 2022-11-17 04:47:08 -05:00
parent 4f10a55f95
commit 8d3b4165da
4 changed files with 94 additions and 4 deletions

View file

@ -2,12 +2,13 @@
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#include "about.hh" #include "about.hh"
#include <QPushButton>
#include <QtGui> #include <QtGui>
#include <QSysInfo> #include <QSysInfo>
#include "utils.hh" #include "utils.hh"
About::About( QWidget * parent ): QDialog( parent ) About::About(std::vector< sptr< Dictionary::Class > > * dictonaries, QWidget * parent ): QDialog( parent )
{ {
ui.setupUi( this ); ui.setupUi( this );
@ -40,6 +41,50 @@ About::About( QWidget * parent ): QDialog( parent )
#endif #endif
); );
// copy basic debug info to clipboard
connect(ui.copyInfoBtn, &QPushButton::clicked, [=]{
QGuiApplication::clipboard()->setText(
"Goldendict " + version + "\n" +
QSysInfo::productType() + " " + QSysInfo::kernelType() + " " + QSysInfo::kernelVersion() + " " +
"Qt " + QLatin1String(qVersion()) + " " +
QSysInfo::buildAbi() + "\n" +
compilerVersion + "\n"
#ifdef Q_OS_LINUX
+ "Flags:"
#ifdef USE_XAPIAN
+" USE_XAPIAN "
#endif
#ifdef MAKE_ZIM_SUPPORT
+" MAKE_ZIM_SUPPORT"
#endif
#ifdef MAKE_EXTRA_TIFF_HANDLER
+" MAKE_EXTRA_TIFF_HANDLER"
#endif
#ifdef NO_EPWING_SUPPORT
+" NO_EPWING_SUPPORT"
#endif
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
+" MAKE_CHINESE_CONVERSION_SUPPORT"
#endif
#endif
);
});
connect(ui.copyDictListBtn, &QPushButton::clicked, [=]{
QString tempDictList{};
for (auto dict : *dictonaries) {
tempDictList.append(QString::fromStdString(dict->getName() + "\n"));
}
QGuiApplication::clipboard()->setText(tempDictList);
});
QFile creditsFile( ":/CREDITS.txt" ); QFile creditsFile( ":/CREDITS.txt" );
if ( creditsFile.open( QFile::ReadOnly ) ) if ( creditsFile.open( QFile::ReadOnly ) )

View file

@ -5,14 +5,16 @@
#define ABOUT_HH #define ABOUT_HH
#include "ui_about.h" #include "ui_about.h"
#include "sptr.hh"
#include "dictionary.hh"
#include <QDialog> #include <QDialog>
#include <vector>
class About: public QDialog class About: public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
About(std::vector< sptr< Dictionary::Class > > * dictonaries, QWidget * parent = 0 );
About( QWidget * parent = 0 );
private: private:

View file

@ -115,6 +115,49 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="copyInfoBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Copy version info</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="copyDictListBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Copy dictionaries list</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View file

@ -3224,7 +3224,7 @@ void MainWindow::visitForum()
void MainWindow::showAbout() void MainWindow::showAbout()
{ {
About about( this ); About about(&dictionaries, this);
about.show(); about.show();
about.exec(); about.exec();