Source Code (Use browser search to find items of interest.)

Class Index

kimageshop'KisConfig (./koffice/kimageshop/core/kis_config.h:59)

class KisConfig : public QObject
{
  Q_OBJECT

public:

  /**
   * A factory for config objects. Use it to create a new config object for
   * each new KImageShopView instance
   * Notice: make sure you delete the object when you don't need it anymore!
   */
  static KisConfig *getNewConfig();

  ~KisConfig();

  /**
   * saves all document specific settings to disk - but for this instance only
   */
  void 	saveConfig();

  /**
   * saves all global settings - called from @see #saveAll and when the last
   * instance is closed
   */
  void 	saveGlobalSettings();

  /**
   * saves all settings for ALL instances - only called from sessionmanagement
   */
  void 	saveAll();

  /**
   * loads all document specific settings for this instance from disk - called
   * from the first constructor and from sessionmanagement (when there are
   * different documents created with different settings)
   */
  void 	loadConfig();


  void 	loadDialogSettings();
  void 	saveDialogSettings();

  
  // accessors for config entries
  
  static QFont smallFont() 			{ return m_smallFont; }
  static QFont tinyFont()  			{ return m_tinyFont;  }
  static const  QStringList& blendings();
  // many more to come...

  
  typedef enum { Normal = 0,
		 Dissolve,
		 Behind,
		 Multiply,
		 Screen,
		 Overlay,
		 Difference,
		 Addition,
		 Subtract,
		 DarkenOnly,
		 LightenOnly,
		 Hue,
		 Saturation,
		 Color,
		 Value
  } Blending;

  
protected:

  /**
   * This constructor creates the first KisConfig object and loads
   * the settings from disk. Subsequent objects get these settings from this
   * object thru the copy constructor, but transparently (@see #getNewConfig)
   */
  KisConfig();

  /**
   *  A copy constructor for the KisConfig class (doh)
   *
   * Used by @see #getNewConfig to create a new KisConfig object for a
   * new KImageShopView
   */
  KisConfig( const KisConfig& );

  /**
   * This method initializes all static members
   * called only once from the very first constructor
   */
  static void 	initStatic();


signals:
  void 	globalConfigChanged();


private:

  // loads the global settings - called only once from the constructor of the
  // first instance
  static void 	loadGlobalSettings();

  
  // static objects - global items that are the same for _all_
  // KImageShopDoc objects
  static KConfig 	*kc;
  static bool		doInit;
  static QList<KisConfig> 	instanceList;

  static QFont 		m_smallFont;
  static QFont		m_tinyFont;
  static QStringList 	m_blendList;


  // document specific configuration (non-static)
  //  LayerDlgConfig 	*m_pLayerDlgConfig;
  // ...
};



// separate configuration classes for all dialogs

/**
 * The interface, every configuration class must implement
 * (pure virtual class)
 */

kimageshop'KisConfig::getNewConfig() (./koffice/kimageshop/core/kis_config.cc:40)

KisConfig * KisConfig::getNewConfig()
{
  if ( doInit ) {
    return ( new KisConfig() );
  }

  else {
    if ( instanceList.count() == 0 ) {
      return ( new KisConfig() );
    }

    return ( new KisConfig( *instanceList.first() ) );
  }
}



kimageshop'KisConfig::KisConfig() (./koffice/kimageshop/core/kis_config.cc:56)

KisConfig::KisConfig() : QObject( 0L, "kimageshop config" )
{
  // load and init global settings only once
  if ( doInit ) {
    initStatic();
  }

  instanceList.append( this );

  // now load all the settings for the config objects
  loadConfig();
}



kimageshop'KisConfig::KisConfig() (./koffice/kimageshop/core/kis_config.cc:70)

KisConfig::KisConfig( const KisConfig& /*config*/ )
  : QObject()
{
  instanceList.append( this );

  // ...
}



kimageshop'KisConfig::~KisConfig() (./koffice/kimageshop/core/kis_config.cc:79)

KisConfig::~KisConfig()
{
  instanceList.remove( this );

  // when the last document is closed, save the global settings
  if ( instanceList.isEmpty() )
    saveGlobalSettings();

  // ...
}



kimageshop'KisConfig::initStatic() (./koffice/kimageshop/core/kis_config.cc:91)

void KisConfig::initStatic()
{
  kc = KGlobal::config();

  instanceList.clear();
  instanceList.setAutoDelete( false );

  loadGlobalSettings();
  
  (void) m_blendList.append( i18n("Normal") );
  (void) m_blendList.append( i18n("Dissolve") );
  (void) m_blendList.append( i18n("Behind") );
  (void) m_blendList.append( i18n("Multiply") );
  (void) m_blendList.append( i18n("Screen") );
  (void) m_blendList.append( i18n("Overlay") );
  (void) m_blendList.append( i18n("Difference") );
  (void) m_blendList.append( i18n("Addition") );
  (void) m_blendList.append( i18n("Subtract") );
  (void) m_blendList.append( i18n("Darken only") );
  (void) m_blendList.append( i18n("Lighten only") );
  (void) m_blendList.append( i18n("Hue") );
  (void) m_blendList.append( i18n("Saturation") );
  (void) m_blendList.append( i18n("Color") );
  (void) m_blendList.append( i18n("Value") );

  doInit = false;
}


// a convenience method - load all document specific configuration

kimageshop'KisConfig::loadConfig() (./koffice/kimageshop/core/kis_config.cc:121)

void KisConfig::loadConfig()
{
  loadDialogSettings();
  // ...
}


// save all document specific configuration

kimageshop'KisConfig::saveConfig() (./koffice/kimageshop/core/kis_config.cc:129)

void KisConfig::saveConfig()
{
  saveDialogSettings();
  // ...
}



kimageshop'KisConfig::saveAll() (./koffice/kimageshop/core/kis_config.cc:136)

void KisConfig::saveAll()
{
  KisConfig *config = 0L;
  for ( config = instanceList.first(); config; config = instanceList.next() ) {
    config->saveConfig();
  }

  saveGlobalSettings();
}



kimageshop'KisConfig::loadGlobalSettings() (./koffice/kimageshop/core/kis_config.cc:147)

void KisConfig::loadGlobalSettings()
{
  // read some fonts
  QFont font = KGlobal::generalFont();
  font.setPointSize( 10 );
  m_smallFont = kc->readFontEntry( "Small Font", &font );

  font = KGlobal::generalFont();
  font.setPointSize( 8 );
  m_tinyFont = kc->readFontEntry( "Tiny Font", &font );

  // ...
}



kimageshop'KisConfig::saveGlobalSettings() (./koffice/kimageshop/core/kis_config.cc:162)

void KisConfig::saveGlobalSettings()
{
  kc->setGroup( "General Settings" );

  kc->writeEntry( "Small Font", m_smallFont );
  kc->writeEntry( "Tiny Font", m_tinyFont );

  // ...
}



kimageshop'KisConfig::loadDialogSettings() (./koffice/kimageshop/core/kis_config.cc:173)

void KisConfig::loadDialogSettings()
{
  //m_pLayerDlgConfig->loadConfig( kc );
  // ...
}



kimageshop'KisConfig::saveDialogSettings() (./koffice/kimageshop/core/kis_config.cc:180)

void KisConfig::saveDialogSettings()
{
  //m_pLayerDlgConfig->saveConfig( kc );
  // ...
}



kimageshop'KisConfig::blendings() (./koffice/kimageshop/core/kis_config.cc:187)

const QStringList& KisConfig::blendings()
{
  if ( doInit )
    KisConfig::initStatic();
  return KisConfig::m_blendList;
}

// The base configuration class