mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
generic: purge Qt support with fire
see commit in kdelibs repository Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
86711afe4d
commit
480c5f698f
31 changed files with 36 additions and 2885 deletions
|
@ -116,14 +116,6 @@ set_package_properties(Fontconfig PROPERTIES
|
|||
TYPE OPTIONAL
|
||||
)
|
||||
|
||||
macro_optional_find_package(QJSON)
|
||||
set_package_properties(QJSON PROPERTIES
|
||||
DESCRIPTION "Library to manage JSON objects with Qt"
|
||||
URL "http://qjson.sourceforge.net/"
|
||||
PURPOSE "Required to build Chrome/Chromium support for Plasma Bookmarks Runners"
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
|
||||
find_package(LibGcrypt 1.5.0)
|
||||
set_package_properties(LibGcrypt PROPERTIES
|
||||
DESCRIPTION "general purpose cryptographic library based on the code from GnuPG"
|
||||
|
|
|
@ -89,18 +89,6 @@ install(TARGETS textthumbnail DESTINATION ${PLUGIN_INSTALL_DIR})
|
|||
|
||||
########### next target ###############
|
||||
|
||||
if(QT_QTWEBKIT_FOUND)
|
||||
set(htmlthumbnail_PART_SRCS htmlcreator.cpp)
|
||||
|
||||
kde4_add_plugin(htmlthumbnail ${htmlthumbnail_PART_SRCS})
|
||||
|
||||
target_link_libraries(htmlthumbnail ${KDE4_KDEWEBKIT_LIBS})
|
||||
|
||||
install(TARGETS htmlthumbnail DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
endif()
|
||||
|
||||
########### next target ###############
|
||||
|
||||
set(djvuthumbnail_PART_SRCS djvucreator.cpp)
|
||||
|
||||
kde4_add_plugin(djvuthumbnail ${djvuthumbnail_PART_SRCS})
|
||||
|
@ -182,7 +170,6 @@ install(
|
|||
imagethumbnail.desktop
|
||||
jpegthumbnail.desktop
|
||||
textthumbnail.desktop
|
||||
htmlthumbnail.desktop
|
||||
djvuthumbnail.desktop
|
||||
desktopthumbnail.desktop
|
||||
comicbookthumbnail.desktop
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
/* This file is part of the KDE libraries
|
||||
Copyright (C) 2000 Malte Starostik <malte@kde.org>
|
||||
Copyright (C) 2006 Roberto Cappuccio <roberto.cappuccio@gmail.com>
|
||||
Copyright (C) 2011 Dawit Alemayehu <adawit@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "htmlcreator.h"
|
||||
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include <QtWebKit/QWebFrame>
|
||||
|
||||
#include <kapplication.h>
|
||||
#include <kwebpage.h>
|
||||
#include <kurl.h>
|
||||
#include <kdebug.h>
|
||||
#include <kdemacros.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
KDE_EXPORT ThumbCreator *new_creator()
|
||||
{
|
||||
return new HTMLCreator;
|
||||
}
|
||||
}
|
||||
|
||||
HTMLCreator::HTMLCreator()
|
||||
: m_loadedOk(true), m_page(0)
|
||||
{
|
||||
}
|
||||
|
||||
HTMLCreator::~HTMLCreator()
|
||||
{
|
||||
delete m_page;
|
||||
}
|
||||
|
||||
bool HTMLCreator::create(const QString &path, int width, int height, QImage &img)
|
||||
{
|
||||
if (!m_page)
|
||||
{
|
||||
m_page = new KWebPage;
|
||||
connect(m_page, SIGNAL(loadFinished(bool)), SLOT(slotFinished(bool)));
|
||||
m_page->settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
|
||||
m_page->settings()->setAttribute(QWebSettings::JavaEnabled, false);
|
||||
m_page->settings()->setAttribute(QWebSettings::PluginsEnabled, false);
|
||||
m_page->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, false);
|
||||
m_page->settings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true);
|
||||
}
|
||||
|
||||
KUrl url(path);
|
||||
m_loadedOk = false;
|
||||
m_page->mainFrame()->load(url);
|
||||
|
||||
const int t = startTimer((url.isLocalFile()?5000:30000));
|
||||
m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||
killTimer(t);
|
||||
|
||||
if (m_page->mainFrame()->contentsSize().isEmpty()) {
|
||||
m_loadedOk = false;
|
||||
}
|
||||
|
||||
if (!m_loadedOk) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QPixmap pix;
|
||||
if (width > 400 || height > 600) {
|
||||
if (height * 3 > width * 4) {
|
||||
pix = QPixmap(width, width * 4 / 3);
|
||||
} else {
|
||||
pix = QPixmap(height * 3 / 4, height);
|
||||
}
|
||||
} else {
|
||||
pix = QPixmap(400, 600);
|
||||
}
|
||||
pix.fill(Qt::transparent);
|
||||
const int borderX = pix.width() / width;
|
||||
const int borderY = pix.height() / height;
|
||||
QRect clip (borderX, borderY, pix.width() - borderX * 2, pix.height() - borderY * 2);
|
||||
QPainter p (&pix);
|
||||
m_page->setViewportSize(m_page->mainFrame()->contentsSize());
|
||||
m_page->mainFrame()->render(&p, QWebFrame::ContentsLayer, clip);
|
||||
|
||||
img = pix.toImage();
|
||||
return true;
|
||||
}
|
||||
|
||||
void HTMLCreator::timerEvent(QTimerEvent *)
|
||||
{
|
||||
m_eventLoop.quit();
|
||||
}
|
||||
|
||||
void HTMLCreator::slotFinished(bool ok)
|
||||
{
|
||||
m_loadedOk = ok;
|
||||
m_eventLoop.quit();
|
||||
}
|
||||
|
||||
ThumbCreator::Flags HTMLCreator::flags() const
|
||||
{
|
||||
return DrawFrame;
|
||||
}
|
||||
|
||||
#include "moc_htmlcreator.cpp"
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/* This file is part of the KDE libraries
|
||||
Copyright (C) 2000 Malte Starostik <malte@kde.org>
|
||||
Copyright (C) 2006 Roberto Cappuccio <roberto.cappuccio@gmail.com>
|
||||
Copyright (C) 2011 Dawit Alemayehu <adawit@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef HTMLCREATOR_H
|
||||
#define HTMLCREATOR_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QEventLoop>
|
||||
|
||||
#include <kio/thumbcreator.h>
|
||||
|
||||
class KWebPage;
|
||||
|
||||
class HTMLCreator : public QObject, public ThumbCreator
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HTMLCreator();
|
||||
virtual ~HTMLCreator();
|
||||
virtual bool create(const QString &path, int width, int height, QImage &img);
|
||||
virtual Flags flags() const;
|
||||
|
||||
protected:
|
||||
virtual void timerEvent (QTimerEvent*);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotFinished(bool);
|
||||
|
||||
private:
|
||||
bool m_loadedOk;
|
||||
KWebPage *m_page;
|
||||
QEventLoop m_eventLoop;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,99 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Type=Service
|
||||
Name=HTML Files
|
||||
Name[af]=HTML Lêers
|
||||
Name[ar]=HTML ملفات
|
||||
Name[ast]=Ficheros HTML
|
||||
Name[be]=Файлы HTML
|
||||
Name[be@latin]=Fajły HTML
|
||||
Name[bg]=HTML файлове
|
||||
Name[bn]=HTML ফাইল
|
||||
Name[bn_IN]=HTML ফাইল
|
||||
Name[br]=Restroù HTML
|
||||
Name[bs]=HTML datoteke
|
||||
Name[ca]=Fitxers HTML
|
||||
Name[ca@valencia]=Fitxers HTML
|
||||
Name[cs]=HTML soubory
|
||||
Name[csb]=Lopczi HTML
|
||||
Name[cy]=Ffeiliau HTML
|
||||
Name[da]=HTML-filer
|
||||
Name[de]=HTML-Dateien
|
||||
Name[el]=Αρχεία HTML
|
||||
Name[en_GB]=HTML Files
|
||||
Name[eo]=HTML-dosieroj
|
||||
Name[es]=Archivos HTML
|
||||
Name[et]=HTML-failid
|
||||
Name[eu]=HTML fitxategiak
|
||||
Name[fa]=پروندههای زنگام
|
||||
Name[fi]=HTML-tiedostot
|
||||
Name[fr]=Fichiers HTML
|
||||
Name[fy]=HTML-triemmen
|
||||
Name[ga]=Comhaid HTML
|
||||
Name[gl]=Ficheiros HTML
|
||||
Name[gu]=HTML ફાઇલો
|
||||
Name[he]=קבצי HTML
|
||||
Name[hi]=एचटीएमएल फ़ाइलें
|
||||
Name[hne]=एचटीएमएल फाइल मन ल
|
||||
Name[hr]=HTML datoteke
|
||||
Name[hsb]=HTML-dataje
|
||||
Name[hu]=HTML-fájlok
|
||||
Name[ia]=Files HTML
|
||||
Name[id]=Berkas HTML
|
||||
Name[is]=HTML skrár
|
||||
Name[it]=File HTML
|
||||
Name[ja]=HTML ファイル
|
||||
Name[ka]=HTML ფაილები
|
||||
Name[kk]=HTML файлдары
|
||||
Name[km]=ឯកសារ HTML
|
||||
Name[kn]=HTML ಕಡತಗಳು
|
||||
Name[ko]=HTML 파일
|
||||
Name[ku]=Pelên HTML
|
||||
Name[lt]=HTML failai
|
||||
Name[lv]=HTML Faili
|
||||
Name[mai]=HTML फाइल
|
||||
Name[mk]=HTML-датотеки
|
||||
Name[ml]=എച്ച്ടിഎംഎല് ഫയലുകള്
|
||||
Name[mr]=HTML फाईल
|
||||
Name[ms]=Fail HTML
|
||||
Name[nb]=HTML-filer
|
||||
Name[nds]=HTML-Dateien
|
||||
Name[ne]=HTML फाइल
|
||||
Name[nl]=HTML-bestanden
|
||||
Name[nn]=HTML-filer
|
||||
Name[oc]=Fichièrs HTML
|
||||
Name[or]=HTML ଫାଇଲଗୁଡ଼ିକ
|
||||
Name[pa]=HTML ਫਾਇਲਾਂ
|
||||
Name[pl]=Strony HTML
|
||||
Name[pt]=Ficheiros HTML
|
||||
Name[pt_BR]=Arquivos HTML
|
||||
Name[ro]=Fișiere HTML
|
||||
Name[ru]=Страницы HTML
|
||||
Name[se]=HTML-fiillat
|
||||
Name[si]=HTML ගොනු
|
||||
Name[sk]=HTML súbory
|
||||
Name[sl]=Datoteke HTML
|
||||
Name[sr]=ХТМЛ фајлови
|
||||
Name[sr@ijekavian]=ХТМЛ фајлови
|
||||
Name[sr@ijekavianlatin]=HTML fajlovi
|
||||
Name[sr@latin]=HTML fajlovi
|
||||
Name[sv]=HTML-filer
|
||||
Name[ta]=HTML கோப்புகள்
|
||||
Name[te]=హెచ్ టి ఎం ఎల్ దస్త్రాలు
|
||||
Name[tg]=Файлҳои HTML
|
||||
Name[th]=แฟ้มเอกสาร HTML
|
||||
Name[tr]=HTML Dosyaları
|
||||
Name[ug]=HTML ھۆججەتلەر
|
||||
Name[uk]=Файли HTML
|
||||
Name[uz]=HTML-fayllari
|
||||
Name[uz@cyrillic]=HTML-файллари
|
||||
Name[vi]=Tập tin HTML
|
||||
Name[wa]=Fitchîs HTML
|
||||
Name[xh]=Iifayile ze HTML
|
||||
Name[x-test]=xxHTML Filesxx
|
||||
Name[zh_CN]=HTML 文件
|
||||
Name[zh_TW]=HTML 檔案
|
||||
X-KDE-ServiceTypes=ThumbCreator
|
||||
MimeType=text/html;
|
||||
X-KDE-Protocols=KIO
|
||||
X-KDE-Library=htmlthumbnail
|
||||
CacheThumbnail=true
|
|
@ -1,18 +1,12 @@
|
|||
add_subdirectory(icon)
|
||||
add_subdirectory(lock_logout)
|
||||
add_subdirectory(panelspacer)
|
||||
|
||||
add_subdirectory(analog-clock)
|
||||
add_subdirectory(batterymonitor)
|
||||
add_subdirectory(calendar)
|
||||
add_subdirectory(devicenotifier)
|
||||
add_subdirectory(digital-clock)
|
||||
add_subdirectory(quicklaunch)
|
||||
|
||||
if(QT_QTWEBKIT_FOUND)
|
||||
add_subdirectory(webbrowser)
|
||||
endif(QT_QTWEBKIT_FOUND)
|
||||
|
||||
add_subdirectory(system-monitor)
|
||||
#notifications
|
||||
#should compile also on windows? (even if doesn't really make sense)
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
project(webbrowser)
|
||||
|
||||
set(webbrowser_SRCS
|
||||
bookmarksdelegate.cpp
|
||||
bookmarkitem.cpp
|
||||
webbrowser.cpp
|
||||
webviewoverlay.cpp
|
||||
browserhistorycombobox.cpp
|
||||
browsermessagebox.cpp
|
||||
errorpage.cpp
|
||||
webbrowserpage.cpp
|
||||
webbrowserconfig.ui
|
||||
)
|
||||
|
||||
kde4_add_plugin(plasma_applet_webbrowser ${webbrowser_SRCS})
|
||||
target_link_libraries(plasma_applet_webbrowser ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${QT_QTWEBKIT_LIBRARY} ${KDE4_KDEWEBKIT_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KPARTS_LIBS})
|
||||
|
||||
install(TARGETS plasma_applet_webbrowser DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
install(FILES plasma-applet-webbrowser.desktop DESTINATION ${SERVICES_INSTALL_DIR})
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
$EXTRACTRC *.ui >> rc.cpp
|
||||
$XGETTEXT *.cpp -o $podir/plasma_applet_webbrowser.pot
|
||||
rm -f rc.cpp
|
|
@ -1,70 +0,0 @@
|
|||
/* Copyright (C) 2008 Marco Martin <notmart@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2 as published by the Free Software Foundation.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include "bookmarkitem.h"
|
||||
|
||||
|
||||
#include <kbookmarkmanager.h>
|
||||
#include <kicon.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
BookmarkItem::BookmarkItem(KBookmark &bookmark)
|
||||
: QStandardItem(),
|
||||
m_bookmark(bookmark)
|
||||
{
|
||||
}
|
||||
|
||||
BookmarkItem::~BookmarkItem()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
KBookmark BookmarkItem::bookmark() const
|
||||
{
|
||||
return m_bookmark;
|
||||
}
|
||||
|
||||
void BookmarkItem::setBookmark(const KBookmark &bookmark)
|
||||
{
|
||||
m_bookmark = bookmark;
|
||||
}
|
||||
|
||||
QVariant BookmarkItem::data(int role) const
|
||||
{
|
||||
if (m_bookmark.isNull()) {
|
||||
return QStandardItem::data(role);
|
||||
}
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return m_bookmark.text();
|
||||
case Qt::DecorationRole:
|
||||
if (m_bookmark.isGroup() && m_bookmark.icon().isNull()) {
|
||||
return KIcon("folder-bookmarks");
|
||||
} else {
|
||||
return KIcon(m_bookmark.icon());
|
||||
}
|
||||
case UrlRole:
|
||||
return m_bookmark.url().prettyUrl();
|
||||
default:
|
||||
return QStandardItem::data(role);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/* Copyright (C) 2008 Marco Martin <notmart@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2 as published by the Free Software Foundation.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BOOKMARKITEM_H
|
||||
#define BOOKMARKITEM_H
|
||||
|
||||
|
||||
#include <QtGui/qstandarditemmodel.h>
|
||||
#include <QtCore/qabstractitemmodel.h>
|
||||
#include <kbookmark.h>
|
||||
|
||||
|
||||
class BookmarkItem : public QStandardItem
|
||||
{
|
||||
|
||||
public:
|
||||
enum BookmarkRoles
|
||||
{
|
||||
UrlRole = Qt::UserRole+1
|
||||
};
|
||||
|
||||
BookmarkItem(KBookmark &bookmark);
|
||||
~BookmarkItem();
|
||||
|
||||
KBookmark bookmark() const;
|
||||
void setBookmark(const KBookmark &bookmark);
|
||||
QVariant data(int role) const;
|
||||
|
||||
|
||||
private:
|
||||
KBookmark m_bookmark;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
Copyright 2008 Marco Martin <notmart@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
// Own
|
||||
#include "bookmarksdelegate.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <math.h>
|
||||
|
||||
// Qt
|
||||
#include <QtCore/qabstractitemmodel.h>
|
||||
#include <QtGui/qevent.h>
|
||||
#include <QPainter>
|
||||
#include <QtGui/qstyleoption.h>
|
||||
|
||||
// KDE
|
||||
#include <KDebug>
|
||||
#include <KColorScheme>
|
||||
#include <KIcon>
|
||||
#include <KIconLoader>
|
||||
|
||||
// plasma
|
||||
#include <Plasma/PaintUtils>
|
||||
#include <Plasma/Theme>
|
||||
|
||||
|
||||
class BookmarksDelegatePrivate
|
||||
{
|
||||
public:
|
||||
BookmarksDelegatePrivate() {
|
||||
}
|
||||
|
||||
~BookmarksDelegatePrivate() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
BookmarksDelegate::BookmarksDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent),
|
||||
d(/*new BookmarksDelegatePrivate*/0)
|
||||
{
|
||||
}
|
||||
|
||||
BookmarksDelegate::~BookmarksDelegate()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void BookmarksDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
|
||||
if (option.state & (QStyle::State_MouseOver | QStyle::State_Selected)) {
|
||||
QRect destroyIconRect = QStyle::alignedRect(option.direction,
|
||||
option.decorationPosition == QStyleOptionViewItem::Left ?
|
||||
Qt::AlignRight : Qt::AlignLeft,
|
||||
QSize(option.rect.height(), option.rect.height()),
|
||||
option.rect);
|
||||
painter->drawPixmap(destroyIconRect, KIcon("list-remove").pixmap(KIconLoader::SizeSmall, KIconLoader::SizeSmall));
|
||||
}
|
||||
}
|
||||
|
||||
bool BookmarksDelegate::editorEvent(QEvent *event,
|
||||
QAbstractItemModel *model,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index)
|
||||
{
|
||||
QRect destroyIconRect = QStyle::alignedRect(option.direction,
|
||||
option.decorationPosition == QStyleOptionViewItem::Left ?
|
||||
Qt::AlignRight : Qt::AlignLeft,
|
||||
QSize(option.rect.height(), option.rect.height()),
|
||||
option.rect);
|
||||
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
|
||||
if (destroyIconRect.contains(mouseEvent->pos())) {
|
||||
emit destroyBookmark(index);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QStyledItemDelegate::editorEvent(event, model, option, index);
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
Copyright 2008 Marco Martin <notmart@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef BOOKMARKSDELEGATE_H
|
||||
#define BOOKMARKSDELEGATE_H
|
||||
|
||||
// Qt
|
||||
#include <QtGui/QStyledItemDelegate>
|
||||
|
||||
|
||||
class BookmarksDelegatePrivate;
|
||||
|
||||
class BookmarksDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
|
||||
BookmarksDelegate(QObject *parent = 0);
|
||||
~BookmarksDelegate();
|
||||
|
||||
//Reimplemented
|
||||
virtual void paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
|
||||
|
||||
protected:
|
||||
bool editorEvent(QEvent *event,
|
||||
QAbstractItemModel *model,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index);
|
||||
|
||||
Q_SIGNALS:
|
||||
void destroyBookmark(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
BookmarksDelegatePrivate * const d;
|
||||
};
|
||||
|
||||
#endif // BOOKMARKSDELEGATE_H
|
|
@ -1,446 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, 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 Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "browserhistorycombobox.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
#include <kcombobox.h>
|
||||
#include <kmimetype.h>
|
||||
#include <kiconeffect.h>
|
||||
#include <kiconloader.h>
|
||||
|
||||
#include <plasma/theme.h>
|
||||
#include <plasma/framesvg.h>
|
||||
#include <plasma/animator.h>
|
||||
#include <plasma/paintutils.h>
|
||||
#include <Plasma/ComboBox>
|
||||
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtCore/QSharedData>
|
||||
#include <QtGui/QStyle>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class ComboBoxPrivate
|
||||
{
|
||||
public:
|
||||
ComboBoxPrivate(BrowserHistoryComboBox *comboBox)
|
||||
: q(comboBox),
|
||||
background(0),
|
||||
customFont(false),
|
||||
underMouse(false)
|
||||
{
|
||||
}
|
||||
|
||||
~ComboBoxPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
void syncActiveRect();
|
||||
void syncBorders();
|
||||
void animationUpdate(qreal progress);
|
||||
|
||||
BrowserHistoryComboBox *q;
|
||||
|
||||
FrameSvg *background;
|
||||
FrameSvg *lineEditBackground;
|
||||
int animId;
|
||||
QPropertyAnimation *animation;
|
||||
qreal opacity;
|
||||
QRectF activeRect;
|
||||
QStyle *style;
|
||||
bool customFont;
|
||||
bool underMouse;
|
||||
Plasma::ComboBox *styleParent;
|
||||
int progressValue;
|
||||
bool displayProgress;
|
||||
};
|
||||
|
||||
void ComboBoxPrivate::syncActiveRect()
|
||||
{
|
||||
background->setElementPrefix("normal");
|
||||
|
||||
qreal left, top, right, bottom;
|
||||
background->getMargins(left, top, right, bottom);
|
||||
|
||||
background->setElementPrefix("active");
|
||||
qreal activeLeft, activeTop, activeRight, activeBottom;
|
||||
background->getMargins(activeLeft, activeTop, activeRight, activeBottom);
|
||||
|
||||
activeRect = QRectF(QPointF(0, 0), q->size());
|
||||
activeRect.adjust(left - activeLeft, top - activeTop,
|
||||
-(right - activeRight), -(bottom - activeBottom));
|
||||
|
||||
background->setElementPrefix("normal");
|
||||
}
|
||||
|
||||
void ComboBoxPrivate::syncBorders()
|
||||
{
|
||||
//set margins from the normal element
|
||||
qreal left, top, right, bottom;
|
||||
|
||||
background->setElementPrefix("normal");
|
||||
background->getMargins(left, top, right, bottom);
|
||||
q->setContentsMargins(left, top, right, bottom);
|
||||
|
||||
//calc the rect for the over effect
|
||||
syncActiveRect();
|
||||
|
||||
KComboBox *native = q->nativeWidget();
|
||||
if (customFont) {
|
||||
native->setFont(q->font());
|
||||
} else {
|
||||
native->setFont(Theme::defaultTheme()->font(Theme::DefaultFont));
|
||||
}
|
||||
}
|
||||
|
||||
void ComboBoxPrivate::animationUpdate(qreal progress)
|
||||
{
|
||||
opacity = progress;
|
||||
|
||||
// explicit update
|
||||
q->update();
|
||||
}
|
||||
|
||||
BrowserHistoryComboBox::BrowserHistoryComboBox(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new ComboBoxPrivate(this))
|
||||
{
|
||||
d->background = new FrameSvg(this);
|
||||
d->background->setImagePath("widgets/button");
|
||||
d->background->setCacheAllRenderedFrames(true);
|
||||
d->background->setElementPrefix("normal");
|
||||
d->lineEditBackground = new FrameSvg(this);
|
||||
d->lineEditBackground->setImagePath("widgets/lineedit");
|
||||
d->lineEditBackground->setCacheAllRenderedFrames(true);
|
||||
setZValue(900);
|
||||
|
||||
setAcceptHoverEvents(true);
|
||||
|
||||
d->styleParent = new Plasma::ComboBox();
|
||||
d->style = d->styleParent->nativeWidget()->style();
|
||||
|
||||
setNativeWidget(new KComboBox);
|
||||
|
||||
d->animation = new QPropertyAnimation(this, "animationUpdate", this);
|
||||
d->animation->setStartValue(0);
|
||||
d->animation->setEndValue(1);
|
||||
|
||||
connect(Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(syncBorders()));
|
||||
|
||||
d->displayProgress = false;
|
||||
d->progressValue = 0;
|
||||
}
|
||||
|
||||
BrowserHistoryComboBox::~BrowserHistoryComboBox()
|
||||
{
|
||||
delete d->styleParent;
|
||||
delete d;
|
||||
}
|
||||
|
||||
QString BrowserHistoryComboBox::text() const
|
||||
{
|
||||
return static_cast<KComboBox*>(widget())->currentText();
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::setStyleSheet(const QString &stylesheet)
|
||||
{
|
||||
widget()->setStyleSheet(stylesheet);
|
||||
}
|
||||
|
||||
QString BrowserHistoryComboBox::styleSheet()
|
||||
{
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::setNativeWidget(KComboBox *nativeWidget)
|
||||
{
|
||||
if (widget()) {
|
||||
widget()->deleteLater();
|
||||
}
|
||||
|
||||
connect(nativeWidget, SIGNAL(activated(QString)), this, SIGNAL(activated(QString)));
|
||||
connect(nativeWidget, SIGNAL(currentIndexChanged(QString)),
|
||||
this, SIGNAL(textChanged(QString)));
|
||||
|
||||
setWidget(nativeWidget);
|
||||
|
||||
nativeWidget->setAttribute(Qt::WA_NoSystemBackground);
|
||||
nativeWidget->setStyle(d->style);
|
||||
|
||||
d->syncBorders();
|
||||
}
|
||||
|
||||
KComboBox *BrowserHistoryComboBox::nativeWidget() const
|
||||
{
|
||||
return static_cast<KComboBox*>(widget());
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::addItem(const QString &text)
|
||||
{
|
||||
static_cast<KComboBox*>(widget())->addItem(text);
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::clear()
|
||||
{
|
||||
static_cast<KComboBox*>(widget())->clear();
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
if (d->background) {
|
||||
//resize needed panels
|
||||
d->syncActiveRect();
|
||||
|
||||
d->background->setElementPrefix("focus");
|
||||
d->background->resizeFrame(size());
|
||||
|
||||
d->background->setElementPrefix("active");
|
||||
d->background->resizeFrame(d->activeRect.size());
|
||||
|
||||
d->background->setElementPrefix("normal");
|
||||
d->background->resizeFrame(size());
|
||||
}
|
||||
|
||||
QGraphicsProxyWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::paint(QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget)
|
||||
{
|
||||
QAbstractAnimation::State animState = d->animation->state();
|
||||
|
||||
if (!styleSheet().isNull() ||
|
||||
Theme::defaultTheme()->useNativeWidgetStyle()) {
|
||||
QGraphicsProxyWidget::paint(painter, option, widget);
|
||||
return;
|
||||
}
|
||||
|
||||
if (nativeWidget()->isEditable()) {
|
||||
if (d->displayProgress) {
|
||||
painter->fillRect(QRectF(option->rect.x() + 2, option->rect.y() + 3, (int) (((qreal) (option->rect.width() - 4) / 100) * d->progressValue), option->rect.height() - 4), Theme::defaultTheme()->color(Theme::LinkColor));
|
||||
}
|
||||
if (d->lineEditBackground->hasElement("hint-focus-over-base")) {
|
||||
QGraphicsProxyWidget::paint(painter, option, widget);
|
||||
}
|
||||
if (animState != QAbstractAnimation::Stopped || hasFocus() || d->underMouse) {
|
||||
if (hasFocus()) {
|
||||
d->lineEditBackground->setElementPrefix("focus");
|
||||
} else {
|
||||
d->lineEditBackground->setElementPrefix("hover");
|
||||
}
|
||||
qreal left, top, right, bottom;
|
||||
d->lineEditBackground->getMargins(left, top, right, bottom);
|
||||
d->lineEditBackground->resizeFrame(size()+QSizeF(left+right, top+bottom));
|
||||
if (qFuzzyCompare(d->opacity, (qreal)1.0)) {
|
||||
d->lineEditBackground->paintFrame(painter, QPoint(-left, -top));
|
||||
} else {
|
||||
QPixmap bufferPixmap = d->lineEditBackground->framePixmap();
|
||||
QPainter buffPainter(&bufferPixmap);
|
||||
buffPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
buffPainter.fillRect(bufferPixmap.rect(), QColor(0, 0, 0, 256*d->opacity));
|
||||
buffPainter.end();
|
||||
painter->drawPixmap(bufferPixmap.rect().translated(QPoint(-left, -top)), bufferPixmap, bufferPixmap.rect());
|
||||
}
|
||||
}
|
||||
if (!d->lineEditBackground->hasElement("hint-focus-over-base")) {
|
||||
QGraphicsProxyWidget::paint(painter, option, widget);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
QPixmap bufferPixmap;
|
||||
|
||||
//normal button
|
||||
if (isEnabled()) {
|
||||
d->background->setElementPrefix("normal");
|
||||
|
||||
if (animState == QAbstractAnimation::Stopped) {
|
||||
d->background->paintFrame(painter);
|
||||
}
|
||||
//disabled widget
|
||||
} else {
|
||||
bufferPixmap = QPixmap(rect().size().toSize());
|
||||
bufferPixmap.fill(Qt::transparent);
|
||||
|
||||
QPainter buffPainter(&bufferPixmap);
|
||||
d->background->paintFrame(&buffPainter);
|
||||
buffPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
buffPainter.fillRect(bufferPixmap.rect(), QColor(0, 0, 0, 128));
|
||||
|
||||
painter->drawPixmap(0, 0, bufferPixmap);
|
||||
}
|
||||
|
||||
//if is under mouse draw the animated glow overlay
|
||||
if (isEnabled() && acceptHoverEvents()) {
|
||||
if (animState!= QAbstractAnimation::Stopped) {
|
||||
d->background->setElementPrefix("normal");
|
||||
QPixmap normalPix = d->background->framePixmap();
|
||||
d->background->setElementPrefix("active");
|
||||
painter->drawPixmap(
|
||||
d->activeRect.topLeft(),
|
||||
PaintUtils::transition(d->background->framePixmap(), normalPix, 1 - d->opacity));
|
||||
} else if (isUnderMouse()) {
|
||||
d->background->setElementPrefix("active");
|
||||
d->background->paintFrame(painter, d->activeRect.topLeft());
|
||||
}
|
||||
}
|
||||
|
||||
if (nativeWidget()->hasFocus()) {
|
||||
d->background->setElementPrefix("focus");
|
||||
d->background->paintFrame(painter);
|
||||
}
|
||||
|
||||
painter->setPen(Theme::defaultTheme()->color(Theme::ButtonTextColor));
|
||||
|
||||
QStyleOptionComboBox comboOpt;
|
||||
|
||||
comboOpt.initFrom(nativeWidget());
|
||||
|
||||
comboOpt.palette.setColor(
|
||||
QPalette::ButtonText, Theme::defaultTheme()->color(Theme::ButtonTextColor));
|
||||
comboOpt.currentIcon = nativeWidget()->itemIcon(
|
||||
nativeWidget()->currentIndex());
|
||||
comboOpt.currentText = nativeWidget()->itemText(
|
||||
nativeWidget()->currentIndex());
|
||||
comboOpt.editable = false;
|
||||
|
||||
nativeWidget()->style()->drawControl(
|
||||
QStyle::CE_ComboBoxLabel, &comboOpt, painter, nativeWidget());
|
||||
comboOpt.rect = nativeWidget()->style()->subControlRect(
|
||||
QStyle::CC_ComboBox, &comboOpt, QStyle::SC_ComboBoxArrow, nativeWidget());
|
||||
nativeWidget()->style()->drawPrimitive(
|
||||
QStyle::PE_IndicatorArrowDown, &comboOpt, painter, nativeWidget());
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::setAnimationUpdate(qreal progress)
|
||||
{
|
||||
d->animationUpdate(progress);
|
||||
}
|
||||
|
||||
qreal BrowserHistoryComboBox::animationUpdate() const
|
||||
{
|
||||
return d->opacity;
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::focusInEvent(QFocusEvent *event)
|
||||
{
|
||||
if (nativeWidget()->isEditable() && !d->underMouse) {
|
||||
const int FadeInDuration = 75;
|
||||
|
||||
if (d->animation->state() != QAbstractAnimation::Stopped) {
|
||||
d->animation->stop();
|
||||
}
|
||||
d->animation->setDuration(FadeInDuration);
|
||||
d->animation->setDirection(QAbstractAnimation::Forward);
|
||||
d->animation->start();
|
||||
}
|
||||
|
||||
QGraphicsProxyWidget::focusInEvent(event);
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
if (nativeWidget()->isEditable() && !d->underMouse) {
|
||||
const int FadeOutDuration = 150;
|
||||
|
||||
if (d->animation->state() != QAbstractAnimation::Stopped) {
|
||||
d->animation->stop();
|
||||
}
|
||||
d->animation->setDuration(FadeOutDuration);
|
||||
d->animation->setDirection(QAbstractAnimation::Backward);
|
||||
d->animation->start();
|
||||
}
|
||||
|
||||
|
||||
QGraphicsProxyWidget::focusInEvent(event);
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
d->underMouse = true;
|
||||
if (nativeWidget()->isEditable() && hasFocus()) {
|
||||
return;
|
||||
}
|
||||
const int FadeInDuration = 75;
|
||||
|
||||
if (d->animation->state() != QAbstractAnimation::Stopped) {
|
||||
d->animation->stop();
|
||||
}
|
||||
d->animation->setDuration(FadeInDuration);
|
||||
d->animation->setDirection(QAbstractAnimation::Forward);
|
||||
d->animation->start();
|
||||
|
||||
d->background->setElementPrefix("active");
|
||||
|
||||
QGraphicsProxyWidget::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
d->underMouse = false;
|
||||
if (nativeWidget()->isEditable() && hasFocus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int FadeOutDuration = 150;
|
||||
|
||||
if (d->animation->state() != QAbstractAnimation::Stopped) {
|
||||
d->animation->stop();
|
||||
}
|
||||
d->animation->setDuration(FadeOutDuration);
|
||||
d->animation->setDirection(QAbstractAnimation::Backward);
|
||||
d->animation->start();
|
||||
|
||||
d->background->setElementPrefix("active");
|
||||
|
||||
QGraphicsProxyWidget::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::FontChange) {
|
||||
d->customFont = true;
|
||||
nativeWidget()->setFont(font());
|
||||
}
|
||||
|
||||
QGraphicsProxyWidget::changeEvent(event);
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::setProgressValue(int value)
|
||||
{
|
||||
d->progressValue = value;
|
||||
update();
|
||||
}
|
||||
|
||||
void BrowserHistoryComboBox::setDisplayProgress(bool enable)
|
||||
{
|
||||
d->displayProgress = enable;
|
||||
update();
|
||||
}
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#include "moc_browserhistorycombobox.cpp"
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008 Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, 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 Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef BROWSERHISTORYCOMBOBOX_H
|
||||
#define BROWSERHISTORYCOMBOBOX_H
|
||||
|
||||
#include <QtGui/QGraphicsProxyWidget>
|
||||
|
||||
class KComboBox;
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class ComboBoxPrivate;
|
||||
|
||||
/**
|
||||
* @class ComboBox plasma/widgets/combobox.h <Plasma/Widgets/ComboBox>
|
||||
*
|
||||
* @short Provides a Plasma-themed combo box.
|
||||
*/
|
||||
class BrowserHistoryComboBox : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString text READ text NOTIFY textChanged)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(KComboBox *nativeWidget READ nativeWidget WRITE setNativeWidget)
|
||||
|
||||
Q_PROPERTY(qreal animationUpdate READ animationUpdate WRITE setAnimationUpdate)
|
||||
|
||||
public:
|
||||
explicit BrowserHistoryComboBox(QGraphicsWidget *parent = 0);
|
||||
~BrowserHistoryComboBox();
|
||||
|
||||
/**
|
||||
* @return the display text
|
||||
*/
|
||||
QString text() const;
|
||||
|
||||
/**
|
||||
* Sets the stylesheet used to control the visual display of this ComboBox
|
||||
*
|
||||
* @arg stylesheet a CSS string
|
||||
*/
|
||||
void setStyleSheet(const QString &stylesheet);
|
||||
|
||||
/**
|
||||
* @return the stylesheet currently used with this widget
|
||||
*/
|
||||
QString styleSheet();
|
||||
|
||||
/**
|
||||
* Sets the combo box wrapped by this ComboBox (widget must inherit KComboBox), ownership is transferred to the ComboBox
|
||||
*
|
||||
* @arg combo box that will be wrapped by this ComboBox
|
||||
* @since KDE4.4
|
||||
*/
|
||||
void setNativeWidget(KComboBox *nativeWidget);
|
||||
|
||||
/**
|
||||
* @return the native widget wrapped by this ComboBox
|
||||
*/
|
||||
KComboBox *nativeWidget() const;
|
||||
|
||||
/**
|
||||
* Adds an item to the combo box with the given text. The
|
||||
* item is appended to the list of existing items.
|
||||
*/
|
||||
void addItem(const QString &text);
|
||||
|
||||
void setProgressValue(int value);
|
||||
|
||||
void setDisplayProgress(bool enable);
|
||||
|
||||
public Q_SLOTS:
|
||||
void clear();
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is sent when the user chooses an item in the combobox.
|
||||
* The item's text is passed.
|
||||
*/
|
||||
void activated(const QString &text);
|
||||
|
||||
/**
|
||||
* This signal is sent whenever the currentIndex in the combobox changes
|
||||
* either through user interaction or programmatically.
|
||||
* The item's text is passed.
|
||||
*/
|
||||
void textChanged(const QString &text);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
void paint(QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
void focusInEvent(QFocusEvent *event);
|
||||
void focusOutEvent(QFocusEvent *event);
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
void changeEvent(QEvent *event);
|
||||
|
||||
private slots:
|
||||
void setAnimationUpdate(qreal progress);
|
||||
qreal animationUpdate() const;
|
||||
|
||||
private:
|
||||
ComboBoxPrivate * const d;
|
||||
|
||||
friend class ComboBoxPrivate;
|
||||
Q_PRIVATE_SLOT(d, void syncBorders())
|
||||
};
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#endif // multiple inclusion guard
|
|
@ -1,59 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2010 Davide Bettio <davide.bettio@kdemail.net> *
|
||||
* *
|
||||
* 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 2 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, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
#include "browsermessagebox.h"
|
||||
|
||||
#include <QGraphicsLinearLayout>
|
||||
|
||||
#include <Plasma/Label>
|
||||
#include <Plasma/PushButton>
|
||||
#include <Plasma/WebView>
|
||||
|
||||
BrowserMessageBox::BrowserMessageBox(QGraphicsWidget *parent, QString message)
|
||||
: QGraphicsWidget(parent)
|
||||
{
|
||||
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(this);
|
||||
layout->setOrientation(Qt::Horizontal);
|
||||
|
||||
Plasma::Label *messageLabel = new Plasma::Label(this);
|
||||
messageLabel->setText(message);
|
||||
layout->addItem(messageLabel);
|
||||
|
||||
m_okButton = new Plasma::PushButton(this);
|
||||
m_okButton->setText(i18n("OK"));
|
||||
connect(m_okButton, SIGNAL(clicked()), this, SIGNAL(okClicked()));
|
||||
layout->addItem(m_okButton);
|
||||
|
||||
m_cancelButton = new Plasma::PushButton(this);
|
||||
m_cancelButton->setText(i18n("Cancel"));
|
||||
connect(m_cancelButton, SIGNAL(clicked()), this, SIGNAL(cancelClicked()));
|
||||
layout->addItem(m_cancelButton);
|
||||
}
|
||||
|
||||
Plasma::PushButton *BrowserMessageBox::okButton()
|
||||
{
|
||||
return m_okButton;
|
||||
}
|
||||
|
||||
Plasma::PushButton *BrowserMessageBox::cancelButton()
|
||||
{
|
||||
return m_cancelButton;
|
||||
}
|
||||
|
||||
#include "moc_browsermessagebox.cpp"
|
|
@ -1,49 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2010 Davide Bettio <davide.bettio@kdemail.net> *
|
||||
* *
|
||||
* 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 2 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, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef BROWSERMESSAGEBOX_H
|
||||
#define BROWSERMESSAGEBOX_H
|
||||
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class PushButton;
|
||||
}
|
||||
|
||||
class BrowserMessageBox : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BrowserMessageBox(QGraphicsWidget *parent, QString message);
|
||||
|
||||
Plasma::PushButton *okButton();
|
||||
Plasma::PushButton *cancelButton();
|
||||
|
||||
private:
|
||||
Plasma::PushButton *m_okButton;
|
||||
Plasma::PushButton *m_cancelButton;
|
||||
|
||||
Q_SIGNALS:
|
||||
void okClicked();
|
||||
void cancelClicked();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,158 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
*
|
||||
* Copyright (C) Hamish Rodda, Urs Wolfer, Davide Bettio
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
#include <QNetworkReply>
|
||||
#include <QTextDocument>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kio/global.h>
|
||||
#include <KIconLoader>
|
||||
#include <KLocale>
|
||||
#include <KStandardDirs>
|
||||
|
||||
#include "errorpage.h"
|
||||
|
||||
int webKitErrorToKIOError(int eValue)
|
||||
{
|
||||
switch (eValue){
|
||||
case QNetworkReply::NoError:
|
||||
return 0;
|
||||
|
||||
case QNetworkReply::ConnectionRefusedError:
|
||||
return KIO::ERR_COULD_NOT_CONNECT;
|
||||
|
||||
case QNetworkReply::HostNotFoundError:
|
||||
return KIO::ERR_UNKNOWN_HOST;
|
||||
|
||||
case QNetworkReply::TimeoutError:
|
||||
return KIO::ERR_SERVER_TIMEOUT;
|
||||
|
||||
case QNetworkReply::OperationCanceledError:
|
||||
return KIO::ERR_ABORTED;
|
||||
|
||||
case QNetworkReply::ProxyNotFoundError:
|
||||
return KIO::ERR_UNKNOWN_PROXY_HOST;
|
||||
|
||||
case QNetworkReply::ContentAccessDenied:
|
||||
return KIO::ERR_ACCESS_DENIED;
|
||||
|
||||
case QNetworkReply::ContentOperationNotPermittedError:
|
||||
return KIO::ERR_WRITE_ACCESS_DENIED;
|
||||
|
||||
case QNetworkReply::ContentNotFoundError:
|
||||
return KIO::ERR_NO_CONTENT;
|
||||
|
||||
case QNetworkReply::AuthenticationRequiredError:
|
||||
return KIO::ERR_COULD_NOT_AUTHENTICATE;
|
||||
|
||||
case QNetworkReply::ProtocolUnknownError:
|
||||
return KIO::ERR_UNSUPPORTED_PROTOCOL;
|
||||
|
||||
case QNetworkReply::ProtocolInvalidOperationError:
|
||||
return KIO::ERR_UNSUPPORTED_ACTION;
|
||||
|
||||
default:
|
||||
return KIO::ERR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* from khtml_part code
|
||||
*/
|
||||
QString errorPageHtml( int errorCode, const QString& text, const KUrl& reqUrl )
|
||||
{
|
||||
QString errorName, techName, description;
|
||||
QStringList causes, solutions;
|
||||
|
||||
QByteArray raw = KIO::rawErrorDetail( errorCode, text, &reqUrl );
|
||||
QDataStream stream(raw);
|
||||
|
||||
stream >> errorName >> techName >> description >> causes >> solutions;
|
||||
|
||||
QString url, protocol, datetime;
|
||||
url = Qt::escape( reqUrl.prettyUrl() );
|
||||
protocol = reqUrl.protocol();
|
||||
datetime = KGlobal::locale()->formatDateTime( QDateTime::currentDateTime(),
|
||||
KLocale::LongDate );
|
||||
|
||||
QString filename( KStandardDirs::locate( "data", "khtml/error.html" ) );
|
||||
QFile file( filename );
|
||||
bool isOpened = file.open( QIODevice::ReadOnly );
|
||||
if ( !isOpened )
|
||||
kWarning(6050) << "Could not open error html template:" << filename;
|
||||
|
||||
QString html = QString( QLatin1String( file.readAll() ) );
|
||||
|
||||
html.replace( QLatin1String( "TITLE" ), i18n( "Error: %1 - %2", errorName, url ) );
|
||||
html.replace( QLatin1String( "DIRECTION" ), QApplication::isRightToLeft() ? "rtl" : "ltr" );
|
||||
KUrl iconUrl(KIconLoader::global()->iconPath( "dialog-warning", -KIconLoader::SizeHuge ));
|
||||
iconUrl.setProtocol("file://");
|
||||
html.replace( QLatin1String( "ICON_PATH" ), iconUrl.url());
|
||||
|
||||
QString doc = QLatin1String( "<h1>" );
|
||||
doc += i18n( "The requested operation could not be completed" );
|
||||
doc += QLatin1String( "</h1><h2>" );
|
||||
doc += errorName;
|
||||
doc += QLatin1String( "</h2>" );
|
||||
if ( !techName.isNull() ) {
|
||||
doc += QLatin1String( "<h2>" );
|
||||
doc += i18n( "Technical Reason: " );
|
||||
doc += techName;
|
||||
doc += QLatin1String( "</h2>" );
|
||||
}
|
||||
doc += QLatin1String( "<h3>" );
|
||||
doc += i18n( "Details of the Request:" );
|
||||
doc += QLatin1String( "</h3><ul><li>" );
|
||||
doc += i18n( "URL: %1" , url );
|
||||
doc += QLatin1String( "</li><li>" );
|
||||
if ( !protocol.isNull() ) {
|
||||
doc += i18n( "Protocol: %1", protocol );
|
||||
doc += QLatin1String( "</li><li>" );
|
||||
}
|
||||
doc += i18n( "Date and Time: %1" , datetime );
|
||||
doc += QLatin1String( "</li><li>" );
|
||||
doc += i18n( "Additional Information: %1" , text );
|
||||
doc += QLatin1String( "</li></ul><h3>" );
|
||||
doc += i18n( "Description:" );
|
||||
doc += QLatin1String( "</h3><p>" );
|
||||
doc += description;
|
||||
doc += QLatin1String( "</p>" );
|
||||
if ( causes.count() ) {
|
||||
doc += QLatin1String( "<h3>" );
|
||||
doc += i18n( "Possible Causes:" );
|
||||
doc += QLatin1String( "</h3><ul><li>" );
|
||||
doc += causes.join( "</li><li>" );
|
||||
doc += QLatin1String( "</li></ul>" );
|
||||
}
|
||||
if ( solutions.count() ) {
|
||||
doc += QLatin1String( "<h3>" );
|
||||
doc += i18n( "Possible Solutions:" );
|
||||
doc += QLatin1String( "</h3><ul><li>" );
|
||||
doc += solutions.join( "</li><li>" );
|
||||
doc += QLatin1String( "</li></ul>" );
|
||||
}
|
||||
|
||||
html.replace( QLatin1String("TEXT"), doc );
|
||||
|
||||
return html;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2010 Davide Bettio <davide.bettio@kdemail.net> *
|
||||
* *
|
||||
* 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 2 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, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef ERRORPAGE_H
|
||||
#define ERRORPAGE_H
|
||||
|
||||
#include <QString>
|
||||
#include <KUrl>
|
||||
|
||||
int webKitErrorToKIOError(int eValue);
|
||||
QString errorPageHtml( int errorCode, const QString& text, const KUrl& reqUrl );
|
||||
|
||||
#endif
|
|
@ -1,185 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Web Browser
|
||||
Name[af]=Web Blaaier
|
||||
Name[ar]=متصفح الوِب
|
||||
Name[ast]=Restolador Web
|
||||
Name[be]=Вандроўнік па Сеціве
|
||||
Name[be@latin]=Hartač sieciva
|
||||
Name[bg]=Уеб браузър
|
||||
Name[bn]=ওয়েব ব্রাউজার
|
||||
Name[bn_IN]=ওয়েব ব্রাউজার
|
||||
Name[br]=Furcher an Internet
|
||||
Name[bs]=veb pregledač
|
||||
Name[ca]=Navegació Web
|
||||
Name[ca@valencia]=Navegació Web
|
||||
Name[cs]=Prohlížeč Webu
|
||||
Name[csb]=Przezérnik WWW
|
||||
Name[cy]=Porydd Gwê
|
||||
Name[da]=Browser
|
||||
Name[de]=Webbrowser
|
||||
Name[el]=Περιηγητής ιστού
|
||||
Name[en_GB]=Web Browser
|
||||
Name[eo]=Retumilo
|
||||
Name[es]=Navegador Web
|
||||
Name[et]=Veebibrauser
|
||||
Name[eu]=Web-arakatzailea
|
||||
Name[fa]=مرورگر وب
|
||||
Name[fi]=Verkkoselain
|
||||
Name[fr]=Navigateur Web
|
||||
Name[fy]=Webblêder
|
||||
Name[ga]=Brabhsálaí Gréasáin
|
||||
Name[gl]=Navegador web
|
||||
Name[gu]=વેબ બ્રાઉઝર
|
||||
Name[he]=דפדפן אינטרנט
|
||||
Name[hi]=वेब ब्राउज़र
|
||||
Name[hne]=वेब ब्राउजर
|
||||
Name[hr]=Web preglednik
|
||||
Name[hsb]=Web Browser
|
||||
Name[hu]=Webböngésző
|
||||
Name[ia]=Navigator Web
|
||||
Name[id]=Peramban Web
|
||||
Name[is]=Vafri
|
||||
Name[it]=Browser Web
|
||||
Name[ja]=ウェブブラウザ
|
||||
Name[ka]=ვებ ბრაუზერი
|
||||
Name[kk]=Веб шолғышы
|
||||
Name[km]=កម្មវិធីរុករកបណ្ដាញ
|
||||
Name[kn]=ಚಾಲ ವೀಕ್ಷಕ
|
||||
Name[ko]=웹 브라우저
|
||||
Name[ku]=Geroka Torê
|
||||
Name[lt]=Žiniatinklio naršyklė
|
||||
Name[lv]=Tīmekļa pārlūks
|
||||
Name[mai]=वेब ब्राउजर
|
||||
Name[mk]=Веб-прелистувач
|
||||
Name[ml]=വെബ് ബ്രൌസര്
|
||||
Name[mr]=वेब ब्राऊजर
|
||||
Name[ms]=Pelayar Web
|
||||
Name[nb]=Nettleser
|
||||
Name[nds]=Nettkieker
|
||||
Name[ne]=वेब ब्राउजर
|
||||
Name[nl]=Webbrowser
|
||||
Name[nn]=Nettlesar
|
||||
Name[oc]=Navigador web
|
||||
Name[or]=ୱେବ ବ୍ରାଉଜର
|
||||
Name[pa]=ਵੈੱਬ ਬਰਾਊਜ਼ਰ
|
||||
Name[pl]=Przeglądarka sieciowa
|
||||
Name[pt]=Navegação Web
|
||||
Name[pt_BR]=Navegador Web
|
||||
Name[ro]=Navigator de web
|
||||
Name[ru]=Браузер
|
||||
Name[se]=Fierpmádatlogan
|
||||
Name[si]=වෙබ් ගවේශකය
|
||||
Name[sk]=Webový prehliadač
|
||||
Name[sl]=Spletni brskalnik
|
||||
Name[sr]=веб прегледач
|
||||
Name[sr@ijekavian]=веб прегледач
|
||||
Name[sr@ijekavianlatin]=veb pregledač
|
||||
Name[sr@latin]=veb pregledač
|
||||
Name[sv]=Webbläsning
|
||||
Name[ta]=வலை உலாவி
|
||||
Name[te]=వెబ్ బ్రౌజర్
|
||||
Name[tg]=Намоишгари Интернет
|
||||
Name[th]=เว็บเบราว์เซอร์
|
||||
Name[tr]=Web Tarayıcı
|
||||
Name[ug]=توركۆرگۈ
|
||||
Name[uk]=Переглядач інтернету
|
||||
Name[uz]=Veb-brauzer
|
||||
Name[uz@cyrillic]=Веб-браузер
|
||||
Name[vi]=Trình duyệt Mạng
|
||||
Name[wa]=Betchteu waibe
|
||||
Name[xh]=Umkhangeli zincwadi we Web
|
||||
Name[x-test]=xxWeb Browserxx
|
||||
Name[zh_CN]=网络浏览器
|
||||
Name[zh_TW]=網頁瀏覽器
|
||||
Comment=A simple web browser
|
||||
Comment[ar]=متصفح وِب بسيط
|
||||
Comment[ast]=Restolador cenciellu
|
||||
Comment[be@latin]=Prosty hartač sieciva
|
||||
Comment[bg]=Обикновен уеб браузър
|
||||
Comment[bn]=একটি সরল ওয়েব ব্রাউজার
|
||||
Comment[bn_IN]=একটি সাধারণ ওয়েব ব্রাউজার
|
||||
Comment[bs]=Jednostavan veb pregledač
|
||||
Comment[ca]=Un navegador web senzill
|
||||
Comment[ca@valencia]=Un navegador web senzill
|
||||
Comment[cs]=Jednoduchý webový prohlížeč
|
||||
Comment[csb]=Prosti przezérnik WWW
|
||||
Comment[da]=En simpel webbrowser
|
||||
Comment[de]=Einfacher Webbrowser
|
||||
Comment[el]=Ένας απλός περιηγητής ιστού
|
||||
Comment[en_GB]=A simple web browser
|
||||
Comment[eo]=Simpla foliumilo
|
||||
Comment[es]=Navegador sencillo
|
||||
Comment[et]=Lihtne veebibrauser
|
||||
Comment[eu]=Web-arakatzaile soila
|
||||
Comment[fi]=Yksinkertainen selain
|
||||
Comment[fr]=Un navigateur Web simple
|
||||
Comment[fy]=In ienfâldige webblêder
|
||||
Comment[ga]=Brabhsálaí simplí
|
||||
Comment[gl]=Un navegador web simples
|
||||
Comment[gu]=સરળ વેબ બ્રાઉઝર
|
||||
Comment[he]=דפדפן אינטרנט פשוט
|
||||
Comment[hi]=एक सादा वेब ब्राउज़र
|
||||
Comment[hne]=एक सादा ब्राउजर
|
||||
Comment[hr]=Jednostavni web preglednik
|
||||
Comment[hsb]=Jednory web browser
|
||||
Comment[hu]=Egyszerű webböngésző
|
||||
Comment[ia]=Un simple navigator web
|
||||
Comment[id]=Peramban web sederhana
|
||||
Comment[is]=Einfaldur vafri
|
||||
Comment[it]=Un semplice browser Web
|
||||
Comment[ja]=シンプルなウェブブラウザ
|
||||
Comment[kk]=Қарапайым веб шолғышы
|
||||
Comment[km]=កម្មវិធីរុករកបណ្ដាញធម្មតា
|
||||
Comment[kn]=ಒಂದು ಸರಳ ಜಾಲ ವೀಕ್ಷಕ
|
||||
Comment[ko]=간단한 웹 브라우저
|
||||
Comment[ku]=Geroka torê yê hêsan
|
||||
Comment[lt]=Paprasta žiniatinklio naršyklė
|
||||
Comment[lv]=Vienkāršs tīmekļa pārlūks
|
||||
Comment[mk]=Едноставен веб-прелистувач
|
||||
Comment[ml]=ലളിതമായ വെബ് ബ്രൌസര്
|
||||
Comment[mr]=सोपा वेब ब्राऊजर
|
||||
Comment[nb]=Enkel nettleser
|
||||
Comment[nds]=En eenfach Nettkieker
|
||||
Comment[nl]=Eenvoudige webbrowser
|
||||
Comment[nn]=Enkel nettlesar
|
||||
Comment[or]=ଗୋଟିଏ ସରଳ ୱେବ ବ୍ରାଉଜର
|
||||
Comment[pa]=ਇੱਕ ਸਧਾਰਨ ਵੈੱਬ ਬਰਾਊਜ਼ਰ
|
||||
Comment[pl]=Prosta przeglądarka sieciowa
|
||||
Comment[pt]=Um navegador Web simples
|
||||
Comment[pt_BR]=Um navegador da Internet simples
|
||||
Comment[ro]=Un navigator web simplu
|
||||
Comment[ru]=Простой браузер
|
||||
Comment[si]=සරල වෙබ් ගවේශකයක්
|
||||
Comment[sk]=Jednoduchý webový prehliadač
|
||||
Comment[sl]=Preprost spletni brskalnik
|
||||
Comment[sr]=Једноставан веб прегледач
|
||||
Comment[sr@ijekavian]=Једноставан веб прегледач
|
||||
Comment[sr@ijekavianlatin]=Jednostavan veb pregledač
|
||||
Comment[sr@latin]=Jednostavan veb pregledač
|
||||
Comment[sv]=En enkel webbläsare
|
||||
Comment[ta]=எளிய உலாவி
|
||||
Comment[tg]=Веб-браузери Cisco
|
||||
Comment[th]=เว็บเบราว์เซอร์พื้นฐาน
|
||||
Comment[tr]=Basit bir ağ tarayıcı
|
||||
Comment[ug]=ئاددىي توركۆرگۈ
|
||||
Comment[uk]=Простий переглядач інтернету
|
||||
Comment[wa]=On simpe betchteu waibe
|
||||
Comment[x-test]=xxA simple web browserxx
|
||||
Comment[zh_CN]=简单网络浏览器
|
||||
Comment[zh_TW]=簡易瀏覽器
|
||||
Type=Service
|
||||
Icon=konqueror
|
||||
ServiceTypes=Plasma/Applet
|
||||
X-Plasma-DropMimeTypes=text/html
|
||||
|
||||
X-KDE-Library=plasma_applet_webbrowser
|
||||
X-KDE-PluginInfo-Author=Marco Martin
|
||||
X-KDE-PluginInfo-Email=notmart@gmail.com
|
||||
X-KDE-PluginInfo-Name=webbrowser
|
||||
X-KDE-PluginInfo-Version=0.5
|
||||
X-KDE-PluginInfo-Website=
|
||||
X-KDE-PluginInfo-Category=Online Services
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv2+
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
|
@ -1,672 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 Marco Martin <notmart@gmail.com> *
|
||||
* Copyright (C) 2010 Davide Bettio <davide.bettio@kdemail.net> *
|
||||
* *
|
||||
* 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 2 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, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
#include "webbrowser.h"
|
||||
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QtCore/qabstractitemmodel.h>
|
||||
#include <QNetworkReply>
|
||||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTimer>
|
||||
#include <QTreeView>
|
||||
#include <QWebPage>
|
||||
#include <QWebFrame>
|
||||
#include <QWebHistory>
|
||||
|
||||
#include <KIcon>
|
||||
#include <KCompletion>
|
||||
#include <KBookmarkManager>
|
||||
#include <KIconLoader>
|
||||
#include <KUriFilter>
|
||||
#include <KMessageBox>
|
||||
#include <KConfigDialog>
|
||||
#include <KHistoryComboBox>
|
||||
#include <KWebPage>
|
||||
#include <kwebwallet.h>
|
||||
#include <KStandardDirs>
|
||||
|
||||
#include <Plasma/Animation>
|
||||
#include <Plasma/IconWidget>
|
||||
#include <Plasma/WebView>
|
||||
#include <Plasma/TreeView>
|
||||
#include <Plasma/PushButton>
|
||||
#include <Plasma/Slider>
|
||||
|
||||
#include "bookmarksdelegate.h"
|
||||
#include "bookmarkitem.h"
|
||||
#include "webviewoverlay.h"
|
||||
#include "browserhistorycombobox.h"
|
||||
#include "browsermessagebox.h"
|
||||
#include "errorpage.h"
|
||||
#include "webbrowserpage.h"
|
||||
|
||||
using Plasma::MessageButton;
|
||||
|
||||
WebBrowser::WebBrowser(QObject *parent, const QVariantList &args)
|
||||
: Plasma::PopupApplet(parent, args),
|
||||
m_browser(0),
|
||||
m_verticalScrollValue(0),
|
||||
m_horizontalScrollValue(0),
|
||||
m_completion(0),
|
||||
m_bookmarkManager(0),
|
||||
m_bookmarkModel(0),
|
||||
m_autoRefreshTimer(0)
|
||||
{
|
||||
setHasConfigurationInterface(true);
|
||||
setAspectRatioMode(Plasma::IgnoreAspectRatio);
|
||||
|
||||
m_historyCombo = 0;
|
||||
m_graphicsWidget = 0;
|
||||
m_webOverlay = 0;
|
||||
|
||||
m_layout = 0;
|
||||
resize(500,500);
|
||||
if (!args.isEmpty()) {
|
||||
m_url = KUrl(args.value(0).toString());
|
||||
}
|
||||
setPopupIcon("konqueror");
|
||||
}
|
||||
|
||||
QGraphicsWidget *WebBrowser::graphicsWidget()
|
||||
{
|
||||
if (m_graphicsWidget) {
|
||||
return m_graphicsWidget;
|
||||
}
|
||||
|
||||
m_layout = new QGraphicsLinearLayout(Qt::Vertical);
|
||||
m_toolbarLayout = new QGraphicsLinearLayout(Qt::Horizontal);
|
||||
m_statusbarLayout = new QGraphicsLinearLayout(Qt::Horizontal);
|
||||
|
||||
m_back = addTool("go-previous", m_toolbarLayout);
|
||||
m_forward = addTool("go-next", m_toolbarLayout);
|
||||
|
||||
m_nativeHistoryCombo = new KHistoryComboBox();
|
||||
m_historyCombo = new Plasma::BrowserHistoryComboBox(this);
|
||||
m_historyCombo->setNativeWidget(m_nativeHistoryCombo);
|
||||
m_historyCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
m_historyCombo->setZValue(999);
|
||||
|
||||
m_nativeHistoryCombo->setDuplicatesEnabled(false);
|
||||
|
||||
m_toolbarLayout->addItem(m_historyCombo);
|
||||
m_go = addTool("go-jump-locationbar", m_toolbarLayout);
|
||||
m_goAction = m_go->action();
|
||||
m_reloadAction = new QAction(KIcon("view-refresh"), QString(), this);
|
||||
|
||||
m_layout->addItem(m_toolbarLayout);
|
||||
|
||||
m_browser = new Plasma::WebView(this);
|
||||
m_browser->setPage(new WebBrowserPage(this));
|
||||
m_browser->setPreferredSize(400, 400);
|
||||
m_browser->setMinimumSize(130, 130);
|
||||
m_browser->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
m_layout->addItem(m_browser);
|
||||
|
||||
//bookmarks
|
||||
m_bookmarkManager = KBookmarkManager::userBookmarksManager();
|
||||
connect(m_bookmarkManager, SIGNAL(changed(QString,QString)), this, SLOT(bookmarksModelInit()));
|
||||
bookmarksModelInit();
|
||||
|
||||
m_bookmarksView = new Plasma::TreeView(this);
|
||||
m_bookmarksView->setZValue(1);
|
||||
m_bookmarksView->nativeWidget()->setAttribute(Qt::WA_NoSystemBackground, false);
|
||||
m_bookmarksView->nativeWidget()->verticalScrollBar()->setStyle(QApplication::style());
|
||||
m_bookmarksView->nativeWidget()->horizontalScrollBar()->setStyle(QApplication::style());
|
||||
m_bookmarksView->setModel(m_bookmarkModel);
|
||||
m_bookmarksView->nativeWidget()->setHeaderHidden(true);
|
||||
m_bookmarksView->hide();
|
||||
|
||||
m_bookmarksDelegate = new BookmarksDelegate(this);
|
||||
m_bookmarksView->nativeWidget()->setItemDelegate(m_bookmarksDelegate);
|
||||
|
||||
connect(m_bookmarksDelegate, SIGNAL(destroyBookmark(QModelIndex)), this, SLOT(removeBookmark(QModelIndex)));
|
||||
|
||||
m_layout->addItem(m_statusbarLayout);
|
||||
|
||||
m_addBookmark = addTool("bookmark-new", m_statusbarLayout);
|
||||
m_addBookmarkAction = m_addBookmark->action();
|
||||
m_removeBookmarkAction = new QAction(KIcon("list-remove"), QString(), this);
|
||||
m_organizeBookmarks = addTool("bookmarks-organize", m_statusbarLayout);
|
||||
|
||||
m_bookmarksViewAnimation = Plasma::Animator::create(Plasma::Animator::FadeAnimation, this);
|
||||
m_bookmarksViewAnimation->setTargetWidget(m_bookmarksView);
|
||||
connect(m_bookmarksViewAnimation, SIGNAL(finished()), this, SLOT(bookmarksAnimationFinished()));
|
||||
|
||||
m_stop = addTool("process-stop", m_statusbarLayout);
|
||||
|
||||
QGraphicsWidget *spacer = new QGraphicsWidget(this);
|
||||
spacer->setMaximumWidth(INT_MAX);
|
||||
spacer->setMaximumHeight(0);
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
m_statusbarLayout->addItem(spacer);
|
||||
|
||||
m_zoom = new Plasma::Slider(this);
|
||||
m_zoom->setMaximum(100);
|
||||
m_zoom->setMinimum(0);
|
||||
m_zoom->setValue(50);
|
||||
m_zoom->setOrientation(Qt::Horizontal);
|
||||
m_zoom->hide();
|
||||
m_zoom->setMaximumWidth(200);
|
||||
m_statusbarLayout->addItem(m_zoom);
|
||||
|
||||
connect(m_zoom, SIGNAL(valueChanged(int)), this, SLOT(zoom(int)));
|
||||
m_browser->setUrl(m_url);
|
||||
m_browser->update();
|
||||
|
||||
connect(m_back->action(), SIGNAL(triggered()), this, SLOT(back()));
|
||||
connect(m_forward->action(), SIGNAL(triggered()), this, SLOT(forward()));
|
||||
connect(m_reloadAction, SIGNAL(triggered()), this, SLOT(reload()));
|
||||
connect(m_goAction, SIGNAL(triggered()), this, SLOT(returnPressed()));
|
||||
connect(m_stop->action(), SIGNAL(triggered()), m_browser->page()->action(QWebPage::Stop), SLOT(trigger()));
|
||||
|
||||
connect(m_historyCombo->nativeWidget(), SIGNAL(returnPressed()), this, SLOT(returnPressed()));
|
||||
connect(m_historyCombo->nativeWidget(), SIGNAL(activated(int)), this, SLOT(returnPressed()));
|
||||
connect(m_historyCombo, SIGNAL(activated(QString)), this, SLOT(comboTextChanged(QString)));
|
||||
connect(m_browser->page()->mainFrame(), SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
|
||||
connect(m_browser, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
|
||||
|
||||
connect(m_addBookmarkAction, SIGNAL(triggered()), this, SLOT(addBookmark()));
|
||||
connect(m_removeBookmarkAction, SIGNAL(triggered()), this, SLOT(removeBookmark()));
|
||||
connect(m_organizeBookmarks->action(), SIGNAL(triggered()), this, SLOT(bookmarksToggle()));
|
||||
connect(m_bookmarksView->nativeWidget(), SIGNAL(clicked(QModelIndex)), this, SLOT(bookmarkClicked(QModelIndex)));
|
||||
|
||||
//Autocompletion stuff
|
||||
m_completion = new KCompletion();
|
||||
m_nativeHistoryCombo->setCompletionObject(m_completion);
|
||||
|
||||
m_graphicsWidget = new QGraphicsWidget(this);
|
||||
m_graphicsWidget->setLayout(m_layout);
|
||||
|
||||
m_back->setEnabled(m_browser->page()->history()->canGoBack());
|
||||
m_forward->setEnabled(m_browser->page()->history()->canGoForward());
|
||||
|
||||
configChanged();
|
||||
|
||||
connect(this, SIGNAL(messageButtonPressed(MessageButton)), this, SLOT(removeBookmarkMessageButtonPressed(MessageButton)));
|
||||
|
||||
return m_graphicsWidget;
|
||||
}
|
||||
|
||||
WebBrowser::~WebBrowser()
|
||||
{
|
||||
KConfigGroup cg = config();
|
||||
saveState(cg);
|
||||
delete m_completion;
|
||||
delete m_bookmarkModel;
|
||||
}
|
||||
|
||||
Plasma::IconWidget *WebBrowser::addTool(const QString &iconString, QGraphicsLinearLayout *layout)
|
||||
{
|
||||
Plasma::IconWidget *icon = new Plasma::IconWidget(this);
|
||||
QAction *action = new QAction(KIcon(iconString), QString(), this);
|
||||
icon->setAction(action);
|
||||
icon->setPreferredSize(icon->sizeFromIconSize(IconSize(KIconLoader::Toolbar)));
|
||||
layout->addItem(icon);
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
void WebBrowser::bookmarksModelInit()
|
||||
{
|
||||
if (m_bookmarkModel) {
|
||||
m_bookmarkModel->clear();
|
||||
} else {
|
||||
m_bookmarkModel = new QStandardItemModel;
|
||||
}
|
||||
|
||||
fillGroup(0, m_bookmarkManager->root());
|
||||
}
|
||||
|
||||
void WebBrowser::configChanged()
|
||||
{
|
||||
KConfigGroup cg = config();
|
||||
|
||||
m_browser->setDragToScroll(cg.readEntry("DragToScroll", false));
|
||||
|
||||
if (!m_url.isValid()) {
|
||||
m_url = KUrl(cg.readEntry("Url", "http://www.kde.org"));
|
||||
m_verticalScrollValue = cg.readEntry("VerticalScrollValue", 0);
|
||||
m_horizontalScrollValue = cg.readEntry("HorizontalScrollValue", 0);
|
||||
int value = cg.readEntry("Zoom", 50);
|
||||
m_zoom->setValue(value);
|
||||
qreal zoomFactor = qMax((qreal)0.2, ((qreal)value/(qreal)50));
|
||||
if ((zoomFactor > 0.95) && (zoomFactor < 1.05)){
|
||||
zoomFactor = 1;
|
||||
}
|
||||
m_browser->setZoomFactor(zoomFactor);
|
||||
m_browser->setUrl(m_url);
|
||||
}
|
||||
|
||||
m_autoRefresh = cg.readEntry("autoRefresh", false);
|
||||
m_autoRefreshInterval = qMax(2, cg.readEntry("autoRefreshInterval", 5));
|
||||
|
||||
if (m_autoRefresh) {
|
||||
m_autoRefreshTimer = new QTimer(this);
|
||||
m_autoRefreshTimer->start(m_autoRefreshInterval*60*1000);
|
||||
connect(m_autoRefreshTimer, SIGNAL(timeout()), this, SLOT(reload()));
|
||||
}
|
||||
|
||||
QStringList list = cg.readEntry("History list", QStringList());
|
||||
m_nativeHistoryCombo->setHistoryItems(list);
|
||||
}
|
||||
|
||||
void WebBrowser::fillGroup(BookmarkItem *parentItem, const KBookmarkGroup &group)
|
||||
{
|
||||
KBookmark it = group.first();
|
||||
|
||||
while (!it.isNull()) {
|
||||
BookmarkItem *bookmarkItem = new BookmarkItem(it);
|
||||
bookmarkItem->setEditable(false);
|
||||
|
||||
if (it.isGroup()) {
|
||||
KBookmarkGroup grp = it.toGroup();
|
||||
fillGroup( bookmarkItem, grp );
|
||||
|
||||
}
|
||||
|
||||
if (parentItem) {
|
||||
parentItem->appendRow(bookmarkItem);
|
||||
} else {
|
||||
m_bookmarkModel->appendRow(bookmarkItem);
|
||||
}
|
||||
|
||||
it = m_bookmarkManager->root().next(it);
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::saveState(KConfigGroup &cg) const
|
||||
{
|
||||
cg.writeEntry("Url", m_url.prettyUrl());
|
||||
|
||||
if (m_historyCombo) {
|
||||
const QStringList list = m_nativeHistoryCombo->historyItems();
|
||||
cg.writeEntry("History list", list);
|
||||
}
|
||||
|
||||
if (m_browser) {
|
||||
cg.writeEntry("VerticalScrollValue", m_browser->page()->mainFrame()->scrollBarValue(Qt::Vertical));
|
||||
cg.writeEntry("HorizontalScrollValue", m_browser->page()->mainFrame()->scrollBarValue(Qt::Horizontal));
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::back()
|
||||
{
|
||||
m_browser->page()->history()->back();
|
||||
}
|
||||
|
||||
void WebBrowser::forward()
|
||||
{
|
||||
m_browser->page()->history()->forward();
|
||||
}
|
||||
|
||||
void WebBrowser::reload()
|
||||
{
|
||||
m_browser->setUrl(m_url);
|
||||
}
|
||||
|
||||
void WebBrowser::returnPressed()
|
||||
{
|
||||
KUrl url(m_nativeHistoryCombo->currentText());
|
||||
|
||||
|
||||
KUriFilter::self()->filterUri( url );
|
||||
|
||||
m_verticalScrollValue = 0;
|
||||
m_horizontalScrollValue = 0;
|
||||
m_browser->setUrl(url);
|
||||
}
|
||||
|
||||
|
||||
void WebBrowser::urlChanged(const QUrl &url)
|
||||
{
|
||||
//ask for a favicon
|
||||
Plasma::DataEngine *engine = dataEngine( "favicons" );
|
||||
if (engine) {
|
||||
//engine->disconnectSource( url.toString(), this );
|
||||
engine->connectSource( url.toString(), this );
|
||||
|
||||
engine->query( url.toString() );
|
||||
}
|
||||
|
||||
m_url = KUrl(url);
|
||||
|
||||
if (m_bookmarkModel->match(m_bookmarkModel->index(0,0), BookmarkItem::UrlRole, m_url.prettyUrl()).isEmpty()) {
|
||||
m_addBookmark->setAction(m_addBookmarkAction);
|
||||
} else {
|
||||
m_addBookmark->setAction(m_removeBookmarkAction);
|
||||
}
|
||||
|
||||
m_nativeHistoryCombo->addToHistory(m_url.prettyUrl());
|
||||
m_nativeHistoryCombo->setCurrentIndex(0);
|
||||
|
||||
m_go->setAction(m_reloadAction);
|
||||
|
||||
KConfigGroup cg = config();
|
||||
saveState(cg);
|
||||
|
||||
m_back->setEnabled(m_browser->page()->history()->canGoBack());
|
||||
m_forward->setEnabled(m_browser->page()->history()->canGoForward());
|
||||
setAssociatedApplicationUrls(KUrl(url));
|
||||
}
|
||||
|
||||
void WebBrowser::comboTextChanged(const QString &string)
|
||||
{
|
||||
Q_UNUSED(string)
|
||||
|
||||
m_go->setAction(m_goAction);
|
||||
}
|
||||
|
||||
void WebBrowser::dataUpdated( const QString &source, const Plasma::DataEngine::Data &data )
|
||||
{
|
||||
//TODO: find a way to update bookmarks and history combobox here, at the moment the data engine
|
||||
// is only used to save the icon files
|
||||
if (source == m_nativeHistoryCombo->currentText()) {
|
||||
QPixmap favicon(QPixmap::fromImage(data["Icon"].value<QImage>()));
|
||||
if (!favicon.isNull()) {
|
||||
m_nativeHistoryCombo->setItemIcon(
|
||||
m_nativeHistoryCombo->currentIndex(), QIcon(favicon));
|
||||
setPopupIcon(QIcon(favicon));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::addBookmark()
|
||||
{
|
||||
KBookmark bookmark = m_bookmarkManager->root().addBookmark(m_browser->page()->mainFrame()->title(), m_url);
|
||||
m_bookmarkManager->save();
|
||||
|
||||
BookmarkItem *bookmarkItem = new BookmarkItem(bookmark);
|
||||
m_bookmarkModel->appendRow(bookmarkItem);
|
||||
|
||||
m_addBookmark->setAction(m_removeBookmarkAction);
|
||||
}
|
||||
|
||||
void WebBrowser::removeBookmark(const QModelIndex &index)
|
||||
{
|
||||
BookmarkItem *item = dynamic_cast<BookmarkItem *>(m_bookmarkModel->itemFromIndex(index));
|
||||
|
||||
if (item) {
|
||||
KBookmark bookmark = item->bookmark();
|
||||
|
||||
const QString text(i18nc("@info", "Do you really want to remove the bookmark to %1?", bookmark.url().host()));
|
||||
showMessage(KIcon("dialog-warning"), text, Plasma::ButtonYes | Plasma::ButtonNo);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item && item->parent()) {
|
||||
item->parent()->removeRow(index.row());
|
||||
} else {
|
||||
m_bookmarkModel->removeRow(index.row());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void WebBrowser::removeBookmarkMessageButtonPressed(const Plasma::MessageButton button)
|
||||
{
|
||||
if (button == Plasma::ButtonNo){
|
||||
return;
|
||||
}
|
||||
|
||||
const QModelIndexList list = m_bookmarkModel->match(m_bookmarkModel->index(0,0), BookmarkItem::UrlRole, m_url.prettyUrl());
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
const QModelIndex &index = list.first();
|
||||
BookmarkItem *item = dynamic_cast<BookmarkItem *>(m_bookmarkModel->itemFromIndex(index));
|
||||
|
||||
if (item) {
|
||||
KBookmark bookmark = item->bookmark();
|
||||
|
||||
bookmark.parentGroup().deleteBookmark(bookmark);
|
||||
m_bookmarkManager->save();
|
||||
}
|
||||
|
||||
if (item && item->parent()) {
|
||||
item->parent()->removeRow(index.row());
|
||||
} else {
|
||||
m_bookmarkModel->removeRow(index.row());
|
||||
}
|
||||
}
|
||||
|
||||
m_addBookmark->setAction(m_addBookmarkAction);
|
||||
}
|
||||
void WebBrowser::removeBookmark()
|
||||
{
|
||||
const QModelIndexList list = m_bookmarkModel->match(m_bookmarkModel->index(0,0), BookmarkItem::UrlRole, m_url.prettyUrl());
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
removeBookmark(list.first());
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::bookmarksToggle()
|
||||
{
|
||||
if (m_bookmarksView->isVisible()) {
|
||||
m_bookmarksViewAnimation->setProperty("startOpacity", 1);
|
||||
m_bookmarksViewAnimation->setProperty("targetOpacity", 0);
|
||||
m_bookmarksViewAnimation->start();
|
||||
} else {
|
||||
m_bookmarksView->show();
|
||||
m_bookmarksView->setOpacity(0);
|
||||
updateOverlaysGeometry();
|
||||
m_bookmarksViewAnimation->setProperty("startOpacity", 0);
|
||||
m_bookmarksViewAnimation->setProperty("targetOpacity", 1);
|
||||
m_bookmarksViewAnimation->start();
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::bookmarksAnimationFinished()
|
||||
{
|
||||
if (qFuzzyCompare(m_bookmarksView->opacity() + 1, 1)){
|
||||
m_bookmarksView->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::bookmarkClicked(const QModelIndex &index)
|
||||
{
|
||||
QStandardItem *item = m_bookmarkModel->itemFromIndex(index);
|
||||
|
||||
if (item) {
|
||||
KUrl url(item->data(BookmarkItem::UrlRole).value<QString>());
|
||||
|
||||
if (url.isValid()) {
|
||||
m_browser->setUrl(url);
|
||||
bookmarksToggle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::zoom(int value)
|
||||
{
|
||||
config().writeEntry("Zoom", value);
|
||||
m_browser->setZoomFactor((qreal)0.2 + ((qreal)value/(qreal)50));
|
||||
}
|
||||
|
||||
void WebBrowser::loadProgress(int progress)
|
||||
{
|
||||
m_historyCombo->setProgressValue(progress);
|
||||
|
||||
if (progress == 100) {
|
||||
m_historyCombo->setDisplayProgress(false);
|
||||
m_stop->hide();
|
||||
m_stop->setMaximumWidth(0);
|
||||
m_zoom->show();
|
||||
m_statusbarLayout->invalidate();
|
||||
|
||||
m_browser->page()->mainFrame()->setScrollBarValue(Qt::Vertical, m_verticalScrollValue);
|
||||
m_browser->page()->mainFrame()->setScrollBarValue(Qt::Horizontal, m_horizontalScrollValue);
|
||||
|
||||
} else {
|
||||
m_historyCombo->setDisplayProgress(true);
|
||||
m_stop->show();
|
||||
m_stop->setMaximumWidth(INT_MAX);
|
||||
m_zoom->hide();
|
||||
m_statusbarLayout->invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::createConfigurationInterface(KConfigDialog *parent)
|
||||
{
|
||||
QWidget *widget = new QWidget();
|
||||
ui.setupUi(widget);
|
||||
parent->addPage(widget, i18n("General"), icon());
|
||||
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
|
||||
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
|
||||
|
||||
ui.autoRefresh->setChecked(m_autoRefresh);
|
||||
ui.autoRefreshInterval->setValue(m_autoRefreshInterval);
|
||||
ui.autoRefreshInterval->setSuffix(ki18np(" minute", " minutes"));
|
||||
ui.dragToScroll->setChecked(m_browser->dragToScroll());
|
||||
connect(ui.autoRefresh, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
||||
connect(ui.dragToScroll, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
|
||||
connect(ui.autoRefreshInterval, SIGNAL(valueChanged(int)), parent, SLOT(settingsModified()));
|
||||
}
|
||||
|
||||
void WebBrowser::configAccepted()
|
||||
{
|
||||
KConfigGroup cg = config();
|
||||
|
||||
m_autoRefresh = ui.autoRefresh->isChecked();
|
||||
m_autoRefreshInterval = ui.autoRefreshInterval->value();
|
||||
|
||||
cg.writeEntry("autoRefresh", m_autoRefresh);
|
||||
cg.writeEntry("autoRefreshInterval", m_autoRefreshInterval);
|
||||
cg.writeEntry("DragToScroll", ui.dragToScroll->isChecked());
|
||||
m_browser->setDragToScroll(ui.dragToScroll->isChecked());
|
||||
|
||||
if (m_autoRefresh) {
|
||||
if (!m_autoRefreshTimer) {
|
||||
m_autoRefreshTimer = new QTimer(this);
|
||||
connect(m_autoRefreshTimer, SIGNAL(timeout()), this, SLOT(reload()));
|
||||
}
|
||||
|
||||
m_autoRefreshTimer->start(m_autoRefreshInterval*60*1000);
|
||||
} else {
|
||||
delete m_autoRefreshTimer;
|
||||
m_autoRefreshTimer = 0;
|
||||
}
|
||||
|
||||
emit configNeedsSaving();
|
||||
}
|
||||
|
||||
void WebBrowser::constraintsEvent(Plasma::Constraints constraints)
|
||||
{
|
||||
if (constraints & Plasma::SizeConstraint){
|
||||
updateOverlaysGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::updateOverlaysGeometry()
|
||||
{
|
||||
QRect overlayGeometry(m_browser->pos().x() + contentsRect().x(),
|
||||
m_browser->pos().y() + contentsRect().y(),
|
||||
m_browser->geometry().width(),
|
||||
m_browser->geometry().height());
|
||||
|
||||
if (m_bookmarksView->isVisible()) {
|
||||
m_bookmarksView->setGeometry(overlayGeometry);
|
||||
}
|
||||
|
||||
if (m_webOverlay){
|
||||
m_webOverlay->setGeometry(overlayGeometry);
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(contentsRect)
|
||||
|
||||
if (!isIconified()){
|
||||
p->save();
|
||||
p->setBrush(QApplication::palette().window());
|
||||
p->setRenderHint(QPainter::Antialiasing);
|
||||
p->setPen(Qt::NoPen);
|
||||
p->drawRoundedRect(m_browser->pos().x() + contentsRect.x() - 2,
|
||||
m_browser->pos().y() + contentsRect.y() - 2,
|
||||
m_browser->geometry().width() + 4,
|
||||
m_browser->geometry().height() + 4,
|
||||
2, 2);
|
||||
p->restore();
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::closeWebViewOverlay()
|
||||
{
|
||||
if (m_webOverlay){
|
||||
m_webOverlay->deleteLater();
|
||||
m_webOverlay = 0;
|
||||
}
|
||||
}
|
||||
|
||||
QWebPage *WebBrowser::createWindow(QWebPage::WebWindowType type)
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
|
||||
if (!m_webOverlay){
|
||||
m_webOverlay = new WebViewOverlay(this);
|
||||
updateOverlaysGeometry();
|
||||
m_webOverlay->setZValue(999);
|
||||
connect(m_webOverlay, SIGNAL(closeRequested()), this, SLOT(closeWebViewOverlay()));
|
||||
}
|
||||
|
||||
return m_webOverlay->page();
|
||||
}
|
||||
|
||||
//
|
||||
// Wallet managment
|
||||
//
|
||||
|
||||
void WebBrowser::saveFormDataRequested(const QString &uid, const QUrl &url)
|
||||
{
|
||||
BrowserMessageBox *messageBox = new BrowserMessageBox(this, i18n("Do you want to store this password for %1?", url.host()));
|
||||
messageBox->okButton()->setText(i18n("Store"));
|
||||
messageBox->okButton()->setIcon(KIcon("document-save"));
|
||||
messageBox->cancelButton()->setText(i18n("Do not store this time"));
|
||||
messageBox->cancelButton()->setIcon(KIcon("dialog-cancel"));
|
||||
m_layout->insertItem(1, messageBox);
|
||||
walletRequests.insert(messageBox, uid);
|
||||
connect(messageBox, SIGNAL(okClicked()), this, SLOT(acceptWalletRequest()));
|
||||
connect(messageBox, SIGNAL(cancelClicked()), this, SLOT(rejectWalletRequest()));
|
||||
}
|
||||
|
||||
void WebBrowser::acceptWalletRequest()
|
||||
{
|
||||
static_cast<KWebPage *>(m_browser->page())->wallet()->acceptSaveFormDataRequest(
|
||||
walletRequests[static_cast<BrowserMessageBox *>(QObject::sender())]);
|
||||
QObject::sender()->deleteLater();
|
||||
}
|
||||
|
||||
void WebBrowser::rejectWalletRequest()
|
||||
{
|
||||
static_cast<KWebPage *>(m_browser->page())->wallet()->rejectSaveFormDataRequest(
|
||||
walletRequests[static_cast<BrowserMessageBox *>(QObject::sender())]);
|
||||
QObject::sender()->deleteLater();
|
||||
}
|
||||
|
||||
//
|
||||
// End of wallet managment
|
||||
//
|
||||
|
||||
K_EXPORT_PLASMA_APPLET(webbrowser, WebBrowser)
|
||||
|
||||
#include "moc_webbrowser.cpp"
|
|
@ -1,161 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Marco Martin <notmart@gmail.com> *
|
||||
* *
|
||||
* 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 2 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, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef WEBBROWSER_H
|
||||
#define WEBBROWSER_H
|
||||
|
||||
#include <QHash>
|
||||
#include <QWebPage>
|
||||
|
||||
#include <Plasma/PopupApplet>
|
||||
#include <Plasma/DataEngine>
|
||||
|
||||
#include "ui_webbrowserconfig.h"
|
||||
#include "browsermessagebox.h"
|
||||
|
||||
class WebViewOverlay;
|
||||
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QStandardItemModel>
|
||||
#include <QStandardItem>
|
||||
#include <QTimer>
|
||||
class KHistoryComboBox;
|
||||
class KUrl;
|
||||
class KCompletion;
|
||||
class KBookmarkManager;
|
||||
class KBookmarkGroup;
|
||||
#include <QModelIndex>
|
||||
#include <QAction>
|
||||
class BookmarksDelegate;
|
||||
class BookmarkItem;
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class BrowserHistoryComboBox;
|
||||
class IconWidget;
|
||||
class ComboBox;
|
||||
class WebView;
|
||||
class TreeView;
|
||||
class Slider;
|
||||
}
|
||||
|
||||
|
||||
using Plasma::MessageButton;
|
||||
|
||||
class WebBrowser : public Plasma::PopupApplet
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
WebBrowser(QObject *parent, const QVariantList &args);
|
||||
~WebBrowser();
|
||||
|
||||
QGraphicsWidget *graphicsWidget();
|
||||
void paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect);
|
||||
QWebPage *createWindow(QWebPage::WebWindowType type);
|
||||
|
||||
//TODO: put in a separate file
|
||||
enum BookmarkRoles
|
||||
{
|
||||
UrlRole = Qt::UserRole+1,
|
||||
BookmarkRole = Qt::UserRole+2
|
||||
};
|
||||
|
||||
public Q_SLOTS:
|
||||
void dataUpdated(const QString &source, const Plasma::DataEngine::Data &data);
|
||||
void saveFormDataRequested(const QString &uid, const QUrl &url);
|
||||
|
||||
protected:
|
||||
void saveState(KConfigGroup &cg) const;
|
||||
Plasma::IconWidget *addTool(const QString &iconString, QGraphicsLinearLayout *layout);
|
||||
void createConfigurationInterface(KConfigDialog *parent);
|
||||
void constraintsEvent(Plasma::Constraints constraints);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void back();
|
||||
void forward();
|
||||
void reload();
|
||||
void returnPressed();
|
||||
void urlChanged(const QUrl &url);
|
||||
void comboTextChanged(const QString &string);
|
||||
void addBookmark();
|
||||
void removeBookmark(const QModelIndex &index);
|
||||
void removeBookmark();
|
||||
void bookmarksToggle();
|
||||
void bookmarkClicked(const QModelIndex &index);
|
||||
void zoom(int value);
|
||||
void loadProgress(int progress);
|
||||
void bookmarksModelInit();
|
||||
void configAccepted();
|
||||
void configChanged();
|
||||
void bookmarksAnimationFinished();
|
||||
void removeBookmarkMessageButtonPressed(const MessageButton button);
|
||||
void closeWebViewOverlay();
|
||||
|
||||
void acceptWalletRequest();
|
||||
void rejectWalletRequest();
|
||||
|
||||
private:
|
||||
void fillGroup(BookmarkItem *parentItem, const KBookmarkGroup &group);
|
||||
void updateOverlaysGeometry();
|
||||
QHash<BrowserMessageBox *, QString> walletRequests;
|
||||
|
||||
|
||||
QGraphicsLinearLayout *m_layout;
|
||||
QGraphicsLinearLayout *m_toolbarLayout;
|
||||
QGraphicsLinearLayout *m_statusbarLayout;
|
||||
Plasma::WebView *m_browser;
|
||||
WebViewOverlay *m_webOverlay;
|
||||
KUrl m_url;
|
||||
int m_verticalScrollValue;
|
||||
int m_horizontalScrollValue;
|
||||
KCompletion *m_completion;
|
||||
KBookmarkManager *m_bookmarkManager;
|
||||
QStandardItemModel *m_bookmarkModel;
|
||||
Plasma::TreeView *m_bookmarksView;
|
||||
Plasma::Animation *m_bookmarksViewAnimation;
|
||||
|
||||
QTimer *m_autoRefreshTimer;
|
||||
bool m_autoRefresh;
|
||||
int m_autoRefreshInterval;
|
||||
|
||||
QGraphicsWidget *m_graphicsWidget;
|
||||
|
||||
Plasma::BrowserHistoryComboBox *m_historyCombo;
|
||||
KHistoryComboBox *m_nativeHistoryCombo;
|
||||
BookmarksDelegate *m_bookmarksDelegate;
|
||||
|
||||
Plasma::IconWidget *m_back;
|
||||
Plasma::IconWidget *m_forward;
|
||||
|
||||
Plasma::IconWidget *m_go;
|
||||
QAction *m_goAction;
|
||||
QAction *m_reloadAction;
|
||||
|
||||
Plasma::IconWidget *m_addBookmark;
|
||||
QAction *m_addBookmarkAction;
|
||||
QAction *m_removeBookmarkAction;
|
||||
|
||||
Plasma::IconWidget *m_organizeBookmarks;
|
||||
Plasma::IconWidget *m_stop;
|
||||
Plasma::Slider *m_zoom;
|
||||
|
||||
Ui::WebBrowserConfig ui;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,120 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>WebBrowserConfig</class>
|
||||
<widget class="QWidget" name="WebBrowserConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>298</width>
|
||||
<height>140</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Auto refresh:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>autoRefresh</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="autoRefresh">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Interval:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>autoRefreshInterval</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QWidget" name="intervalGroup" native="true">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="KIntSpinBox" name="autoRefreshInterval">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Drag to scroll the page:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>dragToScroll</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="dragToScroll">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KIntSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>knuminput.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>autoRefresh</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>intervalGroup</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>238</x>
|
||||
<y>11</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>238</x>
|
||||
<y>39</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -1,67 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2010 Davide Bettio <davide.bettio@kdemail.net> *
|
||||
* *
|
||||
* 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 2 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, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
#include "webbrowserpage.h"
|
||||
#include "webbrowser.h"
|
||||
#include "errorpage.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QWebFrame>
|
||||
|
||||
#include <kwebwallet.h>
|
||||
|
||||
WebBrowserPage::WebBrowserPage(WebBrowser *parent)
|
||||
: KWebPage(parent)
|
||||
{
|
||||
m_browser = parent;
|
||||
//settings()->setAttribute(QWebSettings::JavaEnabled, true);
|
||||
settings()->setAttribute(QWebSettings::PluginsEnabled, true);
|
||||
|
||||
connect(networkAccessManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(networkAccessFinished(QNetworkReply*)));
|
||||
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(pageLoadFinished(bool)));
|
||||
connect(wallet(), SIGNAL(saveFormDataRequested(QString,QUrl)),
|
||||
m_browser, SLOT(saveFormDataRequested(QString,QUrl)));
|
||||
}
|
||||
|
||||
QWebPage *WebBrowserPage::createWindow(WebWindowType type)
|
||||
{
|
||||
return m_browser->createWindow(type);
|
||||
}
|
||||
|
||||
void WebBrowserPage::pageLoadFinished(bool ok)
|
||||
{
|
||||
if (ok){
|
||||
wallet()->fillFormData(mainFrame());
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowserPage::networkAccessFinished(QNetworkReply *nReply)
|
||||
{
|
||||
switch (nReply->error()){
|
||||
case QNetworkReply::NoError:
|
||||
case QNetworkReply::UnknownContentError:
|
||||
case QNetworkReply::ContentNotFoundError:
|
||||
return;
|
||||
|
||||
default:
|
||||
mainFrame()->setHtml(errorPageHtml(webKitErrorToKIOError(nReply->error()), nReply->url().toString(), nReply->url()));
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_webbrowserpage.cpp"
|
|
@ -1,45 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2010 Davide Bettio <davide.bettio@kdemail.net> *
|
||||
* *
|
||||
* 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 2 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, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef WEBBROWSERPAGE_H
|
||||
#define WEBBROWSERPAGE_H
|
||||
|
||||
#include <KWebPage>
|
||||
|
||||
class WebBrowser;
|
||||
|
||||
class WebBrowserPage : public KWebPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WebBrowserPage(WebBrowser *parent);
|
||||
|
||||
protected:
|
||||
QWebPage *createWindow(WebWindowType type);
|
||||
|
||||
private Q_SLOTS:
|
||||
void pageLoadFinished(bool ok);
|
||||
void networkAccessFinished(QNetworkReply *nReply);
|
||||
|
||||
private:
|
||||
WebBrowser *m_browser;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,63 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2010 Davide Bettio <davide.bettio@kdemail.net> *
|
||||
* *
|
||||
* 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 2 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, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
#include "webviewoverlay.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QtGui/qstyleoption.h>
|
||||
#include <QPainter>
|
||||
|
||||
#include <Plasma/PushButton>
|
||||
#include <Plasma/WebView>
|
||||
|
||||
#include "webbrowser.h"
|
||||
#include "webbrowserpage.h"
|
||||
|
||||
WebViewOverlay::WebViewOverlay(WebBrowser *parent)
|
||||
: QGraphicsWidget(parent)
|
||||
{
|
||||
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(this);
|
||||
layout->setOrientation(Qt::Vertical);
|
||||
|
||||
m_webView = new Plasma::WebView(this);
|
||||
m_webView->setPage(new WebBrowserPage(parent));
|
||||
m_webView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
layout->addItem(m_webView);
|
||||
|
||||
m_closeButton = new Plasma::PushButton(this);
|
||||
m_closeButton->setText(i18n("Close"));
|
||||
connect(m_closeButton, SIGNAL(clicked()), this, SIGNAL(closeRequested()));
|
||||
layout->addItem(m_closeButton);
|
||||
connect(m_webView->page(), SIGNAL(windowCloseRequested()), this, SIGNAL(closeRequested()));
|
||||
}
|
||||
|
||||
QWebPage *WebViewOverlay::page()
|
||||
{
|
||||
return m_webView->page();
|
||||
}
|
||||
|
||||
void WebViewOverlay::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(widget)
|
||||
|
||||
painter->fillRect(option->rect, QApplication::palette().window());
|
||||
}
|
||||
|
||||
#include "moc_webviewoverlay.cpp"
|
|
@ -1,53 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2010 Davide Bettio <davide.bettio@kdemail.net> *
|
||||
* *
|
||||
* 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 2 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, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef WEBVIEWOVERLAY_H
|
||||
#define WEBVIEWOVERLAY_H
|
||||
|
||||
#include <QGraphicsWidget>
|
||||
#include <QWebPage>
|
||||
|
||||
class WebBrowser;
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class PushButton;
|
||||
class WebView;
|
||||
}
|
||||
|
||||
class WebViewOverlay : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WebViewOverlay(WebBrowser *parent);
|
||||
QWebPage *page();
|
||||
|
||||
Q_SIGNALS:
|
||||
void closeRequested();
|
||||
|
||||
protected:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
private:
|
||||
Plasma::WebView *m_webView;
|
||||
Plasma::PushButton *m_closeButton;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -11,12 +11,18 @@ include_directories(
|
|||
${KDE4_INCLUDES}
|
||||
)
|
||||
|
||||
if(QT_QTWEBKIT_FOUND)
|
||||
add_definitions(-DHAVE_QTWEBKIT)
|
||||
endif()
|
||||
|
||||
add_library(graphicswidgetsbindingsplugin SHARED ${graphicswidgetsbindings_SRCS})
|
||||
target_link_libraries(graphicswidgetsbindingsplugin ${KDE4_PLASMA_LIBS} ${QT_QTSCRIPT_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY})
|
||||
target_link_libraries(graphicswidgetsbindingsplugin
|
||||
${KDE4_PLASMA_LIBS}
|
||||
${QT_QTSCRIPT_LIBRARY}
|
||||
${QT_QTDECLARATIVE_LIBRARY}
|
||||
)
|
||||
|
||||
install(TARGETS graphicswidgetsbindingsplugin DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/graphicswidgets)
|
||||
install(FILES qmldir DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/graphicswidgets)
|
||||
install(
|
||||
TARGETS graphicswidgetsbindingsplugin
|
||||
DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/graphicswidgets
|
||||
)
|
||||
install(
|
||||
FILES qmldir
|
||||
DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/graphicswidgets
|
||||
)
|
||||
|
|
|
@ -46,9 +46,6 @@
|
|||
#include <Plasma/TextEdit>
|
||||
#include <Plasma/ToolButton>
|
||||
#include <Plasma/TreeView>
|
||||
#ifdef HAVE_QTWEBKIT
|
||||
#include <Plasma/WebView>
|
||||
#endif
|
||||
|
||||
#include "declarativetabbar.h"
|
||||
|
||||
|
@ -99,9 +96,6 @@ void GraphicsWidgetsBindingsPlugin::registerTypes(const char *uri)
|
|||
qmlRegisterType<Plasma::TextEdit>(uri, 0, 1, "TextEdit");
|
||||
qmlRegisterType<Plasma::ToolButton>(uri, 0, 1, "ToolButton");
|
||||
qmlRegisterType<Plasma::TreeView>(uri, 0, 1, "TreeView");
|
||||
#ifdef HAVE_QTWEBKIT
|
||||
qmlRegisterType<Plasma::WebView>(uri, 0, 1, "WebView");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,4 @@
|
|||
########### next target ###############
|
||||
set(EXTERNAL_LIBS ${KDE4_KIO_LIBS} ${QT_QTSCRIPT_LIBRARY} ${KDE4_PLASMA_LIBS} ${QT_QTSQL_LIBRARY})
|
||||
if(QJSON_FOUND)
|
||||
add_definitions(-DHAVE_QJSON=1)
|
||||
# Some distributions (e.g. Debian or Ubuntu 12.10) seem to install a QJSONConfig.cmake with lower-case variables,
|
||||
# which is preferred to our FindQJSON.cmake. Make sure this does not break the build.
|
||||
set(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${QJSON_LIBRARIES} ${qjson_LIBRARIES} )
|
||||
include_directories(${QJSON_INCLUDE_DIR} ${qjson_INCLUDE_DIR})
|
||||
endif(QJSON_FOUND)
|
||||
|
||||
set(krunner_bookmarksrunner_SRCS
|
||||
browserfactory.cpp
|
||||
|
@ -18,28 +10,24 @@ set(krunner_bookmarksrunner_SRCS
|
|||
bookmarksrunner.cpp
|
||||
browsers/kdebrowser.cpp
|
||||
browsers/firefox.cpp
|
||||
browsers/chromefindprofile.cpp
|
||||
browsers/chrome.cpp
|
||||
)
|
||||
|
||||
if(QJSON_FOUND)
|
||||
set(krunner_bookmarksrunner_SRCS
|
||||
${krunner_bookmarksrunner_SRCS}
|
||||
browsers/chromefindprofile.cpp
|
||||
browsers/chrome.cpp
|
||||
)
|
||||
endif(QJSON_FOUND)
|
||||
|
||||
|
||||
kde4_add_plugin(krunner_bookmarksrunner ${krunner_bookmarksrunner_SRCS})
|
||||
target_link_libraries(krunner_bookmarksrunner ${EXTERNAL_LIBS})
|
||||
target_link_libraries(krunner_bookmarksrunner
|
||||
${KDE4_KIO_LIBS}
|
||||
${KDE4_PLASMA_LIBS}
|
||||
${QT_QTSCRIPT_LIBRARY}
|
||||
${QT_QTSQL_LIBRARY}
|
||||
)
|
||||
|
||||
install(TARGETS krunner_bookmarksrunner DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||
|
||||
|
||||
########### install files ###############
|
||||
|
||||
install(FILES plasma-runner-bookmarks.desktop DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
|
||||
# Currently tests include only chrome, so no need to get include them if json is not found
|
||||
if(QJSON_FOUND AND ENABLE_TESTING)
|
||||
if(ENABLE_TESTING)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
|
|
@ -37,12 +37,10 @@ Browser *BrowserFactory::find(const QString& browserName, QObject* parent)
|
|||
m_previousBrowser = new Firefox(parent);
|
||||
} else if (browserName.contains("opera", Qt::CaseInsensitive)) {
|
||||
m_previousBrowser = new Opera(parent);
|
||||
#ifdef HAVE_QJSON
|
||||
} else if (browserName.contains("chrome", Qt::CaseInsensitive)) {
|
||||
m_previousBrowser = new Chrome(new FindChromeProfile("google-chrome", QDir::homePath(), parent), parent);
|
||||
} else if (browserName.contains("chromium", Qt::CaseInsensitive)) {
|
||||
m_previousBrowser = new Chrome(new FindChromeProfile("chromium", QDir::homePath(), parent), parent);
|
||||
#endif // HAVE_QJSON
|
||||
} else {
|
||||
m_previousBrowser = new KDEBrowser(parent);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
set( testChromeBookmarks_SRCS testchromebookmarks.cpp
|
||||
../browsers/chrome.cpp
|
||||
../faviconfromblob.cpp
|
||||
../browsers/chromefindprofile.cpp
|
||||
../bookmarkmatch.cpp
|
||||
../favicon.cpp
|
||||
../fetchsqlite.cpp
|
||||
set( testChromeBookmarks_SRCS
|
||||
testchromebookmarks.cpp
|
||||
../browsers/chrome.cpp
|
||||
../faviconfromblob.cpp
|
||||
../browsers/chromefindprofile.cpp
|
||||
../bookmarkmatch.cpp
|
||||
../favicon.cpp
|
||||
../fetchsqlite.cpp
|
||||
)
|
||||
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/.. )
|
||||
kde4_add_test(plasma-runner-bookmarks-TestChromeBookmarks ${testChromeBookmarks_SRCS} )
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
${CMAKE_CURRENT_BINARY_DIR}/..
|
||||
)
|
||||
|
||||
kde4_add_test(plasma-runner-bookmarks-TestChromeBookmarks ${testChromeBookmarks_SRCS})
|
||||
|
||||
target_link_libraries(plasma-runner-bookmarks-TestChromeBookmarks
|
||||
${KDE4_KDECORE_LIBS}
|
||||
|
@ -15,7 +20,6 @@ target_link_libraries(plasma-runner-bookmarks-TestChromeBookmarks
|
|||
${QT_QTSQL_LIBRARY}
|
||||
${KDE4_PLASMA_LIBS}
|
||||
${KDE4_KIO_LIBS}
|
||||
${QJSON_LIBRARIES} ${qjson_LIBRARIES}
|
||||
)
|
||||
|
||||
file(COPY chrome-config-home DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
|
Loading…
Add table
Reference in a new issue