File indexing completed on 2024-05-05 05:40:58

0001 /***************************************************************************
0002  *   Copyright (C) 2015 by Renaud Guezennec                                *
0003  *   https://rolisteam.org/contact                   *
0004  *                                                                         *
0005  *   rolisteam is free software; you can redistribute it and/or modify     *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 #include "tipofdayviewer.h"
0021 #include "ui_tipofdayviewer.h"
0022 #include <QDesktopServices>
0023 #include <QFile>
0024 #include <QMessageBox>
0025 
0026 TipOfDayViewer::TipOfDayViewer(QString title, QString msg, QString url, QWidget* parent)
0027     : QDialog(parent), m_ui(new Ui::TipOfDayViewer)
0028 {
0029     m_ui->setupUi(this);
0030     setWindowTitle(tr("%1 - Tip Of The Day").arg(title));
0031     m_ui->m_text->setText(msg);
0032     connect(m_ui->m_neverShowAgain, &QCheckBox::toggled, this, [&](bool value) { m_dontshowAgain= value; });
0033 
0034     if(!url.isEmpty())
0035     {
0036         connect(m_ui->m_buttonBox, &QDialogButtonBox::clicked, this, [&](QAbstractButton* btn) {
0037             auto standard= m_ui->m_buttonBox->standardButton(btn);
0038             if(QDialogButtonBox::Open == standard)
0039             {
0040                 if(!QDesktopServices::openUrl(QUrl(url)))
0041                 {
0042                     QMessageBox* msgBox= new QMessageBox(QMessageBox::Information, tr("No Service to open links"),
0043                         tr("Please find the type here: <a href=\"%1\">%1</a>").arg(url), QMessageBox::Ok);
0044                     msgBox->exec();
0045                 }
0046             }
0047         });
0048     }
0049 }
0050 
0051 bool TipOfDayViewer::dontshowAgain() const
0052 {
0053     return m_dontshowAgain;
0054 }
0055 
0056 void TipOfDayViewer::setDontshowAgain(bool dontshowAgain)
0057 {
0058     m_dontshowAgain= dontshowAgain;
0059 }