static void initMainWindow(HWND hwnd) { // append version number to title CString titleFormat = getString(IDS_TITLE); setWindowText(hwnd, CStringUtil::format(titleFormat.c_str(), kApplication, kVersion)); // load configuration bool configLoaded = loadConfig(ARG->m_config, s_configTime, s_userConfig); if (configLoaded) { s_lastConfig = ARG->m_config; } // get settings from registry bool isServer = configLoaded; int debugLevel = s_defaultDebug; CString server; HKEY key = CArchMiscWindows::openKey(HKEY_CURRENT_USER, getSettingsPath()); if (key != NULL) { if (isServer && CArchMiscWindows::hasValue(key, "isServer")) { isServer = (CArchMiscWindows::readValueInt(key, "isServer") != 0); } if (CArchMiscWindows::hasValue(key, "debug")) { debugLevel = static_cast<int>( CArchMiscWindows::readValueInt(key, "debug")); if (debugLevel < 0) { debugLevel = 0; } else if (debugLevel > kDEBUG2) { debugLevel = kDEBUG2; } } server = CArchMiscWindows::readValueString(key, "server"); CArchMiscWindows::closeKey(key); } // choose client/server radio buttons HWND child; child = getItem(hwnd, IDC_MAIN_CLIENT_RADIO); setItemChecked(child, !isServer); child = getItem(hwnd, IDC_MAIN_SERVER_RADIO); setItemChecked(child, isServer); // set server name child = getItem(hwnd, IDC_MAIN_CLIENT_SERVER_NAME_EDIT); setWindowText(child, server); // debug level child = getItem(hwnd, IDC_MAIN_DEBUG); for (unsigned int i = 0; i < sizeof(s_debugName) / sizeof(s_debugName[0]); ++i) { SendMessage(child, CB_ADDSTRING, 0, (LPARAM)s_debugName[i][0]); } SendMessage(child, CB_SETCURSEL, debugLevel, 0); // update controls enableMainWindowControls(hwnd); }
void SettingsCache::setDeckEditorFilterSize(const QSize &value) { deckEditorFilterSize = value; QString file = getSettingsPath(); file.append("layouts/deckLayout.ini"); QSettings layout_settings(file , QSettings::IniFormat); layout_settings.setValue("layouts/deckEditor_FilterSize",value); }
void SettingsCache::setDeckEditorGeometry(const QByteArray &value) { deckEditorGeometry = value; QString file = getSettingsPath(); file.append("layouts/deckLayout.ini"); QSettings layout_settings(file , QSettings::IniFormat); layout_settings.setValue("layouts/deckEditor_geometry",value); }
bool CAdvancedOptions::save(HWND hwnd) { HWND child = getItem(hwnd, IDC_ADVANCED_NAME_EDIT); CString name = getWindowText(child); if (!m_config->isValidScreenName(name)) { showError(hwnd, CStringUtil::format( getString(IDS_INVALID_SCREEN_NAME).c_str(), name.c_str())); SetFocus(child); return false; } if (!m_isClient && !m_config->isScreen(name)) { showError(hwnd, CStringUtil::format( getString(IDS_UNKNOWN_SCREEN_NAME).c_str(), name.c_str())); SetFocus(child); return false; } // get and verify port child = getItem(hwnd, IDC_ADVANCED_PORT_EDIT); CString portString = getWindowText(child); int port = atoi(portString.c_str()); if (port < 1 || port > 65535) { CString defaultPortString = CStringUtil::print("%d", kDefaultPort); showError(hwnd, CStringUtil::format( getString(IDS_INVALID_PORT).c_str(), portString.c_str(), defaultPortString.c_str())); SetFocus(child); return false; } // save state m_screenName = name; m_port = port; // save values to registry HKEY key = CArchMiscWindows::openKey(HKEY_CURRENT_USER, getSettingsPath()); if (key != NULL) { CArchMiscWindows::setValue(key, "port", m_port); CArchMiscWindows::setValue(key, "name", m_screenName); CArchMiscWindows::closeKey(key); } return true; }
static void saveMainWindow(HWND hwnd) { HKEY key = CArchMiscWindows::openKey(HKEY_CURRENT_USER, getSettingsPath()); if (key != NULL) { HWND child; child = getItem(hwnd, IDC_MAIN_CLIENT_SERVER_NAME_EDIT); CArchMiscWindows::setValue(key, "server", getWindowText(child)); child = getItem(hwnd, IDC_MAIN_DEBUG); CArchMiscWindows::setValue(key, "debug", SendMessage(child, CB_GETCURSEL, 0, 0)); CArchMiscWindows::setValue(key, "isServer", isClientChecked(hwnd) ? 0 : 1); CArchMiscWindows::closeKey(key); } }
void CAdvancedOptions::init() { // get values from registry HKEY key = CArchMiscWindows::openKey(HKEY_CURRENT_USER, getSettingsPath()); if (key != NULL) { DWORD newPort = CArchMiscWindows::readValueInt(key, "port"); CString newName = CArchMiscWindows::readValueString(key, "name"); if (newPort != 0) { m_port = static_cast<int>(newPort); } if (!newName.empty()) { m_screenName = newName; } CArchMiscWindows::closeKey(key); } }
void SettingsCache::translateLegacySettings() { if (isPortableBuild) return; // Layouts QFile layoutFile(getSettingsPath() + "layouts/deckLayout.ini"); if (layoutFile.exists()) if (layoutFile.copy(getSettingsPath() + "layouts.ini")) layoutFile.remove(); QStringList usedKeys; QSettings legacySetting; // Sets legacySetting.beginGroup("sets"); QStringList setsGroups = legacySetting.childGroups(); for (int i = 0; i < setsGroups.size(); i++) { legacySetting.beginGroup(setsGroups.at(i)); cardDatabase().setEnabled(setsGroups.at(i), legacySetting.value("enabled").toBool()); cardDatabase().setIsKnown(setsGroups.at(i), legacySetting.value("isknown").toBool()); cardDatabase().setSortKey(setsGroups.at(i), legacySetting.value("sortkey").toUInt()); legacySetting.endGroup(); } QStringList setsKeys = legacySetting.allKeys(); for (int i = 0; i < setsKeys.size(); ++i) { usedKeys.append("sets/" + setsKeys.at(i)); } legacySetting.endGroup(); // Servers legacySetting.beginGroup("server"); servers().setPreviousHostLogin(legacySetting.value("previoushostlogin").toInt()); servers().setPreviousHostList(legacySetting.value("previoushosts").toStringList()); servers().setHostName(legacySetting.value("hostname").toString()); servers().setPort(legacySetting.value("port").toString()); servers().setPlayerName(legacySetting.value("playername").toString()); servers().setPassword(legacySetting.value("password").toString()); servers().setSavePassword(legacySetting.value("save_password").toInt()); servers().setAutoConnect(legacySetting.value("auto_connect").toInt()); servers().setFPHostName(legacySetting.value("fphostname").toString()); servers().setFPPort(legacySetting.value("fpport").toString()); servers().setFPPlayerName(legacySetting.value("fpplayername").toString()); usedKeys.append(legacySetting.allKeys()); QStringList allKeysServer = legacySetting.allKeys(); for (int i = 0; i < allKeysServer.size(); ++i) { usedKeys.append("server/" + allKeysServer.at(i)); } legacySetting.endGroup(); // Messages legacySetting.beginGroup("messages"); QStringList allMessages = legacySetting.allKeys(); for (int i = 0; i < allMessages.size(); ++i) { if (allMessages.at(i) != "count") { QString temp = allMessages.at(i); int index = temp.remove("msg").toInt(); messages().setMessageAt(index, legacySetting.value(allMessages.at(i)).toString()); } } messages().setCount(legacySetting.value("count").toInt()); QStringList allKeysmessages = legacySetting.allKeys(); for (int i = 0; i < allKeysmessages.size(); ++i) { usedKeys.append("messages/" + allKeysmessages.at(i)); } legacySetting.endGroup(); // Game filters legacySetting.beginGroup("filter_games"); gameFilters().setUnavailableGamesVisible(legacySetting.value("unavailable_games_visible").toBool()); gameFilters().setShowPasswordProtectedGames(legacySetting.value("show_password_protected_games").toBool()); gameFilters().setGameNameFilter(legacySetting.value("game_name_filter").toString()); gameFilters().setShowBuddiesOnlyGames(legacySetting.value("show_buddies_only_games").toBool()); gameFilters().setMinPlayers(legacySetting.value("min_players").toInt()); if (legacySetting.value("max_players").toInt() > 1) gameFilters().setMaxPlayers(legacySetting.value("max_players").toInt()); else gameFilters().setMaxPlayers(99); // This prevents a bug where no games will show if max was not set before QStringList allFilters = legacySetting.allKeys(); for (int i = 0; i < allFilters.size(); ++i) { if (allFilters.at(i).startsWith("game_type")) { gameFilters().setGameHashedTypeEnabled(allFilters.at(i), legacySetting.value(allFilters.at(i)).toBool()); } } QStringList allKeysfilter_games = legacySetting.allKeys(); for (int i = 0; i < allKeysfilter_games.size(); ++i) { usedKeys.append("filter_games/" + allKeysfilter_games.at(i)); } legacySetting.endGroup(); QStringList allLegacyKeys = legacySetting.allKeys(); for (int i = 0; i < allLegacyKeys.size(); ++i) { if (usedKeys.contains(allLegacyKeys.at(i))) continue; settings->setValue(allLegacyKeys.at(i), legacySetting.value(allLegacyKeys.at(i))); } }
SettingsCache::SettingsCache() { // first, figure out if we are running in portable mode isPortableBuild = QFile::exists(qApp->applicationDirPath() + "/portable.dat"); if (isPortableBuild) qDebug() << "Portable mode enabled"; // define a dummy context that will be used where needed QString dummy = QT_TRANSLATE_NOOP("i18n", "English"); QString dataPath = getDataPath(); QString settingsPath = getSettingsPath(); settings = new QSettings(settingsPath + "global.ini", QSettings::IniFormat, this); shortcutsSettings = new ShortcutsSettings(settingsPath, this); cardDatabaseSettings = new CardDatabaseSettings(settingsPath, this); serversSettings = new ServersSettings(settingsPath, this); messageSettings = new MessageSettings(settingsPath, this); gameFiltersSettings = new GameFiltersSettings(settingsPath, this); layoutsSettings = new LayoutsSettings(settingsPath, this); downloadSettings = new DownloadSettings(settingsPath, this); if (!QFile(settingsPath + "global.ini").exists()) translateLegacySettings(); // updates - don't reorder them or their index in the settings won't match // append channels one by one, or msvc will add them in the wrong order. releaseChannels << new StableReleaseChannel(); releaseChannels << new BetaReleaseChannel(); mbDownloadSpoilers = settings->value("personal/downloadspoilers", false).toBool(); notifyAboutUpdates = settings->value("personal/updatenotification", true).toBool(); notifyAboutNewVersion = settings->value("personal/newversionnotification", true).toBool(); updateReleaseChannel = settings->value("personal/updatereleasechannel", 0).toInt(); lang = settings->value("personal/lang").toString(); keepalive = settings->value("personal/keepalive", 5).toInt(); // tip of the day settings showTipsOnStartup = settings->value("tipOfDay/showTips", true).toBool(); for (const auto &tipNumber : settings->value("tipOfDay/seenTips").toList()) { seenTips.append(tipNumber.toInt()); } deckPath = getSafeConfigPath("paths/decks", dataPath + "/decks/"); replaysPath = getSafeConfigPath("paths/replays", dataPath + "/replays/"); picsPath = getSafeConfigPath("paths/pics", dataPath + "/pics/"); // this has never been exposed as an user-configurable setting if (picsPath.endsWith("/")) { customPicsPath = getSafeConfigPath("paths/custompics", picsPath + "CUSTOM/"); } else { customPicsPath = getSafeConfigPath("paths/custompics", picsPath + "/CUSTOM/"); } // this has never been exposed as an user-configurable setting customCardDatabasePath = getSafeConfigPath("paths/customsets", dataPath + "/customsets/"); cardDatabasePath = getSafeConfigFilePath("paths/carddatabase", dataPath + "/cards.xml"); tokenDatabasePath = getSafeConfigFilePath("paths/tokendatabase", dataPath + "/tokens.xml"); spoilerDatabasePath = getSafeConfigFilePath("paths/spoilerdatabase", dataPath + "/spoiler.xml"); themeName = settings->value("theme/name").toString(); // we only want to reset the cache once, then its up to the user bool updateCache = settings->value("revert/pixmapCacheSize", false).toBool(); if (!updateCache) { pixmapCacheSize = PIXMAPCACHE_SIZE_DEFAULT; settings->setValue("personal/pixmapCacheSize", pixmapCacheSize); settings->setValue("personal/picturedownloadhq", false); settings->setValue("revert/pixmapCacheSize", true); } else pixmapCacheSize = settings->value("personal/pixmapCacheSize", PIXMAPCACHE_SIZE_DEFAULT).toInt(); // sanity check if (pixmapCacheSize < PIXMAPCACHE_SIZE_MIN || pixmapCacheSize > PIXMAPCACHE_SIZE_MAX) pixmapCacheSize = PIXMAPCACHE_SIZE_DEFAULT; picDownload = settings->value("personal/picturedownload", true).toBool(); mainWindowGeometry = settings->value("interface/main_window_geometry").toByteArray(); tokenDialogGeometry = settings->value("interface/token_dialog_geometry").toByteArray(); notificationsEnabled = settings->value("interface/notificationsenabled", true).toBool(); spectatorNotificationsEnabled = settings->value("interface/specnotificationsenabled", false).toBool(); doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool(); playToStack = settings->value("interface/playtostack", true).toBool(); annotateTokens = settings->value("interface/annotatetokens", false).toBool(); tabGameSplitterSizes = settings->value("interface/tabgame_splittersizes").toByteArray(); displayCardNames = settings->value("cards/displaycardnames", true).toBool(); horizontalHand = settings->value("hand/horizontal", true).toBool(); invertVerticalCoordinate = settings->value("table/invert_vertical", false).toBool(); minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 4).toInt(); tapAnimation = settings->value("cards/tapanimation", true).toBool(); chatMention = settings->value("chat/mention", true).toBool(); chatMentionCompleter = settings->value("chat/mentioncompleter", true).toBool(); chatMentionForeground = settings->value("chat/mentionforeground", true).toBool(); chatHighlightForeground = settings->value("chat/highlightforeground", true).toBool(); chatMentionColor = settings->value("chat/mentioncolor", "A6120D").toString(); chatHighlightColor = settings->value("chat/highlightcolor", "A6120D").toString(); zoneViewSortByName = settings->value("zoneview/sortbyname", true).toBool(); zoneViewSortByType = settings->value("zoneview/sortbytype", true).toBool(); zoneViewPileView = settings->value("zoneview/pileview", true).toBool(); soundEnabled = settings->value("sound/enabled", false).toBool(); soundThemeName = settings->value("sound/theme").toString(); maxFontSize = settings->value("game/maxfontsize", DEFAULT_FONT_SIZE).toInt(); ignoreUnregisteredUsers = settings->value("chat/ignore_unregistered", false).toBool(); ignoreUnregisteredUserMessages = settings->value("chat/ignore_unregistered_messages", false).toBool(); scaleCards = settings->value("cards/scaleCards", true).toBool(); showMessagePopups = settings->value("chat/showmessagepopups", true).toBool(); showMentionPopups = settings->value("chat/showmentionpopups", true).toBool(); roomHistory = settings->value("chat/roomhistory", true).toBool(); leftJustified = settings->value("interface/leftjustified", false).toBool(); masterVolume = settings->value("sound/mastervolume", 100).toInt(); cardInfoViewMode = settings->value("cards/cardinfoviewmode", 0).toInt(); highlightWords = settings->value("personal/highlightWords", QString()).toString(); gameDescription = settings->value("game/gamedescription", "").toString(); maxPlayers = settings->value("game/maxplayers", 2).toInt(); gameTypes = settings->value("game/gametypes", "").toString(); onlyBuddies = settings->value("game/onlybuddies", false).toBool(); onlyRegistered = settings->value("game/onlyregistered", true).toBool(); spectatorsAllowed = settings->value("game/spectatorsallowed", true).toBool(); spectatorsNeedPassword = settings->value("game/spectatorsneedpassword", false).toBool(); spectatorsCanTalk = settings->value("game/spectatorscantalk", false).toBool(); spectatorsCanSeeEverything = settings->value("game/spectatorscanseeeverything", false).toBool(); rememberGameSettings = settings->value("game/remembergamesettings", true).toBool(); clientID = settings->value("personal/clientid", "notset").toString(); clientVersion = settings->value("personal/clientversion", "notset").toString(); knownMissingFeatures = settings->value("interface/knownmissingfeatures", "").toString(); }
Settings::Settings() { if(!fileExists(getSettingsPath())) createSettingsFile(); }
static bool saveMainWindow(HWND hwnd, bool quiting, CString* cmdLineOut = NULL) { DWORD errorID = 0; CString arg; CString cmdLine; // save dialog state bool isClient = isClientChecked(hwnd); HKEY key = CArchMiscWindows::addKey(HKEY_CURRENT_USER, getSettingsPath()); if (key != NULL) { HWND child; child = getItem(hwnd, IDC_MAIN_CLIENT_SERVER_NAME_EDIT); CArchMiscWindows::setValue(key, "server", getWindowText(child)); child = getItem(hwnd, IDC_MAIN_DEBUG); CArchMiscWindows::setValue(key, "debug", SendMessage(child, CB_GETCURSEL, 0, 0)); CArchMiscWindows::setValue(key, "isServer", isClient ? 0 : 1); CArchMiscWindows::closeKey(key); } // save user's configuration if (!saveConfig(ARG->m_config, false)) { errorID = IDS_SAVE_FAILED; arg = getErrorString(GetLastError()); goto failed; } // save autostart configuration if (CAutoStart::isDaemonInstalled()) { if (!saveConfig(ARG->m_config, true)) { errorID = IDS_AUTOSTART_SAVE_FAILED; arg = getErrorString(GetLastError()); goto failed; } } // get autostart command cmdLine = getCommandLine(hwnd, false, quiting); if (cmdLineOut != NULL) { *cmdLineOut = cmdLine; } if (cmdLine.empty()) { return quiting; } // save autostart command if (CAutoStart::isDaemonInstalled()) { try { CAutoStart::reinstallDaemon(isClient, cmdLine); CAutoStart::uninstallDaemons(!isClient); } catch (XArchDaemon& e) { errorID = IDS_INSTALL_GENERIC_ERROR; arg = e.what(); goto failed; } } return true; failed: CString errorMessage = CStringUtil::format(getString(errorID).c_str(), arg.c_str()); if (quiting) { errorMessage += "\n"; errorMessage += getString(IDS_UNSAVED_DATA_REALLY_QUIT); if (askVerify(hwnd, errorMessage)) { return true; } } else { showError(hwnd, errorMessage); } return false; }
SettingsCache::SettingsCache() { settings = new QSettings(this); shortcutsSettings = new ShortcutsSettings(getSettingsPath(),this); lang = settings->value("personal/lang").toString(); keepalive = settings->value("personal/keepalive", 5).toInt(); deckPath = settings->value("paths/decks").toString(); replaysPath = settings->value("paths/replays").toString(); picsPath = settings->value("paths/pics").toString(); cardDatabasePath = settings->value("paths/carddatabase").toString(); tokenDatabasePath = settings->value("paths/tokendatabase").toString(); handBgPath = settings->value("zonebg/hand").toString(); stackBgPath = settings->value("zonebg/stack").toString(); tableBgPath = settings->value("zonebg/table").toString(); playerBgPath = settings->value("zonebg/playerarea").toString(); cardBackPicturePath = settings->value("paths/cardbackpicture").toString(); // we only want to reset the cache once, then its up to the user bool updateCache = settings->value("revert/pixmapCacheSize", false).toBool(); if (!updateCache) { pixmapCacheSize = PIXMAPCACHE_SIZE_DEFAULT; settings->setValue("personal/pixmapCacheSize", pixmapCacheSize); settings->setValue("personal/picturedownloadhq", false); settings->setValue("revert/pixmapCacheSize", true); } else pixmapCacheSize = settings->value("personal/pixmapCacheSize", PIXMAPCACHE_SIZE_DEFAULT).toInt(); //sanity check if(pixmapCacheSize < PIXMAPCACHE_SIZE_MIN || pixmapCacheSize > PIXMAPCACHE_SIZE_MAX) pixmapCacheSize = PIXMAPCACHE_SIZE_DEFAULT; picDownload = settings->value("personal/picturedownload", true).toBool(); picDownloadHq = settings->value("personal/picturedownloadhq", true).toBool(); picUrl = settings->value("personal/picUrl", PIC_URL_DEFAULT).toString(); picUrlHq = settings->value("personal/picUrlHq", PIC_URL_HQ_DEFAULT).toString(); picUrlFallback = settings->value("personal/picUrlFallback", PIC_URL_FALLBACK).toString(); picUrlHqFallback = settings->value("personal/picUrlHqFallback", PIC_URL_HQ_FALLBACK).toString(); mainWindowGeometry = settings->value("interface/main_window_geometry").toByteArray(); notificationsEnabled = settings->value("interface/notificationsenabled", true).toBool(); spectatorNotificationsEnabled = settings->value("interface/specnotificationsenabled", false).toBool(); doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool(); playToStack = settings->value("interface/playtostack", false).toBool(); annotateTokens = settings->value("interface/annotatetokens", false).toBool(); cardInfoMinimized = settings->value("interface/cardinfominimized", 0).toInt(); tabGameSplitterSizes = settings->value("interface/tabgame_splittersizes").toByteArray(); displayCardNames = settings->value("cards/displaycardnames", true).toBool(); horizontalHand = settings->value("hand/horizontal", true).toBool(); invertVerticalCoordinate = settings->value("table/invert_vertical", false).toBool(); minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 5).toInt(); tapAnimation = settings->value("cards/tapanimation", true).toBool(); chatMention = settings->value("chat/mention", true).toBool(); chatMentionCompleter = settings->value("chat/mentioncompleter", true).toBool(); chatMentionForeground = settings->value("chat/mentionforeground", true).toBool(); chatHighlightForeground = settings->value("chat/highlightforeground", true).toBool(); chatMentionColor = settings->value("chat/mentioncolor", "A6120D").toString(); chatHighlightColor = settings->value("chat/highlightcolor", "A6120D").toString(); zoneViewSortByName = settings->value("zoneview/sortbyname", true).toBool(); zoneViewSortByType = settings->value("zoneview/sortbytype", true).toBool(); zoneViewPileView = settings->value("zoneview/pileview", true).toBool(); soundEnabled = settings->value("sound/enabled", false).toBool(); soundPath = settings->value("sound/path").toString(); priceTagFeature = settings->value("deckeditor/pricetags", false).toBool(); priceTagSource = settings->value("deckeditor/pricetagsource", 0).toInt(); ignoreUnregisteredUsers = settings->value("chat/ignore_unregistered", false).toBool(); ignoreUnregisteredUserMessages = settings->value("chat/ignore_unregistered_messages", false).toBool(); attemptAutoConnect = settings->value("server/auto_connect", 0).toBool(); scaleCards = settings->value("cards/scaleCards", true).toBool(); showMessagePopups = settings->value("chat/showmessagepopups", true).toBool(); showMentionPopups = settings->value("chat/showmentionpopups", true).toBool(); leftJustified = settings->value("interface/leftjustified", false).toBool(); masterVolume = settings->value("sound/mastervolume", 100).toInt(); cardInfoViewMode = settings->value("cards/cardinfoviewmode", 0).toInt(); highlightWords = settings->value("personal/highlightWords", QString()).toString(); gameDescription = settings->value("game/gamedescription","").toString(); maxPlayers = settings->value("game/maxplayers", 2).toInt(); gameTypes = settings->value("game/gametypes","").toString(); onlyBuddies = settings->value("game/onlybuddies", false).toBool(); onlyRegistered = settings->value("game/onlyregistered", true).toBool(); spectatorsAllowed = settings->value("game/spectatorsallowed", true).toBool(); spectatorsNeedPassword = settings->value("game/spectatorsneedpassword", false).toBool(); spectatorsCanTalk = settings->value("game/spectatorscantalk", false).toBool(); spectatorsCanSeeEverything = settings->value("game/spectatorscanseeeverything", false).toBool(); clientID = settings->value("personal/clientid", "notset").toString(); QString file = getSettingsPath(); file.append("layouts/deckLayout.ini"); QSettings layout_settings(file , QSettings::IniFormat); deckEditorLayoutState = layout_settings.value("layouts/deckEditor_state").toByteArray(); deckEditorGeometry = layout_settings.value("layouts/deckEditor_geometry").toByteArray(); deckEditorCardSize = layout_settings.value("layouts/deckEditor_CardSize", QSize(250,500)).toSize(); deckEditorFilterSize = layout_settings.value("layouts/deckEditor_FilterSize", QSize(250,250)).toSize(); deckEditorDeckSize = layout_settings.value("layouts/deckEditor_DeckSize", QSize(250,360)).toSize(); }
bool CAdvancedOptions::save(HWND hwnd) { SetCursor(LoadCursor(NULL, IDC_WAIT)); HWND child = getItem(hwnd, IDC_ADVANCED_NAME_EDIT); CString name = getWindowText(child); if (!m_config->isValidScreenName(name)) { showError(hwnd, CStringUtil::format( getString(IDS_INVALID_SCREEN_NAME).c_str(), name.c_str())); SetFocus(child); return false; } if (!m_isClient && !m_config->isScreen(name)) { showError(hwnd, CStringUtil::format( getString(IDS_UNKNOWN_SCREEN_NAME).c_str(), name.c_str())); SetFocus(child); return false; } child = getItem(hwnd, IDC_ADVANCED_INTERFACE_EDIT); CString iface = getWindowText(child); if (!m_isClient) { try { if (!iface.empty()) { ARCH->nameToAddr(iface); } } catch (XArchNetworkName& e) { showError(hwnd, CStringUtil::format( getString(IDS_INVALID_INTERFACE_NAME).c_str(), iface.c_str(), e.what().c_str())); SetFocus(child); return false; } } // get and verify port child = getItem(hwnd, IDC_ADVANCED_PORT_EDIT); CString portString = getWindowText(child); int port = atoi(portString.c_str()); if (port < 1 || port > 65535) { CString defaultPortString = CStringUtil::print("%d", kDefaultPort); showError(hwnd, CStringUtil::format( getString(IDS_INVALID_PORT).c_str(), portString.c_str(), defaultPortString.c_str())); SetFocus(child); return false; } // save state m_screenName = name; m_port = port; m_interface = iface; // save values to registry HKEY key = CArchMiscWindows::addKey(HKEY_CURRENT_USER, getSettingsPath()); if (key != NULL) { CArchMiscWindows::setValue(key, "port", m_port); CArchMiscWindows::setValue(key, "name", m_screenName); CArchMiscWindows::setValue(key, "interface", m_interface); CArchMiscWindows::closeKey(key); } return true; }
static void initMainWindow(HWND hwnd) { // append version number to title CString titleFormat = getString(IDS_TITLE); setWindowText(hwnd, CStringUtil::format(titleFormat.c_str(), VERSION)); // load configuration bool configLoaded = loadConfig(ARG->m_config); ARG->m_oldConfig = ARG->m_config; enableSaveControls(hwnd); // get settings from registry bool isServer = configLoaded; int debugLevel = s_defaultDebug; CString server; HKEY key = CArchMiscWindows::openKey(HKEY_CURRENT_USER, getSettingsPath()); if (key != NULL) { if (isServer && CArchMiscWindows::hasValue(key, "isServer")) { isServer = (CArchMiscWindows::readValueInt(key, "isServer") != 0); } if (CArchMiscWindows::hasValue(key, "debug")) { debugLevel = static_cast<int>( CArchMiscWindows::readValueInt(key, "debug")); if (debugLevel < 0) { debugLevel = 0; } else if (debugLevel > CLog::kDEBUG2) { debugLevel = CLog::kDEBUG2; } } server = CArchMiscWindows::readValueString(key, "server"); CArchMiscWindows::closeKey(key); } // choose client/server radio buttons HWND child; child = getItem(hwnd, IDC_MAIN_CLIENT_RADIO); setItemChecked(child, !isServer); child = getItem(hwnd, IDC_MAIN_SERVER_RADIO); setItemChecked(child, isServer); // set server name child = getItem(hwnd, IDC_MAIN_CLIENT_SERVER_NAME_EDIT); setWindowText(child, server); // if config is loaded then initialize server controls if (configLoaded) { int i = 1; child = getItem(hwnd, IDC_MAIN_SERVER_SCREENS_LIST); for (CConfig::const_iterator index = ARG->m_config.begin(); index != ARG->m_config.end(); ++i, ++index) { ARG->m_screens.push_back(*index); CString item = CStringUtil::print("%d. %s", i, index->c_str()); SendMessage(child, LB_ADDSTRING, 0, (LPARAM)item.c_str()); } } // debug level child = getItem(hwnd, IDC_MAIN_DEBUG); for (unsigned int i = 0; i < sizeof(s_debugName) / sizeof(s_debugName[0]); ++i) { SendMessage(child, CB_ADDSTRING, 0, (LPARAM)s_debugName[i][0]); } SendMessage(child, CB_SETCURSEL, debugLevel, 0); // update neighbor combo boxes enableMainWindowControls(hwnd); updateNeighbors(hwnd); }