Added support for Qt 4, fully compiles and runs.
This commit is contained in:
parent
705811a401
commit
253ae7b84f
186
CMakeLists.txt
186
CMakeLists.txt
@ -5,7 +5,7 @@ project(rssguard)
|
||||
set(APP_NAME "RSS Guard")
|
||||
set(APP_UP_NAME "RSSGuard")
|
||||
set(APP_LOW_NAME "rssguard")
|
||||
set(APP_VERSION "2.0.0-prealpha-1")
|
||||
set(APP_VERSION "2.0.0-prealpha-2")
|
||||
set(APP_AUTHOR "Martin Rotter")
|
||||
set(APP_URL "http://rssguard.sf.net")
|
||||
|
||||
@ -22,12 +22,19 @@ endif(APPLE)
|
||||
# Find includes in corresponding build directories
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
# Obtain revision number if available.
|
||||
message(STATUS "[${APP_LOW_NAME}] Obtaining revision number.")
|
||||
|
||||
# Select which Qt version to use.
|
||||
if(${USE_QT_5})
|
||||
message(STATUS "[${APP_LOW_NAME}] Using Qt 5 library for building.")
|
||||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
else(${USE_QT_5})
|
||||
message(STATUS "[${APP_LOW_NAME}] Using Qt 4 library for building.")
|
||||
endif(${USE_QT_5})
|
||||
|
||||
if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
@ -99,36 +106,43 @@ endif(CMAKE_BUILD_TYPE STREQUAL "release" OR CMAKE_BUILD_TYPE STREQUAL "Release"
|
||||
# Force Qt to use string builders.
|
||||
add_definitions(-DQT_USE_QSTRINGBUILDER)
|
||||
|
||||
# Check for C++ 11 features availability.
|
||||
# See http://stackoverflow.com/questions/10984442/how-to-detect-c11-support-of-a-compiler-with-cmake
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION
|
||||
)
|
||||
|
||||
if(NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
|
||||
message(FATAL_ERROR "[${APP_LOW_NAME}] Your C++ compiler does not support C++ 11.")
|
||||
else(NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
|
||||
add_definitions(-std=c++11)
|
||||
endif(NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
|
||||
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
add_definitions(-std=c++11 -stdlib=libc++)
|
||||
elseif(${MSVC_VERSION} VERSION_LESS 1600)
|
||||
message(FATAL_ERROR "[${APP_LOW_NAME}] Your C++ compiler does not support C++ 11.")
|
||||
endif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||
|
||||
# Unicode settings.
|
||||
add_definitions(-DUNICODE -D_UNICODE)
|
||||
|
||||
# Find all needed Qt modules.
|
||||
find_package(Qt5Sql)
|
||||
find_package(Qt5WebKit)
|
||||
find_package(Qt5WebKitWidgets)
|
||||
find_package(Qt5Widgets)
|
||||
find_package(Qt5Xml)
|
||||
find_package(Qt5Network)
|
||||
find_package(Qt5LinguistTools)
|
||||
if(${USE_QT_5})
|
||||
# Check for C++ 11 features availability.
|
||||
# See http://stackoverflow.com/questions/10984442/how-to-detect-c11-support-of-a-compiler-with-cmake
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION
|
||||
)
|
||||
|
||||
if(NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
|
||||
message(FATAL_ERROR "[${APP_LOW_NAME}] Your C++ compiler does not support C++ 11.")
|
||||
else(NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
|
||||
add_definitions(-std=c++11)
|
||||
endif(NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
|
||||
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
add_definitions(-std=c++11 -stdlib=libc++)
|
||||
elseif(${MSVC_VERSION} VERSION_LESS 1600)
|
||||
message(FATAL_ERROR "[${APP_LOW_NAME}] Your C++ compiler does not support C++ 11.")
|
||||
endif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||
endif(${USE_QT_5})
|
||||
|
||||
# Setup libraries.
|
||||
if(${USE_QT_5})
|
||||
find_package(Qt5Sql)
|
||||
find_package(Qt5WebKit)
|
||||
find_package(Qt5WebKitWidgets)
|
||||
find_package(Qt5Widgets)
|
||||
find_package(Qt5Xml)
|
||||
find_package(Qt5Network)
|
||||
find_package(Qt5LinguistTools)
|
||||
else(${USE_QT_5})
|
||||
find_package(Qt4 REQUIRED QtCore QtGui QtSql QtNetwork QtWebkit QtXml)
|
||||
include(${QT_USE_FILE})
|
||||
endif(${USE_QT_5})
|
||||
|
||||
# Compile application icon if compiling with MinGW on WIN32.
|
||||
if(MINGW AND WIN32)
|
||||
@ -263,16 +277,26 @@ set(APP_MISC
|
||||
)
|
||||
|
||||
# Wrap files, create moc files.
|
||||
qt5_wrap_cpp(APP_MOC ${APP_HEADERS})
|
||||
qt5_wrap_ui(APP_UI ${APP_FORMS})
|
||||
qt5_add_resources(APP_RCC ${APP_RESOURCES})
|
||||
|
||||
if(Qt5LinguistTools_FOUND)
|
||||
message(STATUS "[${APP_LOW_NAME}] Qt Linguist Tools found. Translations will get refreshed.")
|
||||
qt5_add_translation(APP_QM ${APP_TRANSLATIONS})
|
||||
else(Qt5LinguistTools_FOUND)
|
||||
message(STATUS "[${APP_LOW_NAME}] Qt Linguist Tools NOT found. No refreshing for translations.")
|
||||
endif(Qt5LinguistTools_FOUND)
|
||||
if(${USE_QT_5})
|
||||
#qt5_wrap_cpp(APP_MOC ${APP_HEADERS})
|
||||
qt5_wrap_ui(APP_UI ${APP_FORMS})
|
||||
qt5_add_resources(APP_RCC ${APP_RESOURCES})
|
||||
|
||||
# Load translations.
|
||||
if(Qt5LinguistTools_FOUND)
|
||||
message(STATUS "[${APP_LOW_NAME}] Qt Linguist Tools found. Translations will get refreshed.")
|
||||
qt5_add_translation(APP_QM ${APP_TRANSLATIONS})
|
||||
else(Qt5LinguistTools_FOUND)
|
||||
message(STATUS "[${APP_LOW_NAME}] Qt Linguist Tools NOT found. No refreshing for translations.")
|
||||
endif(Qt5LinguistTools_FOUND)
|
||||
else(${USE_QT_5})
|
||||
qt4_wrap_cpp(APP_MOC ${APP_HEADERS})
|
||||
qt4_wrap_ui(APP_UI ${APP_FORMS})
|
||||
qt4_add_resources(APP_RCC ${APP_RESOURCES})
|
||||
|
||||
# Load translations.
|
||||
qt4_add_translation(APP_QM ${APP_TRANSLATIONS})
|
||||
endif(${USE_QT_5})
|
||||
|
||||
# Include additional directory paths.
|
||||
include_directories (
|
||||
@ -282,33 +306,55 @@ include_directories (
|
||||
${CMAKE_CURRENT_BINARY_DIR}/src
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
# Setup compilation.
|
||||
if(${USE_QT_5})
|
||||
if(WIN32)
|
||||
add_executable(${EXE_NAME} WIN32
|
||||
${APP_SOURCES}
|
||||
${APP_FORMS}
|
||||
${APP_RCC}
|
||||
${APP_QM}
|
||||
)
|
||||
target_link_libraries(${EXE_NAME} Qt5::WinMain)
|
||||
else(WIN32)
|
||||
add_executable(${EXE_NAME}
|
||||
${APP_SOURCES}
|
||||
${APP_FORMS}
|
||||
${APP_RCC}
|
||||
${APP_QM}
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
# Use modules from Qt.
|
||||
qt5_use_modules(${EXE_NAME}
|
||||
Core
|
||||
Widgets
|
||||
Sql
|
||||
Network
|
||||
Xml
|
||||
WebKit
|
||||
WebKitWidgets
|
||||
)
|
||||
else(${USE_QT_5})
|
||||
add_executable(${EXE_NAME} WIN32
|
||||
${APP_SOURCES}
|
||||
${APP_FORMS}
|
||||
${APP_MOC}
|
||||
${APP_RCC}
|
||||
${APP_QM}
|
||||
)
|
||||
target_link_libraries(${EXE_NAME} Qt5::WinMain)
|
||||
else(WIN32)
|
||||
add_executable(${EXE_NAME}
|
||||
${APP_SOURCES}
|
||||
${APP_FORMS}
|
||||
${APP_RCC}
|
||||
${APP_QM}
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
# Use modules from Qt.
|
||||
qt5_use_modules(${EXE_NAME}
|
||||
Core
|
||||
Widgets
|
||||
Sql
|
||||
Network
|
||||
Xml
|
||||
WebKit
|
||||
WebKitWidgets
|
||||
)
|
||||
# Link modules from Qt.
|
||||
target_link_libraries( ${EXE_NAME}
|
||||
${QT_QTCORE_LIBRARY}
|
||||
${QT_QTGUI_LIBRARY}
|
||||
${QT_QTNETWORK_LIBRARY}
|
||||
${QT_QTSQL_LIBRARY}
|
||||
${QT_QTXML_LIBRARY}
|
||||
${QT_QTMAIN_LIBRARY}
|
||||
${QT_QTWEBKIT_LIBRARY}
|
||||
)
|
||||
endif(${USE_QT_5})
|
||||
|
||||
# Installation stage.
|
||||
if(WIN32)
|
||||
@ -366,8 +412,16 @@ include(CPack)
|
||||
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
|
||||
|
||||
# make lupdate and make lrelease implementation.
|
||||
add_custom_target(lupdate
|
||||
${Qt5Core_QMAKE_EXECUTABLE} -project -o ${CMAKE_CURRENT_BINARY_DIR}/${APP_LOW_NAME}.pro
|
||||
COMMAND ${Qt5_LUPDATE_EXECUTABLE} -ts ${APP_TRANSLATIONS_WO_QT} -pro ${CMAKE_CURRENT_BINARY_DIR}/${APP_LOW_NAME}.pro
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
if(${USE_QT_5})
|
||||
add_custom_target(lupdate
|
||||
${Qt5Core_QMAKE_EXECUTABLE} -project -o ${CMAKE_CURRENT_BINARY_DIR}/${APP_LOW_NAME}.pro
|
||||
COMMAND ${Qt5_LUPDATE_EXECUTABLE} -ts ${APP_TRANSLATIONS_WO_QT} -pro ${CMAKE_CURRENT_BINARY_DIR}/${APP_LOW_NAME}.pro
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
else(${USE_QT_5})
|
||||
add_custom_target(lupdate
|
||||
${QT_QMAKE_EXECUTABLE} -project -o ${CMAKE_CURRENT_BINARY_DIR}/${APP_LOW_NAME}.pro
|
||||
COMMAND ${QT_LUPDATE_EXECUTABLE} -ts ${APP_TRANSLATIONS_WO_QT} -pro ${CMAKE_CURRENT_BINARY_DIR}/${APP_LOW_NAME}.pro
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
endif(${USE_QT_5})
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <QNetworkProxy>
|
||||
#include <QNetworkRequest>
|
||||
|
||||
#include "core/settings.h"
|
||||
#include "core/defs.h"
|
||||
@ -28,17 +29,18 @@ void BaseNetworkAccessManager::loadSettings() {
|
||||
setProxy(QNetworkProxy::NoProxy);
|
||||
return;
|
||||
}
|
||||
Settings *settings = Settings::getInstance();
|
||||
|
||||
// Custom proxy is selected, set it up.
|
||||
new_proxy.setType(selected_proxy_type);
|
||||
new_proxy.setHostName(Settings::getInstance()->value(APP_CFG_PROXY,
|
||||
"host").toString());
|
||||
new_proxy.setPort(Settings::getInstance()->value(APP_CFG_PROXY,
|
||||
"port", 80).toInt());
|
||||
new_proxy.setUser(Settings::getInstance()->value(APP_CFG_PROXY,
|
||||
"username").toString());
|
||||
new_proxy.setPassword(Settings::getInstance()->value(APP_CFG_PROXY,
|
||||
"password").toString());
|
||||
new_proxy.setHostName(settings->value(APP_CFG_PROXY,
|
||||
"host").toString());
|
||||
new_proxy.setPort(settings->value(APP_CFG_PROXY,
|
||||
"port", 80).toInt());
|
||||
new_proxy.setUser(settings->value(APP_CFG_PROXY,
|
||||
"username").toString());
|
||||
new_proxy.setPassword(settings->value(APP_CFG_PROXY,
|
||||
"password").toString());
|
||||
setProxy(new_proxy);
|
||||
}
|
||||
|
||||
@ -52,6 +54,7 @@ QNetworkReply *BaseNetworkAccessManager::createRequest(QNetworkAccessManager::Op
|
||||
new_request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
|
||||
|
||||
// Setup custom user-agent.
|
||||
new_request.setHeader(QNetworkRequest::UserAgentHeader, static_cast<QString>(APP_USERAGENT));
|
||||
new_request.setRawHeader("User-Agent", QString(APP_USERAGENT).toLocal8Bit());
|
||||
|
||||
return QNetworkAccessManager::createRequest(op, new_request, outgoingData);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
BaseWebPage::BaseWebPage(QObject *parent)
|
||||
: QWebPage(parent), m_openInNewTab(false) {
|
||||
: QWebPage(parent) {
|
||||
// Setup global network access manager.
|
||||
// NOTE: This makes network settings easy for all web browsers.
|
||||
setNetworkAccessManager(WebBrowser::globalNetworkManager());
|
||||
|
@ -14,11 +14,6 @@ class BaseWebPage : public QWebPage {
|
||||
|
||||
protected:
|
||||
QWebPage *createWindow(WebWindowType type);
|
||||
|
||||
private:
|
||||
friend class BaseWebView;
|
||||
|
||||
bool m_openInNewTab;
|
||||
};
|
||||
|
||||
#endif // BASEWEBPAGE_H
|
||||
|
@ -6,11 +6,12 @@
|
||||
|
||||
class DateTime {
|
||||
private:
|
||||
DateTime();
|
||||
explicit DateTime();
|
||||
|
||||
public:
|
||||
// Returns QDatetime instance from input QString.
|
||||
// If parsing fails, then invalid QDateTime is returned.
|
||||
// NOTE: Format of input date-time string is brute-force-determined.
|
||||
static QDateTime fromString(const QString &date_time);
|
||||
};
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <cstdio>
|
||||
|
||||
#ifndef QT_NO_DEBUG_OUTPUT
|
||||
#if QT_VERSION >= 0x050000
|
||||
#define DEBUG_OUTPUT_WORKER(type_string, file, line, message) \
|
||||
fprintf(stderr, "[%s] %s (%s:%d): %s\n", \
|
||||
APP_LOW_NAME, \
|
||||
@ -14,12 +15,17 @@
|
||||
file, \
|
||||
line, \
|
||||
qPrintable(message));
|
||||
#else
|
||||
#define DEBUG_OUTPUT_WORKER(type_string, message) \
|
||||
fprintf(stderr, "[%s] %s: %s\n", \
|
||||
APP_LOW_NAME, \
|
||||
type_string, \
|
||||
qPrintable(message));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
Debugging::Debugging() {
|
||||
}
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
void Debugging::debugHandler(QtMsgType type,
|
||||
const QMessageLogContext &placement,
|
||||
const QString &message) {
|
||||
@ -47,3 +53,31 @@ void Debugging::debugHandler(QtMsgType type,
|
||||
Q_UNUSED(message);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
void Debugging::debugHandler(QtMsgType type, const char *message) {
|
||||
#ifndef QT_NO_DEBUG_OUTPUT
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
DEBUG_OUTPUT_WORKER("INFO", message);
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
DEBUG_OUTPUT_WORKER("WARNING", message);
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
DEBUG_OUTPUT_WORKER("CRITICAL", message);
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
DEBUG_OUTPUT_WORKER("FATAL", message);
|
||||
qApp->exit(EXIT_FAILURE);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(type);
|
||||
Q_UNUSED(message);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
Debugging::Debugging() {
|
||||
}
|
||||
|
@ -6,15 +6,20 @@
|
||||
|
||||
class Debugging {
|
||||
private:
|
||||
Debugging();
|
||||
explicit Debugging();
|
||||
|
||||
public:
|
||||
// Specifies format of output console messages.
|
||||
// Macros:
|
||||
// QT_NO_DEBUG_OUTPUT - disables debug outputs completely!!!
|
||||
#if QT_VERSION >= 0x050000
|
||||
static void debugHandler(QtMsgType type,
|
||||
const QMessageLogContext &placement,
|
||||
const QString &message);
|
||||
#else
|
||||
static void debugHandler(QtMsgType type,
|
||||
const char *message);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // DEBUGGING_H
|
||||
|
@ -2,7 +2,11 @@
|
||||
#define DEFS_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QtWebKitVersion>
|
||||
#else
|
||||
#include <qwebkitversion.h>
|
||||
#endif
|
||||
|
||||
#define CMAKE_VERSION "@CMAKE_VERSION@"
|
||||
#define CMAKE_SYSTEM "@CMAKE_SYSTEM@"
|
||||
|
@ -9,18 +9,22 @@ DynamicShortcuts::DynamicShortcuts() {
|
||||
}
|
||||
|
||||
void DynamicShortcuts::save(const QList<QAction *> actions) {
|
||||
Settings *settings = Settings::getInstance();
|
||||
|
||||
foreach (QAction *action, actions) {
|
||||
Settings::getInstance()->setValue(APP_CFG_CUTS,
|
||||
action->objectName(),
|
||||
action->shortcut().toString(QKeySequence::NativeText));
|
||||
settings->setValue(APP_CFG_CUTS,
|
||||
action->objectName(),
|
||||
action->shortcut().toString(QKeySequence::NativeText));
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicShortcuts::load(const QList<QAction *> actions) {
|
||||
Settings *settings = Settings::getInstance();
|
||||
|
||||
foreach (QAction *action, actions) {
|
||||
QString shortcut_for_action = Settings::getInstance()->value(APP_CFG_CUTS,
|
||||
action->objectName(),
|
||||
action->shortcut().toString(QKeySequence::NativeText)).toString();
|
||||
QString shortcut_for_action = settings->value(APP_CFG_CUTS,
|
||||
action->objectName(),
|
||||
action->shortcut().toString(QKeySequence::NativeText)).toString();
|
||||
action->setShortcut(QKeySequence::fromString(shortcut_for_action,
|
||||
QKeySequence::NativeText));
|
||||
}
|
||||
|
@ -3,11 +3,12 @@
|
||||
|
||||
#include <QList>
|
||||
|
||||
|
||||
class QAction;
|
||||
|
||||
class DynamicShortcuts {
|
||||
private:
|
||||
DynamicShortcuts();
|
||||
explicit DynamicShortcuts();
|
||||
|
||||
public:
|
||||
// Checks the application settings and then initializes shortcut of
|
||||
|
@ -11,19 +11,19 @@
|
||||
if (app_translator.load(QString("rssguard_%1.qm").arg(locale_name), \
|
||||
APP_LANG_PATH)) { \
|
||||
QApplication::installTranslator(&app_translator); \
|
||||
qDebug("Application localization %s loaded successfully. Setting up locale.", \
|
||||
qDebug("Application localization %s loaded successfully.", \
|
||||
qPrintable(locale_name)); \
|
||||
} \
|
||||
else { \
|
||||
qDebug("Application localization %s was not loaded.", qPrintable(locale_name)); \
|
||||
qWarning("Application localization %s was not loaded.", qPrintable(locale_name)); \
|
||||
} \
|
||||
if (qt_translator.load(QString("qt_%1.qm").arg(locale_name), \
|
||||
APP_LANG_PATH)) { \
|
||||
qDebug("Qt localization %s loaded successfully. Setting up locale.", \
|
||||
qDebug("Qt localization %s loaded successfully.", \
|
||||
qPrintable(locale_name)); \
|
||||
} \
|
||||
else { \
|
||||
qDebug("Qt localization %s was not loaded.", qPrintable(locale_name)); \
|
||||
qWarning("Qt localization %s was not loaded.", qPrintable(locale_name)); \
|
||||
} \
|
||||
QLocale::setDefault(QLocale(locale_name));
|
||||
|
||||
@ -40,10 +40,9 @@ struct Language {
|
||||
|
||||
class Localization {
|
||||
private:
|
||||
Localization();
|
||||
explicit Localization();
|
||||
|
||||
public:
|
||||
|
||||
// Returns list of installed application localizations.
|
||||
// This list is used ie. in settings dialog.
|
||||
static QList<Language> getInstalledLanguages();
|
||||
|
@ -39,9 +39,8 @@ Settings::~Settings() {
|
||||
|
||||
QSettings::Status Settings::checkSettings() {
|
||||
qDebug("Syncing settings.");
|
||||
s_instance->sync();
|
||||
|
||||
return s_instance->status();
|
||||
sync();
|
||||
return status();
|
||||
}
|
||||
|
||||
Settings *Settings::getInstance() {
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define SETTINGS_H
|
||||
|
||||
#include <QSettings>
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
class Settings : public QSettings {
|
||||
|
@ -37,7 +37,7 @@ SystemFactory::AutoStartStatus SystemFactory::getAutoStartStatus() {
|
||||
|
||||
// No correct path was found.
|
||||
if (desktop_file_location.isEmpty()) {
|
||||
qDebug("Searching for auto-start function status failed. HOME variable not found.");
|
||||
qWarning("Searching for auto-start function status failed. HOME variable not found.");
|
||||
return SystemFactory::Unavailable;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
class SystemFactory {
|
||||
private:
|
||||
SystemFactory();
|
||||
explicit SystemFactory();
|
||||
|
||||
public:
|
||||
// Specifies possible states of auto-start functionality.
|
||||
|
@ -6,4 +6,5 @@ WebBrowserNetworkAccessManager::WebBrowserNetworkAccessManager(QObject *parent)
|
||||
}
|
||||
|
||||
WebBrowserNetworkAccessManager::~WebBrowserNetworkAccessManager() {
|
||||
qDebug("Destroying WebBrowserNetworkAccessManager instance.");
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ class WebBrowserNetworkAccessManager : public BaseNetworkAccessManager {
|
||||
// Constructors and destructors.
|
||||
explicit WebBrowserNetworkAccessManager(QObject *parent = 0);
|
||||
virtual ~WebBrowserNetworkAccessManager();
|
||||
|
||||
};
|
||||
|
||||
#endif // WEBBROWSERNETWORKACCESSMANAGER_H
|
||||
|
@ -30,11 +30,22 @@ void BaseWebView::onLoadFinished(bool ok) {
|
||||
}
|
||||
}
|
||||
|
||||
void BaseWebView::openLinkInNewTab() {
|
||||
emit linkMiddleClicked(m_contextLinkUrl);
|
||||
}
|
||||
|
||||
void BaseWebView::openImageInNewTab() {
|
||||
emit linkMiddleClicked(m_contextImageUrl);
|
||||
}
|
||||
|
||||
void BaseWebView::createConnections() {
|
||||
connect(this, &BaseWebView::loadFinished,
|
||||
this, &BaseWebView::onLoadFinished);
|
||||
connect(this, &BaseWebView::customContextMenuRequested,
|
||||
this, &BaseWebView::popupContextMenu);
|
||||
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
|
||||
connect(this, SIGNAL(customContextMenuRequested(QPoint)),
|
||||
this, SLOT(popupContextMenu(QPoint)));
|
||||
|
||||
connect(m_actionOpenLinkNewTab,SIGNAL(triggered()), this, SLOT(openLinkInNewTab()));
|
||||
connect(m_actionOpenImageNewTab, SIGNAL(triggered()),
|
||||
this, SLOT(openImageInNewTab()));
|
||||
}
|
||||
|
||||
void BaseWebView::setupIcons() {
|
||||
@ -42,6 +53,9 @@ void BaseWebView::setupIcons() {
|
||||
m_actionCopyLink->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-copy"));
|
||||
m_actionCopyImage->setIcon(IconThemeFactory::getInstance()->fromTheme("insert-image"));
|
||||
m_actionCopyImageUrl->setIcon(IconThemeFactory::getInstance()->fromTheme("edit-copy"));
|
||||
m_actionOpenLinkThisTab->setIcon(IconThemeFactory::getInstance()->fromTheme("text-html"));
|
||||
m_actionOpenLinkNewTab->setIcon(IconThemeFactory::getInstance()->fromTheme("text-html"));
|
||||
m_actionOpenImageNewTab->setIcon(IconThemeFactory::getInstance()->fromTheme("insert-image"));
|
||||
}
|
||||
|
||||
void BaseWebView::initializeActions() {
|
||||
@ -66,12 +80,20 @@ void BaseWebView::initializeActions() {
|
||||
m_actionCopyImageUrl->setText(tr("Copy image url"));
|
||||
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"));
|
||||
|
||||
m_actionOpenLinkThisTab = pageAction(QWebPage::OpenLink);
|
||||
m_actionOpenLinkThisTab->setParent(this);
|
||||
m_actionOpenLinkThisTab->setText(tr("Follow link"));
|
||||
m_actionOpenLinkThisTab->setToolTip(tr("Open the hyperlink in this tab"));
|
||||
|
||||
m_actionOpenImageNewTab = pageAction(QWebPage::OpenImageInNewWindow);
|
||||
m_actionOpenImageNewTab->setParent(this);
|
||||
m_actionOpenImageNewTab->setText(tr("Open image in new tab"));
|
||||
m_actionOpenImageNewTab->setToolTip(tr("Open this image in this tab"));
|
||||
}
|
||||
|
||||
void BaseWebView::displayErrorPage() {
|
||||
@ -82,34 +104,46 @@ void BaseWebView::displayErrorPage() {
|
||||
void BaseWebView::popupContextMenu(const QPoint &pos) {
|
||||
QMenu context_menu(tr("Web browser"), this);
|
||||
QMenu image_submenu(tr("Image"), &context_menu);
|
||||
QMenu link_submenu(tr("Hyperlink"), this);
|
||||
QWebHitTestResult hit_result = page()->mainFrame()->hitTestContent(pos);
|
||||
|
||||
image_submenu.setIcon(IconThemeFactory::getInstance()->fromTheme("image-x-generic"));
|
||||
link_submenu.setIcon(IconThemeFactory::getInstance()->fromTheme("text-html"));
|
||||
|
||||
// Assemble the menu from actions.
|
||||
context_menu.addAction(m_actionReload);
|
||||
|
||||
if (hit_result.linkUrl().isValid()) {
|
||||
context_menu.addAction(m_actionCopyLink);
|
||||
QUrl hit_url = hit_result.linkUrl();
|
||||
QUrl hit_image_url = hit_result.imageUrl();
|
||||
|
||||
if (hit_url.isValid()) {
|
||||
m_contextLinkUrl = hit_url;
|
||||
|
||||
context_menu.addMenu(&link_submenu);
|
||||
link_submenu.addAction(m_actionOpenLinkThisTab);
|
||||
link_submenu.addAction(m_actionOpenLinkNewTab);
|
||||
link_submenu.addAction(m_actionCopyLink);
|
||||
}
|
||||
|
||||
if (!hit_result.pixmap().isNull()) {
|
||||
// Add 'Image' menu, because if user clicked image it needs to be visible.
|
||||
context_menu.addMenu(&image_submenu);
|
||||
|
||||
if (hit_image_url.isValid()) {
|
||||
m_contextImageUrl = hit_image_url;
|
||||
image_submenu.addAction(m_actionOpenImageNewTab);
|
||||
image_submenu.addAction(m_actionCopyImageUrl);
|
||||
}
|
||||
image_submenu.addAction(m_actionCopyImage);
|
||||
}
|
||||
|
||||
if (hit_result.imageUrl().isValid()) {
|
||||
image_submenu.addAction(m_actionCopyImageUrl);
|
||||
}
|
||||
|
||||
// Display the menu.
|
||||
context_menu.exec(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void BaseWebView::mousePressEvent(QMouseEvent *event) {
|
||||
if (event->button() & Qt::MiddleButton) {
|
||||
if ((event->button() & Qt::MiddleButton) ||
|
||||
(event->button() & Qt::LeftButton && event->modifiers() & Qt::ControlModifier)) {
|
||||
QWebHitTestResult hit_result = page()->mainFrame()->hitTestContent(event->pos());
|
||||
|
||||
// Check if user clicked with middle mouse button on some
|
||||
@ -119,7 +153,6 @@ void BaseWebView::mousePressEvent(QMouseEvent *event) {
|
||||
|
||||
if (link_url.isValid()) {
|
||||
emit linkMiddleClicked(link_url);
|
||||
|
||||
// No more handling of event is now needed. Return.
|
||||
return;
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define BASEWEBVIEW_H
|
||||
|
||||
#include <QWebView>
|
||||
#include <QAction>
|
||||
|
||||
|
||||
class QAction;
|
||||
class QPaintEvent;
|
||||
class BaseWebPage;
|
||||
|
||||
@ -30,6 +30,9 @@ class BaseWebView : public QWebView {
|
||||
// Executes if loading of any page is done.
|
||||
void onLoadFinished(bool ok);
|
||||
|
||||
void openLinkInNewTab();
|
||||
void openImageInNewTab();
|
||||
|
||||
// Provides custom context menu.
|
||||
void popupContextMenu(const QPoint &pos);
|
||||
|
||||
@ -56,9 +59,13 @@ class BaseWebView : public QWebView {
|
||||
QAction *m_actionCopyLink;
|
||||
QAction *m_actionCopyImage;
|
||||
QAction *m_actionCopyImageUrl;
|
||||
QAction *m_actionOpenLinkThisTab;
|
||||
QAction *m_actionOpenLinkNewTab;
|
||||
QAction *m_actionOpenImageNewTab;
|
||||
|
||||
QPoint m_gestureOrigin;
|
||||
QUrl m_contextLinkUrl;
|
||||
QUrl m_contextImageUrl;
|
||||
};
|
||||
|
||||
#endif // BASEWEBVIEW_H
|
||||
|
@ -15,13 +15,13 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout)
|
||||
m_ui->m_lblIcon->setPixmap(QPixmap(APP_ICON_PATH));
|
||||
|
||||
// Load information from embedded text files.
|
||||
QTextStream str;
|
||||
QTextStream text_stream;
|
||||
QFile file;
|
||||
str.setDevice(&file);
|
||||
text_stream.setDevice(&file);
|
||||
|
||||
file.setFileName(APP_INFO_PATH + "/COPYING_GNU_GPL_HTML");
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
m_ui->m_txtLicenseGnu->setText(str.readAll());
|
||||
m_ui->m_txtLicenseGnu->setText(text_stream.readAll());
|
||||
}
|
||||
else {
|
||||
m_ui->m_txtLicenseGnu->setText(tr("License not found."));
|
||||
@ -30,7 +30,7 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout)
|
||||
|
||||
file.setFileName(APP_INFO_PATH + "/COPYING_BSD");
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
m_ui->m_txtLicenseBsd->setText(str.readAll());
|
||||
m_ui->m_txtLicenseBsd->setText(text_stream.readAll());
|
||||
}
|
||||
else {
|
||||
m_ui->m_txtLicenseBsd->setText(tr("License not found."));
|
||||
@ -39,7 +39,7 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout)
|
||||
|
||||
file.setFileName(APP_INFO_PATH + "/AUTHORS");
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
m_ui->m_txtThanks->setText(str.readAll());
|
||||
m_ui->m_txtThanks->setText(text_stream.readAll());
|
||||
}
|
||||
else {
|
||||
m_ui->m_txtThanks->setText(tr("Authors information not found."));
|
||||
@ -48,7 +48,7 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout)
|
||||
|
||||
file.setFileName(APP_INFO_PATH + "/CHANGELOG");
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
m_ui->m_txtChangelog->setText(str.readAll());
|
||||
m_ui->m_txtChangelog->setText(text_stream.readAll());
|
||||
}
|
||||
else {
|
||||
m_ui->m_txtChangelog->setText(tr("Changelog not found."));
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "gui/formmain.h"
|
||||
#include "gui/formabout.h"
|
||||
@ -21,9 +20,8 @@ FormMain::FormMain(QWidget *parent) : QMainWindow(parent), m_ui(new Ui::FormMain
|
||||
// Initialize singleton.
|
||||
s_instance = this;
|
||||
|
||||
// Prepare main window.
|
||||
// Prepare main window and tabs.
|
||||
prepareMenus();
|
||||
|
||||
m_ui->m_tabWidget->initializeTabs();
|
||||
|
||||
// Establish connections.
|
||||
@ -61,9 +59,6 @@ QList<QAction*> FormMain::getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
void FormMain::prepareTabs() {
|
||||
}
|
||||
|
||||
void FormMain::prepareMenus() {
|
||||
// Setup menu for tray icon.
|
||||
if (SystemTrayIcon::isSystemTrayAvailable()) {
|
||||
@ -96,7 +91,6 @@ void FormMain::switchFullscreenMode(bool turn_fullscreen_on) {
|
||||
if (turn_fullscreen_on) {
|
||||
showFullScreen();
|
||||
} else {
|
||||
|
||||
showNormal();
|
||||
}
|
||||
}
|
||||
@ -158,19 +152,19 @@ void FormMain::setupIcons() {
|
||||
|
||||
void FormMain::createConnections() {
|
||||
// Menu "File" connections.
|
||||
connect(m_ui->m_actionQuit, &QAction::triggered, this, &FormMain::quit);
|
||||
connect(m_ui->m_actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
|
||||
|
||||
// Menu "View" connections.
|
||||
connect(m_ui->m_actionFullscreen, &QAction::triggered, this, &FormMain::switchFullscreenMode);
|
||||
connect(m_ui->m_actionFullscreen, SIGNAL(triggered(bool)), this, SLOT(switchFullscreenMode(bool)));
|
||||
|
||||
// Menu "Tools" connections.
|
||||
connect(m_ui->m_actionSettings, &QAction::triggered, this, &FormMain::showSettings);
|
||||
connect(m_ui->m_actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
|
||||
|
||||
// Menu "Help" connections.
|
||||
connect(m_ui->m_actionAboutGuard, &QAction::triggered, this, &FormMain::showAbout);
|
||||
connect(m_ui->m_actionAboutGuard, SIGNAL(triggered()), this, SLOT(showAbout()));
|
||||
|
||||
// General connections.
|
||||
connect(qApp, &QCoreApplication::aboutToQuit, this, &FormMain::cleanupResources);
|
||||
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(cleanupResources()));
|
||||
}
|
||||
|
||||
void FormMain::closeEvent(QCloseEvent *event) {
|
||||
|
@ -18,6 +18,7 @@ class FormMain : public QMainWindow {
|
||||
// Returns menu for the tray icon.
|
||||
QMenu *getTrayMenu();
|
||||
|
||||
// Returns global tab widget.
|
||||
TabWidget *getTabWidget();
|
||||
|
||||
// Returns list of all globally available actions.
|
||||
@ -31,9 +32,6 @@ class FormMain : public QMainWindow {
|
||||
// Creates all needed menus and sets them up.
|
||||
void prepareMenus();
|
||||
|
||||
// Initializes "Feeds" tab and related stuff.
|
||||
void prepareTabs();
|
||||
|
||||
// Creates needed connections for this window.
|
||||
void createConnections();
|
||||
|
||||
|
@ -26,11 +26,21 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form
|
||||
// Setup behavior.
|
||||
m_ui->m_treeLanguages->setColumnCount(5);
|
||||
m_ui->m_treeLanguages->setHeaderHidden(false);
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
m_ui->m_treeLanguages->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
m_ui->m_treeLanguages->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
||||
m_ui->m_treeLanguages->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
|
||||
m_ui->m_treeLanguages->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
|
||||
m_ui->m_treeLanguages->header()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
|
||||
#else
|
||||
m_ui->m_treeLanguages->header()->setResizeMode(0, QHeaderView::ResizeToContents);
|
||||
m_ui->m_treeLanguages->header()->setResizeMode(1, QHeaderView::ResizeToContents);
|
||||
m_ui->m_treeLanguages->header()->setResizeMode(2, QHeaderView::ResizeToContents);
|
||||
m_ui->m_treeLanguages->header()->setResizeMode(3, QHeaderView::ResizeToContents);
|
||||
m_ui->m_treeLanguages->header()->setResizeMode(4, QHeaderView::ResizeToContents);
|
||||
#endif
|
||||
|
||||
m_ui->m_treeLanguages->setHeaderLabels(QStringList()
|
||||
<< tr("Language")
|
||||
<< tr("Code")
|
||||
@ -39,13 +49,13 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form
|
||||
<< tr("Email"));
|
||||
|
||||
// Establish needed connections.
|
||||
connect(this, &FormSettings::accepted, this, &FormSettings::saveSettings);
|
||||
connect(m_ui->m_cmbProxyType, static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged),
|
||||
this, &FormSettings::onProxyTypeChanged);
|
||||
connect(m_ui->m_checkShowPassword, &QCheckBox::stateChanged,
|
||||
this, &FormSettings::displayProxyPassword);
|
||||
connect(m_ui->m_btnBrowserProgressColor, &QPushButton::clicked,
|
||||
this, &FormSettings::changeBrowserProgressColor);
|
||||
connect(this, SIGNAL(accepted()), this, SLOT(saveSettings()));
|
||||
connect(m_ui->m_cmbProxyType, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(onProxyTypeChanged(int)));
|
||||
connect(m_ui->m_checkShowPassword, SIGNAL(stateChanged(int)),
|
||||
this, SLOT(displayProxyPassword(int)));
|
||||
connect(m_ui->m_btnBrowserProgressColor, SIGNAL(clicked()),
|
||||
this, SLOT(changeBrowserProgressColor()));
|
||||
|
||||
// Load all settings.
|
||||
loadGeneral();
|
||||
@ -107,35 +117,39 @@ void FormSettings::onProxyTypeChanged(int index) {
|
||||
}
|
||||
|
||||
void FormSettings::loadBrowser() {
|
||||
Settings *settings = Settings::getInstance();
|
||||
|
||||
// Load settings of web browser GUI.
|
||||
m_initialSettings.m_webBrowserProgress = Settings::getInstance()->value(APP_CFG_BROWSER,
|
||||
"browser_progress_color",
|
||||
QColor(0, 255, 0, 100)).value<QColor>();
|
||||
m_ui->m_checkBrowserProgressColor->setChecked(Settings::getInstance()->value(APP_CFG_BROWSER,
|
||||
"browser_colored_progress_enabled",
|
||||
true).toBool());
|
||||
m_ui->m_checkMouseGestures->setChecked(Settings::getInstance()->value(APP_CFG_BROWSER,
|
||||
"gestures_enabled",
|
||||
true).toBool());
|
||||
m_ui->m_checkQueueTabs->setChecked(Settings::getInstance()->value(APP_CFG_BROWSER,
|
||||
"queue_tabs",
|
||||
true).toBool());
|
||||
m_initialSettings.m_webBrowserProgress = settings->value(APP_CFG_BROWSER,
|
||||
"browser_progress_color",
|
||||
QColor(0, 255, 0, 100)).value<QColor>();
|
||||
m_ui->m_checkBrowserProgressColor->setChecked(settings->value(APP_CFG_BROWSER,
|
||||
"browser_colored_progress_enabled",
|
||||
true).toBool());
|
||||
m_ui->m_checkMouseGestures->setChecked(settings->value(APP_CFG_BROWSER,
|
||||
"gestures_enabled",
|
||||
true).toBool());
|
||||
m_ui->m_checkQueueTabs->setChecked(settings->value(APP_CFG_BROWSER,
|
||||
"queue_tabs",
|
||||
true).toBool());
|
||||
}
|
||||
|
||||
void FormSettings::saveBrowser() {
|
||||
Settings *settings = Settings::getInstance();
|
||||
|
||||
// Save settings of GUI of web browser.
|
||||
Settings::getInstance()->setValue(APP_CFG_BROWSER,
|
||||
"browser_progress_color",
|
||||
m_initialSettings.m_webBrowserProgress);
|
||||
Settings::getInstance()->setValue(APP_CFG_BROWSER,
|
||||
"browser_colored_progress_enabled",
|
||||
m_ui->m_checkBrowserProgressColor->isChecked());
|
||||
Settings::getInstance()->setValue(APP_CFG_BROWSER,
|
||||
"gestures_enabled",
|
||||
m_ui->m_checkMouseGestures->isChecked());
|
||||
Settings::getInstance()->setValue(APP_CFG_BROWSER,
|
||||
"queue_tabs",
|
||||
m_ui->m_checkQueueTabs->isChecked());
|
||||
settings->setValue(APP_CFG_BROWSER,
|
||||
"browser_progress_color",
|
||||
m_initialSettings.m_webBrowserProgress);
|
||||
settings->setValue(APP_CFG_BROWSER,
|
||||
"browser_colored_progress_enabled",
|
||||
m_ui->m_checkBrowserProgressColor->isChecked());
|
||||
settings->setValue(APP_CFG_BROWSER,
|
||||
"gestures_enabled",
|
||||
m_ui->m_checkMouseGestures->isChecked());
|
||||
settings->setValue(APP_CFG_BROWSER,
|
||||
"queue_tabs",
|
||||
m_ui->m_checkQueueTabs->isChecked());
|
||||
}
|
||||
|
||||
void FormSettings::loadProxy() {
|
||||
@ -147,28 +161,32 @@ void FormSettings::loadProxy() {
|
||||
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(Settings::getInstance()->value(APP_CFG_PROXY,
|
||||
"proxy_type",
|
||||
QNetworkProxy::NoProxy).toInt());
|
||||
Settings *settings = Settings::getInstance();
|
||||
|
||||
m_ui->m_cmbProxyType->setCurrentIndex(m_ui->m_cmbProxyType->findData(selected_proxy_type));
|
||||
m_ui->m_txtProxyHost->setText(Settings::getInstance()->value(APP_CFG_PROXY,
|
||||
"host").toString());
|
||||
m_ui->m_txtProxyUsername->setText(Settings::getInstance()->value(APP_CFG_PROXY,
|
||||
"username").toString());
|
||||
m_ui->m_txtProxyPassword->setText(Settings::getInstance()->value(APP_CFG_PROXY,
|
||||
"password").toString());
|
||||
m_ui->m_spinProxyPort->setValue(Settings::getInstance()->value(APP_CFG_PROXY,
|
||||
"port", 80).toInt());
|
||||
m_ui->m_txtProxyHost->setText(settings->value(APP_CFG_PROXY,
|
||||
"host").toString());
|
||||
m_ui->m_txtProxyUsername->setText(settings->value(APP_CFG_PROXY,
|
||||
"username").toString());
|
||||
m_ui->m_txtProxyPassword->setText(settings->value(APP_CFG_PROXY,
|
||||
"password").toString());
|
||||
m_ui->m_spinProxyPort->setValue(settings->value(APP_CFG_PROXY,
|
||||
"port", 80).toInt());
|
||||
}
|
||||
|
||||
void FormSettings::saveProxy() {
|
||||
Settings::getInstance()->setValue(APP_CFG_PROXY, "proxy_type",
|
||||
m_ui->m_cmbProxyType->itemData(m_ui->m_cmbProxyType->currentIndex()));
|
||||
Settings::getInstance()->setValue(APP_CFG_PROXY, "host",
|
||||
m_ui->m_txtProxyHost->text());
|
||||
Settings::getInstance()->setValue(APP_CFG_PROXY, "username",
|
||||
m_ui->m_txtProxyUsername->text());
|
||||
Settings::getInstance()->setValue(APP_CFG_PROXY, "password",
|
||||
m_ui->m_txtProxyPassword->text());
|
||||
Settings::getInstance()->setValue(APP_CFG_PROXY, "port",
|
||||
m_ui->m_spinProxyPort->value());
|
||||
Settings *settings = Settings::getInstance();
|
||||
|
||||
settings->setValue(APP_CFG_PROXY, "proxy_type",
|
||||
m_ui->m_cmbProxyType->itemData(m_ui->m_cmbProxyType->currentIndex()));
|
||||
settings->setValue(APP_CFG_PROXY, "host",
|
||||
m_ui->m_txtProxyHost->text());
|
||||
settings->setValue(APP_CFG_PROXY, "username",
|
||||
m_ui->m_txtProxyUsername->text());
|
||||
settings->setValue(APP_CFG_PROXY, "password",
|
||||
m_ui->m_txtProxyPassword->text());
|
||||
settings->setValue(APP_CFG_PROXY, "port",
|
||||
m_ui->m_spinProxyPort->value());
|
||||
|
||||
// Reload settings for all network access managers.
|
||||
WebBrowser::globalNetworkManager()->loadSettings();
|
||||
@ -198,18 +216,19 @@ void FormSettings::loadLanguage() {
|
||||
}
|
||||
|
||||
void FormSettings::saveLanguage() {
|
||||
if (m_ui->m_treeLanguages->currentItem() == nullptr) {
|
||||
if (m_ui->m_treeLanguages->currentItem() == NULL) {
|
||||
qDebug("No localizations loaded in settings dialog, so no saving for them.");
|
||||
return;
|
||||
}
|
||||
|
||||
QString actual_lang = Settings::getInstance()->value(APP_CFG_GEN,
|
||||
"language",
|
||||
"en").toString();
|
||||
Settings *settings = Settings::getInstance();
|
||||
QString actual_lang = settings->value(APP_CFG_GEN,
|
||||
"language",
|
||||
"en").toString();
|
||||
QString new_lang = m_ui->m_treeLanguages->currentItem()->text(1);
|
||||
|
||||
if (new_lang != actual_lang) {
|
||||
Settings::getInstance()->setValue(APP_CFG_GEN, "language", new_lang);
|
||||
settings->setValue(APP_CFG_GEN, "language", new_lang);
|
||||
|
||||
QMessageBox msg_question(this);
|
||||
msg_question.setText(tr("Language of RSS Guard was changed. Note that changes will take effect on next Qonverter start."));
|
||||
@ -276,17 +295,19 @@ void FormSettings::saveGeneral() {
|
||||
}
|
||||
|
||||
void FormSettings::loadInterface() {
|
||||
Settings *settings = Settings::getInstance();
|
||||
|
||||
// Load settings of tray icon.
|
||||
if (SystemTrayIcon::isSystemTrayAvailable()) {
|
||||
m_ui->m_radioTrayOff->setChecked(!Settings::getInstance()->value(APP_CFG_GUI,
|
||||
"use_tray_icon",
|
||||
true).toBool());
|
||||
m_ui->m_cmbTrayClose->setCurrentIndex(Settings::getInstance()->value(APP_CFG_GUI,
|
||||
"close_win_action",
|
||||
0).toInt());
|
||||
m_ui->m_checkHidden->setChecked(Settings::getInstance()->value(APP_CFG_GUI,
|
||||
"start_hidden",
|
||||
false).toBool());
|
||||
m_ui->m_radioTrayOff->setChecked(!settings->value(APP_CFG_GUI,
|
||||
"use_tray_icon",
|
||||
true).toBool());
|
||||
m_ui->m_cmbTrayClose->setCurrentIndex(settings->value(APP_CFG_GUI,
|
||||
"close_win_action",
|
||||
0).toInt());
|
||||
m_ui->m_checkHidden->setChecked(settings->value(APP_CFG_GUI,
|
||||
"start_hidden",
|
||||
false).toBool());
|
||||
}
|
||||
// Tray icon is not supported on this machine.
|
||||
else {
|
||||
@ -316,35 +337,44 @@ void FormSettings::loadInterface() {
|
||||
|
||||
// Mark active theme.
|
||||
if (current_theme == APP_THEME_SYSTEM) {
|
||||
// Because system icon theme lies at the index 1.
|
||||
// Because system icon theme lies at the index 0.
|
||||
m_ui->m_cmbIconTheme->setCurrentIndex(0);
|
||||
}
|
||||
else {
|
||||
#if QT_VERSION >= 0x050000
|
||||
m_ui->m_cmbIconTheme->setCurrentText(current_theme);
|
||||
#else
|
||||
int theme_index = m_ui->m_cmbIconTheme->findText(current_theme);
|
||||
if (theme_index >= 0) {
|
||||
m_ui->m_cmbIconTheme->setCurrentIndex(theme_index);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Load tab settings.
|
||||
m_ui->m_checkCloseTabsMiddleClick->setChecked(Settings::getInstance()->value(APP_CFG_GUI,
|
||||
"tab_close_mid_button",
|
||||
true).toBool());
|
||||
m_ui->m_checkCloseTabsDoubleClick->setChecked(Settings::getInstance()->value(APP_CFG_GUI,
|
||||
"tab_close_double_button",
|
||||
true).toBool());
|
||||
m_ui->m_checkNewTabDoubleClick->setChecked(Settings::getInstance()->value(APP_CFG_GUI,
|
||||
"tab_new_double_button",
|
||||
true).toBool());
|
||||
m_ui->m_checkCloseTabsMiddleClick->setChecked(settings->value(APP_CFG_GUI,
|
||||
"tab_close_mid_button",
|
||||
true).toBool());
|
||||
m_ui->m_checkCloseTabsDoubleClick->setChecked(settings->value(APP_CFG_GUI,
|
||||
"tab_close_double_button",
|
||||
true).toBool());
|
||||
m_ui->m_checkNewTabDoubleClick->setChecked(settings->value(APP_CFG_GUI,
|
||||
"tab_new_double_button",
|
||||
true).toBool());
|
||||
}
|
||||
|
||||
void FormSettings::saveInterface() {
|
||||
Settings *settings = Settings::getInstance();
|
||||
|
||||
// Save tray icon.
|
||||
if (SystemTrayIcon::isSystemTrayAvailable()) {
|
||||
Settings::getInstance()->setValue(APP_CFG_GUI, "use_tray_icon",
|
||||
m_ui->m_radioTrayOn->isChecked());
|
||||
Settings::getInstance()->setValue(APP_CFG_GUI, "close_win_action",
|
||||
m_ui->m_cmbTrayClose->currentIndex());
|
||||
Settings::getInstance()->setValue(APP_CFG_GUI, "start_hidden",
|
||||
m_ui->m_checkHidden->isChecked());
|
||||
if (Settings::getInstance()->value(APP_CFG_GUI, "use_tray_icon", true).toBool()) {
|
||||
settings->setValue(APP_CFG_GUI, "use_tray_icon",
|
||||
m_ui->m_radioTrayOn->isChecked());
|
||||
settings->setValue(APP_CFG_GUI, "close_win_action",
|
||||
m_ui->m_cmbTrayClose->currentIndex());
|
||||
settings->setValue(APP_CFG_GUI, "start_hidden",
|
||||
m_ui->m_checkHidden->isChecked());
|
||||
if (settings->value(APP_CFG_GUI, "use_tray_icon", true).toBool()) {
|
||||
SystemTrayIcon::getInstance()->show();
|
||||
}
|
||||
else {
|
||||
@ -358,10 +388,10 @@ void FormSettings::saveInterface() {
|
||||
IconThemeFactory::getInstance()->setCurrentIconTheme(selected_icon_theme);
|
||||
|
||||
// Save tab settings.
|
||||
Settings::getInstance()->setValue(APP_CFG_GUI, "tab_close_mid_button",
|
||||
m_ui->m_checkCloseTabsMiddleClick->isChecked());
|
||||
Settings::getInstance()->setValue(APP_CFG_GUI, "tab_close_double_button",
|
||||
m_ui->m_checkCloseTabsDoubleClick->isChecked());
|
||||
Settings::getInstance()->setValue(APP_CFG_GUI, "tab_new_double_button",
|
||||
m_ui->m_checkNewTabDoubleClick->isChecked());
|
||||
settings->setValue(APP_CFG_GUI, "tab_close_mid_button",
|
||||
m_ui->m_checkCloseTabsMiddleClick->isChecked());
|
||||
settings->setValue(APP_CFG_GUI, "tab_close_double_button",
|
||||
m_ui->m_checkCloseTabsDoubleClick->isChecked());
|
||||
settings->setValue(APP_CFG_GUI, "tab_new_double_button",
|
||||
m_ui->m_checkNewTabDoubleClick->isChecked());
|
||||
}
|
||||
|
@ -21,9 +21,12 @@ FormWelcome::FormWelcome(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormWe
|
||||
move(screen.center() - rect().center());
|
||||
|
||||
// Make sure that clicked hyperlinks are opened in defult web browser.
|
||||
connect(m_ui->m_lblInfo, &QLabel::linkActivated, [=] (const QString &link) {
|
||||
QDesktopServices::openUrl(QUrl(link));
|
||||
});
|
||||
connect(m_ui->m_lblInfo, SIGNAL(linkActivated(QString)),
|
||||
this, SLOT(openLink(QString)));
|
||||
}
|
||||
|
||||
void FormWelcome::openLink(const QString &link) {
|
||||
QDesktopServices::openUrl(QUrl(link));
|
||||
}
|
||||
|
||||
FormWelcome::~FormWelcome() {
|
||||
|
@ -18,6 +18,9 @@ class FormWelcome : public QDialog {
|
||||
explicit FormWelcome(QWidget *parent = 0);
|
||||
virtual ~FormWelcome();
|
||||
|
||||
private slots:
|
||||
void openLink(const QString &link);
|
||||
|
||||
private:
|
||||
Ui::FormWelcome *m_ui;
|
||||
};
|
||||
|
@ -21,6 +21,7 @@ ThemeFactoryEvent::ThemeFactoryEvent() : QEvent(ThemeFactoryEvent::type()) {
|
||||
}
|
||||
|
||||
ThemeFactoryEvent::~ThemeFactoryEvent() {
|
||||
qDebug("Destroying IconThemeFactoryEvent.");
|
||||
}
|
||||
|
||||
QEvent::Type ThemeFactoryEvent::type() {
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QString>
|
||||
#include <QEvent>
|
||||
#include <QIcon>
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
class IconThemeFactory : public QObject {
|
||||
@ -13,6 +14,9 @@ class IconThemeFactory : public QObject {
|
||||
// Singleton getter.
|
||||
static IconThemeFactory *getInstance();
|
||||
|
||||
// Destructor.
|
||||
virtual ~IconThemeFactory();
|
||||
|
||||
// Wrapper for QIcon::fromTheme.
|
||||
// TODO: If icon is not found in user-defined icon theme,
|
||||
// then it is searched in system-default theme (ThemeFactory::getSystemIconTheme()).
|
||||
@ -40,9 +44,8 @@ class IconThemeFactory : public QObject {
|
||||
void setCurrentIconTheme(const QString &theme_name);
|
||||
|
||||
private:
|
||||
// Constructors and destructors
|
||||
// Constructor.
|
||||
explicit IconThemeFactory(QObject *parent = 0);
|
||||
virtual ~IconThemeFactory();
|
||||
|
||||
// Holds name of the current icon theme.
|
||||
QString m_currentIconTheme;
|
||||
|
@ -50,20 +50,21 @@ void LocationLineEdit::mousePressEvent(QMouseEvent *event) {
|
||||
|
||||
void LocationLineEdit::paintEvent(QPaintEvent *event) {
|
||||
// Draw "progress bar" if needed.
|
||||
if (m_progress > 0 && Settings::getInstance()->value(APP_CFG_BROWSER,
|
||||
"browser_colored_progress_enabled",
|
||||
true).toBool()) {
|
||||
Settings *settings = Settings::getInstance();
|
||||
|
||||
if (m_progress > 0 && settings->value(APP_CFG_BROWSER,
|
||||
"browser_colored_progress_enabled",
|
||||
true).toBool()) {
|
||||
QPalette current_palette = palette();
|
||||
QColor loadingColor = Settings::getInstance()->value(APP_CFG_BROWSER,
|
||||
"browser_progress_color",
|
||||
QColor(0, 255, 0, 100)).value<QColor>();
|
||||
QColor loadingColor = settings->value(APP_CFG_BROWSER,
|
||||
"browser_progress_color",
|
||||
QColor(0, 255, 0, 100)).value<QColor>();
|
||||
QLinearGradient gradient(0, 0, width(), 0);
|
||||
qreal percentage_border = m_progress / 100.0;
|
||||
|
||||
gradient.setColorAt(0, loadingColor);
|
||||
gradient.setColorAt(percentage_border - 0.01, loadingColor);
|
||||
gradient.setColorAt(percentage_border - 0.008, loadingColor.lighter(130));
|
||||
//gradient.setColorAt(percentage_border - 0.002, loadingColor);
|
||||
gradient.setColorAt(percentage_border, QApplication::palette().color(QPalette::Base));
|
||||
current_palette.setBrush(QPalette::Base, gradient);
|
||||
|
||||
|
@ -7,7 +7,10 @@
|
||||
class WebBrowser;
|
||||
|
||||
class LocationLineEdit : public BaseLineEdit {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit LocationLineEdit(QWidget *parent = 0);
|
||||
virtual ~LocationLineEdit();
|
||||
|
||||
|
@ -40,7 +40,7 @@ ShortcutButton::~ShortcutButton() {
|
||||
}
|
||||
|
||||
void ShortcutButton::keyPressEvent(QKeyEvent *event) {
|
||||
int pressed_key = event->key();
|
||||
int pressed_key = event->key();
|
||||
|
||||
if (pressed_key == -1) {
|
||||
m_catcher->doneRecording();
|
||||
@ -49,11 +49,11 @@ void ShortcutButton::keyPressEvent(QKeyEvent *event) {
|
||||
Qt::KeyboardModifiers new_modifiers = event->modifiers() &
|
||||
(Qt::SHIFT | Qt::CTRL | Qt::ALT | Qt::META);
|
||||
|
||||
if (m_catcher->m_isRecording == false && (pressed_key == Qt::Key_Return || pressed_key == Qt::Key_Space)) {
|
||||
if (!m_catcher->m_isRecording && (pressed_key == Qt::Key_Return || pressed_key == Qt::Key_Space)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_catcher->m_isRecording == false) {
|
||||
if (!m_catcher->m_isRecording) {
|
||||
return QPushButton::keyPressEvent(event);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,9 @@ class ShortcutCatcher;
|
||||
|
||||
class ShortcutButton : public QPushButton {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit ShortcutButton(ShortcutCatcher *catcher, QWidget *parent = 0);
|
||||
virtual ~ShortcutButton();
|
||||
|
||||
|
@ -55,8 +55,8 @@ ShortcutCatcher::ShortcutCatcher(QWidget *parent)
|
||||
m_layout->addWidget(m_clearButton);
|
||||
|
||||
// Establish needed connections.
|
||||
connect(m_clearButton, &QToolButton::clicked, this, &ShortcutCatcher::clearShortcut);
|
||||
connect(m_sequenceButton, &ShortcutButton::clicked, this, &ShortcutCatcher::startRecording);
|
||||
connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clearShortcut()));
|
||||
connect(m_sequenceButton, SIGNAL(clicked()), this, SLOT(startRecording()));
|
||||
|
||||
// Prepare initial state of the control.
|
||||
updateDisplayShortcut();
|
||||
|
@ -30,7 +30,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define KEYSEQUENCECATCHER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
|
||||
class QHBoxLayout;
|
||||
@ -42,6 +41,7 @@ class ShortcutCatcher : public QWidget {
|
||||
friend class ShortcutButton;
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit ShortcutCatcher(QWidget *parent = 0);
|
||||
virtual ~ShortcutCatcher();
|
||||
|
||||
@ -49,7 +49,7 @@ class ShortcutCatcher : public QWidget {
|
||||
void updateDisplayShortcut();
|
||||
|
||||
QKeySequence shortcut() const;
|
||||
void setShortcut(const QKeySequence& key);
|
||||
void setShortcut(const QKeySequence &key);
|
||||
|
||||
protected slots:
|
||||
void startRecording();
|
||||
@ -59,7 +59,7 @@ class ShortcutCatcher : public QWidget {
|
||||
void clearShortcut();
|
||||
|
||||
signals:
|
||||
void shortcutChanged(QKeySequence seguence);
|
||||
void shortcutChanged(const QKeySequence &seguence);
|
||||
|
||||
private:
|
||||
QToolButton *m_clearButton;
|
||||
|
@ -19,7 +19,7 @@ TrayIconMenu::~TrayIconMenu() {
|
||||
}
|
||||
|
||||
bool TrayIconMenu::event(QEvent *event) {
|
||||
if (QtSingleApplication::activeModalWidget() != nullptr &&
|
||||
if (QtSingleApplication::activeModalWidget() != NULL &&
|
||||
event->type() == QEvent::Show) {
|
||||
QTimer::singleShot(0, this, SLOT(hide()));
|
||||
SystemTrayIcon::getInstance()->showMessage(APP_LONG_NAME,
|
||||
@ -43,7 +43,8 @@ SystemTrayIcon::SystemTrayIcon(const QString &normal_icon,
|
||||
setContextMenu(parent->getTrayMenu());
|
||||
|
||||
// Create necessary connections.
|
||||
connect(this, &SystemTrayIcon::activated, this, &SystemTrayIcon::onActivated);
|
||||
connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||
this, SLOT(onActivated(QSystemTrayIcon::ActivationReason)));
|
||||
}
|
||||
|
||||
SystemTrayIcon::~SystemTrayIcon() {
|
||||
@ -51,7 +52,7 @@ SystemTrayIcon::~SystemTrayIcon() {
|
||||
hide();
|
||||
}
|
||||
|
||||
void SystemTrayIcon::onActivated(const ActivationReason &reason) {
|
||||
void SystemTrayIcon::onActivated(const QSystemTrayIcon::ActivationReason &reason) {
|
||||
switch (reason) {
|
||||
case SystemTrayIcon::Trigger:
|
||||
case SystemTrayIcon::DoubleClick:
|
||||
|
@ -12,6 +12,7 @@ class QEvent;
|
||||
#if defined(Q_OS_WIN)
|
||||
class TrayIconMenu : public QMenu {
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit TrayIconMenu(const QString &title, QWidget *parent);
|
||||
virtual ~TrayIconMenu();
|
||||
|
||||
@ -24,6 +25,7 @@ class SystemTrayIcon : public QSystemTrayIcon {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit SystemTrayIcon(const QString &normal_icon,
|
||||
const QString &plain_icon,
|
||||
FormMain *parent = 0);
|
||||
@ -51,7 +53,7 @@ class SystemTrayIcon : public QSystemTrayIcon {
|
||||
|
||||
private slots:
|
||||
void showPrivate();
|
||||
void onActivated(const ActivationReason &reason);
|
||||
void onActivated(const QSystemTrayIcon::ActivationReason &reason);
|
||||
|
||||
private:
|
||||
QString m_normalIcon;
|
||||
|
@ -19,9 +19,9 @@ TabWidget::~TabWidget() {
|
||||
}
|
||||
|
||||
void TabWidget::createConnections() {
|
||||
connect(tabBar(), &QTabBar::tabCloseRequested, this, &TabWidget::closeTab);
|
||||
connect(tabBar(), &TabBar::emptySpaceDoubleClicked,
|
||||
this, &TabWidget::addEmptyBrowser);
|
||||
connect(tabBar(), SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
|
||||
connect(tabBar(), SIGNAL(emptySpaceDoubleClicked()),
|
||||
this, SLOT(addEmptyBrowser()));
|
||||
}
|
||||
|
||||
TabBar *TabWidget::tabBar() {
|
||||
@ -53,7 +53,7 @@ void TabWidget::setupIcons() {
|
||||
// Other indexes probably contain WebBrowsers.
|
||||
else {
|
||||
WebBrowser *active_browser = widget(index)->webBrowser();
|
||||
if (active_browser != nullptr && active_browser->icon().isNull()) {
|
||||
if (active_browser != NULL && active_browser->icon().isNull()) {
|
||||
// We found WebBrowser instance of this tab page, which
|
||||
// has no suitable icon, load a new one from the icon theme.
|
||||
setTabIcon(index, IconThemeFactory::getInstance()->fromTheme("text-html"));
|
||||
@ -103,14 +103,10 @@ int TabWidget::insertTab(int index, QWidget *widget, const QString &label,
|
||||
}
|
||||
|
||||
int TabWidget::addEmptyBrowser() {
|
||||
// TODO: Add reading of move_after_current and make_active
|
||||
// flags from settings.
|
||||
return addBrowser(false, true);
|
||||
}
|
||||
|
||||
int TabWidget::addLinkedBrowser(const QUrl &initial_url) {
|
||||
// TODO: Add reading of move_after_current and make_active
|
||||
// flags from settings.
|
||||
return addBrowser(Settings::getInstance()->value(APP_CFG_BROWSER,
|
||||
"queue_tabs",
|
||||
true).toBool(),
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define TABWIDGET_H
|
||||
|
||||
#include <QTabWidget>
|
||||
#include <QUrl>
|
||||
|
||||
#include "gui/tabbar.h"
|
||||
#include "gui/tabcontent.h"
|
||||
@ -50,12 +51,12 @@ class TabWidget : public QTabWidget {
|
||||
|
||||
// Adds new WebBrowser with link. This is used when user
|
||||
// selects to "Open link in new tab.".
|
||||
int addLinkedBrowser(const QUrl &initial_url);
|
||||
int addLinkedBrowser(const QUrl &initial_url = QUrl());
|
||||
|
||||
// General method for adding WebBrowsers.
|
||||
int addBrowser(bool move_after_current,
|
||||
bool make_active,
|
||||
const QUrl &initial_url = QUrl());
|
||||
bool make_active,
|
||||
const QUrl &initial_url = QUrl());
|
||||
};
|
||||
|
||||
#endif // TABWIDGET_H
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "core/basewebpage.h"
|
||||
#include "gui/basewebview.h"
|
||||
#include "gui/webbrowser.h"
|
||||
#include "gui/formmain.h"
|
||||
#include "gui/locationlineedit.h"
|
||||
#include "gui/iconthemefactory.h"
|
||||
#include "gui/tabwidget.h"
|
||||
@ -19,7 +20,7 @@
|
||||
QPointer<WebBrowserNetworkAccessManager> WebBrowser::m_networkManager;
|
||||
QList<WebBrowser*> WebBrowser::m_runningWebBrowsers;
|
||||
|
||||
WebBrowser::WebBrowser(TabWidget *parent)
|
||||
WebBrowser::WebBrowser(QWidget *parent)
|
||||
: TabContent(parent), m_layout(new QVBoxLayout(this)),
|
||||
m_toolBar(new QToolBar(tr("Navigation panel"), this)),
|
||||
m_webView(new BaseWebView(this)),
|
||||
@ -71,28 +72,20 @@ WebBrowser::WebBrowser(TabWidget *parent)
|
||||
|
||||
void WebBrowser::createConnections() {
|
||||
// When user confirms new url, then redirect to it.
|
||||
connect(m_txtLocation,
|
||||
&LocationLineEdit::submitted,
|
||||
this,
|
||||
static_cast<void (WebBrowser::*)(const QString &url)>(&WebBrowser::navigateToUrl));
|
||||
connect(m_txtLocation,SIGNAL(submitted(QString)),
|
||||
this, SLOT(navigateToUrl(QString)));
|
||||
// If new page loads, then update current url.
|
||||
connect(m_webView, &BaseWebView::urlChanged,
|
||||
this, &WebBrowser::updateUrl);
|
||||
connect(m_webView, SIGNAL(urlChanged(QUrl)), this, SLOT(updateUrl(QUrl)));
|
||||
|
||||
// Connect this WebBrowser to global TabWidget.
|
||||
// TODO: Think over moving this connections from here to
|
||||
// e.g. TabWidget::addBrowser.
|
||||
TabWidget *parent_widget = static_cast<TabWidget*>(parent());
|
||||
connect(m_webView, &BaseWebView::newTabRequested,
|
||||
parent_widget, &TabWidget::addEmptyBrowser);
|
||||
connect(m_webView, &BaseWebView::linkMiddleClicked,
|
||||
parent_widget, &TabWidget::addLinkedBrowser);
|
||||
TabWidget *tab_widget = FormMain::getInstance()->getTabWidget();
|
||||
connect(m_webView, SIGNAL(newTabRequested()), tab_widget, SLOT(addEmptyBrowser()));
|
||||
connect(m_webView, SIGNAL(linkMiddleClicked(QUrl)),
|
||||
tab_widget, SLOT(addLinkedBrowser(QUrl)));
|
||||
|
||||
// Change location textbox status according to webpage status.
|
||||
connect(m_webView, &BaseWebView::loadProgress,
|
||||
m_txtLocation, &LocationLineEdit::setProgress);
|
||||
connect(m_webView, &BaseWebView::loadFinished,
|
||||
m_txtLocation, &LocationLineEdit::clearProgress);
|
||||
connect(m_webView, SIGNAL(loadProgress(int)), m_txtLocation, SLOT(setProgress(int)));
|
||||
connect(m_webView, SIGNAL(loadFinished(bool)), m_txtLocation, SLOT(clearProgress()));
|
||||
}
|
||||
|
||||
void WebBrowser::updateUrl(const QUrl &url) {
|
||||
@ -106,7 +99,11 @@ void WebBrowser::navigateToUrl(const QUrl &url) {
|
||||
}
|
||||
|
||||
void WebBrowser::navigateToUrl(const QString &textual_url) {
|
||||
navigateToUrl(QUrl::fromUserInput(textual_url));
|
||||
// Prepare input url.
|
||||
QString better_url = textual_url;
|
||||
better_url = better_url.replace('\\', '/');
|
||||
|
||||
navigateToUrl(QUrl::fromUserInput(better_url));
|
||||
}
|
||||
|
||||
WebBrowser::~WebBrowser() {
|
||||
@ -124,7 +121,7 @@ WebBrowser *WebBrowser::webBrowser() {
|
||||
}
|
||||
|
||||
QMenu *WebBrowser::globalMenu() {
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QIcon WebBrowser::icon() {
|
||||
|
@ -2,6 +2,8 @@
|
||||
#define WEBBROWSER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPointer>
|
||||
#include <QUrl>
|
||||
|
||||
#include "gui/tabcontent.h"
|
||||
|
||||
@ -19,7 +21,7 @@ class WebBrowser : public TabContent {
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit WebBrowser(TabWidget *parent = 0);
|
||||
explicit WebBrowser(QWidget *parent = 0);
|
||||
~WebBrowser();
|
||||
|
||||
// Reloads icons for all buttons.
|
||||
|
@ -43,7 +43,11 @@ int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
// Setup debug output system.
|
||||
#if QT_VERSION >= 0x050000
|
||||
qInstallMessageHandler(Debugging::debugHandler);
|
||||
#else
|
||||
qInstallMsgHandler(Debugging::debugHandler);
|
||||
#endif
|
||||
|
||||
// Instantiate base application object.
|
||||
QtSingleApplication application(argc, argv);
|
||||
@ -109,8 +113,8 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
// Setup single-instance behavior.
|
||||
QObject::connect(&application, &QtSingleApplication::messageReceived,
|
||||
&window, &FormMain::processExecutionMessage);
|
||||
QObject::connect(&application, SIGNAL(messageReceived(const QString&)),
|
||||
&window, SLOT(processExecutionMessage(QString)));
|
||||
|
||||
// Enter global event loop.
|
||||
return QtSingleApplication::exec();
|
||||
|
Loading…
x
Reference in New Issue
Block a user