2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2011-10-17 09:57:07 +02:00
|
|
|
* Copyright (C) 2010-2011 David Rosca
|
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/>.
|
|
|
|
* ============================================================ */
|
2011-03-02 16:57:41 +01:00
|
|
|
#include "siteinfowidget.h"
|
|
|
|
#include "ui_siteinfowidget.h"
|
|
|
|
#include "qupzilla.h"
|
2011-03-22 21:36:15 +01:00
|
|
|
#include "webpage.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-03-17 17:03:04 +01:00
|
|
|
SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent) :
|
2011-03-02 16:57:41 +01:00
|
|
|
QMenu(parent)
|
|
|
|
,ui(new Ui::SiteInfoWidget)
|
|
|
|
,p_QupZilla(mainClass)
|
|
|
|
{
|
2011-03-22 21:36:15 +01:00
|
|
|
WebView* view = p_QupZilla->weView();
|
|
|
|
QUrl url = view->url();
|
2011-09-18 15:35:44 +02:00
|
|
|
if (url.isEmpty() || url.scheme() == "qupzilla")
|
2011-03-02 16:57:41 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
this->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2011-03-22 21:36:15 +01:00
|
|
|
if (view->webPage()->sslCertificate().isValid()) {
|
2011-03-02 16:57:41 +01:00
|
|
|
ui->secureLabel->setText(tr("Your connection to this site is <b>secured</b>."));
|
|
|
|
ui->secureIcon->setPixmap(QPixmap(":/icons/locationbar/accept.png"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui->secureLabel->setText(tr("Your connection to this site is <b>unsecured</b>."));
|
|
|
|
ui->secureIcon->setPixmap(QPixmap(":/icons/locationbar/warning.png"));
|
|
|
|
}
|
|
|
|
|
2011-03-22 21:36:15 +01:00
|
|
|
QString scheme = url.scheme();
|
2011-03-02 16:57:41 +01:00
|
|
|
QSqlQuery query;
|
|
|
|
QString host = url.host();
|
|
|
|
QString host2 = host;
|
|
|
|
if (host.startsWith("www."))
|
|
|
|
host2 = url.host().remove("www.");
|
|
|
|
|
|
|
|
query.exec("SELECT sum(count) FROM history WHERE url LIKE '"+scheme+"://"+host+"%' ");
|
|
|
|
if (query.next()) {
|
|
|
|
int count = query.value(0).toInt();
|
|
|
|
if (count > 3) {
|
|
|
|
ui->historyLabel->setText(tr("This is Your <b>%1.</b> visit of this site.").arg(count));
|
|
|
|
ui->historyIcon->setPixmap(QPixmap(":/icons/locationbar/accept.png"));
|
|
|
|
} else if (count == 0) {
|
|
|
|
ui->historyLabel->setText(tr("You have <b>never</b> visited this site before."));
|
|
|
|
ui->historyIcon->setPixmap(QPixmap(":/icons/locationbar/warning.png"));
|
|
|
|
} else {
|
|
|
|
ui->historyIcon->setPixmap(QPixmap(":/icons/locationbar/warning.png"));
|
|
|
|
QString text;
|
|
|
|
if (count == 1)
|
|
|
|
text = tr("first");
|
|
|
|
else if (count == 2)
|
|
|
|
text = tr("second");
|
|
|
|
else if (count == 3)
|
|
|
|
text = tr("third");
|
|
|
|
ui->historyLabel->setText(tr("This is Your <b>%1</b> visit of this site.").arg(text));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
connect(ui->pushButton, SIGNAL(clicked()), p_QupZilla, SLOT(showPageInfo()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SiteInfoWidget::showAt(QWidget* _parent)
|
|
|
|
{
|
|
|
|
QPoint p = _parent->mapToGlobal(QPoint(0, 0));
|
|
|
|
move(p.x(), p.y() + _parent->height());
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
|
|
|
SiteInfoWidget::~SiteInfoWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|