Nastavení ikon + fix kompilace.

This commit is contained in:
Martin Rotter 2017-07-20 08:14:34 +02:00
parent 5cedad03ac
commit dcfa6fd97e
5 changed files with 15 additions and 11 deletions

View File

@ -26,6 +26,8 @@
#define ARGUMENTS_LIST_SEPARATOR "\n"
#define ADBLOCK_ICON_ACTIVE "adblock"
#define ADBLOCK_ICON_DISABLED "adblock-disabled"
#define IS_IN_ARRAY(offset, array) ((offset >= 0) && (offset < array.count()))
#define ADBLOCK_CUSTOMLIST_NAME "customlist.txt"
#define ADBLOCK_LISTS_SUBDIRECTORY "adblock"

View File

@ -58,7 +58,7 @@ Application::Application(const QString &id, int &argc, char **argv)
#if defined(USE_WEBENGINE)
connect(QWebEngineProfile::defaultProfile(), &QWebEngineProfile::downloadRequested, this, &Application::downloadRequested);
QWebEngineProfile::setRequestInterceptor(m_urlInterceptor);
QWebEngineProfile::defaultProfile()->setRequestInterceptor(m_urlInterceptor);
#endif
}
@ -315,6 +315,10 @@ SystemTrayIcon *Application::trayIcon() {
return m_trayIcon;
}
NetworkUrlInterceptor *Application::urlIinterceptor() {
return m_urlInterceptor;
}
void Application::showTrayIcon() {
qDebug("Showing tray icon.");
trayIcon()->show();

View File

@ -80,6 +80,7 @@ class Application : public QtSingleApplication {
FormMain *mainForm();
QWidget *mainFormWidget();
SystemTrayIcon *trayIcon();
NetworkUrlInterceptor *urlIinterceptor();
QString getTempFolderPath();
QString getDocumentsFolderPath();

View File

@ -17,6 +17,7 @@
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#include "network-web/adblock/adblockicon.h"
#include "network-web/adblock/adblockrule.h"
#include "network-web/adblock/adblockmanager.h"
#include "network-web/adblock/adblocksubscription.h"
@ -84,8 +85,7 @@ QAction *AdBlockIcon::menuAction() {
connect(m_menuAction->menu(), SIGNAL(aboutToShow()), this, SLOT(createMenu()));
}
m_menuAction->setIcon(QIcon(m_enabled ? ":icons/other/adblock.png" : ":icons/other/adblock-disabled.png"));
m_menuAction->setIcon(m_enabled ? qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE) : qApp->icons()->miscIcon(ADBLOCK_ICON_DISABLED));
return m_menuAction;
}
@ -180,8 +180,7 @@ void AdBlockIcon::animateIcon() {
}
if (pixmap()->isNull()) {
// TODO: Nastavit ikony.
setPixmap(QIcon(QSL(":icons/other/adblock.png")).pixmap(16));
setPixmap(qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE).pixmap(16));
}
else {
setPixmap(QPixmap());
@ -198,11 +197,10 @@ void AdBlockIcon::stopAnimation() {
void AdBlockIcon::setEnabled(bool enabled) {
if (enabled) {
// TODO: Nastavit ikony.
setPixmap(QIcon(QSL(":icons/other/adblock.png")).pixmap(16));
setPixmap(qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE).pixmap(16));
}
else {
setPixmap(QIcon(QSL(":icons/other/adblock-disabled.png")).pixmap(16));
setPixmap(qApp->icons()->miscIcon(ADBLOCK_ICON_DISABLED).pixmap(16));
}
m_enabled = enabled;

View File

@ -24,6 +24,7 @@
#include "miscellaneous/application.h"
#include "miscellaneous/settings.h"
#include "network-web/networkurlinterceptor.h"
#include <QDateTime>
#include <QTextStream>
@ -312,9 +313,7 @@ void AdBlockManager::load() {
m_matcher->update();
m_loaded = true;
// TODO: instalovat interceptor, asi dát tu logiku
// někam sem, nedávat třeba do Application
//mApp->networkManager()->installUrlInterceptor(m_interceptor);
qApp->urlIinterceptor()->installUrlInterceptor(m_interceptor);
}
void AdBlockManager::updateMatcher() {