Fixed desktop entry path and systemfactory made singleton.
This commit is contained in:
parent
714057eea0
commit
738dbbe5c6
@ -108,7 +108,7 @@ if(UNIX)
|
||||
${PROJECT_SOURCE_DIR}/resources/desktop/rssguard.desktop.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/resources/desktop/rssguard.desktop
|
||||
)
|
||||
set(DESKTOP_ENTRY ${CMAKE_INSTALL_PREFIX}/share/applications)
|
||||
set(DESKTOP_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/applications)
|
||||
endif(UNIX)
|
||||
|
||||
# Configure internal C++ defines.
|
||||
@ -319,6 +319,7 @@ set(APP_HEADERS
|
||||
src/core/basenetworkaccessmanager.h
|
||||
src/core/webbrowsernetworkaccessmanager.h
|
||||
src/core/basewebpage.h
|
||||
src/core/systemfactory.h
|
||||
src/core/databasefactory.h
|
||||
src/core/messagesmodel.h
|
||||
src/core/messagesproxymodel.h
|
||||
|
@ -24,8 +24,6 @@ FeedsModel::FeedsModel(QObject *parent) : QAbstractItemModel(parent) {
|
||||
|
||||
loadFromDatabase();
|
||||
|
||||
loadFromDatabase();
|
||||
|
||||
/*
|
||||
FeedsModelStandardCategory *cat1 = new FeedsModelStandardCategory();
|
||||
FeedsModelStandardCategory *cat2 = new FeedsModelStandardCategory();
|
||||
|
@ -429,7 +429,7 @@ bool MessagesModel::setAllMessagesRead(int read) {
|
||||
|
||||
QSqlQuery query_read_msg(db_handle);
|
||||
if (!query_read_msg.prepare(QString("UPDATE messages SET read = :read "
|
||||
"WHERE feed IN (%1) AND deleted = 0").arg(textualFeeds().join(", ")))) {
|
||||
"WHERE feed IN (%1) AND deleted = 0").arg(textualFeeds().join(", ")))) {
|
||||
qWarning("Query preparation failed for message read change.");
|
||||
|
||||
db_handle.rollback();
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QApplication>
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#include <QSettings>
|
||||
@ -10,9 +11,16 @@
|
||||
#include "core/defs.h"
|
||||
|
||||
|
||||
SystemFactory::SystemFactory() {
|
||||
QPointer<SystemFactory> SystemFactory::s_instance;
|
||||
|
||||
SystemFactory::SystemFactory(QObject *parent) : QObject(parent) {
|
||||
}
|
||||
|
||||
SystemFactory::~SystemFactory() {
|
||||
qDebug("Destroying SystemFactory instance.");
|
||||
}
|
||||
|
||||
|
||||
SystemFactory::AutoStartStatus SystemFactory::getAutoStartStatus() {
|
||||
// User registry way to auto-start the application on Windows.
|
||||
#if defined(Q_OS_WIN)
|
||||
@ -78,6 +86,14 @@ QString SystemFactory::getAutostartDesktopFileLocation() {
|
||||
// No location found, return empty string.
|
||||
return desktop_file_location;
|
||||
}
|
||||
|
||||
SystemFactory *SystemFactory::getInstance() {
|
||||
if (s_instance.isNull()) {
|
||||
s_instance = new SystemFactory(qApp);
|
||||
}
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool SystemFactory::setAutoStartStatus(const AutoStartStatus &new_status) {
|
||||
|
@ -1,12 +1,19 @@
|
||||
#ifndef SYSTEMFACTORY_H
|
||||
#define SYSTEMFACTORY_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
class SystemFactory : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
class SystemFactory {
|
||||
private:
|
||||
explicit SystemFactory();
|
||||
explicit SystemFactory(QObject *parent = 0);
|
||||
|
||||
public:
|
||||
virtual ~SystemFactory();
|
||||
|
||||
// Specifies possible states of auto-start functionality.
|
||||
enum AutoStartStatus {
|
||||
Enabled,
|
||||
@ -15,18 +22,24 @@ class SystemFactory {
|
||||
};
|
||||
|
||||
// Returns current status of auto-start function.
|
||||
static SystemFactory::AutoStartStatus getAutoStartStatus();
|
||||
SystemFactory::AutoStartStatus getAutoStartStatus();
|
||||
|
||||
// Sets new status for auto-start function.
|
||||
// Function returns false if setting of
|
||||
// new status failed.
|
||||
static bool setAutoStartStatus(const SystemFactory::AutoStartStatus &new_status);
|
||||
bool setAutoStartStatus(const SystemFactory::AutoStartStatus &new_status);
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
// Returns standard location where auto-start .desktop files
|
||||
// should be placed.
|
||||
static QString getAutostartDesktopFileLocation();
|
||||
#endif
|
||||
|
||||
// Singleton getter.
|
||||
static SystemFactory *getInstance();
|
||||
|
||||
private:
|
||||
static QPointer<SystemFactory> s_instance;
|
||||
};
|
||||
|
||||
#endif // SYSTEMFACTORY_H
|
||||
|
@ -406,7 +406,7 @@ void FormSettings::saveShortcuts() {
|
||||
|
||||
void FormSettings::loadGeneral() {
|
||||
// Load auto-start status.
|
||||
SystemFactory::AutoStartStatus autostart_status = SystemFactory::getAutoStartStatus();
|
||||
SystemFactory::AutoStartStatus autostart_status = SystemFactory::getInstance()->getAutoStartStatus();
|
||||
switch (autostart_status) {
|
||||
case SystemFactory::Enabled:
|
||||
m_ui->m_checkAutostart->setChecked(true);
|
||||
@ -425,12 +425,12 @@ void FormSettings::loadGeneral() {
|
||||
void FormSettings::saveGeneral() {
|
||||
// If auto-start feature is available and user wants
|
||||
// to turn it on, then turn it on.
|
||||
if (SystemFactory::getAutoStartStatus() != SystemFactory::Unavailable) {
|
||||
if (SystemFactory::getInstance()->getAutoStartStatus() != SystemFactory::Unavailable) {
|
||||
if (m_ui->m_checkAutostart->isChecked()) {
|
||||
SystemFactory::setAutoStartStatus(SystemFactory::Enabled);
|
||||
SystemFactory::getInstance()->setAutoStartStatus(SystemFactory::Enabled);
|
||||
}
|
||||
else {
|
||||
SystemFactory::setAutoStartStatus(SystemFactory::Disabled);
|
||||
SystemFactory::getInstance()->setAutoStartStatus(SystemFactory::Disabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user