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