1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-22 11:46:34 +01:00
falkonOfficial/src/lib/other/siteinfowidget.cpp

91 lines
3.2 KiB
C++
Raw Normal View History

2011-03-03 18:29:20 +01:00
/* ============================================================
2017-08-25 17:11:29 +02:00
* Falkon - Qt web 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/>.
* ============================================================ */
#include "qztools.h"
2011-03-02 16:57:41 +01:00
#include "siteinfowidget.h"
#include "ui_siteinfowidget.h"
#include "browserwindow.h"
#include "mainapplication.h"
#include "webpage.h"
#include "tabbedwebview.h"
2011-03-02 16:57:41 +01:00
#include <QToolTip>
#include <QSqlQuery>
SiteInfoWidget::SiteInfoWidget(BrowserWindow* window, QWidget* parent)
: LocationBarPopup(parent)
, ui(new Ui::SiteInfoWidget)
, m_window(window)
2011-03-02 16:57:41 +01:00
{
this->setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
setPopupAlignment(Qt::AlignLeft);
WebView* view = m_window->weView();
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
}
QString scheme = view->url().scheme();
2011-03-02 16:57:41 +01:00
QSqlQuery query;
QString host = view->url().host();
2011-03-02 16:57:41 +01: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) {
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"));
}
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"));
}
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;
if (count == 1) {
2011-03-02 16:57:41 +01:00
text = tr("first");
}
else if (count == 2) {
2011-03-02 16:57:41 +01:00
text = tr("second");
}
else if (count == 3) {
2011-03-02 16:57:41 +01:00
text = tr("third");
}
ui->historyLabel->setText(tr("This is your <b>%1</b> visit of this site.").arg(text));
2011-03-02 16:57:41 +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;
}