Work on downloader.

This commit is contained in:
Martin Rotter 2015-01-09 19:55:45 +01:00
parent c3aeb0e9db
commit 50ef9c6981
23 changed files with 436 additions and 670 deletions

View File

@ -355,6 +355,8 @@ set(APP_SOURCES
src/gui/styleditemdelegatewithoutfocus.cpp
src/gui/formbackupdatabasesettings.cpp
src/gui/formrestoredatabasesettings.cpp
src/gui/edittableview.cpp
src/gui/squeezelabel.cpp
# DYNAMIC-SHORTCUTS sources.
src/dynamic-shortcuts/shortcutcatcher.cpp
@ -373,6 +375,7 @@ set(APP_SOURCES
src/miscellaneous/skinfactory.cpp
src/miscellaneous/iconfactory.cpp
src/miscellaneous/iofactory.cpp
src/miscellaneous/autosaver.cpp
# CORE sources.
src/core/messagesmodel.cpp
@ -398,9 +401,6 @@ set(APP_SOURCES
src/network-web/webview.cpp
src/network-web/downloader.cpp
src/network-web/downloadmanager.cpp
src/network-web/edittableview.cpp
src/network-web/autosaver.cpp
src/network-web/squeezelabel.cpp
# MAIN sources.
src/main.cpp
@ -446,6 +446,8 @@ set(APP_HEADERS
src/gui/formimportexport.h
src/gui/formbackupdatabasesettings.h
src/gui/formrestoredatabasesettings.h
src/gui/edittableview.h
src/gui/squeezelabel.h
# DYNAMIC-SHORTCUTS headers.
src/dynamic-shortcuts/dynamicshortcutswidget.h
@ -460,6 +462,7 @@ set(APP_HEADERS
src/miscellaneous/databasefactory.h
src/miscellaneous/iconfactory.h
src/miscellaneous/skinfactory.h
src/miscellaneous/autosaver.h
# CORE headers.
src/core/messagesmodel.h
@ -479,9 +482,6 @@ set(APP_HEADERS
src/network-web/webview.h
src/network-web/downloader.h
src/network-web/downloadmanager.h
src/network-web/edittableview.h
src/network-web/autosaver.h
src/network-web/squeezelabel.h
)
# APP form files.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

69
src/gui/edittableview.cpp Normal file
View File

@ -0,0 +1,69 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
//
// RSS Guard is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// RSS Guard 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 RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#include "edittableview.h"
#include <qevent.h>
EditTableView::EditTableView(QWidget *parent)
: QTableView(parent)
{
}
void EditTableView::keyPressEvent(QKeyEvent *event)
{
if (model() && event->key() == Qt::Key_Delete) {
removeSelected();
event->setAccepted(true);
} else {
QAbstractItemView::keyPressEvent(event);
}
}
void EditTableView::removeSelected()
{
if (!model() || !selectionModel() || !selectionModel()->hasSelection())
return;
QModelIndexList selectedRows = selectionModel()->selectedRows();
if (selectedRows.isEmpty())
return;
int newSelectedRow = selectedRows.at(0).row();
for (int i = selectedRows.count() - 1; i >= 0; --i) {
QModelIndex idx = selectedRows.at(i);
model()->removeRow(idx.row(), rootIndex());
}
// select the item at the same position
QModelIndex newSelectedIndex = model()->index(newSelectedRow, 0, rootIndex());
// if that was the last item
if (!newSelectedIndex.isValid())
newSelectedIndex = model()->index(newSelectedRow - 1, 0, rootIndex());
selectionModel()->select(newSelectedIndex, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
setCurrentIndex(newSelectedIndex);
}
void EditTableView::removeAll()
{
if (!model())
return;
model()->removeRows(0, model()->rowCount(rootIndex()), rootIndex());
}

37
src/gui/edittableview.h Normal file
View File

@ -0,0 +1,37 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
//
// RSS Guard is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// RSS Guard 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 RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#ifndef EDITTABLEVIEW_H
#define EDITTABLEVIEW_H
#include <qtableview.h>
class EditTableView : public QTableView
{
Q_OBJECT
public:
EditTableView(QWidget *parent = 0);
void keyPressEvent(QKeyEvent *event);
public slots:
void removeSelected();
void removeAll();
};
#endif // EDITTABLEVIEW_H

37
src/gui/squeezelabel.cpp Normal file
View File

@ -0,0 +1,37 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
//
// RSS Guard is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// RSS Guard 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 RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#include "squeezelabel.h"
SqueezeLabel::SqueezeLabel(QWidget *parent)
: QLabel(parent)
{
}
void SqueezeLabel::paintEvent(QPaintEvent *event)
{
if (m_SqueezedTextCache != text()) {
m_SqueezedTextCache = text();
QFontMetrics fm = fontMetrics();
if (fm.width(m_SqueezedTextCache) > contentsRect().width()) {
QString elided = fm.elidedText(text(), Qt::ElideMiddle, width());
setText(elided);
}
}
QLabel::paintEvent(event);
}

42
src/gui/squeezelabel.h Normal file
View File

@ -0,0 +1,42 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
//
// RSS Guard is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// RSS Guard 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 RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#ifndef SQUEEZELABEL_H
#define SQUEEZELABEL_H
#include <qlabel.h>
/*
A label that will squeeze the set text to fit within the size of the
widget. The text will be elided in the middle.
*/
class SqueezeLabel : public QLabel
{
Q_OBJECT
public:
SqueezeLabel(QWidget *parent = 0);
protected:
void paintEvent(QPaintEvent *event);
private:
QString m_SqueezedTextCache;
};
#endif // SQUEEZELABEL_H

View File

@ -112,7 +112,7 @@ void TabBar::mousePressEvent(QMouseEvent *event) {
// NOTE: This needs to be done here because
// destination does not know the original event.
if (event->button() & Qt::MiddleButton && qApp->settings()->value(GROUP(GUI), SETTING(GUI::TabCloseMiddleClick)).toBool()) {
if (tabType(tab_index) == TabBar::Closable) {
if (tabType(tab_index) == TabBar::Closable || tabType(tab_index) == TabBar::DownloadManager) {
// This tab is closable, so we can close it.
emit tabCloseRequested(tab_index);
}

View File

@ -0,0 +1,74 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
//
// RSS Guard is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// RSS Guard 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 RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#include "autosaver.h"
#include <qdir.h>
#include <qcoreapplication.h>
#include <qmetaobject.h>
#include <qdebug.h>
#define AUTOSAVE_IN 1000 * 3 // seconds
#define MAXWAIT 1000 * 15 // seconds
AutoSaver::AutoSaver(QObject *parent) : QObject(parent)
{
Q_ASSERT(parent);
}
AutoSaver::~AutoSaver()
{
if (m_timer.isActive()) {
qWarning() << "AutoSaver: still active when destroyed, changes not saved.";
if (parent() && parent()->metaObject())
qWarning() << parent() << parent()->metaObject()->className() << "should call saveIfNeccessary";
}
}
void AutoSaver::changeOccurred()
{
if (m_firstChange.isNull())
m_firstChange.start();
if (m_firstChange.elapsed() > MAXWAIT) {
saveIfNeccessary();
} else {
m_timer.start(AUTOSAVE_IN, this);
}
}
void AutoSaver::timerEvent(QTimerEvent *event)
{
if (event->timerId() == m_timer.timerId()) {
saveIfNeccessary();
} else {
QObject::timerEvent(event);
}
}
void AutoSaver::saveIfNeccessary()
{
if (!m_timer.isActive())
return;
m_timer.stop();
m_firstChange = QTime();
if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) {
qWarning() << "AutoSaver: error invoking slot save() on parent";
}
}

View File

@ -0,0 +1,53 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
//
// RSS Guard is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// RSS Guard 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 RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#ifndef AUTOSAVER_H
#define AUTOSAVER_H
#include <qobject.h>
#include <qbasictimer.h>
#include <qdatetime.h>
/*
This class will call the save() slot on the parent object when the parent changes.
It will wait several seconds after changed() to combining multiple changes and
prevent continuous writing to disk.
*/
class AutoSaver : public QObject
{
Q_OBJECT
public:
AutoSaver(QObject *parent);
~AutoSaver();
void saveIfNeccessary();
public slots:
void changeOccurred();
protected:
void timerEvent(QTimerEvent *event);
private:
QBasicTimer m_timer;
QTime m_firstChange;
};
#endif // AUTOSAVER_H

View File

@ -1,119 +0,0 @@
/*
* Copyright 2008 Benjamin C. Meyer <ben@meyerhome.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
*/
/****************************************************************************
**
** Copyright (C) 2007-2008 Trolltech ASA. All rights reserved.
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Alternatively you may (at
** your option) use any later version of the GNU General Public
** License if such license has been publicly approved by Trolltech ASA
** (or its successors, if any) and the KDE Free Qt Foundation. In
** addition, as a special exception, Trolltech gives you certain
** additional rights. These rights are described in the Trolltech GPL
** Exception version 1.2, which can be found at
** http://www.trolltech.com/products/qt/gplexception/ and in the file
** GPL_EXCEPTION.txt in this package.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/. If
** you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** In addition, as a special exception, Trolltech, as the sole
** copyright holder for Qt Designer, grants users of the Qt/Eclipse
** Integration plug-in the right for the Qt/Eclipse Integration to
** link to functionality provided by Qt Designer and its related
** libraries.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not expressly
** granted herein.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include "autosaver.h"
#include <qdir.h>
#include <qcoreapplication.h>
#include <qmetaobject.h>
#include <qdebug.h>
#define AUTOSAVE_IN 1000 * 3 // seconds
#define MAXWAIT 1000 * 15 // seconds
AutoSaver::AutoSaver(QObject *parent) : QObject(parent)
{
Q_ASSERT(parent);
}
AutoSaver::~AutoSaver()
{
if (m_timer.isActive()) {
qWarning() << "AutoSaver: still active when destroyed, changes not saved.";
if (parent() && parent()->metaObject())
qWarning() << parent() << parent()->metaObject()->className() << "should call saveIfNeccessary";
}
}
void AutoSaver::changeOccurred()
{
if (m_firstChange.isNull())
m_firstChange.start();
if (m_firstChange.elapsed() > MAXWAIT) {
saveIfNeccessary();
} else {
m_timer.start(AUTOSAVE_IN, this);
}
}
void AutoSaver::timerEvent(QTimerEvent *event)
{
if (event->timerId() == m_timer.timerId()) {
saveIfNeccessary();
} else {
QObject::timerEvent(event);
}
}
void AutoSaver::saveIfNeccessary()
{
if (!m_timer.isActive())
return;
m_timer.stop();
m_firstChange = QTime();
if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) {
qWarning() << "AutoSaver: error invoking slot save() on parent";
}
}

View File

@ -1,98 +0,0 @@
/*
* Copyright 2008 Benjamin C. Meyer <ben@meyerhome.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
*/
/****************************************************************************
**
** Copyright (C) 2007-2008 Trolltech ASA. All rights reserved.
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Alternatively you may (at
** your option) use any later version of the GNU General Public
** License if such license has been publicly approved by Trolltech ASA
** (or its successors, if any) and the KDE Free Qt Foundation. In
** addition, as a special exception, Trolltech gives you certain
** additional rights. These rights are described in the Trolltech GPL
** Exception version 1.2, which can be found at
** http://www.trolltech.com/products/qt/gplexception/ and in the file
** GPL_EXCEPTION.txt in this package.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/. If
** you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** In addition, as a special exception, Trolltech, as the sole
** copyright holder for Qt Designer, grants users of the Qt/Eclipse
** Integration plug-in the right for the Qt/Eclipse Integration to
** link to functionality provided by Qt Designer and its related
** libraries.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not expressly
** granted herein.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#ifndef AUTOSAVER_H
#define AUTOSAVER_H
#include <qobject.h>
#include <qbasictimer.h>
#include <qdatetime.h>
/*
This class will call the save() slot on the parent object when the parent changes.
It will wait several seconds after changed() to combining multiple changes and
prevent continuous writing to disk.
*/
class AutoSaver : public QObject
{
Q_OBJECT
public:
AutoSaver(QObject *parent);
~AutoSaver();
void saveIfNeccessary();
public slots:
void changeOccurred();
protected:
void timerEvent(QTimerEvent *event);
private:
QBasicTimer m_timer;
QTime m_firstChange;
};
#endif // AUTOSAVER_H

View File

@ -1,7 +1,8 @@
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DownloadItem</class>
<widget class="QWidget" name="DownloadItem" >
<property name="geometry" >
<widget class="QWidget" name="DownloadItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@ -9,54 +10,51 @@
<height>110</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" >
<property name="margin" >
<number>0</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="fileIcon" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<widget class="QLabel" name="fileIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<property name="text">
<string>Ico</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="SqueezeLabel" native="1" name="fileNameLabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
<widget class="SqueezeLabel" name="fileNameLabel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" stdset="0" >
<property name="text" stdset="0">
<string>Filename</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar" >
<property name="value" >
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="SqueezeLabel" native="1" name="downloadInfoLabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
<widget class="SqueezeLabel" name="downloadInfoLabel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" stdset="0" >
<property name="text" stdset="0">
<string/>
</property>
</widget>
@ -64,13 +62,13 @@
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout" >
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer" >
<property name="orientation" >
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" stdset="0">
<size>
<width>17</width>
<height>1</height>
@ -79,35 +77,35 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="tryAgainButton" >
<property name="enabled" >
<widget class="QPushButton" name="tryAgainButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text" >
<property name="text">
<string>Try Again</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="stopButton" >
<property name="text" >
<widget class="QPushButton" name="stopButton">
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="openButton" >
<property name="text" >
<widget class="QPushButton" name="openButton">
<property name="text">
<string>Open</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2" >
<property name="orientation" >
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" stdset="0">
<size>
<width>17</width>
<height>5</height>

View File

@ -1,69 +1,23 @@
/*
* Copyright 2008-2009 Benjamin C. Meyer <ben@meyerhome.net>
* Copyright 2008 Jason A. Donenfeld <Jason@zx2c4.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
*/
/****************************************************************************
**
** Copyright (C) 2008-2008 Trolltech ASA. All rights reserved.
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Alternatively you may (at
** your option) use any later version of the GNU General Public
** License if such license has been publicly approved by Trolltech ASA
** (or its successors, if any) and the KDE Free Qt Foundation. In
** addition, as a special exception, Trolltech gives you certain
** additional rights. These rights are described in the Trolltech GPL
** Exception version 1.2, which can be found at
** http://www.trolltech.com/products/qt/gplexception/ and in the file
** GPL_EXCEPTION.txt in this package.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/. If
** you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** In addition, as a special exception, Trolltech, as the sole
** copyright holder for Qt Designer, grants users of the Qt/Eclipse
** Integration plug-in the right for the Qt/Eclipse Integration to
** link to functionality provided by Qt Designer and its related
** libraries.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not expressly
** granted herein.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
//
// RSS Guard is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// RSS Guard 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 RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#include "downloadmanager.h"
#include "autosaver.h"
#include "miscellaneous/autosaver.h"
#include "miscellaneous/application.h"
@ -483,7 +437,6 @@ DownloadManager::DownloadManager(QWidget *parent)
downloadsView->horizontalHeader()->setStretchLastSection(true);
downloadsView->setModel(m_model);
connect(cleanupButton, SIGNAL(clicked()), this, SLOT(cleanup()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
load();
}
@ -570,7 +523,6 @@ void DownloadManager::addItem(DownloadItem *item)
m_model->beginInsertRows(QModelIndex(), row, row);
m_downloads.append(item);
m_model->endInsertRows();
updateItemCount();
downloadsView->setIndexWidget(m_model->index(row, 0), item);
QIcon icon = style()->standardIcon(QStyle::SP_FileIcon);
item->fileIcon->setPixmap(icon.pixmap(48, 48));
@ -719,7 +671,6 @@ void DownloadManager::cleanup()
if (m_downloads.isEmpty())
return;
m_model->removeRows(0, m_downloads.count());
updateItemCount();
updateActiveItemCount();
if (m_downloads.isEmpty() && m_iconProvider) {
delete m_iconProvider;
@ -728,12 +679,6 @@ void DownloadManager::cleanup()
m_autoSaver->changeOccurred();
}
void DownloadManager::updateItemCount()
{
int count = m_downloads.count();
itemCount->setText(tr("%n Download(s)", "", count));
}
void DownloadManager::setDownloadDirectory(const QString &directory)
{
m_downloadDirectory = directory;
@ -821,7 +766,6 @@ bool DownloadModel::removeRows(int row, int count, const QModelIndex &parent)
}
}
m_downloadManager->m_autoSaver->changeOccurred();
m_downloadManager->updateItemCount();
return true;
}

View File

@ -1,65 +1,19 @@
/*
* Copyright 2008-2009 Benjamin C. Meyer <ben@meyerhome.net>
* Copyright 2008 Jason A. Donenfeld <Jason@zx2c4.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
*/
/****************************************************************************
**
** Copyright (C) 2008-2008 Trolltech ASA. All rights reserved.
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Alternatively you may (at
** your option) use any later version of the GNU General Public
** License if such license has been publicly approved by Trolltech ASA
** (or its successors, if any) and the KDE Free Qt Foundation. In
** addition, as a special exception, Trolltech gives you certain
** additional rights. These rights are described in the Trolltech GPL
** Exception version 1.2, which can be found at
** http://www.trolltech.com/products/qt/gplexception/ and in the file
** GPL_EXCEPTION.txt in this package.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/. If
** you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** In addition, as a special exception, Trolltech, as the sole
** copyright holder for Qt Designer, grants users of the Qt/Eclipse
** Integration plug-in the right for the Qt/Eclipse Integration to
** link to functionality provided by Qt Designer and its related
** libraries.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not expressly
** granted herein.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
//
// RSS Guard is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// RSS Guard 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 RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#ifndef DOWNLOADMANAGER_H
#define DOWNLOADMANAGER_H
@ -180,7 +134,6 @@ class DownloadManager : public TabContent, public Ui_DownloadManager {
private:
void addItem(DownloadItem *item);
void updateItemCount();
void load();
void updateActiveItemCount();

View File

@ -14,10 +14,13 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<item row="0" column="0">
<widget class="EditTableView" name="downloadsView">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="dragEnabled">
<bool>true</bool>
@ -40,7 +43,7 @@
</widget>
</item>
<item>
<spacer>
<spacer name="spacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -54,46 +57,7 @@
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QLabel" name="itemCount">
<property name="text">
<string>0 Items</string>
</property>
</widget>
</item>
</layout>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>30</x>
<y>10</y>
<width>133</width>
<height>25</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>

View File

@ -1,81 +0,0 @@
/**
* Copyright (c) 2008, Benjamin C. Meyer <ben@meyerhome.net>
* Copyright (c) 2009, Jakub Wieczorek <faw217@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Benjamin Meyer nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "edittableview.h"
#include <qevent.h>
EditTableView::EditTableView(QWidget *parent)
: QTableView(parent)
{
}
void EditTableView::keyPressEvent(QKeyEvent *event)
{
if (model() && event->key() == Qt::Key_Delete) {
removeSelected();
event->setAccepted(true);
} else {
QAbstractItemView::keyPressEvent(event);
}
}
void EditTableView::removeSelected()
{
if (!model() || !selectionModel() || !selectionModel()->hasSelection())
return;
QModelIndexList selectedRows = selectionModel()->selectedRows();
if (selectedRows.isEmpty())
return;
int newSelectedRow = selectedRows.at(0).row();
for (int i = selectedRows.count() - 1; i >= 0; --i) {
QModelIndex idx = selectedRows.at(i);
model()->removeRow(idx.row(), rootIndex());
}
// select the item at the same position
QModelIndex newSelectedIndex = model()->index(newSelectedRow, 0, rootIndex());
// if that was the last item
if (!newSelectedIndex.isValid())
newSelectedIndex = model()->index(newSelectedRow - 1, 0, rootIndex());
selectionModel()->select(newSelectedIndex, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
setCurrentIndex(newSelectedIndex);
}
void EditTableView::removeAll()
{
if (!model())
return;
model()->removeRows(0, model()->rowCount(rootIndex()), rootIndex());
}

View File

@ -1,49 +0,0 @@
/**
* Copyright (c) 2008, Benjamin C. Meyer <ben@meyerhome.net>
* Copyright (c) 2009, Jakub Wieczorek <faw217@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Benjamin Meyer nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef EDITTABLEVIEW_H
#define EDITTABLEVIEW_H
#include <qtableview.h>
class EditTableView : public QTableView
{
Q_OBJECT
public:
EditTableView(QWidget *parent = 0);
void keyPressEvent(QKeyEvent *event);
public slots:
void removeSelected();
void removeAll();
};
#endif // EDITTABLEVIEW_H

View File

@ -1,48 +0,0 @@
/**
* Copyright (c) 2009, Benjamin C. Meyer <ben@meyerhome.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Benjamin Meyer nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "squeezelabel.h"
SqueezeLabel::SqueezeLabel(QWidget *parent)
: QLabel(parent)
{
}
void SqueezeLabel::paintEvent(QPaintEvent *event)
{
if (m_SqueezedTextCache != text()) {
m_SqueezedTextCache = text();
QFontMetrics fm = fontMetrics();
if (fm.width(m_SqueezedTextCache) > contentsRect().width()) {
QString elided = fm.elidedText(text(), Qt::ElideMiddle, width());
setText(elided);
}
}
QLabel::paintEvent(event);
}

View File

@ -1,53 +0,0 @@
/**
* Copyright (c) 2009, Benjamin C. Meyer <ben@meyerhome.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Benjamin Meyer nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef SQUEEZELABEL_H
#define SQUEEZELABEL_H
#include <qlabel.h>
/*
A label that will squeeze the set text to fit within the size of the
widget. The text will be elided in the middle.
*/
class SqueezeLabel : public QLabel
{
Q_OBJECT
public:
SqueezeLabel(QWidget *parent = 0);
protected:
void paintEvent(QPaintEvent *event);
private:
QString m_SqueezedTextCache;
};
#endif // SQUEEZELABEL_H

View File

@ -19,6 +19,7 @@
#include "network-web/webbrowsernetworkaccessmanager.h"
#include "network-web/webbrowser.h"
#include "miscellaneous/application.h"
#include <QNetworkReply>
#include <QWebFrame>
@ -29,6 +30,8 @@ WebPage::WebPage(QObject *parent)
// Setup global network access manager.
// NOTE: This makes network settings easy for all web browsers.
setNetworkAccessManager(WebBrowserNetworkAccessManager::instance());
setForwardUnsupportedContent(true);
connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(handleUnsupportedContent(QNetworkReply*)));
}
WebPage::~WebPage() {
@ -38,6 +41,27 @@ QString WebPage::toPlainText() const {
return mainFrame()->toPlainText();
}
void WebPage::handleUnsupportedContent(QNetworkReply *reply) {
if (!reply)
return;
QUrl replyUrl = reply->url();
if (replyUrl.scheme() == QLatin1String("abp"))
return;
switch (reply->error()) {
case QNetworkReply::NoError:
if (reply->header(QNetworkRequest::ContentTypeHeader).isValid()) {
qApp->downloadManager()->handleUnsupportedContent(reply);
return;
}
default:
return;
}
}
QString WebPage::toHtml() const {
return mainFrame()->toHtml();
}

View File

@ -32,6 +32,9 @@ class WebPage : public QWebPage {
QString toHtml() const;
QString toPlainText() const;
private slots:
void handleUnsupportedContent(QNetworkReply *reply);
protected:
bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type);
};

View File

@ -112,6 +112,7 @@ void WebView::saveCurrentPageToFile() {
void WebView::createConnections() {
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(popupContextMenu(QPoint)));
connect(page(), SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadLink(QNetworkRequest)));
connect(m_actionSavePageAs, SIGNAL(triggered()), this, SLOT(saveCurrentPageToFile()));
connect(m_actionPrint, SIGNAL(triggered()), this, SLOT(printCurrentPage()));
@ -126,6 +127,7 @@ void WebView::setupIcons() {
m_actionCopySelectedItem->setIcon(qApp->icons()->fromTheme("edit-copy"));
m_actionCopyLink->setIcon(qApp->icons()->fromTheme("edit-copy"));
m_actionCopyImage->setIcon(qApp->icons()->fromTheme("edit-copy-image"));
m_actionSaveHyperlinkAs->setIcon(qApp->icons()->fromTheme("document-download"));
#if QT_VERSION >= 0x040800
m_actionCopyImageUrl->setIcon(qApp->icons()->fromTheme("edit-copy"));
@ -157,6 +159,11 @@ void WebView::initializeActions() {
addAction(m_actionCopySelectedItem);
#endif
m_actionSaveHyperlinkAs = pageAction(QWebPage::DownloadLinkToDisk);
m_actionSaveHyperlinkAs->setParent(this);
m_actionSaveHyperlinkAs->setText(tr("Save as..."));
m_actionSaveHyperlinkAs->setToolTip(tr("Download content from the hyperlink."));
m_actionCopyLink = pageAction(QWebPage::CopyLinkToClipboard);
m_actionCopyLink->setParent(this);
m_actionCopyLink->setText(tr("Copy link url"));
@ -167,7 +174,7 @@ void WebView::initializeActions() {
m_actionCopyImage->setText(tr("Copy image"));
m_actionCopyImage->setToolTip(tr("Copy image to clipboard."));
m_actionSavePageAs = new QAction(qApp->icons()->fromTheme("document-export"), tr("Save page as..."), this);
m_actionSavePageAs = new QAction(qApp->icons()->fromTheme("document-download"), tr("Save page as..."), this);
#if QT_VERSION >= 0x040800
m_actionCopyImageUrl = pageAction(QWebPage::CopyImageUrlToClipboard);
@ -246,6 +253,7 @@ void WebView::popupContextMenu(const QPoint &pos) {
link_submenu.addAction(m_actionOpenLinkNewTab);
link_submenu.addAction(m_actionOpenLinkExternally);
link_submenu.addAction(m_actionCopyLink);
link_submenu.addAction(m_actionSaveHyperlinkAs);
}
if (!hit_result.pixmap().isNull()) {
@ -273,6 +281,10 @@ void WebView::printCurrentPage() {
print_preview.data()->exec();
}
void WebView::downloadLink(const QNetworkRequest &request) {
qApp->downloadManager()->download(request);
}
void WebView::mousePressEvent(QMouseEvent *event) {
if (event->button() & Qt::LeftButton && event->modifiers() & Qt::ControlModifier) {
QWebHitTestResult hit_result = page()->mainFrame()->hitTestContent(event->pos());

View File

@ -71,6 +71,9 @@ class WebView : public QWebView {
void printCurrentPage();
private slots:
void downloadLink(const QNetworkRequest &request);
protected:
// Initializes all actions.
void initializeActions();
@ -97,6 +100,7 @@ class WebView : public QWebView {
QAction *m_actionCopyLink;
QAction *m_actionCopyImage;
QAction *m_actionSavePageAs;
QAction *m_actionSaveHyperlinkAs;
#if QT_VERSION >= 0x040800
QAction *m_actionCopyImageUrl;