1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

src/tools folder

This commit is contained in:
nowrep 2011-03-03 15:24:23 +01:00
parent 800255a7e4
commit 22aca9c81c
20 changed files with 327 additions and 73 deletions

1
bin/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
qupzilla

1
bin/plugins/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
libExamplePlugin.so

View File

@ -83,7 +83,9 @@ SOURCES += main.cpp\
3rdparty/ecwin7.cpp \
webview/webtab.cpp \
rss/rsswidget.cpp \
autofill/autofillnotification.cpp
autofill/autofillnotification.cpp \
rss/rssnotification.cpp \
tools/notification.cpp
HEADERS += 3rdparty/squeezelabel.h \
3rdparty/qtwin.h \
@ -136,7 +138,9 @@ HEADERS += 3rdparty/squeezelabel.h \
3rdparty/ecwin7.h \
webview/webtab.h \
rss/rsswidget.h \
autofill/autofillnotification.h
autofill/autofillnotification.h \
rss/rssnotification.h \
tools/notification.h
FORMS += \
preferences/autofillmanager.ui \
@ -154,7 +158,8 @@ FORMS += \
downloads/downloaditem.ui \
downloads/downloadmanager.ui \
rss/rsswidget.ui \
autofill/autofillnotification.ui
autofill/autofillnotification.ui \
rss/rssnotification.ui
RESOURCES += \
data/icons.qrc \

View File

@ -26,13 +26,14 @@ AutoFillNotification::AutoFillNotification(QUrl url, QByteArray data, QString pa
connect(ui->notnow, SIGNAL(clicked()), this, SLOT(hide()));
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
qDebug() << this->sizeHint().height();
setMinimumHeight(1);
setMaximumHeight(1);
m_animation = new QTimeLine(300, this);
m_animation->setFrameRange(0, 35);
connect(m_animation, SIGNAL(frameChanged(int)),this, SLOT(frameChanged(int)));
QTimer::singleShot(300, m_animation, SLOT(start()));
QTimer::singleShot(1, m_animation, SLOT(start()));
}
void AutoFillNotification::hide()

View File

@ -5,6 +5,7 @@
#include <QUrl>
#include <QTimeLine>
#include <QTimer>
#include <QDebug>
namespace Ui {
class AutoFillWidget;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -150,7 +150,7 @@ void LocationBar::rssIconClicked()
{
QList<QPair<QString,QString> > _rss = p_QupZilla->weView()->getRss();
RSSWidget* rss = new RSSWidget(_rss, this);
RSSWidget* rss = new RSSWidget(p_QupZilla->weView(), _rss, this);
rss->showAt(this);
}
@ -305,38 +305,6 @@ void LocationBar::keyPressEvent(QKeyEvent *event)
QLineEdit::keyPressEvent(event);
}
void LocationBar::addRss()
{
WebView* view = p_QupZilla->weView();
if(!view)
return;
if (QAction *action = qobject_cast<QAction*>(sender())) {
QUrl url = action->data().toUrl();
QString urlString = url.toString();
if(url.host().isEmpty()) {
if(!urlString.startsWith("/"))
urlString="/"+urlString;
urlString = view->url().host()+urlString;
QUrl temp(urlString);
if(temp.scheme().isEmpty())
urlString="http://"+urlString;
temp = QUrl(urlString);
if(temp.scheme().isEmpty() || temp.host().isEmpty())
return;
}
if (!url.isValid())
return;
QString title;
if (action->toolTip().isEmpty())
title = view->url().host();
else
title = action->toolTip();
p_QupZilla->getMainApp()->rssManager()->addRssFeed(urlString, title);
}
}
LocationBar::~LocationBar()
{
delete m_bookmarkButton;

View File

@ -41,7 +41,6 @@ public slots:
private slots:
void siteIconChanged();
void setPrivacy(bool state);
void addRss();
void textEdit();
void showPopup();
void bookmarkIconClicked();

View File

@ -291,11 +291,10 @@ bool RSSManager::addRssFeed(const QString &address, const QString &title)
query.bindValue(0, address);
query.bindValue(1, title);
query.exec();
QMessageBox::information(getQupZilla(), tr("RSS feed added"), tr("RSS with title '%1' has been successfuly added.").arg(title));
return true;
} else {
QMessageBox::warning(getQupZilla(), tr("RSS feed duplicated"), tr("You already have this feed."));
}
QMessageBox::warning(getQupZilla(), tr("RSS feed duplicated"), tr("You already have this feed."));
return false;
}

View File

@ -0,0 +1,51 @@
#include "rssnotification.h"
#include "ui_rssnotification.h"
#include "mainapplication.h"
#include "qupzilla.h"
RSSNotification::RSSNotification(QString host, QWidget *parent) :
QWidget(parent),
ui(new Ui::RSSNotification)
{
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
setMinimumHeight(1);
setMaximumHeight(1);
ui->closeButton->setIcon(
#ifdef Q_WS_X11
style()->standardIcon(QStyle::SP_DialogCloseButton)
#else
QIcon(":/icons/faenza/close.png")
#endif
);
ui->label->setText(tr("You have successfuly added RSS feed \"%1\".").arg(host));
connect(ui->pushButton, SIGNAL(clicked()), MainApplication::getInstance()->getWindow(), SLOT(showRSSManager()));
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(hide()));
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
m_animation = new QTimeLine(300, this);
m_animation->setFrameRange(0, 35);
connect(m_animation, SIGNAL(frameChanged(int)),this, SLOT(frameChanged(int)));
QTimer::singleShot(1, m_animation, SLOT(start()));
}
void RSSNotification::hide()
{
m_animation->setDirection(QTimeLine::Backward);
m_animation->stop();
m_animation->start();
connect(m_animation, SIGNAL(finished()), this, SLOT(close()));
}
void RSSNotification::frameChanged(int frame)
{
setMinimumHeight(frame);
setMaximumHeight(frame);
}
RSSNotification::~RSSNotification()
{
delete ui;
}

28
src/rss/rssnotification.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef RSSNOTIFICATION_H
#define RSSNOTIFICATION_H
#include <QWidget>
#include <QTimeLine>
namespace Ui {
class RSSNotification;
}
class RSSNotification : public QWidget
{
Q_OBJECT
public:
explicit RSSNotification(QString host, QWidget *parent = 0);
~RSSNotification();
private slots:
void hide();
void frameChanged(int frame);
private:
Ui::RSSNotification *ui;
QTimeLine* m_animation;
};
#endif // RSSNOTIFICATION_H

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RSSNotification</class>
<widget class="QWidget" name="RSSNotification">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>713</width>
<height>36</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="icon">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../data/icons.qrc">:/icons/other/feed.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Read RSS</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="closeButton">
<property name="text">
<string/>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../data/icons.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -1,12 +1,29 @@
#include "rsswidget.h"
#include "ui_rsswidget.h"
#include "mainapplication.h"
#include "webview.h"
#include "rssmanager.h"
#include "rssnotification.h"
RSSWidget::RSSWidget(QList<QPair<QString, QString> > availableRss, QWidget *parent)
RSSWidget::RSSWidget(WebView *view, QList<QPair<QString, QString> > availableRss, QWidget *parent)
:QMenu(parent)
,ui(new Ui::RSSWidget)
,m_avRss(availableRss)
,m_view(view)
{
ui->setupUi(this);
for (int i = 0; i < m_avRss.count(); i++) {
QPair<QString, QString> rss = m_avRss.at(i);
QPushButton* button = new QPushButton(this);
button->setText(tr("Add"));
button->setWhatsThis(rss.second);
button->setToolTip(rss.first);
QLabel* label = new QLabel(this);
label->setText(rss.first);
ui->gridLayout->addWidget(label, i, 0);
ui->gridLayout->addWidget(button, i, 1);
connect(button, SIGNAL(clicked()), this, SLOT(addRss()));
}
}
void RSSWidget::showAt(QWidget* _parent)
@ -16,6 +33,41 @@ void RSSWidget::showAt(QWidget* _parent)
show();
}
void RSSWidget::addRss()
{
if(!m_view)
return;
if (QPushButton *button = qobject_cast<QPushButton*>(sender())) {
QUrl url = QUrl(button->whatsThis());
QString urlString = button->whatsThis();
if(url.host().isEmpty()) {
if(!urlString.startsWith("/"))
urlString="/"+urlString;
urlString = m_view->url().host()+urlString;
QUrl temp(urlString);
if(temp.scheme().isEmpty())
urlString="http://"+urlString;
temp = QUrl(urlString);
if(temp.scheme().isEmpty() || temp.host().isEmpty())
return;
}
if (!url.isValid())
return;
QString title;
if (button->toolTip().isEmpty())
title = m_view->url().host();
else
title = button->toolTip();
if (MainApplication::getInstance()->rssManager()->addRssFeed(urlString, title)) {
RSSNotification* notif = new RSSNotification(title, m_view);
m_view->addNotification(notif);
close();
}
}
}
RSSWidget::~RSSWidget()
{
delete ui;

View File

@ -3,24 +3,31 @@
#include <QWidget>
#include <QMenu>
#include <QPushButton>
#include <QDebug>
namespace Ui {
class RSSWidget;
}
class WebView;
class RSSWidget : public QMenu
{
Q_OBJECT
public:
explicit RSSWidget(QList<QPair<QString,QString> > availableRss, QWidget *parent = 0);
explicit RSSWidget(WebView* view, QList<QPair<QString,QString> > availableRss, QWidget *parent = 0);
~RSSWidget();
void showAt(QWidget* _parent);
private slots:
void addRss();
private:
Ui::RSSWidget *ui;
QList<QPair<QString,QString> > m_avRss;
WebView* m_view;
};
#endif // RSSWIDGET_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>245</width>
<height>66</height>
<width>247</width>
<height>97</height>
</rect>
</property>
<property name="windowTitle">
@ -22,17 +22,19 @@
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="horizontalSpacing">
<number>6</number>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>9</number>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -45,14 +47,35 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add RSS Feeds from this site</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>10</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
</layout>
</item>
</layout>
</widget>
</item>
</layout>

View File

@ -24,7 +24,6 @@ TabWidget::TabWidget(QupZilla* mainClass, QWidget *parent) :
connect(this, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
connect(this, SIGNAL(currentChanged(int)), p_QupZilla, SLOT(refreshHistory()));
connect(this, SIGNAL(currentChanged(int)), p_QupZilla->locationBar(), SLOT(checkRss()));
connect(this, SIGNAL(currentChanged(int)), p_QupZilla->locationBar(), SLOT(siteIconChanged()));
connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
@ -138,7 +137,6 @@ int TabWidget::addView(QUrl url, QString title, OpenUrlIn openIn, bool selectLin
connect(weView(index), SIGNAL(siteIconChanged()), p_QupZilla->locationBar(), SLOT(siteIconChanged()));
connect(weView(index), SIGNAL(showUrl(QUrl)), p_QupZilla->locationBar(), SLOT(showUrl(QUrl)));
connect(weView(index), SIGNAL(checkRss()), p_QupZilla->locationBar(), SLOT(checkRss()));
connect(weView(index), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int)));
connect(weView(index), SIGNAL(changed()), p_QupZilla->getMainApp(), SLOT(setChanged()));
connect(weView(index), SIGNAL(ipChanged(QString)), p_QupZilla->ipLabel(), SLOT(setText(QString)));
@ -168,7 +166,6 @@ void TabWidget::closeTab(int index)
if (weView(index)) {
disconnect(weView(index), SIGNAL(siteIconChanged()), p_QupZilla->locationBar(), SLOT(siteIconChanged()));
disconnect(weView(index), SIGNAL(showUrl(QUrl)), p_QupZilla->locationBar(), SLOT(showUrl(QUrl)));
disconnect(weView(index), SIGNAL(checkRss()), p_QupZilla->locationBar(), SLOT(checkRss()));
disconnect(weView(index), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int)));
disconnect(weView(index), SIGNAL(changed()), p_QupZilla->getMainApp(), SLOT(setChanged()));
disconnect(weView(index), SIGNAL(ipChanged(QString)), p_QupZilla->ipLabel(), SLOT(setText(QString)));

4
tools_/a_showLines.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
cd /home/david/Programování/Qt\ C++/QupZilla/src/ && python /home/david/Programování/Qt\ C++/QupZilla/tools/pythonLineCounter.py
read -p "Press [ENTER] to close terminal"
exit

View File

@ -0,0 +1,20 @@
#!/usr/bin/python
import commands, re
cpp=commands.getoutput("find . -name '*.cpp' | xargs wc -l |grep celkem")
headers=commands.getoutput("find . -name '*.h' | xargs wc -l |grep celkem")
intcpp=int(re.findall(r"\d+",cpp)[0])
intheaders=int(re.findall(r"\d+",headers)[0])
print "\n"
print "##########################"
print "## nowrep line counter! ##"
print "##########################"
print "\n"
print "Lines in Headers (.h files): "+str(intheaders)
print "Lines in Sources (.cpp files): "+str(intcpp)
print "----------------------------------------"
print "\n"
print "::: "+str(intheaders + intcpp)+" LINES IN SUMMARY :::"
print "\n"

View File

@ -0,0 +1,8 @@
#!/bin/bash
/home/david/Programování/qtsdk-2010.05/qt/bin/lupdate /home/david/Programování/Qt\ C++/QupZilla/plugins/TestPlugin/src/TestPlugin.pro -no-obsolete -ts /home/david/Programování/Qt\ C++/QupZilla/plugins/TestPlugin/cs_CZ.ts
/home/david/Programování/qtsdk-2010.05/qt/bin/lupdate /home/david/Programování/Qt\ C++/QupZilla/plugins/TestPlugin/src/TestPlugin.pro -no-obsolete -ts /home/david/Programování/Qt\ C++/QupZilla/plugins/TestPlugin/sk_SK.ts
read -p "Press [ENTER] to close terminal"
exit

14
tools_/updateTranslations.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
## circular inclusions workaround - we comment that buggy line
sed -i 's/include(3rdparty/##temp/g' /home/david/Programování/Qt\ C++/QupZilla/src/QupZilla.pro
/home/david/Programování/qtsdk-2010.05/qt/bin/lupdate /home/david/Programování/Qt\ C++/QupZilla/src/QupZilla.pro -no-obsolete -ts /home/david/Programování/Qt\ C++/QupZilla/translations/cs_CZ.ts
/home/david/Programování/qtsdk-2010.05/qt/bin/lupdate /home/david/Programování/Qt\ C++/QupZilla/src/QupZilla.pro -no-obsolete -ts /home/david/Programování/Qt\ C++/QupZilla/translations/sk_SK.ts
## uncomment it now
sed -i 's/##temp/include(3rdparty/g' /home/david/Programování/Qt\ C++/QupZilla/src/QupZilla.pro
read -p "Press [ENTER] to close terminal"
exit