-#endif
-
-#include "DlgTipOfTheDayImp.h"
-#include "Application.h"
-#include "MainWindow.h"
-
-#include
-#include
-
-using namespace Gui::Dialog;
-
-/* TRANSLATOR Gui::Dialog::DlgTipOfTheDayImp */
-
-/**
- * Constructs a DlgTipOfTheDayImp which is a child of 'parent', with the
- * name 'name' and widget flags set to 'f'
- *
- * The dialog will by default be modeless, unless you set 'modal' to
- * true to construct a modal dialog.
- */
-DlgTipOfTheDayImp::DlgTipOfTheDayImp( QWidget* parent, Qt::WindowFlags fl )
- : QDialog( parent, fl | Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
- WindowParameter("General")
-{
- setupUi(this);
- _http = new QHttp;
- connect(_http, SIGNAL(done(bool)), this, SLOT(onDone(bool)));
- connect(_http, SIGNAL(stateChanged(int)), this, SLOT(onStateChanged(int)));
- connect(_http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
- this, SLOT(onResponseHeaderReceived(const QHttpResponseHeader &)));
-
- bool tips = getWindowParameter()->GetBool("Tipoftheday", true);
- checkShowTips->setChecked(tips);
-
- // Since the resize mode of DlgTipOfTheDayBase does not
- // work properly so set this by hand
- setMinimumSize(QSize(320, 250));
- layout()->setSizeConstraint( QLayout::SetNoConstraint );
-
- reload();
- on_buttonNextTip_clicked();
-}
-
-/** Destroys the object and frees any allocated resources */
-DlgTipOfTheDayImp::~DlgTipOfTheDayImp()
-{
- delete _http;
- getWindowParameter()->SetBool("Tipoftheday", checkShowTips->isChecked());
-}
-
-/** Shows next tip taken from the Tip-of-the-day site. */
-void DlgTipOfTheDayImp::on_buttonNextTip_clicked()
-{
- _iCurrentTip = (_iCurrentTip + 1) % _lTips.size();
- textTip->setText(_lTips[_iCurrentTip]);
-}
-
-/** Reloads all tips from Tip-of-the-day site. */
-void DlgTipOfTheDayImp::reload()
-{
- // set the host and start the download
- _http->setHost(QLatin1String("www.freecadweb.org"));
- _http->get(QLatin1String("/wiki/index.php?title=Tip_of_the_day"), 0);
-
- _iCurrentTip = 0;
- _lTips << tr("If you want to learn more about FreeCAD you must go to %1 or press the Help item in the Help menu.")
- .arg(QLatin1String(""
- "http://www.freecadweb.org/wiki/"));
-}
-
-void DlgTipOfTheDayImp::onResponseHeaderReceived(const QHttpResponseHeader & responseHeader)
-{
- if (responseHeader.statusCode() != 200) {
- QString msg = tr("Download failed: %1\n").arg(responseHeader.reasonPhrase());
- Base::Console().Log(msg.toLatin1());
- _http->abort();
- }
-}
-
-void DlgTipOfTheDayImp::onDone(bool err)
-{
- if (err)
- return;
-
- // get the page and search for the tips section
- QString text = QString::fromLatin1(_http->readAll());
- QRegExp rx(QLatin1String("You find the latest information.+