1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02:00

Completely rewritten all animations (hide/show notifications and search

bars)
This commit is contained in:
nowrep 2011-08-02 16:19:20 +02:00
parent a959d148d3
commit 13f8b67abd
18 changed files with 894 additions and 710 deletions

Binary file not shown.

View File

@ -96,7 +96,7 @@ SOURCES += main.cpp\
rss/rssnotification.cpp \ rss/rssnotification.cpp \
navigation/locationpopup.cpp \ navigation/locationpopup.cpp \
preferences/sslmanager.cpp \ preferences/sslmanager.cpp \
tools/notification.cpp \ tools/animatedwidget.cpp \
tools/htmlhighlighter.cpp \ tools/htmlhighlighter.cpp \
other/sourceviewersearch.cpp \ other/sourceviewersearch.cpp \
adblock/adblocksubscription.cpp \ adblock/adblocksubscription.cpp \
@ -184,7 +184,7 @@ HEADERS += \
rss/rssnotification.h \ rss/rssnotification.h \
navigation/locationpopup.h \ navigation/locationpopup.h \
preferences/sslmanager.h \ preferences/sslmanager.h \
tools/notification.h \ tools/animatedwidget.h \
tools/htmlhighlighter.h \ tools/htmlhighlighter.h \
other/sourceviewersearch.h \ other/sourceviewersearch.h \
adblock/adblocksubscription.h \ adblock/adblocksubscription.h \
@ -247,7 +247,8 @@ FORMS += \
webview/jsconfirm.ui \ webview/jsconfirm.ui \
webview/jsalert.ui \ webview/jsalert.ui \
webview/jsprompt.ui \ webview/jsprompt.ui \
other/browsinglibrary.ui other/browsinglibrary.ui \
webview/searchtoolbar.ui
RESOURCES += \ RESOURCES += \
data/icons.qrc \ data/icons.qrc \

View File

@ -71,7 +71,6 @@ QupZilla::QupZilla(bool tryRestore, QUrl startUrl) :
,m_startingUrl(startUrl) ,m_startingUrl(startUrl)
,m_actionPrivateBrowsing(0) ,m_actionPrivateBrowsing(0)
,m_webInspectorDock(0) ,m_webInspectorDock(0)
,m_webSearchToolbar(0)
,m_sideBar(0) ,m_sideBar(0)
,m_statusBarMessage(new StatusBarMessage(this)) ,m_statusBarMessage(new StatusBarMessage(this))
{ {
@ -150,9 +149,13 @@ void QupZilla::postLaunch()
void QupZilla::setupUi() void QupZilla::setupUi()
{ {
setContentsMargins(0,0,0,0); QWidget* widget = new QWidget(this);
m_mainLayout = new QVBoxLayout(widget);
m_mainLayout->setContentsMargins(0,0,0,0);
m_mainLayout->setSpacing(0);
setCentralWidget(widget);
m_tabWidget = new TabWidget(this); m_tabWidget = new TabWidget(this);
setCentralWidget(m_tabWidget); m_mainLayout->addWidget(m_tabWidget);
m_navigation = new QToolBar(this); m_navigation = new QToolBar(this);
m_navigation->setWindowTitle(tr("Navigation")); m_navigation->setWindowTitle(tr("Navigation"));
@ -1033,18 +1036,16 @@ void QupZilla::aboutQupZilla()
void QupZilla::searchOnPage() void QupZilla::searchOnPage()
{ {
if (!m_webSearchToolbar) {
m_webSearchToolbar = new SearchToolBar(this); if (m_mainLayout->count() == 2) {
addToolBar(Qt::BottomToolBarArea, m_webSearchToolbar); SearchToolBar* search = qobject_cast<SearchToolBar*>( m_mainLayout->itemAt(1)->widget() );
m_webSearchToolbar->showBar(); search->searchLine()->setFocus();
return; return;
} }
if (m_webSearchToolbar->isVisible()) {
m_webSearchToolbar->hideBar(); SearchToolBar* search = new SearchToolBar(this);
weView()->setFocus(); m_mainLayout->insertWidget(1, search);
}else{ search->searchLine()->setFocus();
m_webSearchToolbar->showBar();
}
} }
void QupZilla::openFile() void QupZilla::openFile()
@ -1185,7 +1186,6 @@ QupZilla::~QupZilla()
delete m_menuForward; delete m_menuForward;
delete m_searchLine; delete m_searchLine;
delete m_bookmarksToolbar; delete m_bookmarksToolbar;
delete m_webSearchToolbar;
delete m_buttonBack; delete m_buttonBack;
delete m_buttonNext; delete m_buttonNext;
delete m_buttonHome; delete m_buttonHome;

View File

@ -204,6 +204,7 @@ private:
QUrl m_newtab; QUrl m_newtab;
QUrl m_homepage; QUrl m_homepage;
QVBoxLayout* m_mainLayout;
QToolButton* m_supMenu; QToolButton* m_supMenu;
QMenu* m_superMenu; QMenu* m_superMenu;
QMenu* m_menuFile; QMenu* m_menuFile;
@ -236,7 +237,6 @@ private:
QPointer<QDockWidget> m_webInspectorDock; QPointer<QDockWidget> m_webInspectorDock;
WebSearchBar* m_searchLine; WebSearchBar* m_searchLine;
SearchToolBar* m_webSearchToolbar;
BookmarksToolbar* m_bookmarksToolbar; BookmarksToolbar* m_bookmarksToolbar;
TabWidget* m_tabWidget; TabWidget* m_tabWidget;
QPointer<SideBar> m_sideBar; QPointer<SideBar> m_sideBar;

View File

@ -19,17 +19,17 @@
#include "ui_autofillnotification.h" #include "ui_autofillnotification.h"
#include "autofillmodel.h" #include "autofillmodel.h"
#include "mainapplication.h" #include "mainapplication.h"
#include "notification.h" #include "animatedwidget.h"
AutoFillNotification::AutoFillNotification(QUrl url, QByteArray data, QString pass, QWidget* parent) AutoFillNotification::AutoFillNotification(QUrl url, QByteArray data, QString pass, QWidget* parent)
:Notification(parent) :AnimatedWidget(AnimatedWidget::Down, parent)
,ui(new Ui::AutoFillWidget) ,ui(new Ui::AutoFillWidget)
,m_url(url) ,m_url(url)
,m_data(data) ,m_data(data)
,m_pass(pass) ,m_pass(pass)
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this); ui->setupUi(widget());
ui->label->setText(tr("Do you want QupZilla to remember password on %1?").arg(url.host())); ui->label->setText(tr("Do you want QupZilla to remember password on %1?").arg(url.host()));
ui->closeButton->setIcon( ui->closeButton->setIcon(
#ifdef Q_WS_X11 #ifdef Q_WS_X11
@ -43,7 +43,8 @@ AutoFillNotification::AutoFillNotification(QUrl url, QByteArray data, QString pa
connect(ui->never, SIGNAL(clicked()), this, SLOT(never())); connect(ui->never, SIGNAL(clicked()), this, SLOT(never()));
connect(ui->notnow, SIGNAL(clicked()), this, SLOT(hide())); connect(ui->notnow, SIGNAL(clicked()), this, SLOT(hide()));
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide())); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
QTimer::singleShot(1, this, SLOT(startAnimation()));
startAnimation();
} }
void AutoFillNotification::never() void AutoFillNotification::never()

View File

@ -23,13 +23,13 @@
#include <QTimer> #include <QTimer>
#include <QDebug> #include <QDebug>
#include "notification.h" #include "animatedwidget.h"
namespace Ui { namespace Ui {
class AutoFillWidget; class AutoFillWidget;
} }
class Notification; class AnimatedWidget;
class AutoFillNotification : public Notification class AutoFillNotification : public AnimatedWidget
{ {
Q_OBJECT Q_OBJECT
@ -46,7 +46,6 @@ private:
QUrl m_url; QUrl m_url;
QByteArray m_data; QByteArray m_data;
QString m_pass; QString m_pass;
QTimeLine* m_animation;
}; };
#endif // AUTOFILLWIDGET_H #endif // AUTOFILLWIDGET_H

View File

@ -126,8 +126,7 @@ void SourceViewer::findText()
return; return;
} }
SourceViewerSearch* search = new SourceViewerSearch(this); m_layout->insertWidget(1, new SourceViewerSearch(this));
m_layout->insertWidget(1, search);
} }
void SourceViewer::reload() void SourceViewer::reload()

View File

@ -20,12 +20,12 @@
#include "sourceviewer.h" #include "sourceviewer.h"
SourceViewerSearch::SourceViewerSearch(SourceViewer* parent) : SourceViewerSearch::SourceViewerSearch(SourceViewer* parent) :
Notification((QWidget*)parent) AnimatedWidget(AnimatedWidget::Up)
,m_sourceViewer(parent) ,m_sourceViewer(parent)
,ui(new Ui::SourceViewerSearch) ,ui(new Ui::SourceViewerSearch)
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this); ui->setupUi(widget());
ui->closeButton->setIcon( ui->closeButton->setIcon(
#ifdef Q_WS_X11 #ifdef Q_WS_X11
style()->standardIcon(QStyle::SP_DialogCloseButton) style()->standardIcon(QStyle::SP_DialogCloseButton)
@ -50,12 +50,13 @@ SourceViewerSearch::SourceViewerSearch(SourceViewer* parent) :
#endif #endif
); );
ui->lineEdit->setFocus(); ui->lineEdit->setFocus();
startAnimation();
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide())); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(next())); connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(next()));
connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(next())); connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(next()));
connect(ui->next, SIGNAL(clicked()), this, SLOT(next())); connect(ui->next, SIGNAL(clicked()), this, SLOT(next()));
connect(ui->previous, SIGNAL(clicked()), this, SLOT(previous())); connect(ui->previous, SIGNAL(clicked()), this, SLOT(previous()));
startAnimation();
} }
void SourceViewerSearch::activateLineEdit() void SourceViewerSearch::activateLineEdit()

View File

@ -21,14 +21,14 @@
#include <QTextDocument> #include <QTextDocument>
#include <QTextCursor> #include <QTextCursor>
#include "notification.h" #include "animatedwidget.h"
namespace Ui { namespace Ui {
class SourceViewerSearch; class SourceViewerSearch;
} }
class SourceViewer; class SourceViewer;
class SourceViewerSearch : public Notification class SourceViewerSearch : public AnimatedWidget
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -21,11 +21,11 @@
#include "qupzilla.h" #include "qupzilla.h"
RSSNotification::RSSNotification(QString host, QWidget* parent) : RSSNotification::RSSNotification(QString host, QWidget* parent) :
Notification(parent), AnimatedWidget(AnimatedWidget::Down, parent),
ui(new Ui::RSSNotification) ui(new Ui::RSSNotification)
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this); ui->setupUi(widget());
ui->closeButton->setIcon( ui->closeButton->setIcon(
#ifdef Q_WS_X11 #ifdef Q_WS_X11
style()->standardIcon(QStyle::SP_DialogCloseButton) style()->standardIcon(QStyle::SP_DialogCloseButton)
@ -38,7 +38,7 @@ RSSNotification::RSSNotification(QString host, QWidget* parent) :
connect(ui->pushButton, SIGNAL(clicked()), mApp->getWindow(), SLOT(showRSSManager())); connect(ui->pushButton, SIGNAL(clicked()), mApp->getWindow(), SLOT(showRSSManager()));
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(hide())); connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(hide()));
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide())); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
QTimer::singleShot(1, this, SLOT(startAnimation())); startAnimation();
} }
RSSNotification::~RSSNotification() RSSNotification::~RSSNotification()

View File

@ -20,14 +20,14 @@
#include <QWidget> #include <QWidget>
#include "notification.h" #include "animatedwidget.h"
namespace Ui { namespace Ui {
class RSSNotification; class RSSNotification;
} }
class Notification; class AnimatedWidget;
class RSSNotification : public Notification class RSSNotification : public AnimatedWidget
{ {
Q_OBJECT Q_OBJECT
@ -37,7 +37,6 @@ public:
private: private:
Ui::RSSNotification* ui; Ui::RSSNotification* ui;
QTimeLine* m_animation;
}; };
#endif // RSSNOTIFICATION_H #endif // RSSNOTIFICATION_H

View File

@ -0,0 +1,88 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2011 nowrep
*
* 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 "animatedwidget.h"
#include <QDebug>
AnimatedWidget::AnimatedWidget(const Direction &direction, QWidget* parent)
: QWidget(parent)
, m_widget(new QWidget(this))
, m_direction(direction)
{
m_positionAni = new QPropertyAnimation(m_widget, "pos");
m_positionAni->setDuration(300);
m_minHeightAni = new QPropertyAnimation(this, "minimumHeight");
m_minHeightAni->setDuration(300);
m_maxHeightAni = new QPropertyAnimation(this, "maximumHeight");
m_maxHeightAni->setDuration(300);
m_aniGroup = new QParallelAnimationGroup();
m_aniGroup->addAnimation(m_positionAni);
m_aniGroup->addAnimation(m_minHeightAni);
m_aniGroup->addAnimation(m_maxHeightAni);
setMaximumHeight(0);
}
void AnimatedWidget::startAnimation()
{
if (m_direction == Down) {
Y_SHOWN = 0;
Y_HIDDEN = -m_widget->height();
} else if (m_direction == Up) {
Y_SHOWN = 0;
Y_HIDDEN = 0;
}
m_widget->move(QPoint(m_widget->pos().x(), Y_HIDDEN));
m_positionAni->setEndValue(QPoint(m_widget->pos().x(), Y_SHOWN));
m_minHeightAni->setEndValue(m_widget->height());
m_maxHeightAni->setEndValue(m_widget->height());
m_aniGroup->start();
}
void AnimatedWidget::hide()
{
m_positionAni->setEndValue(QPoint(m_widget->pos().x(), Y_HIDDEN));
m_minHeightAni->setEndValue(0);
m_maxHeightAni->setEndValue(0);
m_aniGroup->start();
connect(m_aniGroup, SIGNAL(finished()), this, SLOT(close()));
}
void AnimatedWidget::resizeEvent(QResizeEvent *event)
{
if (event->size().width() != m_widget->width())
m_widget->resize(event->size().width(), m_widget->height());
QWidget::resizeEvent(event);
}
AnimatedWidget::~AnimatedWidget()
{
delete m_positionAni;
delete m_minHeightAni;
delete m_maxHeightAni;
delete m_aniGroup;
delete m_widget;
}

View File

@ -0,0 +1,55 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2011 nowrep
*
* 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/>.
* ============================================================ */
#ifndef NOTIFICATION_H
#define NOTIFICATION_H
#include <QWidget>
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <QResizeEvent>
class AnimatedWidget : public QWidget
{
Q_OBJECT
public:
enum Direction { Down, Up };
explicit AnimatedWidget(const Direction &direction = Down, QWidget* parent = 0);
~AnimatedWidget();
QWidget* widget() { return m_widget; }
public slots:
void hide();
void startAnimation();
private:
void resizeEvent(QResizeEvent *e);
QPropertyAnimation* m_positionAni;
QPropertyAnimation* m_minHeightAni;
QPropertyAnimation* m_maxHeightAni;
QParallelAnimationGroup* m_aniGroup;
QWidget* m_widget;
int Y_SHOWN;
int Y_HIDDEN;
Direction m_direction;
};
#endif // NOTIFICATION_H

View File

@ -19,149 +19,100 @@
#include "qupzilla.h" #include "qupzilla.h"
#include "webview.h" #include "webview.h"
#include "lineedit.h" #include "lineedit.h"
#include "ui_searchtoolbar.h"
SearchToolBar::SearchToolBar(QupZilla* mainClass, QWidget* parent) : SearchToolBar::SearchToolBar(QupZilla* mainClass, QWidget* parent)
QToolBar(parent) : AnimatedWidget(AnimatedWidget::Up, parent)
,p_QupZilla(mainClass) , ui(new Ui::SearchToolbar)
,m_findFlags(0) , p_QupZilla(mainClass)
, m_findFlags(0)
{ {
setContextMenuPolicy(Qt::CustomContextMenu); setAttribute(Qt::WA_DeleteOnClose);
setObjectName("webSearchToolbar"); ui->setupUi(widget());
setWindowTitle(tr("Search")); ui->closeButton->setIcon(
setMovable(false);
m_searchLine = new LineEdit(this);
m_searchLine->setInactiveText(tr("Search"));
m_searchLine->setMaximumWidth(250);
connect(m_searchLine, SIGNAL(returnPressed()), this, SLOT(findNext()));
m_closeButton = new QAction(this);
#ifdef Q_WS_X11 #ifdef Q_WS_X11
m_closeButton->setIcon(QIcon(style()->standardIcon(QStyle::SP_DialogCloseButton).pixmap(16,16))); style()->standardIcon(QStyle::SP_DialogCloseButton)
#else #else
m_closeButton->setIcon(QIcon(QIcon(":/icons/faenza/close.png").pixmap(16,16))); QIcon(":/icons/faenza/close.png")
#endif #endif
connect(m_closeButton, SIGNAL(triggered()), this, SLOT(hideBar())); );
m_highlightButton = new QAction(tr("Highlight occurrences"),this); ui->next->setIcon(
m_highlightButton->setCheckable(true);
connect(m_highlightButton, SIGNAL(triggered(bool)), this, SLOT(refreshFindFlags(bool)));
m_nextButton = new QAction(tr("Next"),this);
#ifdef Q_WS_X11 #ifdef Q_WS_X11
m_nextButton->setIcon(style()->standardIcon(QStyle::SP_ArrowForward)); style()->standardIcon(QStyle::SP_ArrowForward)
#else #else
m_nextButton->setIcon(QIcon(":/icons/faenza/forward.png")); QIcon(":/icons/faenza/forward.png")
#endif #endif
);
connect(m_nextButton, SIGNAL(triggered()), this, SLOT(findNext())); ui->previous->setIcon(
m_previousButton = new QAction(tr("Previous"),this);
#ifdef Q_WS_X11 #ifdef Q_WS_X11
m_previousButton->setIcon(style()->standardIcon(QStyle::SP_ArrowBack)); style()->standardIcon(QStyle::SP_ArrowBack)
#else #else
m_previousButton->setIcon(QIcon(":/icons/faenza/back.png")); QIcon(":/icons/faenza/back.png")
#endif #endif
connect(m_previousButton, SIGNAL(triggered()), this, SLOT(findPrevious())); );
m_caseSensitiveButton = new QAction(tr("Case sensitive"),this); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
m_caseSensitiveButton->setCheckable(true); connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(searchText(QString)));
connect(m_caseSensitiveButton, SIGNAL(triggered(bool)), this, SLOT(refreshFindFlags(bool))); connect(ui->next, SIGNAL(clicked()), this, SLOT(findNext()));
connect(ui->previous, SIGNAL(clicked()), this, SLOT(findPrevious()));
m_searchResults = new QLabel(this); connect(ui->highligh, SIGNAL(clicked()), this, SLOT(refreshFindFlags()));
connect(ui->caseSensitive, SIGNAL(clicked()), this, SLOT(refreshFindFlags()));
addAction(m_closeButton); startAnimation();
addWidget(new QLabel(tr("Find:")));
addWidget(m_searchLine);
addSeparator();
addAction(m_previousButton);
addAction(m_nextButton);
addAction(m_highlightButton);
addAction(m_caseSensitiveButton);
addWidget(m_searchResults);
frameChanged(0);
connect(m_searchLine, SIGNAL(textChanged(QString)), this, SLOT(searchText(QString)));
m_animation = new QTimeLine(300, this);
connect(m_animation, SIGNAL(frameChanged(int)),this, SLOT(frameChanged(int)));
} }
void SearchToolBar::showBar() QLineEdit* SearchToolBar::searchLine()
{ {
setStyleSheet("QLabel, QToolButton {color: "+p_QupZilla->menuTextColor().name()+";}"); return ui->lineEdit;
m_animation->setFrameRange(0, 35);
m_animation->setDirection(QTimeLine::Forward);
disconnect(m_animation, SIGNAL(finished()),this, SLOT(hide()));
m_animation->stop();
m_animation->start();
m_searchLine->setFocus();
QToolBar::show();
}
void SearchToolBar::hideBar()
{
m_animation->setDirection(QTimeLine::Backward);
m_animation->stop();
m_animation->start();
connect(m_animation, SIGNAL(finished()), this, SLOT(hide()));
m_searchLine->clear();
p_QupZilla->weView()->setFocus();
}
void SearchToolBar::frameChanged(int frame)
{
setMinimumHeight(frame);
setMaximumHeight(frame);
} }
void SearchToolBar::findNext() void SearchToolBar::findNext()
{ {
refreshFindFlags(true); refreshFindFlags();
m_findFlags+=4; m_findFlags+=4;
searchText(m_searchLine->text()); searchText(ui->lineEdit->text());
} }
void SearchToolBar::findPrevious() void SearchToolBar::findPrevious()
{ {
refreshFindFlags(true); refreshFindFlags();
m_findFlags+=5; m_findFlags+=5;
searchText(m_searchLine->text()); searchText(ui->lineEdit->text());
} }
void SearchToolBar::refreshFindFlags(bool b) void SearchToolBar::refreshFindFlags()
{ {
Q_UNUSED(b);
m_findFlags = 0; m_findFlags = 0;
if (m_highlightButton->isChecked()) { if (ui->highligh->isChecked()) {
m_findFlags+=8; m_findFlags+=8;
searchText(m_searchLine->text()); searchText(ui->lineEdit->text());
}else{ }else{
m_findFlags+=8; m_findFlags+=8;
searchText(""); searchText("");
m_findFlags-=8; m_findFlags-=8;
} }
if (m_caseSensitiveButton->isChecked()) { if (ui->caseSensitive->isChecked()) {
m_findFlags+=2; m_findFlags+=2;
searchText(m_searchLine->text()); searchText(ui->lineEdit->text());
} }
} }
void SearchToolBar::searchText(const QString &text) void SearchToolBar::searchText(const QString &text)
{ {
bool found = p_QupZilla->weView()->findText(text, QFlags<QWebPage::FindFlag>(m_findFlags)); bool found = p_QupZilla->weView()->findText(text, QFlags<QWebPage::FindFlag>(m_findFlags));
if (!found && !m_searchLine->text().isEmpty()) { if (!found && !ui->lineEdit->text().isEmpty()) {
m_searchLine->setStyleSheet("background-color: #ff6666;"); ui->lineEdit->setStyleSheet("background-color: #ff6666;");
m_searchResults->setText(tr("No results found.")); ui->results->setText(tr("No results found."));
} }
else{ else{
m_searchLine->setStyleSheet(""); ui->lineEdit->setStyleSheet("");
m_searchResults->clear(); ui->results->clear();
} }
} }
SearchToolBar::~SearchToolBar()
{
delete ui;
}

View File

@ -18,45 +18,42 @@
#ifndef SEARCHTOOLBAR_H #ifndef SEARCHTOOLBAR_H
#define SEARCHTOOLBAR_H #define SEARCHTOOLBAR_H
#include <QToolBar>
#include <QLineEdit> #include <QLineEdit>
#include <QAction> #include <QToolButton>
#include <QWebPage> #include <QWebPage>
#include <QLabel> #include <QLabel>
#include <QFlags> #include <QFlags>
#include <QTimeLine> #include <QPropertyAnimation>
#include "animatedwidget.h"
namespace Ui {
class SearchToolbar;
}
class QupZilla; class QupZilla;
class LineEdit; class LineEdit;
class SearchToolBar : public QToolBar class SearchToolBar : public AnimatedWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SearchToolBar(QupZilla* mainClass, QWidget* parent = 0); explicit SearchToolBar(QupZilla* mainClass, QWidget* parent = 0);
LineEdit* searchLine(){ return m_searchLine; } ~SearchToolBar();
QLineEdit* searchLine();
signals: signals:
public slots: public slots:
void showBar();
void hideBar();
void searchText(const QString &text); void searchText(const QString &text);
void refreshFindFlags(bool b); void refreshFindFlags();
void findNext(); void findNext();
void findPrevious(); void findPrevious();
void frameChanged(int frame);
private: private:
Ui::SearchToolbar* ui;
QupZilla* p_QupZilla; QupZilla* p_QupZilla;
LineEdit* m_searchLine; QPropertyAnimation* m_animation;
QAction* m_closeButton;
QAction* m_highlightButton;
QAction* m_caseSensitiveButton;
QAction* m_nextButton;
QAction* m_previousButton;
QLabel* m_searchResults;
QTimeLine* m_animation;
int m_findFlags; int m_findFlags;
}; };

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SearchToolbar</class>
<widget class="QWidget" name="SearchToolbar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>855</width>
<height>40</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QToolButton" name="closeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Search: </string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="placeholderText">
<string>Search...</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="previous">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="next">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="highligh">
<property name="text">
<string>Highlight</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="caseSensitive">
<property name="text">
<string>Case sensitive</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="results">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>333</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff