mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Save Page screen - last missing feature from first Python QupZilla added
Introduced new global function qz_centerWidgetOnScreen
This commit is contained in:
parent
e6847166f2
commit
f24b6fcc21
Binary file not shown.
@ -133,7 +133,8 @@ SOURCES += main.cpp\
|
||||
navigation/reloadstopbutton.cpp \
|
||||
preferences/thememanager.cpp \
|
||||
network/qupzillaschemehandler.cpp \
|
||||
tools/globalfunctions.cpp
|
||||
tools/globalfunctions.cpp \
|
||||
other/pagescreen.cpp
|
||||
|
||||
HEADERS += \
|
||||
3rdparty/qtwin.h \
|
||||
@ -227,7 +228,8 @@ HEADERS += \
|
||||
navigation/reloadstopbutton.h \
|
||||
preferences/thememanager.h \
|
||||
network/qupzillaschemehandler.h \
|
||||
tools/globalfunctions.h
|
||||
tools/globalfunctions.h \
|
||||
other/pagescreen.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
@ -261,7 +263,8 @@ FORMS += \
|
||||
webview/jsprompt.ui \
|
||||
other/browsinglibrary.ui \
|
||||
webview/searchtoolbar.ui \
|
||||
preferences/thememanager.ui
|
||||
preferences/thememanager.ui \
|
||||
other/pagescreen.ui
|
||||
|
||||
RESOURCES += \
|
||||
data/icons.qrc \
|
||||
@ -288,3 +291,6 @@ win32:LIBS += User32.lib Ole32.lib Shell32.lib ShlWapi.lib Gdi32.lib ComCtl32.li
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "locationbarsettings.h"
|
||||
#include "browsinglibrary.h"
|
||||
#include "navigationbar.h"
|
||||
#include "pagescreen.h"
|
||||
|
||||
const QString QupZilla::VERSION = "1.0.0-b4";
|
||||
//const QString QupZilla::BUILDTIME = QLocale(QLocale::English).toDateTime(__DATE__" "__TIME__, "MMM d yyyy hh:mm:ss").toString("MM/dd/yyyy hh:ss");
|
||||
@ -226,9 +227,9 @@ void QupZilla::setupMenu()
|
||||
m_menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close Window"), this, SLOT(close()))->setShortcut(QKeySequence("Ctrl+Shift+W"));
|
||||
m_menuFile->addSeparator();
|
||||
m_menuFile->addAction(QIcon::fromTheme("document-save"), tr("&Save Page As..."), this, SLOT(savePage()))->setShortcut(QKeySequence("Ctrl+S"));
|
||||
m_menuFile->addAction(tr("Save Page Screen"), this, SLOT(savePageScreen()));
|
||||
m_menuFile->addAction(tr("Send Link..."), this, SLOT(sendLink()));
|
||||
m_menuFile->addAction(QIcon::fromTheme("document-print"), tr("&Print"), this, SLOT(printPage()));
|
||||
m_menuFile->addSeparator();
|
||||
m_menuFile->addAction(QIcon::fromTheme("document-print"), tr("&Print"), this, SLOT(printPage())); m_menuFile->addSeparator();
|
||||
m_menuFile->addAction(QIcon::fromTheme("application-exit"), tr("Quit"), this, SLOT(quitApp()))->setShortcut(QKeySequence("Ctrl+Q"));
|
||||
menuBar()->addMenu(m_menuFile);
|
||||
|
||||
@ -1034,6 +1035,12 @@ void QupZilla::printPage()
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
void QupZilla::savePageScreen()
|
||||
{
|
||||
PageScreen* p = new PageScreen(weView());
|
||||
p->show();
|
||||
}
|
||||
|
||||
void QupZilla::startPrivate(bool state)
|
||||
{
|
||||
if (state) {
|
||||
|
@ -143,6 +143,7 @@ private slots:
|
||||
void aboutQupZilla();
|
||||
void addTab() { m_tabWidget->addView(QUrl(), tr("New tab"), TabWidget::NewTab, true); }
|
||||
void printPage();
|
||||
void savePageScreen();
|
||||
|
||||
void aboutToShowHistoryMenu();
|
||||
void aboutToShowClosedTabsMenu();
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "bookmarksmodel.h"
|
||||
#include "iconprovider.h"
|
||||
#include "browsinglibrary.h"
|
||||
#include "globalfunctions.h"
|
||||
|
||||
BookmarksManager::BookmarksManager(QupZilla* mainClass, QWidget* parent) :
|
||||
QWidget(parent)
|
||||
@ -34,10 +35,7 @@ BookmarksManager::BookmarksManager(QupZilla* mainClass, QWidget* parent) :
|
||||
,m_bookmarksModel(mApp->bookmarksModel())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
//CENTER on scren
|
||||
const QRect screen = QApplication::desktop()->screenGeometry();
|
||||
const QRect &size = QWidget::geometry();
|
||||
QWidget::move( (screen.width()-size.width())/2, (screen.height()-size.height())/2 );
|
||||
qz_centerWidgetOnScreen(this);
|
||||
|
||||
connect(ui->deleteB, SIGNAL(clicked()), this, SLOT(deleteItem()));
|
||||
connect(ui->bookmarksTree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*)));
|
||||
|
@ -20,16 +20,14 @@
|
||||
#include "qupzilla.h"
|
||||
#include "cookiejar.h"
|
||||
#include "mainapplication.h"
|
||||
#include "globalfunctions.h"
|
||||
|
||||
CookieManager::CookieManager(QWidget* parent) :
|
||||
QWidget(parent)
|
||||
,ui(new Ui::CookieManager)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
//CENTER on scren
|
||||
const QRect screen = QApplication::desktop()->screenGeometry();
|
||||
const QRect &size = QWidget::geometry();
|
||||
QWidget::move( (screen.width()-size.width())/2, (screen.height()-size.height())/2 );
|
||||
qz_centerWidgetOnScreen(this);
|
||||
|
||||
//QTimer::singleShot(0, this, SLOT(refreshTable()));
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "networkmanager.h"
|
||||
#include "qtwin.h"
|
||||
#include "desktopnotificationsfactory.h"
|
||||
#include "globalfunctions.h"
|
||||
|
||||
DownloadManager::DownloadManager(QWidget* parent) :
|
||||
QWidget(parent)
|
||||
@ -37,10 +38,7 @@ DownloadManager::DownloadManager(QWidget* parent) :
|
||||
QtWin::extendFrameIntoClientArea(this);
|
||||
#endif
|
||||
ui->clearButton->setIcon(QIcon::fromTheme("edit-clear"));
|
||||
//CENTER on screen
|
||||
const QRect screen = QApplication::desktop()->screenGeometry();
|
||||
const QRect &size = QWidget::geometry();
|
||||
QWidget::move( (screen.width()-size.width())/2, (screen.height()-size.height())/2 );
|
||||
qz_centerWidgetOnScreen(this);
|
||||
|
||||
m_iconProvider = new QFileIconProvider();
|
||||
m_networkManager = mApp->networkManager();
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QFileIconProvider>
|
||||
#include <QDesktopWidget>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QDebug>
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "historymodel.h"
|
||||
#include "iconprovider.h"
|
||||
#include "browsinglibrary.h"
|
||||
#include "globalfunctions.h"
|
||||
|
||||
HistoryManager::HistoryManager(QupZilla* mainClass, QWidget* parent) :
|
||||
QWidget(parent)
|
||||
@ -31,10 +32,7 @@ HistoryManager::HistoryManager(QupZilla* mainClass, QWidget* parent) :
|
||||
ui->setupUi(this);
|
||||
ui->historyTree->setDefaultItemShowMode(TreeWidget::ItemsCollapsed);
|
||||
ui->historyTree->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
//CENTER on scren
|
||||
const QRect screen = QApplication::desktop()->screenGeometry();
|
||||
const QRect &size = QWidget::geometry();
|
||||
QWidget::move( (screen.width()-size.width())/2, (screen.height()-size.height())/2 );
|
||||
qz_centerWidgetOnScreen(this);
|
||||
|
||||
connect(ui->historyTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this, SLOT(itemDoubleClicked(QTreeWidgetItem*)));
|
||||
connect(ui->deleteB, SIGNAL(clicked()), this, SLOT(deleteItem()));
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "rssmanager.h"
|
||||
#include "mainapplication.h"
|
||||
#include "downloaditem.h"
|
||||
#include "globalfunctions.h"
|
||||
|
||||
BrowsingLibrary::BrowsingLibrary(QupZilla* mainClass, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@ -39,10 +40,7 @@ BrowsingLibrary::BrowsingLibrary(QupZilla* mainClass, QWidget *parent)
|
||||
resize(settings.value("size", QSize(760, 470)).toSize());
|
||||
settings.endGroup();
|
||||
|
||||
//CENTER on scren
|
||||
const QRect screen = QApplication::desktop()->screenGeometry();
|
||||
const QRect &size = QWidget::geometry();
|
||||
QWidget::move( (screen.width()-size.width())/2, (screen.height()-size.height())/2 );
|
||||
qz_centerWidgetOnScreen(this);
|
||||
|
||||
ui->tabs->AddTab(m_historyManager, QIcon(":/icons/other/bighistory.png"), tr("History"));
|
||||
ui->tabs->AddTab(m_bookmarksManager, QIcon(":/icons/other/bigstar.png"), tr("Bookmarks"));
|
||||
|
@ -19,7 +19,6 @@
|
||||
#define LIBRARY_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFileInfo>
|
||||
#include <QCloseEvent>
|
||||
|
||||
|
60
src/other/pagescreen.cpp
Normal file
60
src/other/pagescreen.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include "pagescreen.h"
|
||||
#include "ui_pagescreen.h"
|
||||
#include "webview.h"
|
||||
#include "globalfunctions.h"
|
||||
|
||||
PageScreen::PageScreen(WebView *view)
|
||||
: QWidget()
|
||||
, ui(new Ui::PageScreen)
|
||||
, m_view(view)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui->setupUi(this);
|
||||
qz_centerWidgetOnScreen(this);
|
||||
|
||||
createPixmap();
|
||||
ui->label->setPixmap(m_pagePixmap);
|
||||
|
||||
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
|
||||
}
|
||||
|
||||
void PageScreen::buttonClicked(QAbstractButton* b)
|
||||
{
|
||||
QString path;
|
||||
|
||||
switch (ui->buttonBox->standardButton(b)) {
|
||||
case QDialogButtonBox::Cancel:
|
||||
close();
|
||||
break;
|
||||
|
||||
case QDialogButtonBox::Save:
|
||||
path = QFileDialog::getSaveFileName(this, tr("Save Page Screen..."), tr("screen.png"));
|
||||
if (!path.isEmpty())
|
||||
m_pagePixmap.save(path);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PageScreen::createPixmap()
|
||||
{
|
||||
QWebPage* page = m_view->page();
|
||||
QSize originalSize = page->viewportSize();
|
||||
page->setViewportSize(page->mainFrame()->contentsSize());
|
||||
|
||||
QImage image(page->viewportSize(), QImage::Format_ARGB32);
|
||||
QPainter painter(&image);
|
||||
page->mainFrame()->render(&painter);
|
||||
painter.end();
|
||||
|
||||
m_pagePixmap = QPixmap::fromImage(image);
|
||||
|
||||
page->setViewportSize(originalSize);
|
||||
}
|
||||
|
||||
PageScreen::~PageScreen()
|
||||
{
|
||||
delete ui;
|
||||
}
|
34
src/other/pagescreen.h
Normal file
34
src/other/pagescreen.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef PAGESCREEN_H
|
||||
#define PAGESCREEN_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QWebFrame>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QAbstractButton>
|
||||
#include <QFileDialog>
|
||||
|
||||
namespace Ui {
|
||||
class PageScreen;
|
||||
}
|
||||
|
||||
class WebView;
|
||||
class PageScreen : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PageScreen(WebView* view);
|
||||
~PageScreen();
|
||||
|
||||
private slots:
|
||||
void buttonClicked(QAbstractButton* b);
|
||||
|
||||
private:
|
||||
void createPixmap();
|
||||
|
||||
Ui::PageScreen *ui;
|
||||
WebView* m_view;
|
||||
QPixmap m_pagePixmap;
|
||||
};
|
||||
|
||||
#endif // PAGESCREEN_H
|
81
src/other/pagescreen.ui
Normal file
81
src/other/pagescreen.ui
Normal file
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PageScreen</class>
|
||||
<widget class="QWidget" name="PageScreen">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>470</width>
|
||||
<height>425</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Page Screen</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>470</width>
|
||||
<height>376</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -19,6 +19,7 @@
|
||||
#include "webview.h"
|
||||
#include "htmlhighlighter.h"
|
||||
#include "sourceviewersearch.h"
|
||||
#include "globalfunctions.h"
|
||||
|
||||
SourceViewer::SourceViewer(QWebPage* page, const QString &selectedHtml) :
|
||||
QWidget(0)
|
||||
@ -90,10 +91,7 @@ SourceViewer::SourceViewer(QWebPage* page, const QString &selectedHtml) :
|
||||
menuView->actions().at(3)->setChecked(true);
|
||||
menuBar->addMenu(menuView);
|
||||
|
||||
//CENTER on scren
|
||||
const QRect screen = QApplication::desktop()->screenGeometry();
|
||||
const QRect &size = QWidget::geometry();
|
||||
QWidget::move( (screen.width()-size.width())/2, (screen.height()-size.height())/2 );
|
||||
qz_centerWidgetOnScreen(this);
|
||||
|
||||
//Highlight selectedHtml
|
||||
if (!selectedHtml.isEmpty())
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <QWebPage>
|
||||
#include <QWebFrame>
|
||||
#include <QStyle>
|
||||
#include <QDesktopWidget>
|
||||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QFile>
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "treewidget.h"
|
||||
#include "iconprovider.h"
|
||||
#include "browsinglibrary.h"
|
||||
#include "globalfunctions.h"
|
||||
|
||||
RSSManager::RSSManager(QupZilla* mainClass, QWidget* parent) :
|
||||
QWidget(parent)
|
||||
@ -30,10 +31,7 @@ RSSManager::RSSManager(QupZilla* mainClass, QWidget* parent) :
|
||||
,p_QupZilla(mainClass)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
// CENTER on scren
|
||||
const QRect screen = QApplication::desktop()->screenGeometry();
|
||||
const QRect &size = geometry();
|
||||
QWidget::move( (screen.width()-size.width())/2, (screen.height()-size.height())/2 );
|
||||
qz_centerWidgetOnScreen(this);
|
||||
|
||||
ui->tabWidget->setElideMode(Qt::ElideRight);
|
||||
m_networkManager = new QNetworkAccessManager();
|
||||
|
@ -20,3 +20,10 @@ QByteArray qz_readAllFileContents(const QString &filename)
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
void qz_centerWidgetOnScreen(QWidget *w)
|
||||
{
|
||||
const QRect screen = QApplication::desktop()->screenGeometry();
|
||||
const QRect &size = w->geometry();
|
||||
w->move( (screen.width()-size.width())/2, (screen.height()-size.height())/2 );
|
||||
}
|
||||
|
@ -5,8 +5,13 @@
|
||||
#include <QPixmap>
|
||||
#include <QBuffer>
|
||||
#include <QFile>
|
||||
#include <QWidget>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
QByteArray qz_pixmapToByteArray(const QPixmap &pix);
|
||||
QByteArray qz_readAllFileContents(const QString &filename);
|
||||
|
||||
void qz_centerWidgetOnScreen(QWidget* w);
|
||||
|
||||
#endif // GLOBALFUNCTIONS_H
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user