Merge pull request #3 from chozabu/copy_version_info_button

add button to copy version info in first level about box
This commit is contained in:
Cyril Soler 2015-08-23 11:15:05 -04:00
commit e9aa4ff43b
3 changed files with 107 additions and 2 deletions

View File

@ -24,10 +24,15 @@
#include "HelpDialog.h"
#include "rshare.h"
#include <retroshare/rsiface.h>
#include <retroshare/rsplugin.h>
#include <retroshare/rsdisc.h>
#include <retroshare/rspeers.h>
#include "settings/rsharesettings.h"
#include <microhttpd.h>
#include <QClipboard>
#include <QSysInfo>
#include <QHBoxLayout>
#include <QPainter>
#include <QBrush>
@ -721,3 +726,79 @@ NextPieceLabel::NextPieceLabel( QWidget* parent /* = 0*/ ) : QLabel(parent)
setAlignment(Qt::AlignCenter);
setAutoFillBackground(true);
}
static QString addLibraries(const std::string &name, const std::list<RsLibraryInfo> &libraries)
{
QString mTextEdit;
mTextEdit+=QString::fromUtf8(name.c_str());
mTextEdit+="\n";
std::list<RsLibraryInfo>::const_iterator libraryIt;
for (libraryIt = libraries.begin(); libraryIt != libraries.end(); ++libraryIt) {
mTextEdit+=" - ";
mTextEdit+=QString::fromUtf8(libraryIt->mName.c_str());
mTextEdit+=": ";
mTextEdit+=QString::fromUtf8(libraryIt->mVersion.c_str());
mTextEdit+="\n";
}
mTextEdit+="\n";
return mTextEdit;
}
void AboutDialog::on_copy_button_clicked()
{
QString verInfo;
QString rsVerString = "RetroShare Version: ";
rsVerString+=Rshare::retroshareVersion(true);
verInfo+=rsVerString;
verInfo+="\n";
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
#if QT_VERSION >= QT_VERSION_CHECK (5, 4, 0)
verInfo+=QSysInfo::prettyProductName();
#endif
#else
#ifdef Q_WS_X11
verInfo+="Linux";
#endif
#ifdef Q_WS_WIN
verInfo+="Windows";
#endif
#ifdef Q_WS_MACX
verInfo+="Mac";
#endif
#endif
verInfo+=" ";
QString qtver = QString("QT ")+QT_VERSION_STR;
verInfo+=qtver;
verInfo+="\n\n";
/* Add version numbers of libretroshare */
std::list<RsLibraryInfo> libraries;
RsControl::instance()->getLibraries(libraries);
verInfo+=addLibraries("libretroshare", libraries);
/* Add version numbers of RetroShare */
// Add versions here. Find a better place.
libraries.clear();
libraries.push_back(RsLibraryInfo("Libmicrohttpd", MHD_get_version()));
verInfo+=addLibraries("RetroShare", libraries);
/* Add version numbers of plugins */
if (rsPlugins) {
for (int i = 0; i < rsPlugins->nbPlugins(); ++i) {
RsPlugin *plugin = rsPlugins->plugin(i);
if (plugin) {
libraries.clear();
plugin->getLibraries(libraries);
verInfo+=addLibraries(plugin->getPluginName(), libraries);
}
}
}
QApplication::clipboard()->setText(verInfo);
}

View File

@ -50,6 +50,8 @@ private slots:
void sl_levelChanged(int);
void on_help_button_clicked();
void on_copy_button_clicked();
signals:
void si_scoreChanged(QString);
void si_maxScoreChanged(QString);

View File

@ -23,7 +23,16 @@
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
@ -52,6 +61,17 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="copy_button">
<property name="text">
<string>Copy Info</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/copy.png</normaloff>:/images/copy.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -76,7 +96,9 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="images.qrc"/>
</resources>
<connections>
<connection>
<sender>close_button</sender>