Qucs-GUI  0.0.19
/home/travis/build/Qucs/qucs/qucs/qucs/dialogs/aboutdialog.cpp
Go to the documentation of this file.
00001 /*
00002  * aboutdialog.cpp - customary about dialog showing various info
00003  *
00004  * Copyright (C) 2015, Qucs team (see AUTHORS file)
00005  *
00006  * This file is part of Qucs
00007  *
00008  * Qucs is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012  *
00013  * This software is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with Qucs.  If not, see <http://www.gnu.org/licenses/>.
00020  *
00021  */
00022 
00028 #include <array>
00029 #include <algorithm>
00030 #include <random>
00031 
00032 #include <iostream>
00033 #include <string>
00034 
00035 #ifdef HAVE_CONFIG_H
00036 # include <config.h>
00037 #endif
00038 #include "aboutdialog.h"
00039 
00040 #include <QObject>
00041 #include <QTabWidget>
00042 #include <QVBoxLayout>
00043 #include <QPlainTextEdit>
00044 #include <QTextBrowser>
00045 #include <QLabel>
00046 #include <QPushButton>
00047 #include <QApplication>
00048 #include <QDebug>
00049 
00050 
00051 AboutDialog::AboutDialog(QWidget *parent)
00052     : QDialog(parent)
00053 {
00054   currAuths = {{
00055     tr("Guilherme Brondani Torri - GUI programmer, Verilog-A dynamic loader"),
00056     tr("Mike Brinson - testing, modelling and documentation, tutorial contributor"),
00057     tr("Richard Crozier - testing, modelling, Octave."),
00058     tr("Bastien Roucaries - bondwire and rectangular waveguide model implementation"),
00059     tr("Frans Schreuder - GUI programmer, release"),
00060     tr("Clemens Novak - GUI programmer"),
00061     tr("Vadim Kuznetsov - filter synthesis (qucs-activefilter), SPICE integration (NGSPICE, Xyce)"),
00062     tr("You-Tang Lee (YodaLee) - GUI programmer, Qt4 porter"),
00063     tr("Claudio Girardi - testing, general fixes")
00064   }};
00065   
00066   prevDevs = {{
00067     tr("Michael Margraf - founder of the project, GUI programmer"),
00068     tr("Stefan Jahn - Programmer of simulator"),
00069     tr("Jens Flucke - webpages and translator"),
00070     tr("Raimund Jacob - tester and applyer of Stefan's patches, author of documentation"),
00071     tr("Vincent Habchi - coplanar line and filter synthesis code, documentation contributor"),
00072     tr("Toyoyuki Ishikawa - some filter synthesis code and attenuator synthesis"),
00073     tr("Gopala Krishna A - GUI programmer, Qt4 porter"),
00074     tr("Helene Parruitte - programmer of the Verilog-AMS interface"),
00075     tr("Gunther Kraut - equation solver contributions, exponential sources, author of documentation"),
00076     tr("Andrea Zonca - temperature model for rectangular waveguide")
00077   }};
00078 
00079   trAuths = {{
00080     tr("German by Stefan Jahn"),
00081     tr("Polish by Dariusz Pienkowski"),
00082     tr("Romanian by Radu Circa"),
00083     tr("French by Vincent Habchi, F5RCS"),
00084     tr("Portuguese by Luciano Franca, Helio de Sousa, Guilherme Brondani Torri"),
00085     tr("Spanish by Jose L. Redrejo Rodriguez"),
00086     tr("Japanese by Toyoyuki Ishikawa"),
00087     tr("Italian by Giorgio Luparia and Claudio Girardi"),
00088     tr("Hebrew by Dotan Nahum"),
00089     tr("Swedish by Markus Gothe and Peter Landgren"),
00090     tr("Turkish by Onur and Ozgur Cobanoglu"),
00091     tr("Hungarian by Jozsef Bus"),
00092     tr("Russian by Igor Gorbounov"),
00093     tr("Czech by Marek Straka and Martin Stejskal"),
00094     tr("Catalan by Antoni Subirats"),
00095     tr("Ukrainian by Dystryk"),
00096     tr("Arabic by Chabane Noureddine"),
00097     tr("Kazakh by Erbol Keshubaev")
00098   }};
00099   
00100 
00101   std::shuffle(currAuths.begin(), currAuths.end(), rng);
00102 
00103   QLabel *lbl;
00104 
00105   setWindowTitle(tr("About Qucs"));
00106 
00107   all = new QVBoxLayout(this);
00108   //all->setContentsMargins(0,0,0,0);
00109   //all->setSpacing(0);
00110 
00111   QLabel *iconLabel = new QLabel();
00112   iconLabel->setPixmap(QPixmap(QString(":/bitmaps/hicolor/128x128/apps/qucs.png")));
00113 
00114   QWidget *hbox = new QWidget();
00115   QHBoxLayout *hl = new QHBoxLayout(hbox);
00116   hl->setContentsMargins(0,0,0,0);
00117 
00118   hl->addWidget(iconLabel);
00119   all->addWidget(hbox);
00120  
00121   QWidget *vbox = new QWidget();
00122   QVBoxLayout *vl = new QVBoxLayout(vbox);
00123   //vl->setContentsMargins(0,0,0,0);
00124   hl->addWidget(vbox);
00125 
00126   QString versionText;
00127   versionText = tr("Version")+" "+PACKAGE_VERSION+
00128 #ifdef GIT
00129     " ("+GIT+") " +
00130 #endif
00131     "\n";
00132 
00133   vl->addWidget(new QLabel("<span style='font-size:x-large; font-weight:bold;'>Quite Universal Circuit Simulator</span>"));
00134   lbl = new QLabel(versionText);
00135   lbl->setAlignment(Qt::AlignHCenter);
00136   vl->addWidget(lbl);
00137   vl->addWidget(new QLabel(tr("Copyright (C)")+" 2003-2009 "+
00138          tr("by Michael Margraf")+"\n"+
00139          tr("Copyright (C)")+" 2011-2015 "+
00140          tr("Qucs Team")));
00141 
00142   lbl = new QLabel("\nThis is free software; see the source for copying conditions."
00143        "\nThere is NO warranty; not even for MERCHANTABILITY or "
00144        "\nFITNESS FOR A PARTICULAR PURPOSE.\n");
00145   lbl->setAlignment(Qt::AlignHCenter);
00146   all->addWidget(lbl);
00147 
00148   QTabWidget *t = new QTabWidget();
00149   all->addWidget(t);
00150   connect(t, SIGNAL(currentChanged(int)), this, SLOT(currentChangedSlot(int)));
00151 
00152   authorsBrowser = new QTextBrowser;
00153   // the Ctrl-Wheel event we would like to filter is handled by the viewport
00154   authorsBrowser->viewport()->installEventFilter(this);
00155   trBrowser = new QTextBrowser;
00156   trBrowser->viewport()->installEventFilter(this);
00157 
00158   QString supportText;
00159   // link to home page, help mailing list, IRC ?
00160   supportText = tr("Home Page") + " : <a href='http://qucs.sourceforge.net/'>http://qucs.sourceforge.net/</a><br/>"+
00161     tr("Documentation start page") + " : <a href='http://qucs.sourceforge.net/docs.html'>http://qucs.sourceforge.net/docs.html</a><br/>" +
00162     tr("Components reference manual") + " : <a href='http://qucs.github.io/qucs-manual/'>http://qucs.github.io/qucs-manual/</a><br/><br/>" +
00163     tr("If you need help on using Qucs, please join the") + "<br/>" +
00164     tr("help mailing list") + " : <a href='https://sourceforge.net/p/qucs/mailman/qucs-help/'>" + tr("qucs-help on SourceForge") + "</a><br/>" +
00165     "<small>(" + tr("please attach the schematic you are having problems with") + ")</small><br/><br/>" + 
00166     // use http://webchat.freenode.net/?channels=qucs ?
00167     tr("IRC general discussion channel") + " : <a href='irc://irc.freenode.net/qucs'>#qucs on freenode.net</a><br/><br/>" +
00168     tr("Additional resources") + " : <a href='https://github.com/Qucs/qucs#resources'>https://github.com/Qucs/qucs#resources</a>";
00169 
00170   QTextBrowser *supportBrowser = new QTextBrowser;
00171   supportBrowser->viewport()->installEventFilter(this);
00172   supportBrowser->setOpenExternalLinks(true);
00173   supportBrowser->setHtml(supportText);
00174 
00175   QString licenseText;
00176   licenseText = "Qucs is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.<br/><br/>This software is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details..<br/><br/> You should have received a copy of the GNU General Public License along with Qucs, see the file COPYING. If not see <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a> or write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,Boston, MA 02110-1301, USA.";
00177 
00178   QTextBrowser *licenseBrowser = new QTextBrowser;
00179   licenseBrowser->viewport()->installEventFilter(this);
00180   licenseBrowser->setOpenExternalLinks(true);
00181   licenseBrowser->setHtml(licenseText);
00182 
00183   t->addTab(authorsBrowser, tr("Authors"));
00184   t->addTab(trBrowser, tr("Translations"));
00185   t->addTab(supportBrowser, tr("Support"));
00186   t->addTab(licenseBrowser, tr("License"));
00187 
00188   QWidget *hbBtn = new QWidget();
00189   QHBoxLayout *hlBtn = new QHBoxLayout(hbBtn);
00190   hlBtn->setContentsMargins(0,0,0,0);
00191   all->addWidget(hbBtn);
00192 
00193   QPushButton *okButton = new QPushButton(tr("&OK"), parent);
00194   okButton->setFocus();
00195   connect(okButton, SIGNAL(clicked()), this, SLOT(close()));
00196   hlBtn->addStretch();
00197   hlBtn->addWidget(okButton);
00198 
00199   setAuthorsText();
00200   setTrText();
00201   prevTab = 0; // first Tab is selected by default
00202 }
00203 
00204 void AboutDialog::currentChangedSlot(int index) {
00205   if (prevTab == 0) { // deselected tab with current and previous authors
00206     // shuffle them
00207     std::shuffle(currAuths.begin(), currAuths.end(), rng);
00208     std::shuffle(prevDevs.begin(), prevDevs.end(), rng);
00209     setAuthorsText();
00210   } else if (prevTab == 1) {// deselected tab with translators
00211     std::shuffle(trAuths.begin(), trAuths.end(), rng);
00212     setTrText();
00213   }
00214   
00215   prevTab = index;
00216 }
00217 
00218 void AboutDialog::setAuthorsText() {
00219  
00220   QString authorsText;
00221   authorsText = tr("Current Qucs Team:") + "<ul>";
00222   
00223   for(QString& tStr : currAuths) {
00224     authorsText += ("<li>" + tStr + "</li>");
00225   }
00226   authorsText += "</ul>";
00227   authorsText += tr("Previous Developers") + "<ul>";
00228   for(QString& tStr : prevDevs) {
00229     authorsText += ("<li>" + tStr + "</li>");
00230   }
00231   authorsText += "</ul>";
00232   
00233   authorsBrowser->setHtml(authorsText); 
00234 }
00235 
00236 void AboutDialog::setTrText() {
00237   QString trText;
00238   trText = tr("GUI translations :") + "<ul>";
00239   for(QString& tStr : trAuths) {
00240     trText += ("<li>" + tStr + "</li>");
00241   }
00242   trText += "</ul>";
00243   
00244   trBrowser->setHtml(trText); 
00245 }
00246 
00247 // event filter to remove the Ctrl-Wheel (text zoom) event
00248 bool AboutDialog::eventFilter(QObject *obj, QEvent *event) {
00249   if ((event->type() == QEvent::Wheel) &&
00250       (QApplication::keyboardModifiers() & Qt::ControlModifier )) {    
00251     return true; // eat Ctrl-Wheel event
00252   } else {
00253     // pass the event on to the parent class
00254     return QDialog::eventFilter(obj, event);
00255   }
00256 }
00257 
00258 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines