Work on web browsing.
This commit is contained in:
parent
1759d31a8b
commit
8120ff6467
@ -330,8 +330,7 @@ file( GLOB APP_FORMS
|
||||
"src/services/standard/gui/*.ui"
|
||||
"src/services/tt-rss/gui/*.ui"
|
||||
"src/services/owncloud/gui/*.ui"
|
||||
"src/network-web/*.ui"
|
||||
"src/network-web/adblock/*.ui")
|
||||
"src/network-web/*.ui")
|
||||
|
||||
# APP translations.
|
||||
file( GLOB APP_TRANSLATIONS
|
||||
@ -383,7 +382,6 @@ include_directories (
|
||||
${CMAKE_SOURCE_DIR}/src/gui/dialogs
|
||||
${CMAKE_SOURCE_DIR}/src/gui/notifications
|
||||
${CMAKE_SOURCE_DIR}/src/network-web
|
||||
${CMAKE_SOURCE_DIR}/src/network-web/adblock
|
||||
${CMAKE_SOURCE_DIR}/src/dynamic-shortcuts
|
||||
${CMAKE_BINARY_DIR}/src
|
||||
)
|
||||
|
@ -104,11 +104,6 @@
|
||||
#define PLACEHOLDER_UNREAD_COUNTS "%unread"
|
||||
#define PLACEHOLDER_ALL_COUNTS "%all"
|
||||
|
||||
#define ADBLOCK_CUSTOM_LIST_FILENAME "custom_rules.txt"
|
||||
#define ADBLOCK_BASE_DIRECTORY_NAME "data/adblock"
|
||||
#define ADBLOCK_FILTERS_HELP "https://adblockplus.org/en/filters"
|
||||
#define ADBLOCK_EASYLIST_URL "https://easylist-downloads.adblockplus.org/easylist.txt"
|
||||
|
||||
#define BACKUP_NAME_SETTINGS "config"
|
||||
#define BACKUP_SUFFIX_SETTINGS ".ini.backup"
|
||||
#define BACKUP_NAME_DATABASE "database"
|
||||
|
@ -156,7 +156,7 @@ void StatusBar::loadChangeableActions(const QStringList &action_names) {
|
||||
action_to_add->setProperty("type", SPACER_ACTION_NAME);
|
||||
action_to_add->setProperty("name", tr("Toolbar spacer"));
|
||||
}
|
||||
else {
|
||||
else if (matching_action != NULL) {
|
||||
// Add originally toolbar action.
|
||||
PlainToolButton *tool_button = new PlainToolButton(this);
|
||||
tool_button->reactOnActionChange(matching_action);
|
||||
@ -167,13 +167,21 @@ void StatusBar::loadChangeableActions(const QStringList &action_names) {
|
||||
connect(tool_button, SIGNAL(clicked(bool)), matching_action, SLOT(trigger()));
|
||||
connect(matching_action, SIGNAL(changed()), tool_button, SLOT(reactOnActionChange()));
|
||||
}
|
||||
else {
|
||||
action_to_add = NULL;
|
||||
widget_to_add = NULL;
|
||||
}
|
||||
|
||||
action_to_add->setProperty("should_remove_widget", true);
|
||||
if (action_to_add != NULL) {
|
||||
action_to_add->setProperty("should_remove_widget", true);
|
||||
}
|
||||
}
|
||||
|
||||
action_to_add->setProperty("widget", QVariant::fromValue((void*) widget_to_add));
|
||||
addPermanentWidget(widget_to_add);
|
||||
addAction(action_to_add);
|
||||
if (action_to_add != NULL && widget_to_add != NULL) {
|
||||
action_to_add->setProperty("widget", QVariant::fromValue((void*) widget_to_add));
|
||||
addPermanentWidget(widget_to_add);
|
||||
addAction(action_to_add);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
class QProgressBar;
|
||||
class PlainToolButton;
|
||||
class QLabel;
|
||||
class AdBlockIcon;
|
||||
|
||||
class StatusBar : public QStatusBar, public BaseBar {
|
||||
Q_OBJECT
|
||||
|
@ -85,7 +85,7 @@ DKEY GUI::FeedsToolbarActions = "feeds_toolbar";
|
||||
DVALUE(char*) GUI::FeedsToolbarActionsDef = "m_actionUpdateAllItems,m_actionStopRunningItemsUpdate,m_actionMarkAllItemsRead";
|
||||
|
||||
DKEY GUI::StatusbarActions = "status_bar";
|
||||
DVALUE(char*) GUI::StatusbarActionsDef = "m_lblProgressFeedsAction,m_barProgressFeedsAction,m_actionUpdateAllItems,m_actionUpdateSelectedItems,m_actionStopRunningItemsUpdate,m_adBlockIconAction,m_actionFullscreen,m_actionQuit";
|
||||
DVALUE(char*) GUI::StatusbarActionsDef = "m_lblProgressFeedsAction,m_barProgressFeedsAction,m_actionUpdateAllItems,m_actionUpdateSelectedItems,m_actionStopRunningItemsUpdate,m_actionFullscreen,m_actionQuit";
|
||||
|
||||
DKEY GUI::MainWindowInitialSize = "window_size";
|
||||
DKEY GUI::MainWindowInitialPosition = "window_position";
|
||||
@ -241,21 +241,6 @@ DVALUE(char*) Database::ActiveDriverDef = APP_DB_SQLITE_DRIVER;
|
||||
// Keyboard.
|
||||
DKEY Keyboard::ID = "keyboard";
|
||||
|
||||
// Adblock.
|
||||
DKEY AdBlock::ID = "adblock";
|
||||
|
||||
DKEY AdBlock::Enabled = "enabled";
|
||||
DVALUE(bool) AdBlock::EnabledDef = false;
|
||||
|
||||
DKEY AdBlock::UseLimitedEasyList = "use_limited_easylist";
|
||||
DVALUE(bool) AdBlock::UseLimitedEasyListDef = true;
|
||||
|
||||
DKEY AdBlock::DisabledRules = "disabled_rules";
|
||||
DVALUE(QStringList) AdBlock::DisabledRulesDef = QStringList();
|
||||
|
||||
DKEY AdBlock::LastUpdated = "last_updated";
|
||||
DVALUE(QDateTime) AdBlock::LastUpdatedDef = QDateTime();
|
||||
|
||||
// Web browser.
|
||||
DKEY Browser::ID = "browser";
|
||||
|
||||
|
@ -269,23 +269,6 @@ namespace Keyboard {
|
||||
KEY ID;
|
||||
}
|
||||
|
||||
// Adblock.
|
||||
namespace AdBlock {
|
||||
KEY ID;
|
||||
|
||||
KEY Enabled;
|
||||
VALUE(bool) EnabledDef;
|
||||
|
||||
KEY UseLimitedEasyList;
|
||||
VALUE(bool) UseLimitedEasyListDef;
|
||||
|
||||
KEY DisabledRules;
|
||||
VALUE(QStringList) DisabledRulesDef;
|
||||
|
||||
KEY LastUpdated;
|
||||
VALUE(QDateTime) LastUpdatedDef;
|
||||
}
|
||||
|
||||
// Web browser.
|
||||
namespace Browser {
|
||||
KEY ID;
|
||||
|
@ -163,19 +163,18 @@ void WebBrowser::initializeLayout() {
|
||||
void WebBrowser::onLoadingStarted() {
|
||||
m_loadingProgress->setValue(0);
|
||||
m_loadingWidget->show();
|
||||
m_btnDiscoverFeeds->setEnabled(false);
|
||||
}
|
||||
|
||||
void WebBrowser::onLoadingProgress(int progress) {
|
||||
m_loadingProgress->setValue(progress);
|
||||
// TODO: TODO
|
||||
//m_lblProgress->setText(QString(QSL(" %1 kB / %2 kB")).arg(m_webView->page()-> / 1000).arg(m_webView->page()->totalBytes() / 1000));
|
||||
}
|
||||
|
||||
void WebBrowser::onLoadingFinished(bool success) {
|
||||
if (success) {
|
||||
// Let's check if there are any feeds defined on the web and eventually
|
||||
// display "Add feeds" button.
|
||||
m_btnDiscoverFeeds->setFeedAddresses(NetworkFactory::extractFeedLinksFromHtmlPage(m_webView->url(), m_webView->page()->toHtml()));
|
||||
m_webView->page()->toHtml([this](const QString &html) {
|
||||
this->m_btnDiscoverFeeds->setFeedAddresses(NetworkFactory::extractFeedLinksFromHtmlPage(m_webView->url(), html));
|
||||
});
|
||||
}
|
||||
else {
|
||||
m_btnDiscoverFeeds->clearFeedAddresses();
|
||||
|
@ -31,6 +31,7 @@ WebPage::~WebPage() {
|
||||
}
|
||||
|
||||
bool WebPage::isLoading() const {
|
||||
// TODO: nepouzivany?
|
||||
return m_loadProgress < 100;
|
||||
}
|
||||
|
||||
@ -41,9 +42,3 @@ void WebPage::progress(int prog) {
|
||||
void WebPage::finished() {
|
||||
progress(100);
|
||||
}
|
||||
|
||||
QString WebPage::toHtml() const {
|
||||
return QString();
|
||||
// TODO: TODO
|
||||
//return mainFrame()->toHtml();
|
||||
}
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
|
||||
class AdBlockRule;
|
||||
|
||||
class WebPage : public QWebEnginePage {
|
||||
Q_OBJECT
|
||||
|
||||
@ -32,7 +30,6 @@ class WebPage : public QWebEnginePage {
|
||||
explicit WebPage(QObject *parent = 0);
|
||||
virtual ~WebPage();
|
||||
|
||||
QString toHtml() const;
|
||||
bool isLoading() const;
|
||||
|
||||
private slots:
|
||||
|
@ -125,20 +125,21 @@ void WebView::saveCurrentPageToFile() {
|
||||
}*/
|
||||
|
||||
if (!selected_file.isEmpty()) {
|
||||
QFile selected_file_handle(selected_file);
|
||||
page()->toHtml([this, selected_file](const QString &html) {
|
||||
QFile selected_file_handle(selected_file);
|
||||
|
||||
if (selected_file_handle.open(QIODevice::WriteOnly | QIODevice::Unbuffered)) {
|
||||
const QString html_text = page()->toHtml();
|
||||
QTextStream str(&selected_file_handle);
|
||||
if (selected_file_handle.open(QIODevice::WriteOnly | QIODevice::Unbuffered)) {
|
||||
QTextStream str(&selected_file_handle);
|
||||
|
||||
str.setCodec("UTF-16");
|
||||
str << html_text;
|
||||
selected_file_handle.close();
|
||||
}
|
||||
else {
|
||||
MessageBox::show(this, QMessageBox::Critical, tr("Cannot save web page"),
|
||||
tr("Web page cannot be saved because destination file is not writtable."));
|
||||
}
|
||||
str.setCodec("UTF-16");
|
||||
str << html;
|
||||
selected_file_handle.close();
|
||||
}
|
||||
else {
|
||||
MessageBox::show(this, QMessageBox::Critical, tr("Cannot save web page"),
|
||||
tr("Web page cannot be saved because destination file is not writtable."));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user