summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-10-15 07:09:38 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-10-15 07:09:38 (GMT)
commit7cc04115db6f9fa2d79d02d32cff38e4ecd8c52b (patch)
tree7fb17d1a2085b61c116a6c0ee3d7f41fbd60dda2 /examples
parent343535d7cbae16c02517664ce0d363e9834bd74d (diff)
downloadQt-7cc04115db6f9fa2d79d02d32cff38e4ecd8c52b.zip
Qt-7cc04115db6f9fa2d79d02d32cff38e4ecd8c52b.tar.gz
Qt-7cc04115db6f9fa2d79d02d32cff38e4ecd8c52b.tar.bz2
Some improvements to loader
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/loader/Browser.qml58
-rw-r--r--examples/declarative/loader/loader.pro9
-rw-r--r--examples/declarative/loader/main.cpp42
3 files changed, 78 insertions, 31 deletions
diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml
index 5f972f1..9eedd4e 100644
--- a/examples/declarative/loader/Browser.qml
+++ b/examples/declarative/loader/Browser.qml
@@ -2,13 +2,14 @@ import Qt 4.6
Rectangle {
id: root
+ property bool keyPressed: false
width: parent.width
height: parent.height
- color: palette.base
+ color: palette.window
FolderListModel {
id: folders
nameFilters: [ "*.qml" ]
-// folder: "E:"
+ folder: "E:"
}
SystemPalette { id: palette; colorGroup: Qt.Active }
@@ -25,7 +26,7 @@ Rectangle {
}
}
width: root.width
- height: 32
+ height: 48
color: "transparent"
Rectangle {
id: highlight; visible: false
@@ -36,15 +37,15 @@ Rectangle {
}
}
Item {
- width: 32; height: 32
+ width: 46; height: 46
Image { source: "images/fileopen.png"; anchors.centerIn: parent; visible: folders.isFolder(index)}
}
Text {
id: nameText
anchors.fill: parent; verticalAlignment: "AlignVCenter"
- text: fileName; anchors.leftMargin: 32
- font.pointSize: 10
- color: palette.windowText
+ text: fileName; anchors.leftMargin: 48
+ font.pixelSize: 32
+ color: wrapper.isCurrentItem ? palette.highlightedText : palette.text
}
MouseRegion {
id: mouseRegion
@@ -62,13 +63,6 @@ Rectangle {
}
}
- Script {
- function up(path) {
- var pos = path.toString().lastIndexOf("/");
- return path.toString().substring(0, pos);
- }
- }
-
ListView {
id: view
anchors.top: titleBar.bottom
@@ -77,37 +71,59 @@ Rectangle {
anchors.bottom: parent.bottom
model: folders
delegate: folderDelegate
- highlight: Rectangle { color: "#FFFBAF" }
+ highlight: Rectangle { color: palette.highlight; visible: root.keyPressed }
clip: true
focus: true
+ pressDelay: 100
+
Keys.onPressed: {
- if (event.key == Qt.Key_Return || event.key == Qt.Key_Select) {
+ root.keyPressed = true;
+ if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) {
view.currentItem.launch();
event.accepted = true;
}
}
+ Keys.onLeftPressed: folders.folder = up(folders.folder)
}
Rectangle {
id: titleBar
width: parent.width
- height: 32
- color: palette.button; border.color: palette.mid
+ height: 48
+ color: palette.lighter(palette.window); border.color: palette.mid
Rectangle {
id: upButton
- width: 30
+ width: 48
height: titleBar.height
border.color: palette.mid; color: "transparent"
- MouseRegion { anchors.fill: parent; onClicked: folders.folder = up(folders.folder) }
+
+ Script {
+ function up(path) {
+ var pos = path.toString().lastIndexOf("/");
+ return path.toString().substring(0, pos);
+ }
+ }
+
Image { anchors.centerIn: parent; source: "images/up.png" }
+ MouseRegion { id: upRegion; anchors.fill: parent
+ onClicked: if (folders.parentFolder != "") folders.folder = folders.parentFolder
+ }
+ states: [
+ State {
+ name: "pressed"
+ when: upRegion.pressed
+ PropertyChanges { target: upButton; color: palette.highlightedText }
+ }
+ ]
}
Text {
anchors.left: upButton.right; anchors.right: parent.right; height: parent.height
anchors.leftMargin: 4; anchors.rightMargin: 4
- text: folders.folder; color: palette.buttonText
+ text: folders.folder; color: palette.text
elide: "ElideLeft"; horizontalAlignment: "AlignRight"; verticalAlignment: "AlignVCenter"
+ font.pixelSize: 32
}
}
}
diff --git a/examples/declarative/loader/loader.pro b/examples/declarative/loader/loader.pro
index 089eaff..9b03b8f 100644
--- a/examples/declarative/loader/loader.pro
+++ b/examples/declarative/loader/loader.pro
@@ -7,3 +7,12 @@ target.path = $$[QT_INSTALL_EXAMPLES]/declarative/loader
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS loader.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/loader
INSTALLS += target sources
+
+symbian {
+# TARGET.UID3 =
+ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
+ TARGET.EPOCHEAPSIZE = 100000 20000000
+ HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h
+ LIBS += -lesock -lconnmon -linsock
+ TARGET.CAPABILITY = NetworkServices
+}
diff --git a/examples/declarative/loader/main.cpp b/examples/declarative/loader/main.cpp
index fbae5f1..0993814 100644
--- a/examples/declarative/loader/main.cpp
+++ b/examples/declarative/loader/main.cpp
@@ -15,6 +15,15 @@
#include <QDebug>
#include <QNetworkDiskCache>
#include <QNetworkAccessManager>
+#include <QtCore>
+
+#if defined (Q_OS_SYMBIAN)
+#define SYMBIAN_NETWORK_INIT
+#endif
+
+#if defined (SYMBIAN_NETWORK_INIT)
+#include "sym_iap_util.h"
+#endif
QmlView *canvas = 0;
@@ -30,13 +39,11 @@ public:
setLayout(layout);
#ifdef Q_OS_SYMBIAN
QAction *closeAction = new QAction("Close", this);
- closeAction->setSoftKeyRole(QAction::BackSoftKey);
+ closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
-
- QList<QAction*> softKeys;
- softKeys.append(closeAction);
- setSoftKeys(softKeys);
+ addAction(closeAction);
#endif
+ connect(logText, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
}
void append(const QString &text) {
@@ -50,6 +57,9 @@ public:
return logger;
}
+signals:
+ void textChanged();
+
private:
QPlainTextEdit *logText;
};
@@ -112,7 +122,7 @@ public:
}
}
- canvas->setUrl(fileName);
+ canvas->setUrl(url);
canvas->execute();
}
@@ -124,8 +134,9 @@ class MainWindow : public QMainWindow
{
Q_OBJECT
public:
- MainWindow() : QMainWindow() {}
-
+ MainWindow() : QMainWindow()
+ {
+ }
public slots:
void toggleFullScreen()
@@ -149,6 +160,13 @@ public slots:
Logger::instance()->show();
#endif
}
+
+ void enableNetwork()
+ {
+#if defined(SYMBIAN_NETWORK_INIT)
+ qt_SetDefaultIap();
+#endif
+ }
};
class ConfiguredNetworkAccessManager : public QNetworkAccessManager {
@@ -185,8 +203,6 @@ int main(int argc, char *argv[])
canvas->setFocusPolicy(Qt::StrongFocus);
canvas->engine()->setNetworkAccessManager(new ConfiguredNetworkAccessManager);
- mw->setCentralWidget(canvas);
-
QMenuBar *mb = mw->menuBar();
QAction *showLogAction = new QAction("View Log...", mw);
mb->addAction(showLogAction);
@@ -194,6 +210,11 @@ int main(int argc, char *argv[])
QAction *toggleFSAction = new QAction("Fullscreen", mw);
mb->addAction(toggleFSAction);
QObject::connect(toggleFSAction, SIGNAL(triggered()), mw, SLOT(toggleFullScreen()));
+#if defined(SYMBIAN_NETWORK_INIT)
+ QAction *enableNetworkAction = new QAction("Enable Network", mw);
+ mb->addAction(enableNetworkAction);
+ QObject::connect(enableNetworkAction, SIGNAL(triggered()), mw, SLOT(enableNetwork()));
+#endif
QmlContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("qmlLauncher", launcher);
@@ -205,6 +226,7 @@ int main(int argc, char *argv[])
mw->show();
#endif
canvas->execute();
+ mw->setCentralWidget(canvas);
return app.exec();
}