diff options
| author | Javier S. Pedro <maemo@javispedro.com> | 2013-05-04 01:46:06 +0200 | 
|---|---|---|
| committer | Javier S. Pedro <maemo@javispedro.com> | 2013-05-04 01:46:06 +0200 | 
| commit | c8385121987089af08ad95d28514af4b6dc13603 (patch) | |
| tree | cc5ddf549d9cebbb77bfe175a9fcfd0276d51a64 | |
| parent | 8af1436e92c1a853b74bacc9ac0adf012fdbc4ca (diff) | |
| download | sowatch-c8385121987089af08ad95d28514af4b6dc13603.tar.gz sowatch-c8385121987089af08ad95d28514af4b6dc13603.zip  | |
add basic support for settings pages
| -rw-r--r-- | libsowatch/watchletplugininterface.h | 1 | ||||
| -rw-r--r-- | sowatchui/qml/WatchPage.qml | 7 | ||||
| -rw-r--r-- | sowatchui/watchletsmodel.cpp | 4 | ||||
| -rw-r--r-- | sowatchui/watchletsmodel.h | 3 | 
4 files changed, 13 insertions, 2 deletions
diff --git a/libsowatch/watchletplugininterface.h b/libsowatch/watchletplugininterface.h index 31accb9..cccf86f 100644 --- a/libsowatch/watchletplugininterface.h +++ b/libsowatch/watchletplugininterface.h @@ -22,6 +22,7 @@ public:  	struct WatchletInfo {  		QString name;  		QUrl icon; +		QUrl configQmlUrl;  	};  	virtual QStringList watchlets() = 0; diff --git a/sowatchui/qml/WatchPage.qml b/sowatchui/qml/WatchPage.qml index 4799085..8d623a6 100644 --- a/sowatchui/qml/WatchPage.qml +++ b/sowatchui/qml/WatchPage.qml @@ -44,6 +44,7 @@ Page {  	Menu {  		id: watchletMenu  		property string watchlet; +		property url watchletConfigQmlUrl;  		MenuLayout {  			MenuItem {  				text: qsTr("Move up") @@ -54,6 +55,11 @@ Page {  				onClicked: watchletsModel.moveWatchletDown(watchletMenu.watchlet)  			}  			MenuItem { +				text: qsTr("Configure watchlet...") +				onClicked: pageStack.push(watchletMenu.watchletConfigQmlUrl, {'configKey': configKey}) +				visible: watchletMenu.watchletConfigQmlUrl != "" +			} +			MenuItem {  				text: qsTr("Remove watchlet")  				onClicked: watchletsModel.removeWatchlet(watchletMenu.watchlet)  			} @@ -161,6 +167,7 @@ Page {  				delegate: ListDelegate {  					onClicked: {  						watchletMenu.watchlet = model.name; +						watchletMenu.watchletConfigQmlUrl = model.configQmlUrl;  						watchletMenu.open();  					}  				} diff --git a/sowatchui/watchletsmodel.cpp b/sowatchui/watchletsmodel.cpp index d9c8f86..cdc3593 100644 --- a/sowatchui/watchletsmodel.cpp +++ b/sowatchui/watchletsmodel.cpp @@ -13,6 +13,7 @@ WatchletsModel::WatchletsModel(QObject *parent) :  	roles[Qt::DisplayRole] = QByteArray("title");  	roles[Qt::DecorationRole] = QByteArray("iconSource");  	roles[NameRole] = QByteArray("name"); +	roles[ConfigQmlUrlRole] = QByteArray("configQmlUrl");  	setRoleNames(roles);  } @@ -28,7 +29,6 @@ QString WatchletsModel::configKey() const  void WatchletsModel::setConfigKey(const QString &configKey)  { -	qDebug() << "Set confgKey" << configKey;  	QString oldConfigKey = this->configKey();  	if (_config) {  		delete _config; @@ -73,6 +73,8 @@ QVariant WatchletsModel::data(const QModelIndex &index, int role) const  		return QVariant::fromValue(_info[id].icon);  	case NameRole:  		return QVariant::fromValue(id); +	case ConfigQmlUrlRole: +		return QVariant::fromValue(_info[id].configQmlUrl);  	}  	return QVariant();  } diff --git a/sowatchui/watchletsmodel.h b/sowatchui/watchletsmodel.h index e0c2c62..4f7ae8f 100644 --- a/sowatchui/watchletsmodel.h +++ b/sowatchui/watchletsmodel.h @@ -15,7 +15,8 @@ public:  	explicit WatchletsModel(QObject *parent = 0);  	enum DataRoles { -		NameRole = Qt::UserRole +		NameRole = Qt::UserRole, +		ConfigQmlUrlRole  	};  	QString configKey() const;  | 
