123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #include "options.h"
-
- Options* Options::m_options = 0;
-
- Options*Options::instance()
- {
- return m_options;
- }
-
- void Options::init(QObject* p)
- {
- m_options = new Options(p);
- }
-
- bool Options::startAtBoot()
- {
- #ifdef Q_OS_WIN
- QSettings set("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
- return set.childKeys().contains("Epimafia Netsoul");
- #else
- #error "OS sepcific"
- #endif
- }
-
- QString Options::getDefaultLogin(bool override)
- {
- if(override)
- {
- QStringList args = qApp->arguments();
- int index = args.indexOf("-login");
- if(index != -1 && index < args.size() - 1)
- return args.at(index + 1);
- }
-
- return m_settings.value("defaultLogin").toString();
- }
-
- bool Options::isAutoConnect()
- {
- return m_settings.value("autoConnect", false).toBool();
- }
-
- QStringList Options::getContacts()
- {
- return qvariant_cast<QStringList>(m_settings.value("contacts"));
- }
-
- int Options::getAutoReconnectInterval()
- {
- return m_settings.value("autoreconnectInterval", 1000).toInt();
- }
-
- void Options::setStartAtBoot(bool s)
- {
- #ifdef Q_OS_WIN
- QSettings set("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
- if(s)
- set.setValue("Epimafia Netsoul", "\"" + qApp->applicationFilePath() + "\"");
- else
- set.remove("Epimafia Netsoul");
- #else
- #error "OS specific"
- #endif
- }
-
- void Options::setDefaultLogin(QString login)
- {
- m_settings.setValue("defaultLogin", login);
- }
-
- void Options::setAutoConnect(bool c)
- {
- m_settings.setValue("autoConnect", c);
- }
-
- void Options::setContacts(QStringList contacts)
- {
- m_settings.setValue("contacts", contacts);
- }
-
- void Options::setAutoReconnectInterval(int t)
- {
- m_settings.setValue("autoreconnectInterval", t);
- }
-
- Options::Options(QObject *parent) : QObject(parent),
- #ifdef Q_OS_WIN
- m_settings("epimafianetsoul.ini", QSettings::IniFormat)
- #else
- #error "OS specific"
- #endif
- {
- }
|