context: /****************************************************************************
  **
  ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
  ** Contact: http://www.qt-project.org/legal
  **
  ** This file is part of the Qt VS Add-in.
  **
  ** $QT_BEGIN_LICENSE:LGPL$
  ** Commercial License Usage
  ** Licensees holding valid commercial Qt licenses may use this file in
  ** accordance with the commercial license agreement provided with the
  ** Software or, alternatively, in accordance with the terms contained in
  ** a written agreement between you and Digia.  For licensing terms and
  ** conditions see http://qt.digia.com/licensing.  For further information
  ** use the contact form at http://qt.digia.com/contact-us.
  **
  ** GNU Lesser General Public License Usage
  ** Alternatively, this file may be used under the terms of the GNU Lesser
  ** General Public License version 2.1 as published by the Free Software
  ** Foundation and appearing in the file LICENSE.LGPL included in the
  ** packaging of this file.  Please review the following information to
  ** ensure the GNU Lesser General Public License version 2.1 requirements
  ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  **
  ** In addition, as a special exception, Digia gives you certain additional
  ** rights.  These rights are described in the Digia Qt LGPL Exception
  ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  **
  ** GNU General Public License Usage
  ** Alternatively, this file may be used under the terms of the GNU
  ** General Public License version 3.0 as published by the Free Software
  ** Foundation and appearing in the file LICENSE.GPL included in the
  ** packaging of this file.  Please review the following information to
  ** ensure the GNU General Public License version 3.0 requirements will be
  ** met: http://www.gnu.org/copyleft/gpl.html.
  **
  **
  ** $QT_END_LICENSE$
  **
  ****************************************************************************/
  
  using System;
  using Microsoft.Win32;
  using Microsoft.VisualStudio.VCProjectEngine;
  using System.Collections;
  using System.Drawing;
  
  namespace Digia.Qt5ProjectLib
  {
      public class QtVSIPSettings
      {
          static Hashtable mocDirCache = new Hashtable();
          static Hashtable uicDirCache = new Hashtable();
          static Hashtable rccDirCache = new Hashtable();
  
          public static bool GetDisableAutoMocStepsUpdate()
          {
              return GetBoolValue(Resources.disableAutoMocStepsUpdateKeyword, false);
          }
  
          public static void SaveDisableAutoMocStepsUpdate(bool b)
          {
              SetBoolValue(Resources.disableAutoMocStepsUpdateKeyword, b);
          }
  
          public static string GetUicDirectory(EnvDTE.Project project)
          {
              return GetDirectory(project, Resources.uicDirKeyword);
          }
  
          public static void SaveUicDirectory(EnvDTE.Project project, string directory)
          {
              if (directory == null)
                  SaveDirectory(project, Resources.uicDirKeyword, GetDirectory(project, Resources.uicDirKeyword));
              else
                  SaveDirectory(project, Resources.uicDirKeyword, directory);
          }
  
          public static string GetMocDirectory()
          {
              return GetDirectory(Resources.mocDirKeyword);
          }
  
          public static string GetMocDirectory(EnvDTE.Project project)
          {
                  return GetDirectory(project, Resources.mocDirKeyword);
          }
  
          public static string GetMocDirectory(EnvDTE.Project project, string configName, string platformName)
          {
              string dir = GetDirectory(project, Resources.mocDirKeyword);
              if (!string.IsNullOrEmpty(configName))
                  dir = dir.Replace("$(ConfigurationName)", configName);
              if (!string.IsNullOrEmpty(platformName))
                  dir = dir.Replace("$(PlatformName)", platformName);
              return dir;
          }
  
          public static bool HasDifferentMocFilePerConfig(EnvDTE.Project project)
          {
              string mocDir = GetMocDirectory(project);
              return mocDir.Contains("$(ConfigurationName)");
          }
  
          public static bool HasDifferentMocFilePerPlatform(EnvDTE.Project project)
          {
              string mocDir = GetMocDirectory(project);
              return mocDir.Contains("$(PlatformName)");
          }
  
          public static string GetMocOptions()
          {
              return GetOption(Resources.mocOptionsKeyword);
          }
  
          public static string GetMocOptions(EnvDTE.Project project)
          {
              return GetOption(project, Resources.mocOptionsKeyword);
          }
  
          public static bool GetLUpdateOnBuild(EnvDTE.Project project)
          {
              return GetBoolValue(project, Resources.lupdateKeyword);
          }
  
          public static string GetLUpdateOptions()
          {
              return GetOption(Resources.lupdateOptionsKeyword);
          }
  
          public static string GetLUpdateOptions(EnvDTE.Project project)
          {
              return GetOption(project, Resources.lupdateOptionsKeyword);
          }
  
          public static string GetLReleaseOptions()
          {
              return GetOption(Resources.lreleaseOptionsKeyword);
          }
  
          public static string GetLReleaseOptions(EnvDTE.Project project)
          {
              return GetOption(project, Resources.lreleaseOptionsKeyword);
          }
  
          public static string GetDesignerOptions()
          {
              return GetOption(Resources.designerOptionsKeyword);
          }
  
          public static string GetDesignerOptions(EnvDTE.Project project)
          {
              return GetOption(project, Resources.designerOptionsKeyword);
          }
  
          public static string GetLinguistOptions()
          {
              return GetOption(Resources.linguistOptionsKeyword);
          }
  
          public static string GetLinguistOptions(EnvDTE.Project project)
          {
              return GetOption(project, Resources.linguistOptionsKeyword);
          }
  
          public static string GetAssistantOptions()
          {
              return GetOption(Resources.assistantOptionsKeyword);
          }
  
          public static string GetAssistantOptions(EnvDTE.Project project)
          {
              return GetOption(project, Resources.assistantOptionsKeyword);
          }
  
          public static bool GetAskBeforeCheckoutFile()
          {
              return GetBoolValue(Resources.askBeforeCheckoutFileKeyword, true);
          }
  
          public static void SaveAskBeforeCheckoutFile(bool value)
          {
              SetBoolValue(Resources.askBeforeCheckoutFileKeyword, value);
          }
  
          public static bool GetDisableCheckoutFiles()
          {
              return GetBoolValue(Resources.disableCheckoutFilesKeyword, false);
          }
  
          public static void SaveDisableCheckoutFiles(bool value)
          {
              SetBoolValue(Resources.disableCheckoutFilesKeyword, value);
          }
  
          public static void SaveMocDirectory(EnvDTE.Project project, string directory)
          {
              if (directory == null)
                  SaveDirectory(project, Resources.mocDirKeyword, GetDirectory(project, Resources.mocDirKeyword));
              else
                  SaveDirectory(project, Resources.mocDirKeyword, directory);
          }
  
          public static void SaveMocOptions(EnvDTE.Project project, string options)
          {
              if (options == null)
              {
                  options = GetMocOptions();
              }
              SaveOption(project, Resources.mocOptionsKeyword, options);
          }
  
          public static void SaveMocOptions(string options)
          {
              SaveOption(Resources.mocOptionsKeyword, options);
          }
  
          public static void SaveLUpdateOnBuild(EnvDTE.Project project)
          {
              SetBoolValue(project, Resources.lupdateKeyword, GetLUpdateOnBuild());
          }
  
          public static void SaveLUpdateOnBuild(EnvDTE.Project project, bool value)
          {
              SetBoolValue(project, Resources.lupdateKeyword, value);
          }
  
          public static void SaveLUpdateOptions(EnvDTE.Project project, string options)
          {
              if (options == null)
              {
                  options = GetLUpdateOptions();
              }
  
gt:             SaveOption(project, Resources.lupdateOptionsKeyword, options);