示例#1
0
void AppearanceSettings::loadThemes()
{
    QStringList themeNames;
    QStringList installPaths = Qtopia::installPaths();
    qDeleteAll(m_themes);
    m_themes.clear();
    for (int i=0; i<installPaths.size(); i++) {
        QString path(installPaths[i] + "etc/themes/");
        QDir dir;
        if (!dir.exists(path)) {
            qLog(UI) << "Theme style configuration path not found" << path.toLocal8Bit().data();
            continue;
        }

        // read theme.conf files
        dir.setPath(path);
        dir.setNameFilters(QStringList("*.conf")); // No tr

        for (uint j=0; j<dir.count(); j++) {
            QString name = dir[j].mid(0, dir[j].length() - 5); // cut ".conf"
            Theme *theme = Theme::create(path + dir[j], name);
            if (theme) {
                m_themes << theme;
                themeNames << theme->name();
            }
        }
    }
    themeNames << m_moreThemes;

    QStringListModel *model;
    model = qobject_cast<QStringListModel *>(m_themeCombo->model());
    model->setStringList(themeNames);
}
void ConfigureThemesDialog::Private::editedThemeNameChanged()
{
  Theme * set = mEditor->editedTheme();
  if ( !set )
    return;

  ThemeListWidgetItem * it = findThemeItemByTheme( set );
  if ( !it )
    return;

  QString goodName = uniqueNameForTheme( set->name(), set );

  it->setText( goodName );
}
void ConfigureThemesDialog::Private::commitEditor()
{
  Theme * editedTheme = mEditor->editedTheme();
  if ( !editedTheme )
    return;

  mEditor->commit();

  ThemeListWidgetItem * editedItem = findThemeItemByTheme( editedTheme );
  if ( editedItem )
    return;

  // We must reset the runtime column state as the columns might have
  // totally changed in the editor
  editedTheme->resetColumnState();

  QString goodName = uniqueNameForTheme( editedTheme->name(), editedTheme );
  editedTheme->setName( goodName );
  editedItem->setText( goodName );
}
示例#4
0
#include <stdio.h>
#include "UnitTest.h"

#define CCHARP(str)           ((const char*)str)
#define STR_EQUAL(str1, str2) (strcmp(CCHARP(str1), CCHARP(str2)) == 0)

EDELIB_NS_USE

UT_FUNC(ThemeTestReader, "Test Theme reader")
{
	Theme t;
	UT_VERIFY( t.load("theme.et") == true );
	UT_VERIFY( t.loaded() == true );

	UT_VERIFY( t.author() && STR_EQUAL(t.author(), "John Foo <*****@*****.**>") );
	UT_VERIFY( t.name() && STR_EQUAL(t.name(), "Demo") );
	UT_VERIFY( t.sample_image() && STR_EQUAL(t.sample_image(), "img.jpg") );

	char buf[64];
	long lval;

	UT_VERIFY( t.get_item("test style", "item1", buf, sizeof(buf)) );
	UT_VERIFY( STR_EQUAL(buf, "value 1") );

	UT_VERIFY( t.get_item("test style", "item2", buf, sizeof(buf)) );
	UT_VERIFY( STR_EQUAL(buf, "value 2") );

	UT_VERIFY( t.get_item("test style", "item3", lval, 0) );
	UT_VERIFY( lval == 123 );

	/* return false if item wasn't found */