From 921c42088dfa23ed54df8f5a691576c2588ee9dc Mon Sep 17 00:00:00 2001 From: Konstantin Isakov Date: Sun, 14 Nov 2010 19:28:50 +0300 Subject: [PATCH] Implement Credits window in the About dialog to show project contributors. The actual credits file is to be fully populated yet. --- CREDITS.txt | 2 ++ about.cc | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ about.hh | 22 ++++++++++++++++++++ about.ui | 21 +++++++++++++++++-- goldendict.pro | 6 ++++-- mainwindow.cc | 19 ++--------------- resources.qrc | 1 + 7 files changed, 106 insertions(+), 21 deletions(-) create mode 100644 CREDITS.txt create mode 100644 about.cc create mode 100644 about.hh diff --git a/CREDITS.txt b/CREDITS.txt new file mode 100644 index 00000000..590da7a7 --- /dev/null +++ b/CREDITS.txt @@ -0,0 +1,2 @@ +Konstantin Isakov : Principal author of the program +Jennie Petoumenou : Greek transliteration and Greek translation diff --git a/about.cc b/about.cc new file mode 100644 index 00000000..a0bdc133 --- /dev/null +++ b/about.cc @@ -0,0 +1,56 @@ +/* This file is (c) 2008-2011 Konstantin Isakov + * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ + +#include "about.hh" +#include + +About::About( QWidget * parent ): QDialog( parent ) +{ + ui.setupUi( this ); + + QFile versionFile( ":/version.txt" ); + + QString version; + + if ( !versionFile.open( QFile::ReadOnly ) ) + version = tr( "[Unknown]" ); + else + version = QString::fromAscii( versionFile.readAll() ).trimmed(); + + ui.version->setText( version ); + + QFile creditsFile( ":/CREDITS.txt" ); + + if ( creditsFile.open( QFile::ReadOnly ) ) + { + QStringList creditsList = + QString::fromUtf8( + creditsFile.readAll() ).split( '\n', QString::SkipEmptyParts ); + + QString html = ""; + + for( int x = 0; x < creditsList.size(); ++x ) + { + QString str = creditsList[ x ]; + + str.replace( "\\", "@" ); + + str = Qt::escape( str ); + + int colon = str.indexOf( ":" ); + + if ( colon != -1 ) + { + str.replace( colon, 1, "
    " ); + str.prepend( "" ); + } + + html += str; + html += "
"; + } + + html += ""; + + ui.credits->setHtml( html ); + } +} diff --git a/about.hh b/about.hh new file mode 100644 index 00000000..5f648642 --- /dev/null +++ b/about.hh @@ -0,0 +1,22 @@ +/* This file is (c) 2008-2011 Konstantin Isakov + * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ + +#ifndef ABOUT_HH +#define ABOUT_HH + +#include +#include "ui_about.h" + +class About: public QDialog +{ + Q_OBJECT +public: + + About( QWidget * parent = 0 ); + +private: + + Ui::About ui; +}; + +#endif // ABOUT_HH diff --git a/about.ui b/about.ui index c42121ae..eb80d9b9 100644 --- a/about.ui +++ b/about.ui @@ -10,7 +10,7 @@ 0 0 400 - 123 + 235 @@ -58,7 +58,7 @@ - #.# + #.# @@ -88,6 +88,16 @@ + + + + Credits: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + @@ -101,6 +111,13 @@ + + + + true + + + diff --git a/goldendict.pro b/goldendict.pro index a371391f..3b2a229e 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -155,7 +155,8 @@ HEADERS += folding.hh \ greektranslit.hh \ webmultimediadownload.hh \ forvo.hh \ - country.hh + country.hh \ + about.hh FORMS += groups.ui \ dictgroupwidget.ui \ mainwindow.ui \ @@ -236,7 +237,8 @@ SOURCES += folding.cc \ greektranslit.cc \ webmultimediadownload.cc \ forvo.cc \ - country.cc + country.cc \ + about.cc win32 { SOURCES += mouseover_win32/ThTypes.c HEADERS += mouseover_win32/ThTypes.h diff --git a/mainwindow.cc b/mainwindow.cc index 19b165f3..b114e126 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -5,7 +5,7 @@ #include "editdictionaries.hh" #include "loaddictionaries.hh" #include "preferences.hh" -#include "ui_about.h" +#include "about.hh" #include #include #include @@ -1727,22 +1727,7 @@ void MainWindow::visitForum() void MainWindow::showAbout() { - QDialog about( this ); - - Ui::About ui; - - ui.setupUi( &about ); - - QFile versionFile( ":/version.txt" ); - - QString version; - - if ( !versionFile.open( QFile::ReadOnly ) ) - version = tr( "[Unknown]" ); - else - version = QString::fromAscii( versionFile.readAll() ).trimmed(); - - ui.version->setText( version ); + About about( this ); about.show(); about.exec(); diff --git a/resources.qrc b/resources.qrc index caa3ccf9..753d7450 100644 --- a/resources.qrc +++ b/resources.qrc @@ -42,5 +42,6 @@ icons/icon_dsl_native.png icons/forvo.png icons/windows-list.png + CREDITS.txt