From 22aca9c81c47ae1f16db5625d87996125a0fdefa Mon Sep 17 00:00:00 2001 From: nowrep Date: Thu, 3 Mar 2011 15:24:23 +0100 Subject: [PATCH] src/tools folder --- bin/.gitignore | 1 + bin/plugins/.gitignore | 1 + src/QupZilla.pro | 11 +++- src/autofill/autofillnotification.cpp | 3 +- src/autofill/autofillnotification.h | 1 + src/data/icons/other/bigrss.png | Bin 0 -> 1877 bytes src/navigation/locationbar.cpp | 34 +----------- src/navigation/locationbar.h | 1 - src/rss/rssmanager.cpp | 5 +- src/rss/rssnotification.cpp | 51 +++++++++++++++++ src/rss/rssnotification.h | 28 ++++++++++ src/rss/rssnotification.ui | 75 +++++++++++++++++++++++++ src/rss/rsswidget.cpp | 54 +++++++++++++++++- src/rss/rsswidget.h | 9 ++- src/rss/rsswidget.ui | 77 +++++++++++++++++--------- src/webview/tabwidget.cpp | 3 - tools_/a_showLines.sh | 4 ++ tools_/pythonLineCounter.py | 20 +++++++ tools_/updatePluginTranslations.sh | 8 +++ tools_/updateTranslations.sh | 14 +++++ 20 files changed, 327 insertions(+), 73 deletions(-) create mode 100644 bin/.gitignore create mode 100644 bin/plugins/.gitignore create mode 100644 src/data/icons/other/bigrss.png create mode 100644 src/rss/rssnotification.cpp create mode 100644 src/rss/rssnotification.h create mode 100644 src/rss/rssnotification.ui create mode 100755 tools_/a_showLines.sh create mode 100644 tools_/pythonLineCounter.py create mode 100755 tools_/updatePluginTranslations.sh create mode 100755 tools_/updateTranslations.sh diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 000000000..650c516a6 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +qupzilla diff --git a/bin/plugins/.gitignore b/bin/plugins/.gitignore new file mode 100644 index 000000000..07f9dae00 --- /dev/null +++ b/bin/plugins/.gitignore @@ -0,0 +1 @@ +libExamplePlugin.so diff --git a/src/QupZilla.pro b/src/QupZilla.pro index c0a5adce5..33a9f1cdd 100644 --- a/src/QupZilla.pro +++ b/src/QupZilla.pro @@ -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 \ diff --git a/src/autofill/autofillnotification.cpp b/src/autofill/autofillnotification.cpp index 7fc5654d3..c904c8cde 100644 --- a/src/autofill/autofillnotification.cpp +++ b/src/autofill/autofillnotification.cpp @@ -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() diff --git a/src/autofill/autofillnotification.h b/src/autofill/autofillnotification.h index 4f9b5a039..bd45404e4 100644 --- a/src/autofill/autofillnotification.h +++ b/src/autofill/autofillnotification.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace Ui { class AutoFillWidget; diff --git a/src/data/icons/other/bigrss.png b/src/data/icons/other/bigrss.png new file mode 100644 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i*9$d%t?fegE2R?sNVh{)cOK1vb9`fv)x8Afs}OpHu=uoexfLukDb&+P^PP z2UhwE{tA@-*awtekM@p^rvAZRoo6Q|cW)^>L{acHaVbZi4B*p@>fR%GU{TPf_{uN~SUP@nN#p}c5QaB}f~B`y;9KPT`pY4^M|yl@df P00000NkvXXu0mjfFVTP< literal 0 HcmV?d00001 diff --git a/src/navigation/locationbar.cpp b/src/navigation/locationbar.cpp index 84278cffa..e71e31bbe 100644 --- a/src/navigation/locationbar.cpp +++ b/src/navigation/locationbar.cpp @@ -150,7 +150,7 @@ void LocationBar::rssIconClicked() { QList > _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(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; diff --git a/src/navigation/locationbar.h b/src/navigation/locationbar.h index a4b54ecae..bcb3c4b06 100644 --- a/src/navigation/locationbar.h +++ b/src/navigation/locationbar.h @@ -41,7 +41,6 @@ public slots: private slots: void siteIconChanged(); void setPrivacy(bool state); - void addRss(); void textEdit(); void showPopup(); void bookmarkIconClicked(); diff --git a/src/rss/rssmanager.cpp b/src/rss/rssmanager.cpp index 69d87c4cb..078ebc5a1 100644 --- a/src/rss/rssmanager.cpp +++ b/src/rss/rssmanager.cpp @@ -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; } diff --git a/src/rss/rssnotification.cpp b/src/rss/rssnotification.cpp new file mode 100644 index 000000000..fef322ba9 --- /dev/null +++ b/src/rss/rssnotification.cpp @@ -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; +} diff --git a/src/rss/rssnotification.h b/src/rss/rssnotification.h new file mode 100644 index 000000000..fba0aaa51 --- /dev/null +++ b/src/rss/rssnotification.h @@ -0,0 +1,28 @@ +#ifndef RSSNOTIFICATION_H +#define RSSNOTIFICATION_H + +#include +#include + +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 diff --git a/src/rss/rssnotification.ui b/src/rss/rssnotification.ui new file mode 100644 index 000000000..cb188dc14 --- /dev/null +++ b/src/rss/rssnotification.ui @@ -0,0 +1,75 @@ + + + RSSNotification + + + + 0 + 0 + 713 + 36 + + + + Form + + + + 2 + + + 2 + + + + + + 0 + 0 + + + + + + + :/icons/other/feed.png + + + + + + + + 0 + 0 + + + + + + + + + + + Read RSS + + + + + + + + + + true + + + + + + + + + + diff --git a/src/rss/rsswidget.cpp b/src/rss/rsswidget.cpp index a1ea77f85..4d4a47cba 100644 --- a/src/rss/rsswidget.cpp +++ b/src/rss/rsswidget.cpp @@ -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 > availableRss, QWidget *parent) +RSSWidget::RSSWidget(WebView *view, QList > 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 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(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; diff --git a/src/rss/rsswidget.h b/src/rss/rsswidget.h index e6fe965ba..8192a8a14 100644 --- a/src/rss/rsswidget.h +++ b/src/rss/rsswidget.h @@ -3,24 +3,31 @@ #include #include +#include +#include namespace Ui { class RSSWidget; } +class WebView; class RSSWidget : public QMenu { Q_OBJECT public: - explicit RSSWidget(QList > availableRss, QWidget *parent = 0); + explicit RSSWidget(WebView* view, QList > availableRss, QWidget *parent = 0); ~RSSWidget(); void showAt(QWidget* _parent); +private slots: + void addRss(); + private: Ui::RSSWidget *ui; QList > m_avRss; + WebView* m_view; }; #endif // RSSWIDGET_H diff --git a/src/rss/rsswidget.ui b/src/rss/rsswidget.ui index 2abb9c1ea..7be2f95be 100644 --- a/src/rss/rsswidget.ui +++ b/src/rss/rsswidget.ui @@ -6,8 +6,8 @@ 0 0 - 245 - 66 + 247 + 97 @@ -22,35 +22,58 @@ QFrame::NoFrame - - - 6 + + + 0 - - 9 - - - - - - 0 - 0 - + + + + 0 - - - - - :/icons/other/bigrss.png - - + + + + + 0 + 0 + + + + + + + :/icons/other/bigrss.png + + + + + + + + 0 + 0 + + + + Add RSS Feeds from this site + + + + - - - - Add RSS Feeds from this site + + + + 10 - + + 6 + + + 0 + + diff --git a/src/webview/tabwidget.cpp b/src/webview/tabwidget.cpp index a9b36777f..ae74c94f6 100644 --- a/src/webview/tabwidget.cpp +++ b/src/webview/tabwidget.cpp @@ -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))); diff --git a/tools_/a_showLines.sh b/tools_/a_showLines.sh new file mode 100755 index 000000000..41d21b774 --- /dev/null +++ b/tools_/a_showLines.sh @@ -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 diff --git a/tools_/pythonLineCounter.py b/tools_/pythonLineCounter.py new file mode 100644 index 000000000..d2da2fc44 --- /dev/null +++ b/tools_/pythonLineCounter.py @@ -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" diff --git a/tools_/updatePluginTranslations.sh b/tools_/updatePluginTranslations.sh new file mode 100755 index 000000000..637c78457 --- /dev/null +++ b/tools_/updatePluginTranslations.sh @@ -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 diff --git a/tools_/updateTranslations.sh b/tools_/updateTranslations.sh new file mode 100755 index 000000000..e3a412812 --- /dev/null +++ b/tools_/updateTranslations.sh @@ -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