1 /*************************************************************************** 2 softwareupdatedialog.cpp - description 3 ------------------- 4 begin : feb 2017 5 copyright : (C) 2017 by Jaime Robles 6 email : jaime@robles.es 7 ***************************************************************************/ 8 9 /***************************************************************************** 10 * This file is part of KLog. * 11 * * 12 * KLog is free software: you can redistribute it and/or modify * 13 * it under the terms of the GNU General Public License as published by * 14 * the Free Software Foundation, either version 3 of the License, or * 15 * (at your option) any later version. * 16 * * 17 * KLog is distributed in the hope that it will be useful, * 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 20 * GNU General Public License for more details. * 21 * * 22 * You should have received a copy of the GNU General Public License * 23 * along with KLog. If not, see <https://www.gnu.org/licenses/>. * 24 * * 25 *****************************************************************************/ 26 27 #include "softwareupdatedialog.h" 28 29 //#include <QDebug> 30 31 SoftwareUpdateDialog()32SoftwareUpdateDialog::SoftwareUpdateDialog() 33 { 34 //qDebug() << "SoftwareUpdateDialog::SoftwareUpdateDialog" << QT_ENDL; 35 36 textBrowser = new QTextBrowser; 37 textBrowser->setOpenLinks(true); 38 textBrowser->setOpenExternalLinks(true); 39 40 //textBrowser->setFrameShadow(QFrame::Raised); 41 //textBrowser->setFrameStyle(QFrame::StyledPanel); 42 43 QPushButton *acceptButton = new QPushButton(tr("Ok")); 44 45 46 textBrowser->setOpenExternalLinks(true); 47 //textBrowser->setHTML(url); 48 49 50 QHBoxLayout *buttonsLayout = new QHBoxLayout; 51 buttonsLayout->addWidget(acceptButton); 52 53 54 /// 55 QVBoxLayout *mainLayout = new QVBoxLayout; 56 mainLayout->addWidget(textBrowser); 57 mainLayout->addLayout(buttonsLayout); 58 59 setLayout(mainLayout); 60 61 setWindowTitle(tr("KLog update")); 62 63 /// 64 65 connect(acceptButton, SIGNAL(clicked()), this, SLOT(slotAcceptButtonClicked())); 66 //qDebug() << "SoftwareUpdateDialog::SoftwareUpdateDialog - END" << QT_ENDL; 67 } 68 setVersion(const QString tversion,const bool updateNeeded)69void SoftwareUpdateDialog::setVersion(const QString tversion, const bool updateNeeded) 70 { 71 //qDebug() << "SoftwareUpdateDialog::setVersion: " << tversion << QT_ENDL; 72 _version = tversion; 73 if (updateNeeded) 74 { 75 //text = "<center><h2>KLog new version ("+ tversion + ") is available! </h2></center><br>There is a new version of KLog available.<br><br><b>You can get the new version from:<br><br><center><a href=https://www.klog.xyz>https://www.klog.xyz</a></center>"; 76 text = tr("<center><h2>KLog new version (%1) is available! </h2></center><br>There is a new version of KLog available.<br><br><b>You can get the new version from:<br><br><center><a href=https://www.klog.xyz>https://www.klog.xyz</a></center>").arg(tversion); 77 78 } 79 else 80 { 81 text = "<center><h2>" + tr("Congratulations!") + "</h2></center><br><br>" + tr("Your KLog has been updated.") + "<br><br>" + tr("You already have the latest version.") + "<br><center>("+ tversion + ")</center>"; 82 } 83 84 textBrowser->setHtml(text); 85 //qDebug() << "SoftwareUpdateDialog::setVersion: END"<< QT_ENDL; 86 } 87 ~SoftwareUpdateDialog()88SoftwareUpdateDialog::~SoftwareUpdateDialog() 89 { 90 //qDebug() << "SoftwareUpdateDialog::~SoftwareUpdateDialog" << QT_ENDL; 91 } 92 slotAcceptButtonClicked()93void SoftwareUpdateDialog::slotAcceptButtonClicked() 94 { 95 //qDebug() << "SoftwareUpdateDialog::slotAcceptButtonClicked" << QT_ENDL; 96 accept(); 97 //qDebug() << "SoftwareUpdateDialog::slotAcceptButtonClicked END" << QT_ENDL; 98 } 99 100 101 keyPressEvent(QKeyEvent * event)102void SoftwareUpdateDialog::keyPressEvent(QKeyEvent *event) 103 { 104 //qDebug() << "SoftwareUpdateDialog::keyPressEvent" << QT_ENDL; 105 106 if (event->key()>=0) 107 { 108 slotAcceptButtonClicked(); 109 } 110 111 112 //qDebug() << "SoftwareUpdateDialog::keyPressEvent END" << QT_ENDL; 113 } 114