Changes.
This commit is contained in:
parent
e5af61bd4f
commit
9136c6749e
@ -435,7 +435,7 @@ void FormSettings::saveProxy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FormSettings::loadLanguage() {
|
void FormSettings::loadLanguage() {
|
||||||
foreach (const Language &language, Localization::instance()->installedLanguages()) {
|
foreach (const Language &language, qApp->localization()->installedLanguages()) {
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->m_treeLanguages);
|
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->m_treeLanguages);
|
||||||
item->setText(0, language.m_name);
|
item->setText(0, language.m_name);
|
||||||
item->setText(1, language.m_code);
|
item->setText(1, language.m_code);
|
||||||
@ -446,7 +446,7 @@ void FormSettings::loadLanguage() {
|
|||||||
language.m_code));
|
language.m_code));
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QTreeWidgetItem*> matching_items = m_ui->m_treeLanguages->findItems(Localization::instance()->loadedLanguage(),
|
QList<QTreeWidgetItem*> matching_items = m_ui->m_treeLanguages->findItems(qApp->localization()->loadedLanguage(),
|
||||||
Qt::MatchContains,
|
Qt::MatchContains,
|
||||||
1);
|
1);
|
||||||
if (!matching_items.isEmpty()) {
|
if (!matching_items.isEmpty()) {
|
||||||
@ -461,7 +461,7 @@ void FormSettings::saveLanguage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Settings *settings = qApp->settings();
|
Settings *settings = qApp->settings();
|
||||||
QString actual_lang = Localization::instance()->loadedLanguage();
|
QString actual_lang = qApp->localization()->loadedLanguage();
|
||||||
QString new_lang = m_ui->m_treeLanguages->currentItem()->text(1);
|
QString new_lang = m_ui->m_treeLanguages->currentItem()->text(1);
|
||||||
|
|
||||||
// Save prompt for restart if language has changed.
|
// Save prompt for restart if language has changed.
|
||||||
@ -707,9 +707,9 @@ void FormSettings::loadInterface() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load skin.
|
// Load skin.
|
||||||
QString selected_skin = SkinFactory::instance()->selectedSkinName();
|
QString selected_skin = qApp->skins()->selectedSkinName();
|
||||||
|
|
||||||
foreach (const Skin &skin, SkinFactory::instance()->installedSkins()) {
|
foreach (const Skin &skin, qApp->skins()->installedSkins()) {
|
||||||
QTreeWidgetItem *new_item = new QTreeWidgetItem(QStringList() <<
|
QTreeWidgetItem *new_item = new QTreeWidgetItem(QStringList() <<
|
||||||
skin.m_visibleName <<
|
skin.m_visibleName <<
|
||||||
skin.m_version <<
|
skin.m_version <<
|
||||||
@ -804,8 +804,8 @@ void FormSettings::saveInterface() {
|
|||||||
if (m_ui->m_treeSkins->selectedItems().size() > 0) {
|
if (m_ui->m_treeSkins->selectedItems().size() > 0) {
|
||||||
Skin active_skin = m_ui->m_treeSkins->currentItem()->data(0, Qt::UserRole).value<Skin>();
|
Skin active_skin = m_ui->m_treeSkins->currentItem()->data(0, Qt::UserRole).value<Skin>();
|
||||||
|
|
||||||
if (SkinFactory::instance()->selectedSkinName() != active_skin.m_baseName) {
|
if (qApp->skins()->selectedSkinName() != active_skin.m_baseName) {
|
||||||
SkinFactory::instance()->setCurrentSkinName(active_skin.m_baseName);
|
qApp->skins()->setCurrentSkinName(active_skin.m_baseName);
|
||||||
m_changedDataTexts.append(tr("skin changed"));
|
m_changedDataTexts.append(tr("skin changed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
src/main.cpp
10
src/main.cpp
@ -16,18 +16,14 @@
|
|||||||
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "definitions/definitions.h"
|
#include "definitions/definitions.h"
|
||||||
|
#include "miscellaneous/application.h"
|
||||||
#include "miscellaneous/databasefactory.h"
|
#include "miscellaneous/databasefactory.h"
|
||||||
#include "miscellaneous/debugging.h"
|
#include "miscellaneous/debugging.h"
|
||||||
#include "miscellaneous/localization.h"
|
|
||||||
#include "miscellaneous/settings.h"
|
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
#include "miscellaneous/skinfactory.h"
|
|
||||||
#include "dynamic-shortcuts/dynamicshortcuts.h"
|
#include "dynamic-shortcuts/dynamicshortcuts.h"
|
||||||
#include "gui/formmain.h"
|
#include "gui/formmain.h"
|
||||||
#include "gui/systemtrayicon.h"
|
|
||||||
#include "gui/feedmessageviewer.h"
|
#include "gui/feedmessageviewer.h"
|
||||||
#include "gui/feedsview.h"
|
#include "gui/feedsview.h"
|
||||||
#include "miscellaneous/application.h"
|
|
||||||
|
|
||||||
// Needed for setting ini file format on Mac OS.
|
// Needed for setting ini file format on Mac OS.
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
@ -79,10 +75,10 @@ int main(int argc, char *argv[]) {
|
|||||||
// and skin.
|
// and skin.
|
||||||
IconFactory::instance()->setupSearchPaths();
|
IconFactory::instance()->setupSearchPaths();
|
||||||
IconFactory::instance()->loadCurrentIconTheme();
|
IconFactory::instance()->loadCurrentIconTheme();
|
||||||
SkinFactory::instance()->loadCurrentSkin();
|
qApp->skins()->loadCurrentSkin();
|
||||||
|
|
||||||
// Load localization and setup locale before any widget is constructed.
|
// Load localization and setup locale before any widget is constructed.
|
||||||
Localization::instance()->load();
|
qApp->localization()->loadActiveLanguage();
|
||||||
|
|
||||||
// These settings needs to be set before any QSettings object.
|
// These settings needs to be set before any QSettings object.
|
||||||
Application::setApplicationName(APP_NAME);
|
Application::setApplicationName(APP_NAME);
|
||||||
|
@ -23,11 +23,14 @@
|
|||||||
#include "gui/messagebox.h"
|
#include "gui/messagebox.h"
|
||||||
#include "gui/formmain.h"
|
#include "gui/formmain.h"
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
|
||||||
Application::Application(const QString &id, int &argc, char **argv)
|
Application::Application(const QString &id, int &argc, char **argv)
|
||||||
: QtSingleApplication(id, argc, argv),
|
: QtSingleApplication(id, argc, argv),
|
||||||
m_closeLock(NULL), m_userActions(QList<QAction*>()), m_mainForm(NULL),
|
m_closeLock(NULL), m_userActions(QList<QAction*>()), m_mainForm(NULL),
|
||||||
m_trayIcon(NULL), m_settings(NULL), m_system(NULL) {
|
m_trayIcon(NULL), m_settings(NULL), m_system(NULL), m_skins(NULL),
|
||||||
|
m_localization(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application() {
|
Application::~Application() {
|
||||||
@ -76,6 +79,8 @@ void Application::showGuiMessage(const QString& title, const QString& message,
|
|||||||
QSystemTrayIcon::MessageIcon message_type,
|
QSystemTrayIcon::MessageIcon message_type,
|
||||||
QWidget *parent, int duration) {
|
QWidget *parent, int duration) {
|
||||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
if (SystemTrayIcon::isSystemTrayActivated()) {
|
||||||
|
// TODO: Maybe show OSD instead if tray icon bubble,
|
||||||
|
// depending on settings.
|
||||||
trayIcon()->showMessage(title, message, message_type, duration);
|
trayIcon()->showMessage(title, message, message_type, duration);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include "definitions/definitions.h"
|
#include "definitions/definitions.h"
|
||||||
#include "miscellaneous/settings.h"
|
#include "miscellaneous/settings.h"
|
||||||
#include "miscellaneous/systemfactory.h"
|
#include "miscellaneous/systemfactory.h"
|
||||||
|
#include "miscellaneous/skinfactory.h"
|
||||||
|
#include "miscellaneous/localization.h"
|
||||||
#include "gui/systemtrayicon.h"
|
#include "gui/systemtrayicon.h"
|
||||||
|
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
@ -58,6 +60,22 @@ class Application : public QtSingleApplication {
|
|||||||
return m_system;
|
return m_system;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline SkinFactory *skins() {
|
||||||
|
if (m_skins == NULL) {
|
||||||
|
m_skins = new SkinFactory(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_skins;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Localization *localization() {
|
||||||
|
if (m_localization == NULL) {
|
||||||
|
m_localization = new Localization(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_localization;
|
||||||
|
}
|
||||||
|
|
||||||
inline Settings *settings() {
|
inline Settings *settings() {
|
||||||
if (m_settings == NULL) {
|
if (m_settings == NULL) {
|
||||||
m_settings = Settings::setupSettings(this);
|
m_settings = Settings::setupSettings(this);
|
||||||
@ -119,6 +137,8 @@ class Application : public QtSingleApplication {
|
|||||||
SystemTrayIcon *m_trayIcon;
|
SystemTrayIcon *m_trayIcon;
|
||||||
Settings *m_settings;
|
Settings *m_settings;
|
||||||
SystemFactory *m_system;
|
SystemFactory *m_system;
|
||||||
|
SkinFactory *m_skins;
|
||||||
|
Localization *m_localization;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPLICATION_H
|
#endif // APPLICATION_H
|
||||||
|
@ -21,15 +21,12 @@
|
|||||||
#include "miscellaneous/settings.h"
|
#include "miscellaneous/settings.h"
|
||||||
#include "miscellaneous/application.h"
|
#include "miscellaneous/application.h"
|
||||||
|
|
||||||
#include <QPointer>
|
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfoList>
|
#include <QFileInfoList>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
|
||||||
|
|
||||||
QPointer<Localization> Localization::s_instance;
|
|
||||||
|
|
||||||
Localization::Localization(QObject *parent)
|
Localization::Localization(QObject *parent)
|
||||||
: QObject(parent) {
|
: QObject(parent) {
|
||||||
}
|
}
|
||||||
@ -38,21 +35,13 @@ Localization::~Localization() {
|
|||||||
qDebug("Destroying Localization instance.");
|
qDebug("Destroying Localization instance.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Localization *Localization::instance() {
|
|
||||||
if (s_instance.isNull()) {
|
|
||||||
s_instance = new Localization(qApp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return s_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Localization::desiredLanguage() {
|
QString Localization::desiredLanguage() {
|
||||||
return qApp->settings()->value(APP_CFG_GEN,
|
return qApp->settings()->value(APP_CFG_GEN,
|
||||||
"language",
|
"language",
|
||||||
QLocale::system().name()).toString();
|
QLocale::system().name()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Localization::load() {
|
void Localization::loadActiveLanguage() {
|
||||||
QTranslator *qt_translator = new QTranslator(qApp);
|
QTranslator *qt_translator = new QTranslator(qApp);
|
||||||
QTranslator *app_translator = new QTranslator(qApp);
|
QTranslator *app_translator = new QTranslator(qApp);
|
||||||
QString desired_localization = desiredLanguage();
|
QString desired_localization = desiredLanguage();
|
||||||
@ -61,12 +50,10 @@ void Localization::load() {
|
|||||||
APP_LANG_PATH,
|
APP_LANG_PATH,
|
||||||
"-")) {
|
"-")) {
|
||||||
Application::installTranslator(app_translator);
|
Application::installTranslator(app_translator);
|
||||||
qDebug("Application localization '%s' loaded successfully.",
|
qDebug("Application localization '%s' loaded successfully.", qPrintable(desired_localization));
|
||||||
qPrintable(desired_localization));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qWarning("Application localization '%s' was not loaded.", qPrintable(desired_localization));
|
qWarning("Application localization '%s' was not loaded.", qPrintable(desired_localization));
|
||||||
|
|
||||||
desired_localization = DEFAULT_LOCALE;
|
desired_localization = DEFAULT_LOCALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,8 +61,7 @@ void Localization::load() {
|
|||||||
APP_LANG_PATH,
|
APP_LANG_PATH,
|
||||||
"-")) {
|
"-")) {
|
||||||
Application::installTranslator(qt_translator);
|
Application::installTranslator(qt_translator);
|
||||||
qDebug("Qt localization '%s' loaded successfully.",
|
qDebug("Qt localization '%s' loaded successfully.", qPrintable(desired_localization));
|
||||||
qPrintable(desired_localization));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qWarning("Qt localization '%s' was not loaded.", qPrintable(desired_localization));
|
qWarning("Qt localization '%s' was not loaded.", qPrintable(desired_localization));
|
||||||
|
15
src/miscellaneous/localization.h
Normal file → Executable file
15
src/miscellaneous/localization.h
Normal file → Executable file
@ -18,9 +18,9 @@
|
|||||||
#ifndef LOCALIZATION_H
|
#ifndef LOCALIZATION_H
|
||||||
#define LOCALIZATION_H
|
#define LOCALIZATION_H
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
struct Language {
|
struct Language {
|
||||||
@ -34,23 +34,19 @@ struct Language {
|
|||||||
class Localization : public QObject {
|
class Localization : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
public:
|
||||||
// Constructor.
|
// Constructor.
|
||||||
explicit Localization(QObject *parent = 0);
|
explicit Localization(QObject *parent = 0);
|
||||||
|
|
||||||
public:
|
|
||||||
// Destructor.
|
// Destructor.
|
||||||
virtual ~Localization();
|
virtual ~Localization();
|
||||||
|
|
||||||
// Singleton getter.
|
|
||||||
static Localization *instance();
|
|
||||||
|
|
||||||
// Returns code of language that should
|
// Returns code of language that should
|
||||||
// be loaded according to settings.
|
// be loaded according to settings.
|
||||||
QString desiredLanguage();
|
QString desiredLanguage();
|
||||||
|
|
||||||
// Loads currently active language.
|
// Loads currently active language.
|
||||||
void load();
|
void loadActiveLanguage();
|
||||||
|
|
||||||
// Returns list of installed application localizations.
|
// Returns list of installed application localizations.
|
||||||
// This list is used ie. in settings dialog.
|
// This list is used ie. in settings dialog.
|
||||||
@ -65,9 +61,6 @@ class Localization : public QObject {
|
|||||||
private:
|
private:
|
||||||
// Code of loaded language.
|
// Code of loaded language.
|
||||||
QString m_loadedLanguage;
|
QString m_loadedLanguage;
|
||||||
|
|
||||||
// Singleton.
|
|
||||||
static QPointer<Localization> s_instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LOCALIZATION_H
|
#endif // LOCALIZATION_H
|
||||||
|
5
src/miscellaneous/settings.h
Normal file → Executable file
5
src/miscellaneous/settings.h
Normal file → Executable file
@ -58,12 +58,11 @@ class Settings : public QSettings {
|
|||||||
QSettings::Status checkSettings();
|
QSettings::Status checkSettings();
|
||||||
|
|
||||||
// Creates settings file in correct location.
|
// Creates settings file in correct location.
|
||||||
static Settings* setupSettings(QObject *parent);
|
static Settings *setupSettings(QObject *parent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Constructor.
|
// Constructor.
|
||||||
Settings(const QString & file_name, Format format,
|
explicit Settings(const QString & file_name, Format format, const Type &type, QObject *parent = 0);
|
||||||
const Type &type, QObject * parent = 0);
|
|
||||||
|
|
||||||
Type m_initializationStatus;
|
Type m_initializationStatus;
|
||||||
};
|
};
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
|
|
||||||
|
|
||||||
QPointer<SkinFactory> SkinFactory::s_instance;
|
|
||||||
|
|
||||||
SkinFactory::SkinFactory(QObject *parent) : QObject(parent) {
|
SkinFactory::SkinFactory(QObject *parent) : QObject(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,14 +34,6 @@ SkinFactory::~SkinFactory() {
|
|||||||
qDebug("Destroying SkinFactory instance.");
|
qDebug("Destroying SkinFactory instance.");
|
||||||
}
|
}
|
||||||
|
|
||||||
SkinFactory *SkinFactory::instance() {
|
|
||||||
if (s_instance.isNull()) {
|
|
||||||
s_instance = new SkinFactory(qApp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return s_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkinFactory::loadCurrentSkin() {
|
void SkinFactory::loadCurrentSkin() {
|
||||||
QString skin_name_from_settings = selectedSkinName();
|
QString skin_name_from_settings = selectedSkinName();
|
||||||
bool skin_parsed;
|
bool skin_parsed;
|
||||||
|
16
src/miscellaneous/skinfactory.h
Normal file → Executable file
16
src/miscellaneous/skinfactory.h
Normal file → Executable file
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <QPointer>
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
|
||||||
@ -42,14 +41,10 @@ Q_DECLARE_METATYPE(Skin)
|
|||||||
class SkinFactory : public QObject {
|
class SkinFactory : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
public:
|
||||||
// Constructor.
|
// Constructor.
|
||||||
explicit SkinFactory(QObject *parent = 0);
|
explicit SkinFactory(QObject *parent = 0);
|
||||||
|
|
||||||
// Loads the skin from give skin_data.
|
|
||||||
bool loadSkinFromData(const Skin &skin);
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Destructor.
|
// Destructor.
|
||||||
virtual ~SkinFactory();
|
virtual ~SkinFactory();
|
||||||
|
|
||||||
@ -78,15 +73,12 @@ class SkinFactory : public QObject {
|
|||||||
// Sets the desired skin as the active one if it exists.
|
// Sets the desired skin as the active one if it exists.
|
||||||
void setCurrentSkinName(const QString &skin_name);
|
void setCurrentSkinName(const QString &skin_name);
|
||||||
|
|
||||||
// Singleton getter.
|
|
||||||
static SkinFactory *instance();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Loads the skin from give skin_data.
|
||||||
|
bool loadSkinFromData(const Skin &skin);
|
||||||
|
|
||||||
// Holds name of the current skin.
|
// Holds name of the current skin.
|
||||||
Skin m_currentSkin;
|
Skin m_currentSkin;
|
||||||
|
|
||||||
// Singleton.
|
|
||||||
static QPointer<SkinFactory> s_instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SKINFACTORY_H
|
#endif // SKINFACTORY_H
|
||||||
|
@ -217,7 +217,7 @@ void WebBrowser::navigateToUrl(const QUrl &url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WebBrowser::navigateToMessages(const QList<Message> &messages) {
|
void WebBrowser::navigateToMessages(const QList<Message> &messages) {
|
||||||
SkinFactory *factory = SkinFactory::instance();
|
SkinFactory *factory = qApp->skins();
|
||||||
QString messages_layout;
|
QString messages_layout;
|
||||||
QString single_message_layout = factory->currentMarkup();
|
QString single_message_layout = factory->currentMarkup();
|
||||||
|
|
||||||
|
24
src/network-web/webview.cpp
Normal file → Executable file
24
src/network-web/webview.cpp
Normal file → Executable file
@ -140,19 +140,19 @@ void WebView::initializeActions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WebView::displayErrorPage() {
|
void WebView::displayErrorPage() {
|
||||||
setHtml(SkinFactory::instance()->currentMarkupLayout().arg(
|
setHtml(qApp->skins()->currentMarkupLayout().arg(
|
||||||
tr("Error page"),
|
tr("Error page"),
|
||||||
SkinFactory::instance()->currentMarkup().arg(tr("Page not found"),
|
qApp->skins()->currentMarkup().arg(tr("Page not found"),
|
||||||
tr("Check your internet connection or website address"),
|
tr("Check your internet connection or website address"),
|
||||||
QString(),
|
QString(),
|
||||||
tr("This failure can be caused by:<br><ul>"
|
tr("This failure can be caused by:<br><ul>"
|
||||||
"<li>non-functional internet connection,</li>"
|
"<li>non-functional internet connection,</li>"
|
||||||
"<li>incorrect website address,</li>"
|
"<li>incorrect website address,</li>"
|
||||||
"<li>bad proxy server settings,</li>"
|
"<li>bad proxy server settings,</li>"
|
||||||
"<li>target destination outage,</li>"
|
"<li>target destination outage,</li>"
|
||||||
"<li>many other things.</li>"
|
"<li>many other things.</li>"
|
||||||
"</ul>"),
|
"</ul>"),
|
||||||
QDateTime::currentDateTime().toString(Qt::DefaultLocaleLongDate))));
|
QDateTime::currentDateTime().toString(Qt::DefaultLocaleLongDate))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::popupContextMenu(const QPoint &pos) {
|
void WebView::popupContextMenu(const QPoint &pos) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user