controlpanelplugins/themeplugin/src/cpthemechanger.cpp
author hgs
Thu, 10 Jun 2010 16:07:41 +0800
changeset 21 2883a5458389
parent 19 36aa4756ee82
child 22 a5692c68d772
permissions -rw-r--r--
201023

/*
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0""
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
 *
 * Description:  
 *   
 */

#include "cpthemechanger.h"
#include "cpthemechanger_p.h"
#include "cpthemelistmodel.h"

/*!
  @alpha
  \class CpThemeChanger

  \brief CpThemeChanger provides an interface for changing the current
  theme and enumerating the available themes (e.g., for the UI to provide 
  a list of themes to show).

  This API is only for use with the control panel and its theme
  changing plugin.
*/

/*!
  Constructor.
*/
CpThemeChanger::CpThemeChanger(QObject* p) :
    QObject(p),
    d_ptr(new CpThemeChangerPrivate(this))
{
}

/*!
    Provides a list of themes as a const QAbstractItemModel*.
*/
QAbstractItemModel& CpThemeChanger::model()
{
    Q_D(CpThemeChanger);

    return d->mModel;
}


/*!
  Creates a connection to the theme server for the purpose of 
  changing the theme.
 */
bool CpThemeChanger::connectToServer()
{
    Q_D(CpThemeChanger);

    return d->connectToServer();
}

/*!
  Indicates if the client is connected to the theme server.
*/
bool CpThemeChanger::isConnected() const
{
    Q_D(const CpThemeChanger);

    return d->isConnected();
}


/*!
    Returns a ThemeInfo struct containing the current theme name and
    a repersentative HbIcon.

    If no repersentative icon exists, the HbIcon returned will be
    uninitialized.
*/
const CpThemeChanger::ThemeInfo& CpThemeChanger::currentTheme() const
{
    Q_D(const CpThemeChanger);
    
    return d->currentTheme();
}

/*
 *  Returns index of theme from the theme list (not the model).
 */
int CpThemeChanger::indexOf(const ThemeInfo& theme) const
{
    Q_D(const CpThemeChanger);
    
    return d->indexOf(theme);
}

/*!
 Change a theme. Returns true on success, false otherwise.
 */
bool CpThemeChanger::changeTheme(const QString& newtheme)
{
    Q_D(CpThemeChanger);

    return d->changeTheme(newtheme);
}

/*!
 Destructor
 */
CpThemeChanger::~CpThemeChanger()
{
    delete d_ptr;
    d_ptr = 0;
}

#include "moc_cpthemechanger.cpp"

// End of file