void RingoAAM::getResult(Array<char> &buf) { ArrayOutput output_r(buf); RxnfileSaver rcs(output_r); if (!Reaction::haveCoord(_reaction)){ ReactionLayout layout(_reaction); layout.make(); _reaction.markStereocenterBonds(); } rcs.saveReaction(_reaction); }
void Settings::load() { if (loaded) return; if (QFile(FILENAME).exists()) { QSettings ps(FILENAME, QSettings::IniFormat); ps.beginGroup("General"); makeToxPortable = ps.value("makeToxPortable", false).toBool(); ps.endGroup(); } else if (QFile(OLDFILENAME).exists()) { QSettings ps(OLDFILENAME, QSettings::IniFormat); ps.beginGroup("General"); makeToxPortable = ps.value("makeToxPortable", false).toBool(); ps.endGroup(); } else makeToxPortable = false; QDir dir(getSettingsDirPath()); QString filePath = dir.filePath(FILENAME); //if no settings file exist -- use the default one if (!QFile(filePath).exists()) { if (!QFile(filePath = dir.filePath(OLDFILENAME)).exists()) { qDebug() << "No settings file found, using defaults"; filePath = ":/conf/" + FILENAME; } } qDebug() << "Settings: Loading from "<<filePath; QSettings s(filePath, QSettings::IniFormat); s.beginGroup("DHT Server"); if (s.value("useCustomList").toBool()) { useCustomDhtList = true; qDebug() << "Using custom bootstrap nodes list"; int serverListSize = s.beginReadArray("dhtServerList"); for (int i = 0; i < serverListSize; i ++) { s.setArrayIndex(i); DhtServer server; server.name = s.value("name").toString(); server.userId = s.value("userId").toString(); server.address = s.value("address").toString(); server.port = s.value("port").toInt(); dhtServerList << server; } s.endArray(); } else useCustomDhtList=false; s.endGroup(); s.beginGroup("General"); enableIPv6 = s.value("enableIPv6", true).toBool(); translation = s.value("translation", "en").toString(); showSystemTray = s.value("showSystemTray", SHOW_SYSTEM_TRAY_DEFAULT).toBool(); makeToxPortable = s.value("makeToxPortable", false).toBool(); autostartInTray = s.value("autostartInTray", false).toBool(); closeToTray = s.value("closeToTray", false).toBool(); forceTCP = s.value("forceTCP", false).toBool(); useProxy = s.value("useProxy", false).toBool(); proxyAddr = s.value("proxyAddr", "").toString(); proxyPort = s.value("proxyPort", 0).toInt(); currentProfile = s.value("currentProfile", "").toString(); autoAwayTime = s.value("autoAwayTime", 10).toInt(); checkUpdates = s.value("checkUpdates", false).toBool(); showInFront = s.value("showInFront", false).toBool(); fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool(); autoSaveEnabled = s.value("autoSaveEnabled", false).toBool(); globalAutoAcceptDir = s.value("globalAutoAcceptDir", QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory) ).toString(); s.endGroup(); s.beginGroup("Advanced"); int sType = s.value("dbSyncType", static_cast<int>(Db::syncType::stFull)).toInt(); setDbSyncType(sType); s.endGroup(); s.beginGroup("Widgets"); QList<QString> objectNames = s.childKeys(); for (const QString& name : objectNames) { widgetSettings[name] = s.value(name).toByteArray(); } s.endGroup(); s.beginGroup("GUI"); enableSmoothAnimation = s.value("smoothAnimation", true).toBool(); smileyPack = s.value("smileyPack", ":/smileys/cylgom/emoticons.xml").toString(); customEmojiFont = s.value("customEmojiFont", true).toBool(); emojiFontFamily = s.value("emojiFontFamily", "DejaVu Sans").toString(); emojiFontPointSize = s.value("emojiFontPointSize", 12).toInt(); firstColumnHandlePos = s.value("firstColumnHandlePos", 50).toInt(); secondColumnHandlePosFromRight = s.value("secondColumnHandlePosFromRight", 50).toInt(); timestampFormat = s.value("timestampFormat", "hh:mm").toString(); minimizeOnClose = s.value("minimizeOnClose", false).toBool(); minimizeToTray = s.value("minimizeToTray", false).toBool(); lightTrayIcon = s.value("lightTrayIcon", false).toBool(); useNativeStyle = s.value("nativeStyle", false).toBool(); useEmoticons = s.value("useEmoticons", true).toBool(); statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool(); themeColor = s.value("themeColor", 0).toInt(); style = s.value("style", "").toString(); if (style == "") // Default to Fusion if available, otherwise no style { if (QStyleFactory::keys().contains("Fusion")) style = "Fusion"; else style = "None"; } s.endGroup(); s.beginGroup("State"); windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray(); windowState = s.value("windowState", QByteArray()).toByteArray(); splitterState = s.value("splitterState", QByteArray()).toByteArray(); s.endGroup(); s.beginGroup("Privacy"); typingNotification = s.value("typingNotification", false).toBool(); enableLogging = s.value("enableLogging", false).toBool(); encryptLogs = s.value("encryptLogs", false).toBool(); encryptTox = s.value("encryptTox", false).toBool(); s.endGroup(); s.beginGroup("Audio"); inDev = s.value("inDev", "").toString(); outDev = s.value("outDev", "").toString(); s.endGroup(); // Read the embedded DHT bootsrap nodes list if needed if (dhtServerList.isEmpty()) { qDebug() << "Using embeded bootstrap nodes list"; QSettings rcs(":/conf/settings.ini", QSettings::IniFormat); rcs.beginGroup("DHT Server"); int serverListSize = rcs.beginReadArray("dhtServerList"); for (int i = 0; i < serverListSize; i ++) { rcs.setArrayIndex(i); DhtServer server; server.name = rcs.value("name").toString(); server.userId = rcs.value("userId").toString(); server.address = rcs.value("address").toString(); server.port = rcs.value("port").toInt(); dhtServerList << server; } rcs.endArray(); rcs.endGroup(); } loaded = true; if (currentProfile.isEmpty()) // new profile in Core::switchConfiguration return; // load from a profile specific friend data list if possible QString tmp = dir.filePath(currentProfile + ".ini"); if (QFile(tmp).exists()) filePath = tmp; QSettings fs(filePath, QSettings::IniFormat); friendLst.clear(); fs.beginGroup("Friends"); int size = fs.beginReadArray("Friend"); for (int i = 0; i < size; i ++) { fs.setArrayIndex(i); friendProp fp; fp.addr = fs.value("addr").toString(); fp.alias = fs.value("alias").toString(); fp.autoAcceptDir = fs.value("autoAcceptDir").toString(); friendLst[ToxID::fromString(fp.addr).publicKey] = fp; } fs.endArray(); fs.endGroup(); }
void Settings::loadGlobal() { QMutexLocker locker{&bigLock}; if (loaded) return; createSettingsDir(); if (QFile(globalSettingsFile).exists()) { QSettings ps(globalSettingsFile, QSettings::IniFormat); ps.setIniCodec("UTF-8"); ps.beginGroup("General"); makeToxPortable = ps.value("makeToxPortable", false).toBool(); ps.endGroup(); } else { makeToxPortable = false; } QDir dir(getSettingsDirPath()); QString filePath = dir.filePath(globalSettingsFile); // If no settings file exist -- use the default one if (!QFile(filePath).exists()) { qDebug() << "No settings file found, using defaults"; filePath = ":/conf/" + globalSettingsFile; } qDebug() << "Loading settings from " + filePath; QSettings s(filePath, QSettings::IniFormat); s.setIniCodec("UTF-8"); s.beginGroup("Login"); autoLogin = s.value("autoLogin", false).toBool(); s.endGroup(); s.beginGroup("DHT Server"); if (s.value("useCustomList").toBool()) { useCustomDhtList = true; qDebug() << "Using custom bootstrap nodes list"; int serverListSize = s.beginReadArray("dhtServerList"); for (int i = 0; i < serverListSize; i ++) { s.setArrayIndex(i); DhtServer server; server.name = s.value("name").toString(); server.userId = s.value("userId").toString(); server.address = s.value("address").toString(); server.port = s.value("port").toInt(); dhtServerList << server; } s.endArray(); } else { useCustomDhtList=false; } s.endGroup(); s.beginGroup("General"); enableIPv6 = s.value("enableIPv6", true).toBool(); translation = s.value("translation", "en").toString(); showSystemTray = s.value("showSystemTray", SHOW_SYSTEM_TRAY_DEFAULT).toBool(); makeToxPortable = s.value("makeToxPortable", false).toBool(); autostartInTray = s.value("autostartInTray", false).toBool(); closeToTray = s.value("closeToTray", false).toBool(); forceTCP = s.value("forceTCP", false).toBool(); setProxyType(s.value("proxyType", static_cast<int>(ProxyType::ptNone)).toInt()); proxyAddr = s.value("proxyAddr", "").toString(); proxyPort = s.value("proxyPort", 0).toInt(); if (currentProfile.isEmpty()) { currentProfile = s.value("currentProfile", "").toString(); currentProfileId = makeProfileId(currentProfile); } autoAwayTime = s.value("autoAwayTime", 10).toInt(); checkUpdates = s.value("checkUpdates", true).toBool(); showWindow = s.value("showWindow", true).toBool(); showInFront = s.value("showInFront", false).toBool(); notifySound = s.value("notifySound", true).toBool(); groupAlwaysNotify = s.value("groupAlwaysNotify", false).toBool(); fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool(); autoSaveEnabled = s.value("autoSaveEnabled", false).toBool(); globalAutoAcceptDir = s.value("globalAutoAcceptDir", QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory) ).toString(); separateWindow = s.value("separateWindow", false).toBool(); dontGroupWindows = s.value("dontGroupWindows", true).toBool(); groupchatPosition = s.value("groupchatPosition", true).toBool(); markdownPreference = static_cast<MarkdownType>(s.value("markdownPreference", 1).toInt()); s.endGroup(); s.beginGroup("Advanced"); int sType = s.value("dbSyncType", static_cast<int>(Db::syncType::stFull)).toInt(); setDbSyncType(sType); s.endGroup(); s.beginGroup("Widgets"); QList<QString> objectNames = s.childKeys(); for (const QString& name : objectNames) widgetSettings[name] = s.value(name).toByteArray(); s.endGroup(); s.beginGroup("GUI"); const QString DEFAULT_SMILEYS = ":/smileys/Universe/emoticons.xml"; smileyPack = s.value("smileyPack", DEFAULT_SMILEYS).toString(); if (!SmileyPack::isValid(smileyPack)) { smileyPack = DEFAULT_SMILEYS; } emojiFontPointSize = s.value("emojiFontPointSize", 16).toInt(); firstColumnHandlePos = s.value("firstColumnHandlePos", 50).toInt(); secondColumnHandlePosFromRight = s.value("secondColumnHandlePosFromRight", 50).toInt(); timestampFormat = s.value("timestampFormat", "hh:mm:ss").toString(); dateFormat = s.value("dateFormat", "dddd, MMMM d, yyyy").toString(); minimizeOnClose = s.value("minimizeOnClose", false).toBool(); minimizeToTray = s.value("minimizeToTray", false).toBool(); lightTrayIcon = s.value("lightTrayIcon", false).toBool(); useEmoticons = s.value("useEmoticons", true).toBool(); statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool(); themeColor = s.value("themeColor", 0).toInt(); style = s.value("style", "").toString(); if (style == "") // Default to Fusion if available, otherwise no style { if (QStyleFactory::keys().contains("Fusion")) style = "Fusion"; else style = "None"; } s.endGroup(); s.beginGroup("State"); windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray(); windowState = s.value("windowState", QByteArray()).toByteArray(); splitterState = s.value("splitterState", QByteArray()).toByteArray(); dialogGeometry = s.value("dialogGeometry", QByteArray()).toByteArray(); dialogSplitterState = s.value("dialogSplitterState", QByteArray()).toByteArray(); dialogSettingsGeometry = s.value("dialogSettingsGeometry", QByteArray()).toByteArray(); s.endGroup(); s.beginGroup("Audio"); inDev = s.value("inDev", "").toString(); outDev = s.value("outDev", "").toString(); inVolume = s.value("inVolume", 100).toInt(); outVolume = s.value("outVolume", 100).toInt(); filterAudio = s.value("filterAudio", false).toBool(); s.endGroup(); s.beginGroup("Video"); videoDev = s.value("videoDev", "").toString(); camVideoRes = s.value("camVideoRes",QSize()).toSize(); camVideoFPS = s.value("camVideoFPS", 0).toUInt(); s.endGroup(); // Read the embedded DHT bootstrap nodes list if needed if (dhtServerList.isEmpty()) { QSettings rcs(":/conf/settings.ini", QSettings::IniFormat); rcs.setIniCodec("UTF-8"); rcs.beginGroup("DHT Server"); int serverListSize = rcs.beginReadArray("dhtServerList"); for (int i = 0; i < serverListSize; i ++) { rcs.setArrayIndex(i); DhtServer server; server.name = rcs.value("name").toString(); server.userId = rcs.value("userId").toString(); server.address = rcs.value("address").toString(); server.port = rcs.value("port").toInt(); dhtServerList << server; } rcs.endArray(); rcs.endGroup(); } loaded = true; }
void Settings::load() { if (loaded) { return; } QFile portableSettings(FILENAME); if (portableSettings.exists()) { QSettings ps(FILENAME, QSettings::IniFormat); ps.beginGroup("General"); makeToxPortable = ps.value("makeToxPortable", false).toBool(); ps.endGroup(); } else makeToxPortable = false; QString filePath = QDir(getSettingsDirPath()).filePath(FILENAME); //if no settings file exist -- use the default one QFile file(filePath); if (!file.exists()) { qDebug() << "No settings file found, using defaults"; filePath = ":/conf/" + FILENAME; } qDebug() << "Settings: Loading from "<<filePath; QSettings s(filePath, QSettings::IniFormat); s.beginGroup("DHT Server"); if (s.value("useCustomList").toBool()) { useCustomDhtList = true; qDebug() << "Using custom bootstrap nodes list"; int serverListSize = s.beginReadArray("dhtServerList"); for (int i = 0; i < serverListSize; i ++) { s.setArrayIndex(i); DhtServer server; server.name = s.value("name").toString(); server.userId = s.value("userId").toString(); server.address = s.value("address").toString(); server.port = s.value("port").toInt(); dhtServerList << server; } s.endArray(); } else useCustomDhtList=false; s.endGroup(); friendAddresses.clear(); s.beginGroup("Friends"); int size = s.beginReadArray("fullAddresses"); for (int i = 0; i < size; i ++) { s.setArrayIndex(i); friendAddresses.append(s.value("addr").toString()); } s.endArray(); s.endGroup(); s.beginGroup("General"); enableIPv6 = s.value("enableIPv6", true).toBool(); translation = s.value("translation", "").toString(); makeToxPortable = s.value("makeToxPortable", false).toBool(); autostartInTray = s.value("autostartInTray", false).toBool(); closeToTray = s.value("closeToTray", false).toBool(); forceTCP = s.value("forceTCP", false).toBool(); useProxy = s.value("useProxy", false).toBool(); proxyAddr = s.value("proxyAddr", "").toString(); proxyPort = s.value("proxyPort", 0).toInt(); currentProfile = s.value("currentProfile", "").toString(); autoAwayTime = s.value("autoAwayTime", 10).toInt(); autoSaveEnabled = s.value("autoSaveEnabled", false).toBool(); autoSaveDir = s.value("autoSaveDir", QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)).toString(); s.endGroup(); s.beginGroup("Widgets"); QList<QString> objectNames = s.childKeys(); for (const QString& name : objectNames) { widgetSettings[name] = s.value(name).toByteArray(); } s.endGroup(); s.beginGroup("GUI"); enableSmoothAnimation = s.value("smoothAnimation", true).toBool(); smileyPack = s.value("smileyPack", ":/smileys/cylgom/emoticons.xml").toString(); customEmojiFont = s.value("customEmojiFont", true).toBool(); emojiFontFamily = s.value("emojiFontFamily", "DejaVu Sans").toString(); emojiFontPointSize = s.value("emojiFontPointSize", QApplication::font().pointSize()).toInt(); firstColumnHandlePos = s.value("firstColumnHandlePos", 50).toInt(); secondColumnHandlePosFromRight = s.value("secondColumnHandlePosFromRight", 50).toInt(); timestampFormat = s.value("timestampFormat", "hh:mm").toString(); minimizeOnClose = s.value("minimizeOnClose", false).toBool(); minimizeToTray = s.value("minimizeToTray", false).toBool(); useNativeStyle = s.value("nativeStyle", false).toBool(); useEmoticons = s.value("useEmoticons", true).toBool(); style = s.value("style", "None").toString(); statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool(); s.endGroup(); s.beginGroup("State"); windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray(); windowState = s.value("windowState", QByteArray()).toByteArray(); splitterState = s.value("splitterState", QByteArray()).toByteArray(); s.endGroup(); s.beginGroup("Privacy"); typingNotification = s.value("typingNotification", false).toBool(); enableLogging = s.value("enableLogging", false).toBool(); encryptLogs = s.value("encryptLogs", false).toBool(); encryptTox = s.value("encryptTox", false).toBool(); s.endGroup(); s.beginGroup("AutoAccept"); globalAutoAcceptDir = s.value("globalAutoAcceptDir", "").toString(); for (auto& key : s.childKeys()) autoAccept[key] = s.value(key).toString(); s.endGroup(); s.beginGroup("Audio"); inDev = s.value("inDev", "").toString(); outDev = s.value("outDev", "").toString(); s.endGroup(); // try to set a smiley pack if none is selected if (!SmileyPack::isValid(smileyPack) && !SmileyPack::listSmileyPacks().isEmpty()) smileyPack = SmileyPack::listSmileyPacks()[0].second; // Read the embedded DHT bootsrap nodes list if needed if (dhtServerList.isEmpty()) { qDebug() << "Using embeded bootstrap nodes list"; QSettings rcs(":/conf/settings.ini", QSettings::IniFormat); rcs.beginGroup("DHT Server"); int serverListSize = rcs.beginReadArray("dhtServerList"); for (int i = 0; i < serverListSize; i ++) { rcs.setArrayIndex(i); DhtServer server; server.name = rcs.value("name").toString(); server.userId = rcs.value("userId").toString(); server.address = rcs.value("address").toString(); server.port = rcs.value("port").toInt(); dhtServerList << server; } rcs.endArray(); rcs.endGroup(); } loaded = true; }