2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2014-01-11 16:11:42 +01:00
|
|
|
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
2011-03-03 18:29:20 +01:00
|
|
|
*
|
|
|
|
* This program 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2013-01-22 19:04:22 +01:00
|
|
|
#include "qztools.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
#include "siteinfowidget.h"
|
|
|
|
#include "ui_siteinfowidget.h"
|
2014-02-19 22:07:21 +01:00
|
|
|
#include "browserwindow.h"
|
2012-09-12 11:59:23 +02:00
|
|
|
#include "mainapplication.h"
|
2011-03-22 21:36:15 +01:00
|
|
|
#include "webpage.h"
|
2012-01-21 23:19:38 +01:00
|
|
|
#include "tabbedwebview.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QToolTip>
|
|
|
|
#include <QSqlQuery>
|
|
|
|
|
2014-02-19 22:07:21 +01:00
|
|
|
SiteInfoWidget::SiteInfoWidget(BrowserWindow* window, QWidget* parent)
|
2012-09-15 17:39:54 +02:00
|
|
|
: LocationBarPopup(parent)
|
2011-11-06 17:01:23 +01:00
|
|
|
, ui(new Ui::SiteInfoWidget)
|
2014-02-19 22:07:21 +01:00
|
|
|
, m_window(window)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
this->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2012-09-15 17:39:54 +02:00
|
|
|
setPopupAlignment(Qt::AlignLeft);
|
|
|
|
|
2014-02-19 22:07:21 +01:00
|
|
|
WebView* view = m_window->weView();
|
2011-11-07 19:56:53 +01:00
|
|
|
|
2015-09-29 11:37:17 +02:00
|
|
|
if (view->url().scheme() == QL1S("https")) {
|
2011-03-02 16:57:41 +01:00
|
|
|
ui->secureLabel->setText(tr("Your connection to this site is <b>secured</b>."));
|
2014-01-04 22:37:18 +01:00
|
|
|
ui->secureIcon->setPixmap(QPixmap(":/icons/locationbar/safe.png"));
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui->secureLabel->setText(tr("Your connection to this site is <b>unsecured</b>."));
|
2014-01-04 22:37:18 +01:00
|
|
|
ui->secureIcon->setPixmap(QPixmap(":/icons/locationbar/unsafe.png"));
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2015-09-29 11:37:17 +02:00
|
|
|
QString scheme = view->url().scheme();
|
2011-03-02 16:57:41 +01:00
|
|
|
QSqlQuery query;
|
2015-09-29 11:37:17 +02:00
|
|
|
QString host = view->url().host();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-08-23 15:37:43 +02:00
|
|
|
query.prepare("SELECT sum(count) FROM history WHERE url LIKE ?");
|
|
|
|
query.addBindValue(QString("%1://%2%").arg(scheme, host));
|
|
|
|
query.exec();
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
if (query.next()) {
|
|
|
|
int count = query.value(0).toInt();
|
|
|
|
if (count > 3) {
|
2012-01-03 21:02:35 +01:00
|
|
|
ui->historyLabel->setText(tr("This is your <b>%1</b> visit of this site.").arg(QString::number(count) + "."));
|
2014-01-04 22:37:18 +01:00
|
|
|
ui->historyIcon->setPixmap(QPixmap(":/icons/locationbar/visit3.png"));
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else if (count == 0) {
|
|
|
|
ui->historyLabel->setText(tr("You have <b>never</b> visited this site before."));
|
2014-01-04 22:37:18 +01:00
|
|
|
ui->historyIcon->setPixmap(QPixmap(":/icons/locationbar/visit1.png"));
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2014-01-04 22:37:18 +01:00
|
|
|
ui->historyIcon->setPixmap(QPixmap(":/icons/locationbar/visit2.png"));
|
2011-03-02 16:57:41 +01:00
|
|
|
QString text;
|
2011-11-06 17:01:23 +01:00
|
|
|
if (count == 1) {
|
2011-03-02 16:57:41 +01:00
|
|
|
text = tr("first");
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else if (count == 2) {
|
2011-03-02 16:57:41 +01:00
|
|
|
text = tr("second");
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
|
|
|
else if (count == 3) {
|
2011-03-02 16:57:41 +01:00
|
|
|
text = tr("third");
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2012-01-03 21:02:35 +01:00
|
|
|
ui->historyLabel->setText(tr("This is your <b>%1</b> visit of this site.").arg(text));
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
2014-03-13 11:11:52 +01:00
|
|
|
|
|
|
|
connect(ui->pushButton, SIGNAL(clicked()), m_window->action(QSL("Tools/SiteInfo")), SLOT(trigger()));
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SiteInfoWidget::~SiteInfoWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|