Work on webbrowser.
This commit is contained in:
parent
61e0ff26db
commit
705811a401
@ -160,7 +160,7 @@ set(APP_SOURCES
|
|||||||
# GUI sources.
|
# GUI sources.
|
||||||
src/gui/formmain.cpp
|
src/gui/formmain.cpp
|
||||||
src/gui/systemtrayicon.cpp
|
src/gui/systemtrayicon.cpp
|
||||||
src/gui/themefactory.cpp
|
src/gui/iconthemefactory.cpp
|
||||||
src/gui/formsettings.cpp
|
src/gui/formsettings.cpp
|
||||||
src/gui/formwelcome.cpp
|
src/gui/formwelcome.cpp
|
||||||
src/gui/formabout.cpp
|
src/gui/formabout.cpp
|
||||||
@ -202,7 +202,7 @@ set(APP_HEADERS
|
|||||||
# GUI headers.
|
# GUI headers.
|
||||||
src/gui/formmain.h
|
src/gui/formmain.h
|
||||||
src/gui/systemtrayicon.h
|
src/gui/systemtrayicon.h
|
||||||
src/gui/themefactory.h
|
src/gui/iconthemefactory.h
|
||||||
src/gui/formsettings.h
|
src/gui/formsettings.h
|
||||||
src/gui/formwelcome.h
|
src/gui/formwelcome.h
|
||||||
src/gui/formabout.h
|
src/gui/formabout.h
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
#include "gui/webbrowser.h"
|
#include "gui/webbrowser.h"
|
||||||
|
|
||||||
|
|
||||||
BaseWebPage::BaseWebPage(QObject *parent) : QWebPage(parent) {
|
BaseWebPage::BaseWebPage(QObject *parent)
|
||||||
|
: QWebPage(parent), m_openInNewTab(false) {
|
||||||
// Setup global network access manager.
|
// Setup global network access manager.
|
||||||
// NOTE: This makes network settings easy for all web browsers.
|
// NOTE: This makes network settings easy for all web browsers.
|
||||||
setNetworkAccessManager(WebBrowser::globalNetworkManager());
|
setNetworkAccessManager(WebBrowser::globalNetworkManager());
|
||||||
@ -14,3 +15,7 @@ BaseWebPage::BaseWebPage(QObject *parent) : QWebPage(parent) {
|
|||||||
|
|
||||||
BaseWebPage::~BaseWebPage() {
|
BaseWebPage::~BaseWebPage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWebPage *BaseWebPage::createWindow(WebWindowType type) {
|
||||||
|
return QWebPage::createWindow(type);
|
||||||
|
}
|
||||||
|
@ -11,6 +11,14 @@ class BaseWebPage : public QWebPage {
|
|||||||
// Constructors and destructors.
|
// Constructors and destructors.
|
||||||
explicit BaseWebPage(QObject *parent = 0);
|
explicit BaseWebPage(QObject *parent = 0);
|
||||||
virtual ~BaseWebPage();
|
virtual ~BaseWebPage();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QWebPage *createWindow(WebWindowType type);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class BaseWebView;
|
||||||
|
|
||||||
|
bool m_openInNewTab;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BASEWEBPAGE_H
|
#endif // BASEWEBPAGE_H
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
#include "core/basewebpage.h"
|
#include "core/basewebpage.h"
|
||||||
#include "gui/basewebview.h"
|
#include "gui/basewebview.h"
|
||||||
#include "gui/themefactory.h"
|
#include "gui/iconthemefactory.h"
|
||||||
|
|
||||||
|
|
||||||
BaseWebView::BaseWebView(QWidget *parent)
|
BaseWebView::BaseWebView(QWidget *parent)
|
||||||
@ -38,10 +38,10 @@ void BaseWebView::createConnections() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BaseWebView::setupIcons() {
|
void BaseWebView::setupIcons() {
|
||||||
m_actionReload->setIcon(ThemeFactory::getInstance()->fromTheme("view-refresh"));
|
m_actionReload->setIcon(IconThemeFactory::getInstance()->fromTheme("view-refresh"));
|
||||||
m_actionCopyLink->setIcon(ThemeFactory::getInstance()->fromTheme("edit-copy"));
|
m_actionCopyLink->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-copy"));
|
||||||
m_actionCopyImage->setIcon(ThemeFactory::getInstance()->fromTheme("insert-image"));
|
m_actionCopyImage->setIcon(IconThemeFactory::getInstance()->fromTheme("insert-image"));
|
||||||
m_actionCopyImageUrl->setIcon(ThemeFactory::getInstance()->fromTheme("edit-copy"));
|
m_actionCopyImageUrl->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-copy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWebView::initializeActions() {
|
void BaseWebView::initializeActions() {
|
||||||
@ -56,17 +56,22 @@ void BaseWebView::initializeActions() {
|
|||||||
m_actionCopyLink->setText(tr("Copy link url"));
|
m_actionCopyLink->setText(tr("Copy link url"));
|
||||||
m_actionCopyLink->setToolTip(tr("Copy link url to clipboard"));
|
m_actionCopyLink->setToolTip(tr("Copy link url to clipboard"));
|
||||||
|
|
||||||
|
|
||||||
m_actionCopyImage = pageAction(QWebPage::CopyImageToClipboard);
|
m_actionCopyImage = pageAction(QWebPage::CopyImageToClipboard);
|
||||||
m_actionCopyImage->setParent(this);
|
m_actionCopyImage->setParent(this);
|
||||||
m_actionCopyImage->setText(tr("Copy image"));
|
m_actionCopyImage->setText(tr("Copy image"));
|
||||||
m_actionCopyImage->setToolTip(tr("Copy image to clipboard"));
|
m_actionCopyImage->setToolTip(tr("Copy image to clipboard"));
|
||||||
|
|
||||||
|
|
||||||
m_actionCopyImageUrl = pageAction(QWebPage::CopyImageUrlToClipboard);
|
m_actionCopyImageUrl = pageAction(QWebPage::CopyImageUrlToClipboard);
|
||||||
m_actionCopyImageUrl->setParent(this);
|
m_actionCopyImageUrl->setParent(this);
|
||||||
m_actionCopyImageUrl->setText(tr("Copy image url"));
|
m_actionCopyImageUrl->setText(tr("Copy image url"));
|
||||||
m_actionCopyImageUrl->setToolTip(tr("Copy image url to clipboard"));
|
m_actionCopyImageUrl->setToolTip(tr("Copy image url to clipboard"));
|
||||||
|
|
||||||
|
// TODO: Finish implementation of "open link in new tab"
|
||||||
|
// viz WebPage::createWindow in browser example.
|
||||||
|
m_actionOpenLinkNewTab = pageAction(QWebPage::OpenLinkInNewWindow);
|
||||||
|
m_actionOpenLinkNewTab->setParent(this);
|
||||||
|
m_actionOpenLinkNewTab->setText(tr("Open link in new tab"));
|
||||||
|
m_actionOpenLinkNewTab->setToolTip(tr("Open this hyperlink in new tab"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWebView::displayErrorPage() {
|
void BaseWebView::displayErrorPage() {
|
||||||
@ -79,7 +84,7 @@ void BaseWebView::popupContextMenu(const QPoint &pos) {
|
|||||||
QMenu image_submenu(tr("Image"), &context_menu);
|
QMenu image_submenu(tr("Image"), &context_menu);
|
||||||
QWebHitTestResult hit_result = page()->mainFrame()->hitTestContent(pos);
|
QWebHitTestResult hit_result = page()->mainFrame()->hitTestContent(pos);
|
||||||
|
|
||||||
image_submenu.setIcon(ThemeFactory::getInstance()->fromTheme("image-x-generic"));
|
image_submenu.setIcon(IconThemeFactory::getInstance()->fromTheme("image-x-generic"));
|
||||||
|
|
||||||
// Assemble the menu from actions.
|
// Assemble the menu from actions.
|
||||||
context_menu.addAction(m_actionReload);
|
context_menu.addAction(m_actionReload);
|
||||||
|
@ -56,6 +56,7 @@ class BaseWebView : public QWebView {
|
|||||||
QAction *m_actionCopyLink;
|
QAction *m_actionCopyLink;
|
||||||
QAction *m_actionCopyImage;
|
QAction *m_actionCopyImage;
|
||||||
QAction *m_actionCopyImageUrl;
|
QAction *m_actionCopyImageUrl;
|
||||||
|
QAction *m_actionOpenLinkNewTab;
|
||||||
|
|
||||||
QPoint m_gestureOrigin;
|
QPoint m_gestureOrigin;
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "core/datetime.h"
|
#include "core/datetime.h"
|
||||||
#include "gui/formabout.h"
|
#include "gui/formabout.h"
|
||||||
#include "gui/themefactory.h"
|
#include "gui/iconthemefactory.h"
|
||||||
|
|
||||||
|
|
||||||
FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout) {
|
FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout) {
|
||||||
@ -11,7 +11,7 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout)
|
|||||||
|
|
||||||
// Set flags and attributes.
|
// Set flags and attributes.
|
||||||
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog);
|
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog);
|
||||||
setWindowIcon(ThemeFactory::getInstance()->fromTheme("help-about"));
|
setWindowIcon(IconThemeFactory::getInstance()->fromTheme("help-about"));
|
||||||
m_ui->m_lblIcon->setPixmap(QPixmap(APP_ICON_PATH));
|
m_ui->m_lblIcon->setPixmap(QPixmap(APP_ICON_PATH));
|
||||||
|
|
||||||
// Load information from embedded text files.
|
// Load information from embedded text files.
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "gui/formabout.h"
|
#include "gui/formabout.h"
|
||||||
#include "gui/formsettings.h"
|
#include "gui/formsettings.h"
|
||||||
#include "gui/webbrowser.h"
|
#include "gui/webbrowser.h"
|
||||||
#include "gui/themefactory.h"
|
#include "gui/iconthemefactory.h"
|
||||||
#include "gui/systemtrayicon.h"
|
#include "gui/systemtrayicon.h"
|
||||||
#include "gui/tabbar.h"
|
#include "gui/tabbar.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
@ -49,6 +49,10 @@ QMenu *FormMain::getTrayMenu() {
|
|||||||
return m_trayMenu;
|
return m_trayMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TabWidget *FormMain::getTabWidget() {
|
||||||
|
return m_ui->m_tabWidget;
|
||||||
|
}
|
||||||
|
|
||||||
QList<QAction*> FormMain::getActions() {
|
QList<QAction*> FormMain::getActions() {
|
||||||
QList<QAction*> actions;
|
QList<QAction*> actions;
|
||||||
actions << m_ui->m_actionImport << m_ui->m_actionExport <<
|
actions << m_ui->m_actionImport << m_ui->m_actionExport <<
|
||||||
@ -136,12 +140,12 @@ bool FormMain::event(QEvent *event) {
|
|||||||
|
|
||||||
void FormMain::setupIcons() {
|
void FormMain::setupIcons() {
|
||||||
// Setup icons of this main window.
|
// Setup icons of this main window.
|
||||||
m_ui->m_actionSettings->setIcon(ThemeFactory::getInstance()->fromTheme("preferences-system"));
|
m_ui->m_actionSettings->setIcon(IconThemeFactory::getInstance()->fromTheme("preferences-system"));
|
||||||
m_ui->m_actionQuit->setIcon(ThemeFactory::getInstance()->fromTheme("application-exit"));
|
m_ui->m_actionQuit->setIcon(IconThemeFactory::getInstance()->fromTheme("application-exit"));
|
||||||
m_ui->m_actionAboutGuard->setIcon(ThemeFactory::getInstance()->fromTheme("help-about"));
|
m_ui->m_actionAboutGuard->setIcon(IconThemeFactory::getInstance()->fromTheme("help-about"));
|
||||||
m_ui->m_actionImport->setIcon(ThemeFactory::getInstance()->fromTheme("document-import"));
|
m_ui->m_actionImport->setIcon(IconThemeFactory::getInstance()->fromTheme("document-import"));
|
||||||
m_ui->m_actionExport->setIcon(ThemeFactory::getInstance()->fromTheme("document-export"));
|
m_ui->m_actionExport->setIcon(IconThemeFactory::getInstance()->fromTheme("document-export"));
|
||||||
m_ui->m_actionFullscreen->setIcon(ThemeFactory::getInstance()->fromTheme("view-fullscreen"));
|
m_ui->m_actionFullscreen->setIcon(IconThemeFactory::getInstance()->fromTheme("view-fullscreen"));
|
||||||
|
|
||||||
// Setup icons for underlying components: opened web browsers...
|
// Setup icons for underlying components: opened web browsers...
|
||||||
foreach (WebBrowser *browser, WebBrowser::runningWebBrowsers()) {
|
foreach (WebBrowser *browser, WebBrowser::runningWebBrowsers()) {
|
||||||
|
@ -18,6 +18,8 @@ class FormMain : public QMainWindow {
|
|||||||
// Returns menu for the tray icon.
|
// Returns menu for the tray icon.
|
||||||
QMenu *getTrayMenu();
|
QMenu *getTrayMenu();
|
||||||
|
|
||||||
|
TabWidget *getTabWidget();
|
||||||
|
|
||||||
// Returns list of all globally available actions.
|
// Returns list of all globally available actions.
|
||||||
// NOTE: This is used for setting dynamic shortcuts for given actions.
|
// NOTE: This is used for setting dynamic shortcuts for given actions.
|
||||||
QList<QAction*> getActions();
|
QList<QAction*> getActions();
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
|
||||||
#include "gui/formsettings.h"
|
#include "gui/formsettings.h"
|
||||||
#include "gui/themefactory.h"
|
#include "gui/iconthemefactory.h"
|
||||||
#include "gui/systemtrayicon.h"
|
#include "gui/systemtrayicon.h"
|
||||||
#include "gui/formmain.h"
|
#include "gui/formmain.h"
|
||||||
#include "gui/webbrowser.h"
|
#include "gui/webbrowser.h"
|
||||||
@ -21,7 +21,7 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form
|
|||||||
|
|
||||||
// Set flags and attributes.
|
// Set flags and attributes.
|
||||||
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog);
|
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog);
|
||||||
setWindowIcon(ThemeFactory::getInstance()->fromTheme("preferences-system"));
|
setWindowIcon(IconThemeFactory::getInstance()->fromTheme("preferences-system"));
|
||||||
|
|
||||||
// Setup behavior.
|
// Setup behavior.
|
||||||
m_ui->m_treeLanguages->setColumnCount(5);
|
m_ui->m_treeLanguages->setColumnCount(5);
|
||||||
@ -117,6 +117,9 @@ void FormSettings::loadBrowser() {
|
|||||||
m_ui->m_checkMouseGestures->setChecked(Settings::getInstance()->value(APP_CFG_BROWSER,
|
m_ui->m_checkMouseGestures->setChecked(Settings::getInstance()->value(APP_CFG_BROWSER,
|
||||||
"gestures_enabled",
|
"gestures_enabled",
|
||||||
true).toBool());
|
true).toBool());
|
||||||
|
m_ui->m_checkQueueTabs->setChecked(Settings::getInstance()->value(APP_CFG_BROWSER,
|
||||||
|
"queue_tabs",
|
||||||
|
true).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormSettings::saveBrowser() {
|
void FormSettings::saveBrowser() {
|
||||||
@ -130,6 +133,9 @@ void FormSettings::saveBrowser() {
|
|||||||
Settings::getInstance()->setValue(APP_CFG_BROWSER,
|
Settings::getInstance()->setValue(APP_CFG_BROWSER,
|
||||||
"gestures_enabled",
|
"gestures_enabled",
|
||||||
m_ui->m_checkMouseGestures->isChecked());
|
m_ui->m_checkMouseGestures->isChecked());
|
||||||
|
Settings::getInstance()->setValue(APP_CFG_BROWSER,
|
||||||
|
"queue_tabs",
|
||||||
|
m_ui->m_checkQueueTabs->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormSettings::loadProxy() {
|
void FormSettings::loadProxy() {
|
||||||
@ -290,9 +296,9 @@ void FormSettings::loadInterface() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load settings of icon theme.
|
// Load settings of icon theme.
|
||||||
QString current_theme = ThemeFactory::getInstance()->getCurrentIconTheme();
|
QString current_theme = IconThemeFactory::getInstance()->getCurrentIconTheme();
|
||||||
|
|
||||||
foreach (QString icon_theme_name, ThemeFactory::getInstance()->getInstalledIconThemes()) {
|
foreach (QString icon_theme_name, IconThemeFactory::getInstance()->getInstalledIconThemes()) {
|
||||||
if (icon_theme_name == APP_THEME_SYSTEM) {
|
if (icon_theme_name == APP_THEME_SYSTEM) {
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
m_ui->m_cmbIconTheme->addItem(tr("system icon theme (default)"),
|
m_ui->m_cmbIconTheme->addItem(tr("system icon theme (default)"),
|
||||||
@ -349,7 +355,7 @@ void FormSettings::saveInterface() {
|
|||||||
|
|
||||||
// Save selected icon theme.
|
// Save selected icon theme.
|
||||||
QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString();
|
QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString();
|
||||||
ThemeFactory::getInstance()->setCurrentIconTheme(selected_icon_theme);
|
IconThemeFactory::getInstance()->setCurrentIconTheme(selected_icon_theme);
|
||||||
|
|
||||||
// Save tab settings.
|
// Save tab settings.
|
||||||
Settings::getInstance()->setValue(APP_CFG_GUI, "tab_close_mid_button",
|
Settings::getInstance()->setValue(APP_CFG_GUI, "tab_close_mid_button",
|
||||||
|
@ -327,7 +327,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="m_checkMouseGestures">
|
<widget class="QCheckBox" name="m_checkMouseGestures">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable mouse gestures</string>
|
<string>Enable mouse gestures</string>
|
||||||
@ -353,6 +353,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="m_checkQueueTabs">
|
||||||
|
<property name="text">
|
||||||
|
<string>Queue new tabs (with hyperlinks) after the active tab</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QPushButton" name="m_btnBrowserProgressColor">
|
<widget class="QPushButton" name="m_btnBrowserProgressColor">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
#include "gui/themefactory.h"
|
#include "gui/iconthemefactory.h"
|
||||||
#include "qtsingleapplication/qtsingleapplication.h"
|
#include "qtsingleapplication/qtsingleapplication.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
#include "core/defs.h"
|
#include "core/defs.h"
|
||||||
|
|
||||||
|
|
||||||
QPointer<ThemeFactory> ThemeFactory::s_instance;
|
QPointer<IconThemeFactory> IconThemeFactory::s_instance;
|
||||||
QEvent::Type ThemeFactoryEvent::m_typeOfEvent = QEvent::None;
|
QEvent::Type ThemeFactoryEvent::m_typeOfEvent = QEvent::None;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -36,45 +36,45 @@ QEvent::Type ThemeFactoryEvent::type() {
|
|||||||
// ThemeFactory class
|
// ThemeFactory class
|
||||||
//
|
//
|
||||||
|
|
||||||
ThemeFactory::ThemeFactory(QObject *parent)
|
IconThemeFactory::IconThemeFactory(QObject *parent)
|
||||||
: QObject(parent), m_currentIconTheme(APP_THEME_SYSTEM) {
|
: QObject(parent), m_currentIconTheme(APP_THEME_SYSTEM) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemeFactory::~ThemeFactory() {
|
IconThemeFactory::~IconThemeFactory() {
|
||||||
qDebug("Destroying ThemeFactory instance.");
|
qDebug("Destroying ThemeFactory instance.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemeFactory *ThemeFactory::getInstance() {
|
IconThemeFactory *IconThemeFactory::getInstance() {
|
||||||
if (s_instance.isNull()) {
|
if (s_instance.isNull()) {
|
||||||
s_instance = new ThemeFactory(qApp);
|
s_instance = new IconThemeFactory(qApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return s_instance;
|
return s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeFactory::setupSearchPaths() {
|
void IconThemeFactory::setupSearchPaths() {
|
||||||
// Add custom icon theme path to existing ones.
|
// Add custom icon theme path to existing ones.
|
||||||
QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << APP_THEME_PATH);
|
QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << APP_THEME_PATH);
|
||||||
qDebug("Available icon theme paths: %s.",
|
qDebug("Available icon theme paths: %s.",
|
||||||
qPrintable(QIcon::themeSearchPaths().join(", ")));
|
qPrintable(QIcon::themeSearchPaths().join(", ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ThemeFactory::getCurrentIconTheme() {
|
QString IconThemeFactory::getCurrentIconTheme() {
|
||||||
return m_currentIconTheme;
|
return m_currentIconTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon ThemeFactory::fromTheme(const QString &name, const QIcon &fallback) {
|
QIcon IconThemeFactory::fromTheme(const QString &name, const QIcon &fallback) {
|
||||||
return QIcon::fromTheme(name, fallback);
|
return QIcon::fromTheme(name, fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeFactory::setCurrentIconTheme(const QString &theme_name) {
|
void IconThemeFactory::setCurrentIconTheme(const QString &theme_name) {
|
||||||
Settings::getInstance()->setValue(APP_CFG_GUI,
|
Settings::getInstance()->setValue(APP_CFG_GUI,
|
||||||
"icon_theme",
|
"icon_theme",
|
||||||
theme_name);
|
theme_name);
|
||||||
loadCurrentIconTheme(true);
|
loadCurrentIconTheme(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeFactory::loadCurrentIconTheme(bool notify_widgets) {
|
void IconThemeFactory::loadCurrentIconTheme(bool notify_widgets) {
|
||||||
QStringList installed_themes = getInstalledIconThemes();
|
QStringList installed_themes = getInstalledIconThemes();
|
||||||
QString theme_name_from_settings = Settings::getInstance()->value(APP_CFG_GUI,
|
QString theme_name_from_settings = Settings::getInstance()->value(APP_CFG_GUI,
|
||||||
"icon_theme",
|
"icon_theme",
|
||||||
@ -113,7 +113,7 @@ void ThemeFactory::loadCurrentIconTheme(bool notify_widgets) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ThemeFactory::getInstalledIconThemes() {
|
QStringList IconThemeFactory::getInstalledIconThemes() {
|
||||||
QStringList icon_theme_names;
|
QStringList icon_theme_names;
|
||||||
icon_theme_names << APP_THEME_SYSTEM;
|
icon_theme_names << APP_THEME_SYSTEM;
|
||||||
|
|
@ -6,12 +6,12 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
|
||||||
class ThemeFactory : public QObject {
|
class IconThemeFactory : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Singleton getter.
|
// Singleton getter.
|
||||||
static ThemeFactory *getInstance();
|
static IconThemeFactory *getInstance();
|
||||||
|
|
||||||
// Wrapper for QIcon::fromTheme.
|
// Wrapper for QIcon::fromTheme.
|
||||||
// TODO: If icon is not found in user-defined icon theme,
|
// TODO: If icon is not found in user-defined icon theme,
|
||||||
@ -41,14 +41,14 @@ class ThemeFactory : public QObject {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Constructors and destructors
|
// Constructors and destructors
|
||||||
explicit ThemeFactory(QObject *parent = 0);
|
explicit IconThemeFactory(QObject *parent = 0);
|
||||||
virtual ~ThemeFactory();
|
virtual ~IconThemeFactory();
|
||||||
|
|
||||||
// Holds name of the current icon theme.
|
// Holds name of the current icon theme.
|
||||||
QString m_currentIconTheme;
|
QString m_currentIconTheme;
|
||||||
|
|
||||||
// Singleton.
|
// Singleton.
|
||||||
static QPointer<ThemeFactory> s_instance;
|
static QPointer<IconThemeFactory> s_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ThemeFactoryEvent : public QEvent {
|
class ThemeFactoryEvent : public QEvent {
|
@ -31,7 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include "gui/shortcutcatcher.h"
|
#include "gui/shortcutcatcher.h"
|
||||||
#include "gui/shortcutbutton.h"
|
#include "gui/shortcutbutton.h"
|
||||||
#include "gui/themefactory.h"
|
#include "gui/iconthemefactory.h"
|
||||||
|
|
||||||
|
|
||||||
ShortcutCatcher::ShortcutCatcher(QWidget *parent)
|
ShortcutCatcher::ShortcutCatcher(QWidget *parent)
|
||||||
@ -43,7 +43,7 @@ ShortcutCatcher::ShortcutCatcher(QWidget *parent)
|
|||||||
|
|
||||||
// Create clear button.
|
// Create clear button.
|
||||||
m_clearButton = new QToolButton(this);
|
m_clearButton = new QToolButton(this);
|
||||||
m_clearButton->setIcon(ThemeFactory::getInstance()->fromTheme("document-revert"));
|
m_clearButton->setIcon(IconThemeFactory::getInstance()->fromTheme("document-revert"));
|
||||||
m_clearButton->setFocusPolicy(Qt::NoFocus);
|
m_clearButton->setFocusPolicy(Qt::NoFocus);
|
||||||
|
|
||||||
// Clear main shortcut catching button.
|
// Clear main shortcut catching button.
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
#include "core/defs.h"
|
#include "core/defs.h"
|
||||||
|
#include "core/settings.h"
|
||||||
#include "gui/tabwidget.h"
|
#include "gui/tabwidget.h"
|
||||||
#include "gui/tabbar.h"
|
#include "gui/tabbar.h"
|
||||||
#include "gui/themefactory.h"
|
#include "gui/iconthemefactory.h"
|
||||||
#include "gui/webbrowser.h"
|
#include "gui/webbrowser.h"
|
||||||
|
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ void TabWidget::setupIcons() {
|
|||||||
for (int index = 0; index < count(); index++) {
|
for (int index = 0; index < count(); index++) {
|
||||||
// Index 0 usually contains widget which displays feeds & messages.
|
// Index 0 usually contains widget which displays feeds & messages.
|
||||||
if (tabBar()->tabType(index) == TabBar::FeedReader) {
|
if (tabBar()->tabType(index) == TabBar::FeedReader) {
|
||||||
setTabIcon(index, ThemeFactory::getInstance()->fromTheme("application-rss+xml"));
|
setTabIcon(index, IconThemeFactory::getInstance()->fromTheme("application-rss+xml"));
|
||||||
}
|
}
|
||||||
// Other indexes probably contain WebBrowsers.
|
// Other indexes probably contain WebBrowsers.
|
||||||
else {
|
else {
|
||||||
@ -55,7 +56,7 @@ void TabWidget::setupIcons() {
|
|||||||
if (active_browser != nullptr && active_browser->icon().isNull()) {
|
if (active_browser != nullptr && active_browser->icon().isNull()) {
|
||||||
// We found WebBrowser instance of this tab page, which
|
// We found WebBrowser instance of this tab page, which
|
||||||
// has no suitable icon, load a new one from the icon theme.
|
// has no suitable icon, load a new one from the icon theme.
|
||||||
setTabIcon(index, ThemeFactory::getInstance()->fromTheme("text-html"));
|
setTabIcon(index, IconThemeFactory::getInstance()->fromTheme("text-html"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,21 +102,25 @@ int TabWidget::insertTab(int index, QWidget *widget, const QString &label,
|
|||||||
return tab_index;
|
return tab_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabWidget::addEmptyBrowser() {
|
int TabWidget::addEmptyBrowser() {
|
||||||
// TODO: Add reading of move_after_current and make_active
|
// TODO: Add reading of move_after_current and make_active
|
||||||
// flags from settings.
|
// flags from settings.
|
||||||
addBrowser(false, true);
|
return addBrowser(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabWidget::addLinkedBrowser(const QUrl &initial_url) {
|
int TabWidget::addLinkedBrowser(const QUrl &initial_url) {
|
||||||
// TODO: Add reading of move_after_current and make_active
|
// TODO: Add reading of move_after_current and make_active
|
||||||
// flags from settings.
|
// flags from settings.
|
||||||
addBrowser(true, false, initial_url);
|
return addBrowser(Settings::getInstance()->value(APP_CFG_BROWSER,
|
||||||
|
"queue_tabs",
|
||||||
|
true).toBool(),
|
||||||
|
false,
|
||||||
|
initial_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabWidget::addBrowser(bool move_after_current,
|
int TabWidget::addBrowser(bool move_after_current,
|
||||||
bool make_active,
|
bool make_active,
|
||||||
const QUrl &initial_url) {
|
const QUrl &initial_url) {
|
||||||
// Create new WebBrowser.
|
// Create new WebBrowser.
|
||||||
WebBrowser *browser = new WebBrowser(this);
|
WebBrowser *browser = new WebBrowser(this);
|
||||||
int final_index;
|
int final_index;
|
||||||
@ -124,17 +129,16 @@ void TabWidget::addBrowser(bool move_after_current,
|
|||||||
// Insert web browser after current tab.
|
// Insert web browser after current tab.
|
||||||
final_index = insertTab(currentIndex() + 1,
|
final_index = insertTab(currentIndex() + 1,
|
||||||
browser,
|
browser,
|
||||||
ThemeFactory::getInstance()->fromTheme("text-html"),
|
IconThemeFactory::getInstance()->fromTheme("text-html"),
|
||||||
tr("Web browser"),
|
tr("Web browser"),
|
||||||
TabBar::Closable);
|
TabBar::Closable);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Add new browser as the last tab.
|
// Add new browser as the last tab.
|
||||||
final_index = addTab(browser,
|
final_index = addTab(browser,
|
||||||
ThemeFactory::getInstance()->fromTheme("text-html"),
|
IconThemeFactory::getInstance()->fromTheme("text-html"),
|
||||||
tr("Web browser"),
|
tr("Web browser"),
|
||||||
TabBar::Closable);
|
TabBar::Closable);
|
||||||
browser->setFocus(Qt::OtherFocusReason);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load initial web page if desired.
|
// Load initial web page if desired.
|
||||||
@ -145,5 +149,8 @@ void TabWidget::addBrowser(bool move_after_current,
|
|||||||
// Make new web browser active if desired.
|
// Make new web browser active if desired.
|
||||||
if (make_active) {
|
if (make_active) {
|
||||||
setCurrentIndex(final_index);
|
setCurrentIndex(final_index);
|
||||||
|
browser->setFocus(Qt::OtherFocusReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return final_index;
|
||||||
}
|
}
|
||||||
|
@ -46,14 +46,14 @@ class TabWidget : public QTabWidget {
|
|||||||
void closeTab(int index);
|
void closeTab(int index);
|
||||||
|
|
||||||
// Adds new WebBrowser tab to global TabWidget.
|
// Adds new WebBrowser tab to global TabWidget.
|
||||||
void addEmptyBrowser();
|
int addEmptyBrowser();
|
||||||
|
|
||||||
// Adds new WebBrowser with link. This is used when user
|
// Adds new WebBrowser with link. This is used when user
|
||||||
// selects to "Open link in new tab.".
|
// selects to "Open link in new tab.".
|
||||||
void addLinkedBrowser(const QUrl &initial_url);
|
int addLinkedBrowser(const QUrl &initial_url);
|
||||||
|
|
||||||
// General method for adding WebBrowsers.
|
// General method for adding WebBrowsers.
|
||||||
void addBrowser(bool move_after_current,
|
int addBrowser(bool move_after_current,
|
||||||
bool make_active,
|
bool make_active,
|
||||||
const QUrl &initial_url = QUrl());
|
const QUrl &initial_url = QUrl());
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "gui/basewebview.h"
|
#include "gui/basewebview.h"
|
||||||
#include "gui/webbrowser.h"
|
#include "gui/webbrowser.h"
|
||||||
#include "gui/locationlineedit.h"
|
#include "gui/locationlineedit.h"
|
||||||
#include "gui/themefactory.h"
|
#include "gui/iconthemefactory.h"
|
||||||
#include "gui/tabwidget.h"
|
#include "gui/tabwidget.h"
|
||||||
|
|
||||||
|
|
||||||
@ -80,16 +80,14 @@ void WebBrowser::createConnections() {
|
|||||||
this, &WebBrowser::updateUrl);
|
this, &WebBrowser::updateUrl);
|
||||||
|
|
||||||
// Connect this WebBrowser to global TabWidget.
|
// Connect this WebBrowser to global TabWidget.
|
||||||
// TODO: Přemýšlet nad tím, zda toto navázání spojení
|
// TODO: Think over moving this connections from here to
|
||||||
// nepředělat například do TabWidget::AddBrowser a ty signály
|
// e.g. TabWidget::addBrowser.
|
||||||
// z m_webView tedy neforwardovat z WebBrowseru.
|
|
||||||
TabWidget *parent_widget = static_cast<TabWidget*>(parent());
|
TabWidget *parent_widget = static_cast<TabWidget*>(parent());
|
||||||
connect(m_webView, &BaseWebView::newTabRequested,
|
connect(m_webView, &BaseWebView::newTabRequested,
|
||||||
parent_widget, &TabWidget::addEmptyBrowser);
|
parent_widget, &TabWidget::addEmptyBrowser);
|
||||||
connect(m_webView, &BaseWebView::linkMiddleClicked,
|
connect(m_webView, &BaseWebView::linkMiddleClicked,
|
||||||
parent_widget, &TabWidget::addLinkedBrowser);
|
parent_widget, &TabWidget::addLinkedBrowser);
|
||||||
|
|
||||||
|
|
||||||
// Change location textbox status according to webpage status.
|
// Change location textbox status according to webpage status.
|
||||||
connect(m_webView, &BaseWebView::loadProgress,
|
connect(m_webView, &BaseWebView::loadProgress,
|
||||||
m_txtLocation, &LocationLineEdit::setProgress);
|
m_txtLocation, &LocationLineEdit::setProgress);
|
||||||
@ -138,10 +136,10 @@ void WebBrowser::setFocus(Qt::FocusReason reason) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WebBrowser::setupIcons() {
|
void WebBrowser::setupIcons() {
|
||||||
m_actionBack->setIcon(ThemeFactory::getInstance()->fromTheme("go-previous"));
|
m_actionBack->setIcon(IconThemeFactory::getInstance()->fromTheme("go-previous"));
|
||||||
m_actionForward->setIcon(ThemeFactory::getInstance()->fromTheme("go-next"));
|
m_actionForward->setIcon(IconThemeFactory::getInstance()->fromTheme("go-next"));
|
||||||
m_actionReload->setIcon(ThemeFactory::getInstance()->fromTheme("view-refresh"));
|
m_actionReload->setIcon(IconThemeFactory::getInstance()->fromTheme("view-refresh"));
|
||||||
m_actionStop->setIcon(ThemeFactory::getInstance()->fromTheme("process-stop"));
|
m_actionStop->setIcon(IconThemeFactory::getInstance()->fromTheme("process-stop"));
|
||||||
m_webView->setupIcons();
|
m_webView->setupIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "core/localization.h"
|
#include "core/localization.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
#include "core/dynamicshortcuts.h"
|
#include "core/dynamicshortcuts.h"
|
||||||
#include "gui/themefactory.h"
|
#include "gui/iconthemefactory.h"
|
||||||
#include "gui/formmain.h"
|
#include "gui/formmain.h"
|
||||||
#include "gui/formwelcome.h"
|
#include "gui/formwelcome.h"
|
||||||
#include "gui/systemtrayicon.h"
|
#include "gui/systemtrayicon.h"
|
||||||
@ -63,8 +63,8 @@ int main(int argc, char *argv[]) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Add an extra path for non-system icon themes and set current icon theme.
|
// Add an extra path for non-system icon themes and set current icon theme.
|
||||||
ThemeFactory::getInstance()->setupSearchPaths();
|
IconThemeFactory::getInstance()->setupSearchPaths();
|
||||||
ThemeFactory::getInstance()->loadCurrentIconTheme(false);
|
IconThemeFactory::getInstance()->loadCurrentIconTheme(false);
|
||||||
|
|
||||||
// Load localization and setup locale before any widget is constructed.
|
// Load localization and setup locale before any widget is constructed.
|
||||||
LoadLocalization();
|
LoadLocalization();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user