Icons for c-menu for web browser.
This commit is contained in:
parent
815d15728d
commit
eb604bb848
10 changed files with 56 additions and 23 deletions
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
After Width: | Height: | Size: 671 B |
Binary file not shown.
After Width: | Height: | Size: 995 B |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
|
@ -12,10 +12,12 @@
|
||||||
BaseWebView::BaseWebView(QWidget *parent)
|
BaseWebView::BaseWebView(QWidget *parent)
|
||||||
: QWebView(parent), m_page(new BaseWebPage(this)) {
|
: QWebView(parent), m_page(new BaseWebPage(this)) {
|
||||||
setPage(m_page);
|
setPage(m_page);
|
||||||
|
initializeActions();
|
||||||
createConnections();
|
createConnections();
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseWebView::~BaseWebView() {
|
BaseWebView::~BaseWebView() {
|
||||||
|
qDebug("Destroying BaseWebView.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWebView::onLoadFinished(bool ok) {
|
void BaseWebView::onLoadFinished(bool ok) {
|
||||||
|
@ -30,6 +32,38 @@ void BaseWebView::createConnections() {
|
||||||
this, &BaseWebView::onLoadFinished);
|
this, &BaseWebView::onLoadFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseWebView::setupIcons() {
|
||||||
|
m_actionReload->setIcon(ThemeFactory::fromTheme("view-refresh"));
|
||||||
|
m_actionCopyLink->setIcon(ThemeFactory::fromTheme("edit-copy"));
|
||||||
|
m_actionCopyImage->setIcon(ThemeFactory::fromTheme("insert-image"));
|
||||||
|
m_actionCopyImageUrl->setIcon(ThemeFactory::fromTheme("edit-copy"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseWebView::initializeActions() {
|
||||||
|
// Create needed actions.
|
||||||
|
m_actionReload = pageAction(QWebPage::Reload);
|
||||||
|
m_actionReload->setParent(this);
|
||||||
|
m_actionReload->setText(tr("Reload web page"));
|
||||||
|
m_actionReload->setToolTip(tr("Reload current web page"));
|
||||||
|
|
||||||
|
m_actionCopyLink = pageAction(QWebPage::CopyLinkToClipboard);
|
||||||
|
m_actionCopyLink->setParent(this);
|
||||||
|
m_actionCopyLink->setText(tr("Copy link url"));
|
||||||
|
m_actionCopyLink->setToolTip(tr("Copy link url to clipboard"));
|
||||||
|
|
||||||
|
|
||||||
|
m_actionCopyImage = pageAction(QWebPage::CopyImageToClipboard);
|
||||||
|
m_actionCopyImage->setParent(this);
|
||||||
|
m_actionCopyImage->setText(tr("Copy image"));
|
||||||
|
m_actionCopyImage->setToolTip(tr("Copy image to clipboard"));
|
||||||
|
|
||||||
|
|
||||||
|
m_actionCopyImageUrl = pageAction(QWebPage::CopyImageUrlToClipboard);
|
||||||
|
m_actionCopyImageUrl->setParent(this);
|
||||||
|
m_actionCopyImageUrl->setText(tr("Copy image url"));
|
||||||
|
m_actionCopyImageUrl->setToolTip(tr("Copy image url to clipboard"));
|
||||||
|
}
|
||||||
|
|
||||||
void BaseWebView::displayErrorPage() {
|
void BaseWebView::displayErrorPage() {
|
||||||
// TODO: Add better custom error page.
|
// TODO: Add better custom error page.
|
||||||
setHtml("error", url());
|
setHtml("error", url());
|
||||||
|
@ -40,41 +74,28 @@ void BaseWebView::contextMenuEvent(QContextMenuEvent *event) {
|
||||||
QMenu image_submenu(tr("Image"), &context_menu);
|
QMenu image_submenu(tr("Image"), &context_menu);
|
||||||
QWebHitTestResult hit_result = page()->mainFrame()->hitTestContent(event->pos());
|
QWebHitTestResult hit_result = page()->mainFrame()->hitTestContent(event->pos());
|
||||||
|
|
||||||
// Obtain needed actions.
|
image_submenu.setIcon(ThemeFactory::fromTheme("image-x-generic"));
|
||||||
QAction *action_reload = pageAction(QWebPage::Reload);
|
|
||||||
action_reload->setText(tr("Reload web page"));
|
// Assemble the menu from actions.
|
||||||
action_reload->setToolTip(tr("Reload current web page"));
|
context_menu.addAction(m_actionReload);
|
||||||
context_menu.addAction(action_reload);
|
|
||||||
|
|
||||||
if (hit_result.linkUrl().isValid()) {
|
if (hit_result.linkUrl().isValid()) {
|
||||||
QAction *action_copylink = pageAction(QWebPage::CopyLinkToClipboard);
|
context_menu.addAction(m_actionCopyLink);
|
||||||
action_copylink->setText(tr("Copy link url"));
|
|
||||||
action_copylink->setToolTip(tr("Copy link url to clipboard"));
|
|
||||||
action_copylink->setIcon(ThemeFactory::fromTheme("edit-copy"));
|
|
||||||
context_menu.addAction(action_copylink);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hit_result.pixmap().isNull()) {
|
if (!hit_result.pixmap().isNull()) {
|
||||||
|
// Add 'Image' menu, because if user clicked image it needs to be visible.
|
||||||
context_menu.addMenu(&image_submenu);
|
context_menu.addMenu(&image_submenu);
|
||||||
|
|
||||||
QAction *action_copyimage = pageAction(QWebPage::CopyImageToClipboard);
|
image_submenu.addAction(m_actionCopyImage);
|
||||||
action_copyimage->setText(tr("Copy image"));
|
|
||||||
action_copyimage->setToolTip(tr("Copy image to clipboard"));
|
|
||||||
action_copyimage->setIcon(ThemeFactory::fromTheme("insert-image"));
|
|
||||||
image_submenu.addAction(action_copyimage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hit_result.imageUrl().isValid()) {
|
if (hit_result.imageUrl().isValid()) {
|
||||||
QAction *action_copyimageurl = pageAction(QWebPage::CopyImageUrlToClipboard);
|
image_submenu.addAction(m_actionCopyImageUrl);
|
||||||
action_copyimageurl->setText(tr("Copy image url"));
|
|
||||||
action_copyimageurl->setToolTip(tr("Copy image url to clipboard"));
|
|
||||||
action_copyimageurl->setIcon(ThemeFactory::fromTheme("edit-copy"));
|
|
||||||
image_submenu.addAction(action_copyimageurl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the menu.
|
// Display the menu.
|
||||||
context_menu.exec(mapToGlobal(event->pos()));
|
context_menu.exec(mapToGlobal(event->pos()));
|
||||||
context_menu.deleteLater();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWebView::paintEvent(QPaintEvent *event) {
|
void BaseWebView::paintEvent(QPaintEvent *event) {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define BASEWEBVIEW_H
|
#define BASEWEBVIEW_H
|
||||||
|
|
||||||
#include <QWebView>
|
#include <QWebView>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
|
||||||
class QPaintEvent;
|
class QPaintEvent;
|
||||||
|
@ -15,11 +16,15 @@ class BaseWebView : public QWebView {
|
||||||
explicit BaseWebView(QWidget *parent = 0);
|
explicit BaseWebView(QWidget *parent = 0);
|
||||||
virtual ~BaseWebView();
|
virtual ~BaseWebView();
|
||||||
|
|
||||||
|
void setupIcons();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
// Executes if loading of any page is done.
|
// Executes if loading of any page is done.
|
||||||
void onLoadFinished(bool ok);
|
void onLoadFinished(bool ok);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void initializeActions();
|
||||||
|
|
||||||
// Creates necessary connections.
|
// Creates necessary connections.
|
||||||
void createConnections();
|
void createConnections();
|
||||||
|
|
||||||
|
@ -34,6 +39,11 @@ class BaseWebView : public QWebView {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BaseWebPage *m_page;
|
BaseWebPage *m_page;
|
||||||
|
|
||||||
|
QAction *m_actionReload;
|
||||||
|
QAction *m_actionCopyLink;
|
||||||
|
QAction *m_actionCopyImage;
|
||||||
|
QAction *m_actionCopyImageUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BASEWEBVIEW_H
|
#endif // BASEWEBVIEW_H
|
||||||
|
|
|
@ -67,15 +67,16 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout)
|
||||||
"<li>Martin Rotter (<a href=\"mailto://rotter.martinos@gmail.com\">rotter.martinos@gmail.com</a>) (author of RSS Guard)</li>"
|
"<li>Martin Rotter (<a href=\"mailto://rotter.martinos@gmail.com\">rotter.martinos@gmail.com</a>) (author of RSS Guard)</li>"
|
||||||
"<li>snakebite & tiheum (authors of KFaenza/Faenza icon theme)</li>"
|
"<li>snakebite & tiheum (authors of KFaenza/Faenza icon theme)</li>"
|
||||||
"<li>Digia Plc (author of QtSingleApplication component)</li>"
|
"<li>Digia Plc (author of QtSingleApplication component)</li>"
|
||||||
|
"<li>Artem Galichkin (<a href=\"mailto://doomer3d@gmail.com\">doomer3d@gmail.com</a>) (author of original QKeySequenceWidget component)</li>"
|
||||||
"</ul>"
|
"</ul>"
|
||||||
"</body>"));
|
"</body>"));
|
||||||
|
|
||||||
m_ui->m_txtInfo->setText(tr("<body>RSS Guard is a (very) tiny feed reader."
|
m_ui->m_txtInfo->setText(tr("<body>RSS Guard is a (very) tiny feed reader."
|
||||||
"<br><br>This software is distributed under the terms of GNU General Public License, version 3 or later."
|
"<br><br>This software is distributed under the terms of GNU General Public License, version 3."
|
||||||
"<br><br>Contacts:"
|
"<br><br>Contacts:"
|
||||||
"<ul><li><a href=\"mailto://rotter.martinos@gmail.com\">rotter.martinos@gmail</a> ~email</li>"
|
"<ul><li><a href=\"mailto://rotter.martinos@gmail.com\">rotter.martinos@gmail</a> ~email</li>"
|
||||||
"<li><a href=\"http://www.rssguard.sf.net\">www.rssguard.sf.net</a> ~website</li></ul>"
|
"<li><a href=\"http://www.rssguard.sf.net\">www.rssguard.sf.net</a> ~website</li></ul>"
|
||||||
"You can obtain source code for Qonverter from its website."
|
"You can obtain source code for RSS Guard from its website."
|
||||||
"<br><br><br>Copyright © 2011-%1 Martin Rotter</body>").arg(QDateTime::currentDateTime().date().year()));
|
"<br><br><br>Copyright © 2011-%1 Martin Rotter</body>").arg(QDateTime::currentDateTime().date().year()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,7 @@ void WebBrowser::setupIcons() {
|
||||||
m_actionForward->setIcon(ThemeFactory::fromTheme("go-next"));
|
m_actionForward->setIcon(ThemeFactory::fromTheme("go-next"));
|
||||||
m_actionReload->setIcon(ThemeFactory::fromTheme("view-refresh"));
|
m_actionReload->setIcon(ThemeFactory::fromTheme("view-refresh"));
|
||||||
m_actionStop->setIcon(ThemeFactory::fromTheme("process-stop"));
|
m_actionStop->setIcon(ThemeFactory::fromTheme("process-stop"));
|
||||||
|
m_webView->setupIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<WebBrowser *> WebBrowser::runningWebBrowsers() {
|
QList<WebBrowser *> WebBrowser::runningWebBrowsers() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue