// This file is generated by kconfig_compiler_kf5 from kopetechatwindowsettings.kcfg.
// All changes you do to this file will be lost.

#include "kopetechatwindowsettings.h"

#include <qglobal.h>
#include <QFile>

class KopeteChatWindowSettingsHelper
{
  public:
    KopeteChatWindowSettingsHelper() : q(nullptr) {}
    ~KopeteChatWindowSettingsHelper() { delete q; q = nullptr; }
    KopeteChatWindowSettingsHelper(const KopeteChatWindowSettingsHelper&) = delete;
    KopeteChatWindowSettingsHelper& operator=(const KopeteChatWindowSettingsHelper&) = delete;
    KopeteChatWindowSettings *q;
};
Q_GLOBAL_STATIC(KopeteChatWindowSettingsHelper, s_globalKopeteChatWindowSettings)
KopeteChatWindowSettings *KopeteChatWindowSettings::self()
{
  if (!s_globalKopeteChatWindowSettings()->q) {
    new KopeteChatWindowSettings;
    s_globalKopeteChatWindowSettings()->q->read();
  }

  return s_globalKopeteChatWindowSettings()->q;
}

KopeteChatWindowSettings::KopeteChatWindowSettings( )
  : KConfigSkeleton( QStringLiteral( "kopeterc" ) )
  , mSettingsChanged(0)
{
  Q_ASSERT(!s_globalKopeteChatWindowSettings()->q);
  s_globalKopeteChatWindowSettings()->q = this;
  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&KopeteChatWindowSettings::itemChanged);

  setCurrentGroup( QStringLiteral( "Appearance" ) );

  KConfigCompilerSignallingItem  *itemStyleName;
  KConfigSkeleton::ItemString  *innerItemStyleName;
  innerItemStyleName = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "styleName" ), mStyleName, QStringLiteral( "Kopete" ) );
  itemStyleName = new KConfigCompilerSignallingItem(innerItemStyleName, this, notifyFunction, signalStyleChanged);
  addItem( itemStyleName, QStringLiteral( "styleName" ) );
  KConfigSkeleton::ItemString  *itemStyleVariant;
  itemStyleVariant = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "styleVariant" ), mStyleVariant );
  addItem( itemStyleVariant, QStringLiteral( "styleVariant" ) );
  KConfigSkeleton::ItemBool  *itemGroupConsecutiveMessages;
  itemGroupConsecutiveMessages = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "groupConsecutiveMessages" ), mGroupConsecutiveMessages, true );
  addItem( itemGroupConsecutiveMessages, QStringLiteral( "groupConsecutiveMessages" ) );
  KConfigSkeleton::ItemBool  *itemUseCompact;
  itemUseCompact = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "useCompact" ), mUseCompact, true );
  addItem( itemUseCompact, QStringLiteral( "useCompact" ) );
  KConfigCompilerSignallingItem  *itemHighlightForegroundColor;
  KConfigSkeleton::ItemColor  *innerItemHighlightForegroundColor;
  innerItemHighlightForegroundColor = new KConfigSkeleton::ItemColor( currentGroup(), QStringLiteral( "highlightForegroundColor" ), mHighlightForegroundColor, KColorScheme(QPalette::Active, KColorScheme::Selection).foreground().color() );
  itemHighlightForegroundColor = new KConfigCompilerSignallingItem(innerItemHighlightForegroundColor, this, notifyFunction, signalChatwindowAppearanceChanged);
  addItem( itemHighlightForegroundColor, QStringLiteral( "highlightForegroundColor" ) );
  KConfigCompilerSignallingItem  *itemHighlightBackgroundColor;
  KConfigSkeleton::ItemColor  *innerItemHighlightBackgroundColor;
  innerItemHighlightBackgroundColor = new KConfigSkeleton::ItemColor( currentGroup(), QStringLiteral( "highlightBackgroundColor" ), mHighlightBackgroundColor, KColorScheme(QPalette::Active, KColorScheme::Selection).background().color() );
  itemHighlightBackgroundColor = new KConfigCompilerSignallingItem(innerItemHighlightBackgroundColor, this, notifyFunction, signalChatwindowAppearanceChanged);
  addItem( itemHighlightBackgroundColor, QStringLiteral( "highlightBackgroundColor" ) );
  KConfigCompilerSignallingItem  *itemChatFmtOverride;
  KConfigSkeleton::ItemBool  *innerItemChatFmtOverride;
  innerItemChatFmtOverride = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "chatFmtOverride" ), mChatFmtOverride, false );
  itemChatFmtOverride = new KConfigCompilerSignallingItem(innerItemChatFmtOverride, this, notifyFunction, signalMessageOverridesChanged);
  addItem( itemChatFmtOverride, QStringLiteral( "chatFmtOverride" ) );
  KConfigCompilerSignallingItem  *itemChatTextColor;
  KConfigSkeleton::ItemColor  *innerItemChatTextColor;
  innerItemChatTextColor = new KConfigSkeleton::ItemColor( currentGroup(), QStringLiteral( "chatTextColor" ), mChatTextColor, KColorScheme(QPalette::Active, KColorScheme::View).foreground().color() );
  itemChatTextColor = new KConfigCompilerSignallingItem(innerItemChatTextColor, this, notifyFunction, signalChatwindowAppearanceChanged);
  addItem( itemChatTextColor, QStringLiteral( "chatTextColor" ) );
  KConfigCompilerSignallingItem  *itemChatBackgroundColor;
  KConfigSkeleton::ItemColor  *innerItemChatBackgroundColor;
  innerItemChatBackgroundColor = new KConfigSkeleton::ItemColor( currentGroup(), QStringLiteral( "chatBackgroundColor" ), mChatBackgroundColor, KColorScheme(QPalette::Active, KColorScheme::View).background().color() );
  itemChatBackgroundColor = new KConfigCompilerSignallingItem(innerItemChatBackgroundColor, this, notifyFunction, signalChatwindowAppearanceChanged);
  addItem( itemChatBackgroundColor, QStringLiteral( "chatBackgroundColor" ) );
  KConfigCompilerSignallingItem  *itemChatLinkColor;
  KConfigSkeleton::ItemColor  *innerItemChatLinkColor;
  innerItemChatLinkColor = new KConfigSkeleton::ItemColor( currentGroup(), QStringLiteral( "chatLinkColor" ), mChatLinkColor, KColorScheme(QPalette::Active, KColorScheme::Window).foreground(KColorScheme::LinkText).color() );
  itemChatLinkColor = new KConfigCompilerSignallingItem(innerItemChatLinkColor, this, notifyFunction, signalChatwindowAppearanceChanged);
  addItem( itemChatLinkColor, QStringLiteral( "chatLinkColor" ) );
  KConfigCompilerSignallingItem  *itemChatFont;
  KConfigSkeleton::ItemFont  *innerItemChatFont;
  innerItemChatFont = new KConfigSkeleton::ItemFont( currentGroup(), QStringLiteral( "chatFont" ), mChatFont );
  itemChatFont = new KConfigCompilerSignallingItem(innerItemChatFont, this, notifyFunction, signalChatwindowAppearanceChanged);
  addItem( itemChatFont, QStringLiteral( "chatFont" ) );
}

KopeteChatWindowSettings::~KopeteChatWindowSettings()
{
  if (s_globalKopeteChatWindowSettings.exists() && !s_globalKopeteChatWindowSettings.isDestroyed()) {
    s_globalKopeteChatWindowSettings()->q = nullptr;
  }
}

bool KopeteChatWindowSettings::usrSave()
{
  const bool res = KConfigSkeleton::usrSave();
  if (!res) return false;

  if ( mSettingsChanged & signalChatwindowAppearanceChanged )
    Q_EMIT chatwindowAppearanceChanged();
  if ( mSettingsChanged & signalMessageOverridesChanged )
    Q_EMIT messageOverridesChanged();
  if ( mSettingsChanged & signalStyleChanged )
    Q_EMIT styleChanged(mStyleName);
  if ( mSettingsChanged & signalStyleVariantChanged )
    Q_EMIT styleVariantChanged(mStyleVariant);
  mSettingsChanged = 0;
  return true;
}

void KopeteChatWindowSettings::itemChanged(quint64 flags) {
  mSettingsChanged |= flags;

}

#include "kopetechatwindowsettings.moc"

