OSDN Git Service

Version 0.4.9(0.5beta)
authorTakumi ASAKI <takumi.asaki@gmail.com>
Tue, 3 Apr 2012 07:42:16 +0000 (16:42 +0900)
committerTakumi ASAKI <takumi.asaki@gmail.com>
Tue, 3 Apr 2012 07:42:16 +0000 (16:42 +0900)
* Add changing config order.
* Add editing System font.
* Add backup/restore configuration.
* Adjust layouts.

28 files changed:
.gitignore
applicationcontroller.cpp
applicationcontroller.h
fontconfigdefs.h
fontconfigmanager.cpp
fontconfigmanager.h
fontinfo.cpp
fontsconf.cpp
fontsconf.h
fontsconfeditorcontroller.cpp
fontsconfeditorcontroller.h
fontsconfelement.cpp
fontsconfelement.h
main.cpp
qml/fontmanager/EditFontsConfPage.qml
qml/fontmanager/EditorListDelegate.qml [new file with mode: 0644]
qml/fontmanager/FileSelectionPage.qml [moved from qml/fontmanager/FontSelectPage.qml with 84% similarity]
qml/fontmanager/FontInstallPage.qml
qml/fontmanager/FontSelectionPage.qml [new file with mode: 0644]
qml/fontmanager/FontsConfEditor.qml
qml/fontmanager/FontsConfViewPage.qml
qml/fontmanager/HelpDialog.qml
qml/fontmanager/InstalledFontInfoPage.qml
qml/fontmanager/MainPage.qml
qml/fontmanager/PageHeader.qml [new file with mode: 0644]
qml/fontmanager/RestoreFontsConfPage.qml [new file with mode: 0644]
qml/fontmanager/main.qml
qtc_packaging/debian_harmattan/changelog

index 8d827ee..6eaaacd 100644 (file)
@@ -7,3 +7,4 @@ ui_*
 *~
 *.bak
 header.*
+.DS_Store
index c3ae1d3..1241b60 100644 (file)
@@ -96,7 +96,7 @@ void ApplicationController::init()
 
 QString ApplicationController::version() const
 {
-    return QLatin1String("0.4.3");
+    return QLatin1String("0.4.9(0.5beta)");
 }
 
 QString ApplicationController::currentLanguage() const
@@ -175,6 +175,7 @@ FontsConfEditorController *ApplicationController::editorController(const QString
         controller = new FontsConfEditorController(family, this);
         mEditorController.insert(family, controller);
         connect(controller, SIGNAL(appendFamilyToConfig(QString,QString,QString)), SLOT(appendFamilyToConfig(QString,QString,QString)));
+        connect(controller, SIGNAL(insertFamilyToConfig(QString,QString,QString,int)), SLOT(insertFamilyToConfig(QString,QString,QString,int)));
         connect(controller, SIGNAL(removeFamilyFromList(QString,QString,QString)), SLOT(removeFamilyFromConfig(QString,QString,QString)));
         updateEditorController(family);
     }
@@ -210,6 +211,22 @@ void ApplicationController::updateEditorController(const QString &family)
     controller->syncFamilyList();
 }
 
+QUrl ApplicationController::backupDir() const
+{
+    return QUrl(QDir::homePath() + QLatin1String("/MyDocs/Documents"));
+}
+
+QString ApplicationController::defaultBackupFilename() const
+{
+    QString backupdir = backupDir().toString();
+    QString backupfile = backupdir + QLatin1String("/fonts.conf");
+    int idx = 0;
+    while (QFile::exists(backupfile)) {
+        backupfile = backupdir + QString::fromAscii("/fonts-%1.conf").arg(++idx);
+    }
+    return backupfile;
+}
+
 void ApplicationController::updateAllEditorController()
 {
     if (!mFontConfig->fontsConfModified() || mIgnoreUpdate) {
@@ -292,6 +309,16 @@ void ApplicationController::createRecommendedSettings()
     mFontConfig->createRecommendedSettings();
 }
 
+void ApplicationController::backupConfig(const QString &filename)
+{
+    mFontConfig->backupFontsConf(filename);
+}
+
+void ApplicationController::restoreConfig(const QString &filename)
+{
+    mFontConfig->restoreFontsConf(filename);
+}
+
 void ApplicationController::createFontDir()
 {
     QDir fontDir(mFontDirPath);
@@ -390,6 +417,21 @@ void ApplicationController::appendFamilyToConfig(const QString &family, const QS
         mFontConfig->addAcceptFamily(family, value);
 }
 
+void ApplicationController::insertFamilyToConfig(const QString &family, const QString &value, const QString &priority, int index)
+{
+    FontsConfEditorController *controller = qobject_cast<FontsConfEditorController*>(sender());
+    if (controller)
+        mIgnoreUpdate = true;
+    if (priority == PREPEND_DEF)
+        mFontConfig->insertPrependFamily(family, value, index);
+    else if (priority == APPEND_DEF)
+        mFontConfig->insertAppendFamily(family, value, index);
+    else if (priority == PREFER_DEF)
+        mFontConfig->insertPreferFamily(family, value, index);
+    else if (priority == ACCEPT_DEF)
+        mFontConfig->insertAcceptFamily(family, value, index);
+}
+
 void ApplicationController::removeFamilyFromConfig(const QString &family, const QString &value, const QString &priority)
 {
     FontsConfEditorController *controller = qobject_cast<FontsConfEditorController*>(sender());
index 5c6866d..d073c0b 100644 (file)
 #include <QObject>
 #include <QStringList>
 #include <QVariant>
+#include <QUrl>
 
 #include "fontinfo.h"
 
-class QUrl;
-
 class FontConfigManager;
 class InstalledFontInfo;
 class FontsConfEditorController;
@@ -66,6 +65,8 @@ class ApplicationController : public QObject
     Q_PROPERTY(bool showSystemFont READ showSystemFont WRITE setShowSystemFont NOTIFY showSystemFontChanged)
 
     Q_PROPERTY(bool working READ working NOTIFY workingChanged)
+
+    Q_PROPERTY(QUrl backupDir READ backupDir NOTIFY backupDirChanged)
 public:
     explicit ApplicationController(QObject *parent = 0);
     
@@ -95,6 +96,10 @@ public:
 
     Q_INVOKABLE FontsConfEditorController *editorController(const QString &family);
     void updateEditorController(const QString &family);
+
+    QUrl backupDir() const;
+    Q_INVOKABLE QString defaultBackupFilename() const;
+
 public slots:
     void updateAllEditorController();
 
@@ -116,6 +121,9 @@ public slots:
 
     void createRecommendedSettings();
 
+    void backupConfig(const QString &filename);
+    void restoreConfig(const QString &filename);
+
 signals:
     void alertDialog(const QString &message);
 
@@ -139,6 +147,8 @@ signals:
 
     void workingChanged();
 
+    void backupDirChanged();
+
 private slots:
     void readFcListFinished();
 
@@ -157,6 +167,7 @@ public slots:
     void saveFontsConf();
 
     void appendFamilyToConfig(const QString &family, const QString &value, const QString &priority);
+    void insertFamilyToConfig(const QString &family, const QString &value, const QString &priority, int index);
     void removeFamilyFromConfig(const QString &family, const QString &value, const QString &priority);
 
 private:
index e692950..59c6626 100644 (file)
@@ -86,6 +86,7 @@
 #define SANSSERIF_DEF "sans-serif"
 #define SERIF_DEF "serif"
 #define MONOSPACE_DEF "monospace"
+#define SYSTEM_DEF "Nokia Pure Text"
 
 #define TRUE_DEF "true"
 #define FALSE_DEF "false"
index bfb18d9..f9084ee 100644 (file)
@@ -51,6 +51,7 @@
 #include <QVariant>
 #include <QFontInfo>
 #include <QFontMetrics>
+#include <QUrl>
 
 #include <QDebug>
 
@@ -66,7 +67,7 @@ FontConfigManager::FontConfigManager(QObject *parent) :
     QObject(parent), mLang("en"), mLocalFontsConf(0)
 {
     connect(this, SIGNAL(localFontsConfPathChanged()), SIGNAL(localFontsConfExistsChanged()));
-    connect(this, SIGNAL(localFontsConfPathChanged()), SIGNAL(fontsConfUpdated()));
+//    connect(this, SIGNAL(localFontsConfPathChanged()), SIGNAL(fontsConfUpdated()));
 
     mLocalFontsConf = new FontsConf(this);
     mSystemLocalConf = new FontsConf(this);
@@ -657,6 +658,27 @@ void FontConfigManager::saveFontsConf()
     }
 }
 
+void FontConfigManager::backupFontsConf(const QString &filepath)
+{
+    if (filepath.isEmpty() || isEmptyLocalFontsConf())
+        return;
+    mLocalFontsConf->save(filepath);
+}
+
+void FontConfigManager::restoreFontsConf(const QUrl &fileUrl)
+{
+    QString filepath = fileUrl.toLocalFile();
+    if (filepath.isEmpty() || !QFile::exists(filepath))
+        return;
+    FontsConf *restoredConf = new FontsConf(this);
+    restoredConf->load(filepath);
+    if (restoredConf->isValid()) {
+        mLocalFontsConf->copy(restoredConf);
+        emit fontsConfUpdated();
+        restoredConf->deleteLater();
+    }
+}
+
 void FontConfigManager::resetFontsConf()
 {
     if (!mLocalFontsConf)
@@ -689,6 +711,30 @@ void FontConfigManager::addAppendFamily(const QString &family, const QString &va
     emit fontsConfUpdated();
 }
 
+void FontConfigManager::insertPreferFamily(const QString &family, const QString &value, int index)
+{
+    mLocalFontsConf->insertPreferFamilyFor(family, value, index);
+    emit fontsConfUpdated();
+}
+
+void FontConfigManager::insertAcceptFamily(const QString &family, const QString &value, int index)
+{
+    mLocalFontsConf->insertAcceptFamilyFor(family, value, index);
+    emit fontsConfUpdated();
+}
+
+void FontConfigManager::insertPrependFamily(const QString &family, const QString &value, int index)
+{
+    mLocalFontsConf->insertPrependFamilyFor(family, value, index);
+    emit fontsConfUpdated();
+}
+
+void FontConfigManager::insertAppendFamily(const QString &family, const QString &value, int index)
+{
+    mLocalFontsConf->insertAppendFamilyFor(family, value, index);
+    emit fontsConfUpdated();
+}
+
 void FontConfigManager::removePreferFamily(const QString &family, const QString &value)
 {
     mLocalFontsConf->removePreferFamilyFor(family, value);
index dd2c7af..809f492 100644 (file)
@@ -46,6 +46,8 @@
 
 #include "fontsconfigproperties.h"
 
+class QUrl;
+
 class InstalledFontInfo;
 class FontsConf;
 
@@ -93,6 +95,11 @@ public:
     void addPrependFamily(const QString &family, const QString &value);
     void addAppendFamily(const QString &family, const QString &value);
 
+    void insertPreferFamily(const QString &family, const QString &value, int index);
+    void insertAcceptFamily(const QString &family, const QString &value, int index);
+    void insertPrependFamily(const QString &family, const QString &value, int index);
+    void insertAppendFamily(const QString &family, const QString &value, int index);
+
     void removePreferFamily(const QString &family, const QString &value);
     void removeAcceptFamily(const QString &family, const QString &value);
     void removePrependFamily(const QString &family, const QString &value);
@@ -132,6 +139,8 @@ public slots:
     void readFcList();
     void readFontsConf();
     void saveFontsConf();
+    void backupFontsConf(const QString &filepath);
+    void restoreFontsConf(const QUrl &fileUrl);
 
     void resetFontsConf();
 
index 33bf7f4..b62cb17 100644 (file)
@@ -96,16 +96,6 @@ void FontInfo::setFontPath(const QString &fontPath, FontConfigManager *fontConfi
     }
     emit fontPathChanged();
 
-#if 0
-    QFontDatabase fdb;
-    foreach (const QString &family, mFontFamilies) {
-        QList<QFontDatabase::WritingSystem> wslist = fdb.writingSystems(family);
-        qDebug() << family << "(" << wslist.count() << ")";
-        for (int i = 0; i < wslist.count(); i++) {
-            qDebug() << "\t" << QFontDatabase::writingSystemName(wslist.at(i));
-        }
-    }
-#endif
 }
 
 QStringList FontInfo::families() const
index 29d3f67..898785e 100644 (file)
 #include "fontsconfelement.h"
 
 #include <QFile>
+#include <QTextStream>
 #include <QXmlStreamReader>
 
-#include <QDebug>
-
 enum FCState {
     Initialized, Ready, InvalidConfig, UnknownState
 };
@@ -56,7 +55,7 @@ static inline QString boolString(bool val)
 }
 
 FontsConf::FontsConf(QObject *parent) :
-    QObject(parent), mModified(false), mHasUnknownConfig(false)
+    QObject(parent), mModified(false), mValid(true), mHasUnknownConfig(false)
 {
     initFontsConf();
 }
@@ -71,11 +70,21 @@ bool FontsConf::modified() const
     return mModified;
 }
 
+void FontsConf::setModified(bool value)
+{
+    mModified = value;
+}
+
 bool FontsConf::hasUnknownConfig() const
 {
     return mHasUnknownConfig;
 }
 
+bool FontsConf::isValid() const
+{
+    return mValid;
+}
+
 void FontsConf::initFontsConf()
 {
     if (mElements)
@@ -199,6 +208,22 @@ void FontsConf::appendAliasFamilyFor(const QString &family, const QString &mode,
     Q_ASSERT(check);
 }
 
+void FontsConf::insertAliasFamilyFor(const QString &family, const QString &mode, const QString &value, int idx)
+{
+    int index = 0;
+    while ((index = mElements->indexOf(ALIAS_DEF, index)) >= 0) {
+        FontsConfElementPointer aliasElem = mElements->childElementAt(index++);
+        bool check = insertFamilyToAlias(aliasElem, family, mode, value, idx);
+        if (check)
+            return;
+    }
+
+    FontsConfElementPointer aliasElem = aliasElementFor(family);
+    mElements->addChildElement(aliasElem);
+    bool check = appendFamilyToAlias(aliasElem, family, mode, value);
+    Q_ASSERT(check);
+}
+
 void FontsConf::removeAliasFamilyFor(const QString &family, const QString &mode, const QString &value)
 {
     int index = 0;
@@ -242,6 +267,11 @@ void FontsConf::appendPreferFamilyFor(const QString &family, const QString &valu
     appendAliasFamilyFor(family, PREFER_DEF, value);
 }
 
+void FontsConf::insertPreferFamilyFor(const QString &family, const QString &value, int index)
+{
+    insertAliasFamilyFor(family, PREFER_DEF, value, index);
+}
+
 void FontsConf::removePreferFamilyFor(const QString &family, const QString &value)
 {
     removeAliasFamilyFor(family, PREFER_DEF, value);
@@ -257,6 +287,11 @@ void FontsConf::appendAcceptFamilyFor(const QString &family, const QString &valu
     appendAliasFamilyFor(family, ACCEPT_DEF, value);
 }
 
+void FontsConf::insertAcceptFamilyFor(const QString &family, const QString &value, int index)
+{
+    insertAliasFamilyFor(family, ACCEPT_DEF, value, index);
+}
+
 void FontsConf::removeAcceptFamilyFor(const QString &family, const QString &value)
 {
     removeAliasFamilyFor(family, ACCEPT_DEF, value);
@@ -380,6 +415,11 @@ QStringList FontsConf::patternFamilyFor(const QString &family, const QString &mo
 
 void FontsConf::appendPatternFamilyFor(const QString &family, const QString &mode, const QString &value)
 {
+    insertPatternFamilyFor(family, mode, value, -1);
+}
+
+void FontsConf::insertPatternFamilyFor(const QString &family, const QString &mode, const QString &value, int idx)
+{
     FontsConfElementPointer matchElem;
 
     int index = 0;
@@ -426,7 +466,10 @@ void FontsConf::appendPatternFamilyFor(const QString &family, const QString &mod
 
     FontsConfElementPointer stringElem(new FontsConfElement(STRING_DEF));
     stringElem->setText(value);
-    editElem->addChildElement(stringElem);
+    if (idx < 0)
+        editElem->addChildElement(stringElem);
+    else
+        editElem->insertChildElement(stringElem, idx);
     mModified = true;
 }
 
@@ -480,6 +523,11 @@ void FontsConf::appendPrependFamilyFor(const QString &family, const QString &val
     appendPatternFamilyFor(family, PREPEND_DEF, value);
 }
 
+void FontsConf::insertPrependFamilyFor(const QString &family, const QString &value, int index)
+{
+    insertPatternFamilyFor(family, PREPEND_DEF, value, index);
+}
+
 void FontsConf::removePrependFamilyFor(const QString &family, const QString &value)
 {
     removePatternFamilyFor(family, PREPEND_DEF, value);
@@ -495,16 +543,29 @@ void FontsConf::appendAppendFamilyFor(const QString &family, const QString &valu
     appendPatternFamilyFor(family, APPEND_DEF, value);
 }
 
+void FontsConf::insertAppendFamilyFor(const QString &family, const QString &value, int index)
+{
+    insertPatternFamilyFor(family, APPEND_DEF, value, index);
+}
+
 void FontsConf::removeAppendFamilyFor(const QString &family, const QString &value)
 {
     removePatternFamilyFor(family, APPEND_DEF, value);
 }
 
+void FontsConf::copy(FontsConf *src)
+{
+    mModified = true;
+    mValid = src->mValid;
+    mHasUnknownConfig = src->mHasUnknownConfig;
+    mElements = src->mElements;
+}
+
 QStringList FontsConf::genericFamilies()
 {
     static QStringList families;
     if (families.isEmpty())
-        families << SANSSERIF_DEF << SERIF_DEF << MONOSPACE_DEF;
+        families << SANSSERIF_DEF << SERIF_DEF << MONOSPACE_DEF << SYSTEM_DEF;
     return families;
 }
 
@@ -530,9 +591,7 @@ void FontsConf::load(const QString &path)
 
     fp.close();
 
-    bool check = parse(buf);
-    Q_UNUSED(check);
-
+    mValid = parse(buf);
 }
 
 void FontsConf::save(const QString &path)
@@ -548,6 +607,7 @@ void FontsConf::save(const QString &path)
     QXmlStreamWriter xml(&buf);
 
     xml.setAutoFormatting(true);
+    xml.setAutoFormattingIndent(8);
 
     xml.writeStartDocument();
 
@@ -574,6 +634,11 @@ void FontsConf::save(const QString &path)
 
 bool FontsConf::appendFamilyToAlias(FontsConfElementPointer aliasElem, const QString &family, const QString &mode, const QString &value)
 {
+    return insertFamilyToAlias(aliasElem, family, mode, value, -1);
+}
+
+bool FontsConf::insertFamilyToAlias(FontsConfElementPointer aliasElem, const QString &family, const QString &mode, const QString &value, int index)
+{
     if (aliasElem->type() != ALIAS_DEF)
         return false;
 
@@ -597,7 +662,10 @@ bool FontsConf::appendFamilyToAlias(FontsConfElementPointer aliasElem, const QSt
 
     FontsConfElementPointer valueElem(new FontsConfElement(FAMILY_DEF));
     valueElem->setText(value);
-    targetElem->addChildElement(valueElem);
+    if (index < 0)
+        targetElem->addChildElement(valueElem);
+    else
+        targetElem->insertChildElement(valueElem, index);
     mModified = true;
 
     return true;
index 4bb9358..9da9eba 100644 (file)
@@ -52,8 +52,11 @@ public:
 
     bool isEmpty() const;
     bool modified() const;
+    void setModified(bool value);
     bool hasUnknownConfig() const;
 
+    bool isValid() const;
+
     void initFontsConf();
 
     bool parse(const QByteArray &buf);
@@ -61,15 +64,21 @@ public:
     QStringList preferFamily() const;
 
     QStringList aliasFamilyFor(const QString &family, const QString &mode) const;
+    int indxOfAliasFamilyFor(const QString &family, const QString &mode, const QString &value) const;
     void appendAliasFamilyFor(const QString &family, const QString &mode, const QString &value);
+    void insertAliasFamilyFor(const QString &family, const QString &mode, const QString &value, int index);
     void removeAliasFamilyFor(const QString &family, const QString &mode, const QString &value);
 
     QStringList preferFamilyFor(const QString &family) const;
+    int indxOfPreferFamilyFor(const QString &family, const QString &value) const;
     void appendPreferFamilyFor(const QString &family, const QString &value);
+    void insertPreferFamilyFor(const QString &family, const QString &value, int index);
     void removePreferFamilyFor(const QString &family, const QString &value);
 
     QStringList acceptFamilyFor(const QString &family) const;
+    int indxOfAcceptFamilyFor(const QString &family, const QString &value) const;
     void appendAcceptFamilyFor(const QString &family, const QString &value);
+    void insertAcceptFamilyFor(const QString &family, const QString &value, int index);
     void removeAcceptFamilyFor(const QString &family, const QString &value);
 
     QStringList matchFamilyFor(const QString &config, bool val) const;
@@ -78,17 +87,25 @@ public:
     void unsetMatchEditValueFor(const QString &config, const QString &family);
 
     QStringList patternFamilyFor(const QString &family, const QString &mode) const;
+    int indxOfPatternFamilyFor(const QString &family, const QString &mode, const QString &value) const;
     void appendPatternFamilyFor(const QString &family, const QString &mode, const QString &value);
+    void insertPatternFamilyFor(const QString &family, const QString &mode, const QString &value, int index);
     void removePatternFamilyFor(const QString &family, const QString &mode, const QString &value);
 
     QStringList prependFamilyFor(const QString &family) const;
+    int indxOfPrependFamilyFor(const QString &family, const QString &value) const;
     void appendPrependFamilyFor(const QString &family, const QString &value);
+    void insertPrependFamilyFor(const QString &family, const QString &value, int index);
     void removePrependFamilyFor(const QString &family, const QString &value);
 
     QStringList appendFamilyFor(const QString &family) const;
+    int indxOfAppendFamilyFor(const QString &family, const QString &value) const;
     void appendAppendFamilyFor(const QString &family, const QString &value);
+    void insertAppendFamilyFor(const QString &family, const QString &value, int index);
     void removeAppendFamilyFor(const QString &family, const QString &value);
 
+    void copy(FontsConf *src);
+
     static QStringList genericFamilies();
     static QStringList configKeys();
 
@@ -98,6 +115,7 @@ private:
     FontsConfElementPointer patternElementFor(const QString &family) const;
 
     bool appendFamilyToAlias(FontsConfElementPointer aliasElem, const QString &family, const QString &mode, const QString &value);
+    bool insertFamilyToAlias(FontsConfElementPointer aliasElem, const QString &family, const QString &mode, const QString &value, int index);
     bool isMatchElementFor(FontsConfElementPointer matchElem, const QString &config, const QString &family, const QString &val = QString()) const;
     bool isPatternElementFor(FontsConfElementPointer matchElem, const QString &family, const QString &mode = QString()) const;
     FontsConfElementPointer getEditPatternElementFor(FontsConfElementPointer matchElem, const QString &family, const QString &mode = QString()) const;
@@ -113,6 +131,7 @@ public slots:
     
 private:
     bool mModified;
+    bool mValid;
     bool mHasUnknownConfig;
     FontsConfElementPointer mElements;
 };
index d7bb14f..32f1ebc 100644 (file)
@@ -42,7 +42,7 @@
 #include "installedfontinfo.h"
 
 FontsConfEditorController::FontsConfEditorController(const QString &family, QObject *parent) :
-    QObject(parent), mFamily(family)
+    QObject(parent), mFromApp(false), mFamily(family)
 {
 }
 
@@ -51,6 +51,28 @@ int FontsConfEditorController::count() const
     return mPrependFamily.count() + mPreferFamily.count() + mAcceptFamily.count();
 }
 
+int FontsConfEditorController::countOfFamily(const QString &priority) const
+{
+    if (priority == PREPEND_DEF)
+        return mPrependFamily.count();
+    else if (priority == PREFER_DEF)
+        return mPreferFamily.count();
+    else if (priority == ACCEPT_DEF)
+        return mAcceptFamily.count();
+    return -1;
+}
+
+int FontsConfEditorController::indexOfFamily(const QString &family, const QString &priority) const
+{
+    if (priority == PREPEND_DEF)
+        return mPrependFamily.indexOf(family);
+    else if (priority == PREFER_DEF)
+        return mPreferFamily.indexOf(family);
+    else if (priority == ACCEPT_DEF)
+        return mAcceptFamily.indexOf(family);
+    return -1;
+}
+
 void FontsConfEditorController::syncFamilyList()
 {
     emit clearFamilyList();
@@ -76,8 +98,10 @@ void FontsConfEditorController::syncFamilyList()
 
 void FontsConfEditorController::appendFontsInfo(const QString &family, const QString &priority, InstalledFontInfo *info)
 {
+    mFromApp = true;
     mFontInfoMap.insert(family, info);
     appendFamily(family, priority);
+    mFromApp = false;
 }
 
 void FontsConfEditorController::appendFamily(const QString &family, const QString &priority)
@@ -88,7 +112,8 @@ void FontsConfEditorController::appendFamily(const QString &family, const QStrin
         mPreferFamily.append(family);
     else if (priority == ACCEPT_DEF)
         mAcceptFamily.append(family);
-    emit appendFamilyToConfig(mFamily, family, priority);
+    if (!mFromApp)
+        emit appendFamilyToConfig(mFamily, family, priority);
     emit countChanged();
 }
 
@@ -96,23 +121,57 @@ void FontsConfEditorController::removeFamily(const QString &family, const QStrin
 {
     if (priority.isEmpty() || priority == PREPEND_DEF) {
         mPrependFamily.removeOne(family);
-        emit removeFamilyFromList(mFamily, family, PREPEND_DEF);
+        if (!mFromApp)
+            emit removeFamilyFromList(mFamily, family, PREPEND_DEF);
         emit countChanged();
     }
     if (priority.isEmpty() || priority == PREFER_DEF) {
         mPreferFamily.removeOne(family);
-        emit removeFamilyFromList(mFamily, family, PREFER_DEF);
+        if (!mFromApp)
+            emit removeFamilyFromList(mFamily, family, PREFER_DEF);
         emit countChanged();
     }
     if (priority.isEmpty() || priority == ACCEPT_DEF) {
         mAcceptFamily.removeOne(family);
-        emit removeFamilyFromList(mFamily, family, ACCEPT_DEF);
+        if (!mFromApp)
+            emit removeFamilyFromList(mFamily, family, ACCEPT_DEF);
         emit countChanged();
     }
     if (!mPrependFamily.contains(family) && !mPreferFamily.contains(family) && !mAcceptFamily.contains(family))
         mFontInfoMap.remove(family);
 }
 
+void FontsConfEditorController::insertFamily(const QString &family, const QString &priority, int index)
+{
+    if (priority == PREPEND_DEF)
+        mPrependFamily.insert(index, family);
+    else if (priority == PREFER_DEF)
+        mPreferFamily.insert(index, family);
+    else if (priority == ACCEPT_DEF)
+        mAcceptFamily.insert(index, family);
+    if (!mFromApp)
+        emit insertFamilyToConfig(mFamily, family, priority, index);
+    emit countChanged();
+}
+
+void FontsConfEditorController::moveFamilyUp(const QString &family, const QString &priority)
+{
+    int index = indexOfFamily(family, priority);
+    if (index > 0) {
+        removeFamily(family, priority);
+        insertFamily(family, priority, index - 1);
+    }
+}
+
+void FontsConfEditorController::moveFamilyDown(const QString &family, const QString &priority)
+{
+    int index = indexOfFamily(family, priority);
+    if (index - 1 < countOfFamily(priority)) {
+        removeFamily(family, priority);
+        insertFamily(family, priority, index + 1);
+    }
+}
+
 void FontsConfEditorController::clear()
 {
     mFontInfoMap.clear();
index f411f30..f859031 100644 (file)
@@ -54,6 +54,9 @@ public:
     
     int count() const;
 
+    int countOfFamily(const QString &priority) const;
+    int indexOfFamily(const QString &family, const QString &priority) const;
+
 signals:
     void clearFamilyList();
     void startSection(const QString &section, const QString &sectionName);
@@ -63,6 +66,7 @@ signals:
     void countChanged();
 
     void appendFamilyToConfig(const QString &family, const QString &value, const QString &priority);
+    void insertFamilyToConfig(const QString &family, const QString &value, const QString &priority, int index);
 
 public slots:
     void clear();
@@ -72,7 +76,12 @@ public slots:
     void appendFamily(const QString &family, const QString &priority);
     void removeFamily(const QString &family, const QString &priority);
 
+    void insertFamily(const QString &family, const QString &priority, int index);
+    void moveFamilyUp(const QString &family, const QString &priority);
+    void moveFamilyDown(const QString &family, const QString &priority);
+
 private:
+    bool mFromApp;
     QString mFamily;
 
     QStringList mPrependFamily;
index cbfb01a..66f7575 100644 (file)
@@ -179,6 +179,14 @@ void FontsConfElement::addChildElement(FontsConfElementPointer elem)
     mChildElements.append(elem);
 }
 
+void FontsConfElement::insertChildElement(FontsConfElementPointer elem, int index)
+{
+    if (!elem || mChildElements.contains(elem))
+        return;
+    elem->setParent(this);
+    mChildElements.insert(index, elem);
+}
+
 void FontsConfElement::removeAt(int index)
 {
     mChildElements.removeAt(index);
index 16fffe6..42d4919 100644 (file)
@@ -81,6 +81,7 @@ public:
     int indexOf(const QString &type, int from = 0) const;
     FontsConfElementPointer childElementOf(const QString &type, int from = 0) const;
     void addChildElement(FontsConfElementPointer elem);
+    void insertChildElement(FontsConfElementPointer elem, int index);
     void removeAt(int index);
     void removeOne(FontsConfElementPointer elem);
 
index 91cc7c4..60d3dd6 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -64,10 +64,17 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
 
     ApplicationController appController;
 
+#if 0
+    qmlRegisterUncreatableType<FontsConfigProperties>("FontConfig", 1, 0, "FontsConfigProperties", "Error");
+    qmlRegisterUncreatableType<FontInfo>("FontConfig", 1, 0, "FontInfo", "Error");
+    qmlRegisterUncreatableType<InstalledFontInfo>("FontConfig", 1, 0, "InstalledFontInfo", "Error");
+    qmlRegisterUncreatableType<FontsConfEditorController>("FontConfig", 1, 0, "FontsConfEditorController", "Error");
+#else
     qmlRegisterType<FontsConfigProperties>();
     qmlRegisterType<FontInfo>();
     qmlRegisterType<InstalledFontInfo>();
     qmlRegisterType<FontsConfEditorController>();
+#endif
 
     QmlApplicationViewer viewer;
     viewer.rootContext()->setContextProperty("controller", &appController);
index a71e4cb..e3c43ef 100644 (file)
@@ -39,6 +39,7 @@
 // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
 import QtQuick 1.1
 import com.nokia.meego 1.0
+import com.nokia.extras 1.0
 import 'UIConstants.js' as UI
 
 Page {
@@ -66,8 +67,20 @@ Page {
                                      "Please check <a href=\"http://www.freedesktop.org/software/fontconfig/fontconfig-user.html\">fontconfig</a> for more details."
                                      )
 
+    property alias curTab: editFontsConfTab.currentTab
+
+    PageHeader {
+        id: pageHeader
+        anchors.top: parent.top
+        anchors.left: parent.left
+        anchors.right: parent.right
+        text: qsTr("Edit Fonts Config: %1").arg(curTab.familyName)
+    }
+
     TabGroup {
         id: editFontsConfTab
+        anchors.top: pageHeader.bottom
+        anchors.bottom: bottomButtons.top
 
         opacity: enabled ? 1.0 : 0.5
 
@@ -94,13 +107,86 @@ Page {
             editorController: controller.editorController(family)
         }
 
+        FontsConfEditor {
+            id: systemTab
+            family: "Nokia Pure Text"
+            familyName: qsTr("System")
+            editorController: controller.editorController(family)
+        }
+
+    }
+
+    Item {
+        id: bottomButtons
+
+        height: bottomItem.height + importButton.height + UI.DEFAULT_MARGIN * 2
+        anchors.bottom: parent.bottom
+        anchors.left: parent.left
+        anchors.right: parent.right
+
+        Rectangle {
+            anchors.fill: parent
+            anchors.topMargin: UI.DEFAULT_MARGIN / 2
+            gradient: Gradient {
+                GradientStop { position: 0.0; color: Qt.lighter("#76221d") }
+                GradientStop { position: 1.0; color: Qt.lighter("#bd543d") }
+            }
+
+            Component.onCompleted: {
+                console.log("bottomButtons: " + width + " x " + height)
+            }
+        }
+
+        Item {
+            id: bottomItem
+            anchors.bottom: importButton.top
+            anchors.left: parent.left
+            anchors.right: parent.right
+            height: UI.LIST_ITEM_HEIGHT_SMALL
+
+            ListButton {
+                anchors.left: parent.left
+                anchors.leftMargin: UI.DEFAULT_MARGIN
+                iconSource: "image://theme/icon-m-toolbar-down"
+                onClicked: curTab.moveDownFamily()
+                enabled: (curTab.listView.currentIndex >= 0 &&
+                          curTab.listView.currentIndex < curTab.listView.count - 1) &&
+                         (!curTab.listView.model.get(curTab.listView.currentIndex+1).header)
+            }
+
+            ListButton {
+                anchors.horizontalCenter: parent.horizontalCenter
+                iconSource: "image://theme/icon-m-toolbar-delete"
+                onClicked: curTab.removeFamily()
+                enabled: curTab.listView.currentIndex >= 0
+            }
+
+            ListButton {
+                anchors.right: parent.right
+                anchors.rightMargin: UI.DEFAULT_MARGIN
+                iconSource: "image://theme/icon-m-toolbar-up"
+                onClicked: curTab.moveUpFamily()
+                enabled: (curTab.listView.currentIndex > 0) && (!curTab.listView.model.get(curTab.listView.currentIndex-1).header)
+            }
+        }
+
+        Button {
+            id: importButton
+            anchors.horizontalCenter: parent.horizontalCenter
+            anchors.bottom: parent.bottom
+            anchors.bottomMargin: UI.DEFAULT_MARGIN
+            text: qsTr("Import System Settings")
+            onClicked: {
+                controller.importSystemSettings(editFontsConfTab.currentTab.family)
+            }
+        }
     }
 
     MultiSelectionDialog {
         id: selectInstallFamily
         model: installableFamilyListModel
         acceptButtonText: qsTr("Add")
-        titleText: qsTr("Add Family for %1").arg(editFontsConfTab.currentTab.familyName)
+        titleText: qsTr("Add Family for %1").arg(curTab.familyName)
         onAccepted: {
             for (var i = 0; i < selectedIndexes.length; i++) {
                 var idx = selectedIndexes[i]
@@ -138,6 +224,10 @@ Page {
                 text: monospaceTab.familyName
                 tab: monospaceTab
             }
+            TabButton {
+                text: systemTab.familyName
+                tab: systemTab
+            }
         }
         ToolIcon {
             platformIconId: "toolbar-view-menu"
@@ -167,7 +257,7 @@ Page {
             }
             MenuItem {
                 text: qsTr("View current fonts config");
-//                enabled: controller.localFontsConfExists
+                //                enabled: controller.localFontsConfExists
                 onClicked: {
                     editMenu.close()
                     pageStack.push(fontsConfViewPageComponent, { "text": controller.localFontsConf } )
diff --git a/qml/fontmanager/EditorListDelegate.qml b/qml/fontmanager/EditorListDelegate.qml
new file mode 100644 (file)
index 0000000..84761f8
--- /dev/null
@@ -0,0 +1,94 @@
+import QtQuick 1.1
+import com.nokia.meego 1.0
+import com.nokia.extras 1.0
+import 'UIConstants.js' as UI
+
+Item {
+    id: listItem
+
+    signal clicked
+    property bool pressed: false
+
+    property bool isHeader: model.header
+
+    property int titleSize: (model.header ? UI.FONT_XLARGE : UI.FONT_DEFAULT)
+    property int titleWeight: Font.Bold
+    property color titleColor: theme.inverted ? (model.header ? UI.COLOR_FOREGROUND : UI.COLOR_INVERTED_FOREGROUND) : (UI.COLOR_FOREGROUND)
+
+    property int subtitleSize: UI.FONT_XSMALL
+    property int subtitleWeight: Font.Light
+    property color subtitleColor: theme.inverted ? UI.COLOR_SECONDARY_FOREGROUND : UI.COLOR_INVERTED_SECONDARY_FOREGROUND
+
+    height: UI.LIST_ITEM_HEIGHT_SMALL
+    width: parent.width
+
+    Rectangle {
+        anchors.fill: parent
+        anchors.leftMargin: -UI.MARGIN_XLARGE
+        anchors.rightMargin: -UI.MARGIN_XLARGE
+        color: UI.COLOR_SELECT
+        visible: listItem.isHeader
+    }
+
+    Row {
+        anchors.fill: parent
+        spacing: UI.DEFAULT_MARGIN
+
+        Item { width: UI.DEFAULT_MARGIN; height: 1; visible: !model.header }
+
+        Item {
+            //                        anchors.top: parent.top
+            height: UI.LIST_ITEM_HEIGHT_SMALL
+
+            Column {
+                anchors.verticalCenter: parent.verticalCenter
+
+                Label {
+                    id: mainText
+                    text: model.title
+                    font.weight: listItem.titleWeight
+                    font.pixelSize: listItem.titleSize
+                    color: listItem.titleColor
+                }
+
+                Label {
+                    id: subText
+                    text: model.subtitle
+                    font.weight: listItem.subtitleWeight
+                    font.pixelSize: listItem.subtitleSize
+                    color: listItem.subtitleColor
+
+                    visible: text != ""
+                }
+            }
+        }
+    }
+
+    ListButton {
+        id: appendButton
+        anchors.right: parent.right
+        anchors.verticalCenter: parent.verticalCenter
+        anchors.rightMargin: UI.DEFAULT_MARGIN
+        iconSource: "image://theme/icon-m-toolbar-add"
+        onClicked: {
+            controller.syncInstallableFamilyFor(editorPage.family)
+            editorTabPage.currentPriority = model.priority
+            selectInstallFamily.selectedIndexes = []
+            selectInstallFamily.open()
+        }
+        visible: listItem.isHeader
+    }
+
+    MouseArea {
+        id: selectItem
+        anchors.fill: parent
+        enabled: !listItem.isHeader
+        visible: !listItem.isHeader
+        onClicked: {
+            if (preferFamilyListView.currentIndex === index)
+                preferFamilyListView.currentIndex = -1
+            else
+                preferFamilyListView.currentIndex = index
+        }
+    }
+}
similarity index 84%
rename from qml/fontmanager/FontSelectPage.qml
rename to qml/fontmanager/FileSelectionPage.qml
index a9ecc0a..b7cfbc5 100644 (file)
@@ -44,24 +44,25 @@ import com.nokia.extras 1.0
 import 'UIConstants.js' as UI
 
 Page {
+    id: fileSelectionPage
     tools: backToolBar
 
+    property alias pageTitle: pageHeader.text
+    property alias folder: folderListModel.folder
+    property alias nameFilters: folderListModel.nameFilters
+
+    signal clicked(string filePath)
+
     FolderListModel {
         id: folderListModel
-        nameFilters: [ "*.ttf", "*.ttc" ]
         showDotAndDotDot: true
     }
 
-    Label {
+    PageHeader {
         id: pageHeader
         anchors.top: parent.top
-        anchors.horizontalCenter: parent.horizontalCenter
-        anchors.margins: UI.DEFAULT_MARGIN
-
-        horizontalAlignment: Text.AlignHCenter
-        font.pixelSize: UI.FONT_LARGE
-        font.bold: true
-        text: qsTr("Select Font to install")
+        anchors.left: parent.left
+        anchors.right: parent.right
     }
 
     ListView {
@@ -70,7 +71,8 @@ Page {
         anchors.bottom: parent.bottom
         anchors.left: parent.left
         anchors.right: parent.right
-        anchors.margins: UI.DEFAULT_MARGIN
+        anchors.leftMargin: UI.DEFAULT_MARGIN
+        anchors.rightMargin: UI.DEFAULT_MARGIN
         clip: true
 
         model: folderListModel
@@ -103,8 +105,7 @@ Page {
                     if (folderListModel.isFolder(index)) {
                         folderListModel.folder = filePath
                     } else {
-                        var fontInfo = controller.checkFontInfo(filePath)
-                        pageStack.push(fontInstallPage, { "fontInfo": fontInfo })
+                        fileSelectionPage.clicked(filePath)
                     }
                 }
             }
@@ -118,19 +119,10 @@ Page {
 
     ToolBarLayout {
         id: backToolBar
-        visible: true
         ToolIcon {
             platformIconId: "toolbar-back"
-            onClicked: {
-                pageStack.pop()
-            }
+            onClicked: pageStack.pop()
         }
     }
 
-    Component {
-        id: fontInstallPage
-        FontInstallPage {
-
-        }
-    }
 }
index 6a89cc7..7b4cf5f 100644 (file)
@@ -63,15 +63,11 @@ Page {
         }
     }
 
-    Label {
+    PageHeader {
         id: pageHeader
         anchors.top: parent.top
-        anchors.horizontalCenter: parent.horizontalCenter
-        anchors.margins: UI.DEFAULT_MARGIN
-
-        horizontalAlignment: Text.AlignHCenter
-        font.pixelSize: UI.FONT_LARGE
-        font.bold: true
+        anchors.left: parent.left
+        anchors.right: parent.right
         text: qsTr("Install Font")
     }
 
@@ -81,7 +77,9 @@ Page {
         anchors.bottom: parent.bottom
         anchors.left: parent.left
         anchors.right: parent.right
-        anchors.margins: UI.DEFAULT_MARGIN
+        anchors.topMargin: UI.DEFAULT_MARGIN / 2
+        anchors.leftMargin: UI.DEFAULT_MARGIN
+        anchors.rightMargin: UI.DEFAULT_MARGIN
         clip: true
 
         //        contentWidth: contentColumn.width
@@ -174,4 +172,12 @@ Page {
         onAccepted: controller.installFont(fontInfo)
     }
 
+    ToolBarLayout {
+        id: backToolBar
+        ToolIcon {
+            platformIconId: "toolbar-back"
+            onClicked: pageStack.pop()
+        }
+    }
+
 }
diff --git a/qml/fontmanager/FontSelectionPage.qml b/qml/fontmanager/FontSelectionPage.qml
new file mode 100644 (file)
index 0000000..7f2b3bc
--- /dev/null
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Takumi Asaki
+** All rights reserved.
+** Contact: Takumi Asaki (takumi.asaki@gmail.com)
+**
+** This file is part of the fontmanager application.
+**
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+****************************************************************************/
+
+// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
+import QtQuick 1.1
+import com.nokia.meego 1.0
+import Qt.labs.folderlistmodel 1.0
+import com.nokia.extras 1.0
+import 'UIConstants.js' as UI
+
+FileSelectionPage {
+
+    pageTitle: qsTr("Select Font to install")
+    nameFilters: [ "*.ttf", "*.ttc" ]
+
+    onClicked: {
+        var fontInfo = controller.checkFontInfo(filePath)
+        pageStack.push(fontInstallPage, { "fontInfo": fontInfo })
+    }
+
+    Component {
+        id: fontInstallPage
+        FontInstallPage { }
+    }
+
+}
index c8e0686..966ea94 100644 (file)
@@ -48,23 +48,12 @@ Page {
 
     property string family
     property string familyName
-    property variant editorController
-
     property string curSection
     property string curSectionName
 
+    property variant editorController: null
 
-    Label {
-        id: pageHeader
-        anchors.top: parent.top
-        anchors.horizontalCenter: parent.horizontalCenter
-        anchors.margins: UI.DEFAULT_MARGIN
-
-        horizontalAlignment: Text.AlignHCenter
-        font.pixelSize: UI.FONT_LARGE
-        font.bold: true
-        text: qsTr("Edit Fonts Config: %1").arg(familyName)
-    }
+    property alias listView: preferFamilyListView
 
     onEditorControllerChanged: {
         if (editorController) {
@@ -91,7 +80,7 @@ Page {
     function insertFamily(family, priority, systemFont)
     {
         var index = Helper.index(priority)
-//        console.log("insertFamily(" + family + "," + priority + "): " + controller.localeFamily(family))
+        //        console.log("insertFamily(" + family + "," + priority + "): " + controller.localeFamily(family))
         preferFamilyList.insert(index, {
                                     "title": controller.localeFamily(family),
                                     "subtitle": (systemFont ? qsTr("System Font") : qsTr("User Font")),
@@ -105,7 +94,7 @@ Page {
 
     function addFamily(section, family, priority, systemFont)
     {
-//        console.log("addFamily(" + family + "," + priority + "): " + controller.localeFamily(family))
+        //        console.log("addFamily(" + family + "," + priority + "): " + controller.localeFamily(family))
         preferFamilyList.append({
                                     "title": controller.localeFamily(family),
                                     "subtitle": (systemFont ? qsTr("System Font") : qsTr("User Font")),
@@ -117,12 +106,40 @@ Page {
         Helper.setIndex(curSection, preferFamilyList.count)
     }
 
-    function removeFamily(index)
+    function moveUpFamily()
+    {
+        var index = preferFamilyListView.currentIndex
+        if (index < 1)
+            return;
+        var prevItem = preferFamilyList.get(index - 1)
+        if (!prevItem.header) {
+            var item = preferFamilyList.get(index)
+            editorController.moveFamilyUp(item.family, item.priority)
+            preferFamilyList.move(index, index - 1, 1)
+        }
+    }
+
+    function moveDownFamily()
+    {
+        var index = preferFamilyListView.currentIndex
+        if (index >= preferFamilyList.count - 1)
+            return;
+        var nextItem = preferFamilyList.get(index + 1)
+        if (!nextItem.header) {
+            var item = preferFamilyList.get(index)
+            editorController.moveFamilyDown(item.family, item.priority)
+            preferFamilyList.move(index, index + 1, 1)
+        }
+    }
+
+    function removeFamily()
     {
+        var index = preferFamilyListView.currentIndex
         var item = preferFamilyList.get(index)
         editorController.removeFamily(item.family, item.priority)
         preferFamilyList.remove(index)
         Helper.updateRemoveIndexes(index)
+        preferFamilyListView.currentIndex = -1
     }
 
     Component {
@@ -142,12 +159,10 @@ Page {
     }
 
     Item {
-        anchors.top: pageHeader.bottom
-        anchors.bottom: importButton.top
-        anchors.left: parent.left
-        anchors.right: parent.right
-        anchors.topMargin: UI.DEFAULT_MARGIN
-        anchors.bottomMargin: UI.DEFAULT_MARGIN
+//        anchors.top: pageHeader.bottom
+        anchors.fill: parent
+        anchors.topMargin: UI.DEFAULT_MARGIN / 2
+//        anchors.bottomMargin: UI.DEFAULT_MARGIN / 2
         clip: true
 
         ListView {
@@ -156,126 +171,32 @@ Page {
             anchors.leftMargin: UI.DEFAULT_MARGIN
             anchors.rightMargin: UI.DEFAULT_MARGIN
 
+            cacheBuffer: 100
+
+            currentIndex: -1
+
             model: preferFamilyList
-            delegate: editorListDelegate
+            delegate: EditorListDelegate { }
+
+            highlight: Rectangle {
+                x: - UI.MARGIN_XLARGE / 2
+                width: preferFamilyListView.width + UI.MARGIN_XLARGE
+                height: UI.LIST_ITEM_HEIGHT_SMALL
+                color: "transparent"
+                border.width: 5
+                border.color: "#bd543d"
+                radius: 5
+//                z: 1
+            }
+            highlightFollowsCurrentItem: true
+            highlightMoveDuration: 100
         }
 
         ScrollDecorator {
             flickableItem: preferFamilyListView
         }
 
-        //    SectionScroller {
-        //        listView: preferFamilyListView
-        //    }
-
-    }
-
-    Button {
-        id: importButton
-        anchors.horizontalCenter: parent.horizontalCenter
-        //        width: parent.width - UI.DEFAULT_MARGIN * 2
-        anchors.bottom: parent.bottom
-        anchors.bottomMargin: UI.DEFAULT_MARGIN
-        text: qsTr("Import System Settings")
-        onClicked: {
-            controller.importSystemSettings(family)
-        }
-    }
-
-    ButtonStyle {
-        id: buttonStyle
-    }
-
-    Component {
-        id: editorListDelegate
-
-        Item {
-            id: listItem
-
-            signal clicked
-            property bool pressed: false
-
-            property int titleSize: (model.header ? UI.FONT_XLARGE : UI.FONT_DEFAULT)
-            property int titleWeight: Font.Bold
-            property color titleColor: theme.inverted ? (model.header ? UI.COLOR_FOREGROUND : UI.COLOR_INVERTED_FOREGROUND) : (UI.COLOR_FOREGROUND)
-
-            property int subtitleSize: UI.FONT_XSMALL
-            property int subtitleWeight: Font.Light
-            property color subtitleColor: theme.inverted ? UI.COLOR_SECONDARY_FOREGROUND : UI.COLOR_INVERTED_SECONDARY_FOREGROUND
-
-            height: UI.LIST_ITEM_HEIGHT_SMALL
-            width: parent.width
-
-            Rectangle {
-                anchors.fill: parent
-                anchors.leftMargin: -UI.MARGIN_XLARGE
-                anchors.rightMargin: -UI.MARGIN_XLARGE
-                color: model.header ? UI.COLOR_SELECT : UI.COLOR_BACKGROUND
-            }
-
-            Row {
-                anchors.fill: parent
-                spacing: UI.DEFAULT_MARGIN
-
-                Item { width: UI.DEFAULT_MARGIN; height: 1; visible: !model.header }
-
-                Image {
-                    anchors.verticalCenter: parent.verticalCenter
-                    visible: model.iconSource ? true : false
-                    width: UI.SIZE_ICON_DEFAULT
-                    height: UI.SIZE_ICON_DEFAULT
-                    source: model.iconSource ? model.iconSource : ""
-                }
-
-                Column {
-                    anchors.verticalCenter: parent.verticalCenter
-
-
-                    Label {
-                        id: mainText
-                        text: model.title
-                        font.weight: listItem.titleWeight
-                        font.pixelSize: listItem.titleSize
-                        color: listItem.titleColor
-                    }
-
-                    Label {
-                        id: subText
-                        text: model.subtitle
-                        font.weight: listItem.subtitleWeight
-                        font.pixelSize: listItem.subtitleSize
-                        color: listItem.subtitleColor
-
-                        visible: text != ""
-                    }
-                }
-            }
-            //            MouseArea {
-            //                id: mouseArea;
-            //                anchors.fill: parent
-            //                onClicked: {
-            //                    listItem.clicked();
-            //                }
-            //            }
-
-            ListButton {
-                anchors.right: parent.right
-                anchors.verticalCenter: parent.verticalCenter
-                anchors.rightMargin: UI.DEFAULT_MARGIN
-                iconSource: (model.header ? "image://theme/icon-m-toolbar-add" : "image://theme/icon-m-toolbar-delete")
-                onClicked: {
-                    if (model.header) {
-                        controller.syncInstallableFamilyFor(editorPage.family)
-                        editorTabPage.currentPriority = model.priority
-                        selectInstallFamily.selectedIndexes = []
-                        selectInstallFamily.open()
-                    } else {
-                        removeFamily(model.index)
-                    }
-                }
-            }
-
-        }
     }
 
 }
+
index d557064..e78e6df 100644 (file)
@@ -48,15 +48,11 @@ Page {
 
     property alias text: textArea.text
 
-    Label {
+    PageHeader {
         id: pageHeader
         anchors.top: parent.top
-        anchors.horizontalCenter: parent.horizontalCenter
-        anchors.margins: UI.DEFAULT_MARGIN
-
-        horizontalAlignment: Text.AlignHCenter
-        font.pixelSize: UI.FONT_LARGE
-        font.bold: true
+        anchors.left: parent.left
+        anchors.right: parent.right
         text: qsTr("Current Fonts Config")
     }
 
index 1f40597..da85d8c 100644 (file)
@@ -68,7 +68,7 @@ Item {
 
         Button {
             id: okButton
-            text: qsTr("OK")
+            text: qsTr("Close")
             anchors.horizontalCenter: parent.horizontalCenter
             anchors.bottom: parent.bottom
             anchors.margins: UI.DEFAULT_MARGIN
index 691cbf9..c8ed7c7 100644 (file)
@@ -55,15 +55,11 @@ Page {
         }
     }
 
-    Label {
+    PageHeader {
         id: pageHeader
         anchors.top: parent.top
-        anchors.horizontalCenter: parent.horizontalCenter
-        anchors.margins: UI.DEFAULT_MARGIN
-
-        horizontalAlignment: Text.AlignHCenter
-        font.pixelSize: UI.FONT_LARGE
-        font.bold: true
+        anchors.left: parent.left
+        anchors.right: parent.right
         text: qsTr("Installed Font Info")
     }
 
@@ -73,7 +69,7 @@ Page {
         anchors.bottom: parent.bottom
         anchors.left: parent.left
         anchors.right: parent.right
-        anchors.margins: UI.DEFAULT_MARGIN
+        anchors.margins: UI.DEFAULT_MARGIN / 2
         clip: true
 
 //        contentWidth: contentColumn.width
index 3e70790..9f9f366 100644 (file)
@@ -60,19 +60,13 @@ Page {
                                      "<p><b>Create Recommended Settings</b>(Menu): Create recommended settings.  <i>Normal</i> priority is given to user installed font(s).  System fonts have <i>Higher</i> priority.  System CJK fonts conflicts your installed fonts have <i>Lower</i> priority.</p>"
                                      )
 
-    Label {
+    PageHeader {
         id: pageHeader
         anchors.top: parent.top
-        anchors.horizontalCenter: parent.horizontalCenter
-        anchors.margins: UI.DEFAULT_MARGIN
+        anchors.left: parent.left
+        anchors.right: parent.right
         enabled: !disableTools
-        opacity: enabled ? 1.0 : 0.5
-
-        horizontalAlignment: Text.AlignHCenter
-        font.pixelSize: UI.FONT_LARGE
-        font.bold: true
         text: qsTr("Installed Fonts")
-
     }
 
     Connections {
@@ -95,6 +89,7 @@ Page {
         anchors.bottom: parent.bottom
         anchors.left: parent.left
         anchors.right: parent.right
+        anchors.margins: UI.DEFAULT_MARGIN / 2
         clip: true
         enabled: !disableTools
         opacity: enabled ? 1.0 : 0.5
@@ -102,7 +97,6 @@ Page {
         ListView {
             id: listView
             anchors.fill: parent
-            anchors.margins: UI.DEFAULT_MARGIN
 
             model: installedFontList
 
@@ -145,6 +139,10 @@ Page {
         visible: running
     }
 
+    Loader {
+        id: componentLoader
+    }
+
     Component {
         id: installedFontInfoPageComponent
         InstalledFontInfoPage { }
@@ -170,7 +168,7 @@ Page {
             onClicked: {
                 if (mainMenu.status !== DialogStatus.Closed)
                     mainMenu.close()
-                pageStack.push(fontSelectPage)
+                pageStack.push(fontSelectionPage)
             }
         }
         ToolIcon {
@@ -210,6 +208,16 @@ Page {
                 }
             }
             MenuItem {
+                id: backupConfigItem
+                text: qsTr("Backup Config")
+                onClicked: backupConfig()
+            }
+            MenuItem {
+                id: restoreConfigItem
+                text: qsTr("Restore Config")
+                onClicked: pageStack.push(restoreFontsConfPageComponent)
+            }
+            MenuItem {
                 text: qsTr("About")
                 onClicked: aboutDialog.open()
             }
@@ -241,7 +249,30 @@ Page {
         id: aboutDialog
         titleText: qsTr("Font Manager for N9")
         message: qsTr("Version: %1\nAuthor: Takumi Asaki <takumi.asaki@gmail.com>\n\nApplication Icon is created by hirao").arg(controller.version)
-        acceptButtonText: qsTr("OK")
+        acceptButtonText: qsTr("Close")
+    }
+
+    QueryDialog {
+        id: backupDialog
+        width: parent.width
+        property string filepath
+        titleText: qsTr("Backup finished")
+        message: qsTr("Current config is backuped as '%1'").arg(filepath)
+        acceptButtonText: qsTr("Close")
+    }
+
+    Component {
+        id: restoreFontsConfPageComponent
+        RestoreFontsConfPage { }
+    }
+
+    function backupConfig()
+    {
+        var filepath = controller.defaultBackupFilename()
+        controller.backupConfig(filepath)
+        var displaypath = filepath.replace(/^\/home\/[^/]*\//, "~/")
+        backupDialog.filepath = displaypath
+        backupDialog.open()
     }
 
     states: [
diff --git a/qml/fontmanager/PageHeader.qml b/qml/fontmanager/PageHeader.qml
new file mode 100644 (file)
index 0000000..c7e254d
--- /dev/null
@@ -0,0 +1,31 @@
+import QtQuick 1.1
+import com.nokia.meego 1.0
+import com.nokia.extras 1.0
+import 'UIConstants.js' as UI
+
+Item {
+    id: pageHeader
+    height: UI.HEADER_DEFAULT_HEIGHT_PORTRAIT
+    opacity: enabled ? 1.0 : 0.5
+
+    property alias text: label.text
+
+    Rectangle {
+        anchors.fill: parent
+        gradient: Gradient {
+            GradientStop { position: 0.0; color: Qt.lighter("#bd543d") }
+            GradientStop { position: 1.0; color: Qt.lighter("#76221d") }
+        }
+        Component.onCompleted: {
+            console.log("PageHeader: " + width + " x " + height)
+        }
+    }
+
+    Label {
+        id: label
+        anchors.centerIn: parent
+        horizontalAlignment: Text.AlignHCenter
+        font.pixelSize: UI.FONT_LARGE
+        font.bold: true
+    }
+}
\ No newline at end of file
diff --git a/qml/fontmanager/RestoreFontsConfPage.qml b/qml/fontmanager/RestoreFontsConfPage.qml
new file mode 100644 (file)
index 0000000..b5a4145
--- /dev/null
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Takumi Asaki
+** All rights reserved.
+** Contact: Takumi Asaki (takumi.asaki@gmail.com)
+**
+** This file is part of the fontmanager application.
+**
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+****************************************************************************/
+
+// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
+import QtQuick 1.1
+import com.nokia.meego 1.0
+import Qt.labs.folderlistmodel 1.0
+import 'UIConstants.js' as UI
+
+FileSelectionPage {
+
+    pageTitle: qsTr("Restore Fonts Config")
+    folder: controller.backupDir
+    nameFilters: [ "*.conf" ]
+
+    function restoreConfig(filename)
+    {
+        console.log("Restore: " + filename)
+        controller.restoreConfig(filename)
+    }
+
+    onClicked: {
+        restoreConfig(filePath)
+        pageStack.pop()
+    }
+
+}
index a3541a7..ba9f11f 100644 (file)
@@ -78,8 +78,8 @@ PageStackWindow {
     }
 
     Component {
-        id: fontSelectPage
-        FontSelectPage {
+        id: fontSelectionPage
+        FontSelectionPage {
         }
     }
 
@@ -94,7 +94,7 @@ PageStackWindow {
         property string fontpath: "Unknown"
         titleText: qsTr("Install finished")
         message: qsTr("Font '%1' is installed successfully.").arg(fontpath)
-        acceptButtonText: qsTr("OK")
+        acceptButtonText: qsTr("Close")
         onAccepted: { pageStack.pop(mainPage) }
         onRejected: { pageStack.pop(mainPage) }
     }
@@ -104,7 +104,7 @@ PageStackWindow {
         property string fontpath: "Unknown"
         titleText: qsTr("Uninstall finished")
         message: qsTr("Font '%1' is uninstalled successfully.").arg(fontpath)
-        acceptButtonText: qsTr("OK")
+        acceptButtonText: qsTr("Close")
         onAccepted: pageStack.pop(mainPage)
         onRejected: pageStack.pop(mainPage)
     }
index ba9bdc8..70eccda 100644 (file)
@@ -1,3 +1,13 @@
+fontmanager (0.4.9) unstable; urgency=low
+
+  0.5 beta
+  * Add reorder configuration.
+  * Add backup/restore configuration.
+  * Add edit System font configuration.
+  * Adjust UI layout.
+
+ -- Takumi Asaki <takumi.asaki@gmail.com>  Tue,  3 Apr 2012 01:00:00 +0900
+
 fontmanager (0.4.3) unstable; urgency=low
 
   * Don't add non-English family name to ~/.fonts.conf