Skip to content

Commit

Permalink
- update checker implemented for developer and stable versions.
Browse files Browse the repository at this point in the history
 - photo gallery performance fix.
 - cache size + reset
  • Loading branch information
custodian committed Oct 23, 2012
1 parent 0b74160 commit e3743c9
Show file tree
Hide file tree
Showing 14 changed files with 348 additions and 30 deletions.
46 changes: 43 additions & 3 deletions cache.cpp
Expand Up @@ -9,13 +9,15 @@
#include <QByteArray>
#include <QCryptographicHash>
#include <QDesktopServices>
#include <QString>
#include <QDebug>

Cache::Cache(QObject *parent) :
QObject(parent)
{
QDesktopServices dirs;
m_path = dirs.storageLocation(QDesktopServices::CacheLocation);
m_path += "/nelisquare/";
qDebug() << "Cache location: " << m_path;

if (m_path.length()) {
Expand All @@ -33,8 +35,6 @@ void Cache::onDownloadFinished(QNetworkReply * reply){
QString url = reply->request().url().toString();
QString name = m_path + "/" + md5(url);

//qDebug() << "Got url:" << url << "Name:" << name;

QFile file(name);
file.open(QFile::WriteOnly);
file.write(data);
Expand Down Expand Up @@ -67,10 +67,50 @@ QVariant Cache::get(QVariant data)

QVariant Cache::info()
{
return QVariant("empty");
qint64 total = 0;
QDir dir(m_path);
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
QFileInfoList list = dir.entryInfoList();
for (int i=0; i<list.size();i++) {
total += list.at(i).size();
}

{
//TODO: remove legacy code
// Due to error in 0.4.1 will be there until 0.5.0 is out
QDir dir2(m_path+"/../");
dir2.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
dir2.setNameFilters(QStringList("????????????????????????????????"));
QFileInfoList list2 = dir2.entryInfoList();
for (int i=0; i<list2.size();i++) {
total += list2.at(i).size();
}
}

double result = double(total) / 1000000;
return QVariant(QString("%1 MB").arg(result,0,'g',3));
}

QVariant Cache::reset()
{
QDir dir(m_path);
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
QFileInfoList list = dir.entryInfoList();
for (int i=0; i<list.size();i++) {
QFile(list.at(i).absoluteFilePath()).remove();
}

{
//TODO: remove legacy code
// Due to error in 0.4.1 will be there until 0.5.0 is out
QDir dir2(m_path+"/../");
dir2.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
dir2.setNameFilters(QStringList("????????????????????????????????"));
QFileInfoList list2 = dir2.entryInfoList();
for (int i=0; i<list2.size();i++) {
QFile(list2.at(i).absoluteFilePath()).remove();
}
}

return QVariant(true);
}
1 change: 0 additions & 1 deletion main.cpp
Expand Up @@ -90,5 +90,4 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
#endif

return app.exec();

}
62 changes: 44 additions & 18 deletions qml/resources/MainWindow.qml
Expand Up @@ -2,6 +2,7 @@ import Qt 4.7
import QtMobility.location 1.1
import Effects 1.0
import "components"
import "./build.info.js" as BuildInfo
import "js/script.js" as Script
import "js/storage.js" as Storage
import "js/window.js" as Window
Expand All @@ -12,17 +13,44 @@ Rectangle {
property bool blurred: false

property string orientationType: "auto"
property string iconset: "colorful"
property string mapprovider: "googlemaps"
property string checkupdates: "none"

id: window

anchors.fill: parent

color: theme.backGroundColor

function iconsetPath() {
return iconset + "/";
onCheckupdatesChanged: {
if (checkupdates!="none") {
Script.getUpdateInfo(checkupdates,onUpdateAvailable);
}
}

function onUpdateAvailable(build,version,url) {
var update = false;
//console.log("Current: version: " + BuildInfo.version + " build: "+ BuildInfo.build);
//console.log("Updated: version: " + version + " build: "+ build);
//console.log("Update url: " + url);
if (checkupdates == "developer") {
if (build > BuildInfo.build) {
//console.log("Update is available: " + version + " " + build);
update = true;
}
} else if (checkupdates == "stable") {
if (version != BuildInfo.version || build != BuildInfo.build) {
//console.log("Stable version " + version + " is available");
update = true;
}
}

if (update){
updateDialog.build = build;
updateDialog.version = version;
updateDialog.url = url;
updateDialog.state = "shown";
}
}

function onPictureUploaded(response) {
Expand All @@ -43,14 +71,12 @@ Rectangle {
if (value == "") value = "auto";
window.orientationType = value;
windowHelper.setOrientation(value);
} else if (key == "settings.iconset") {
if (value == "") value = "original";
if (value == "Handdraw") value = "colorful";
if (value == "Classic") value = "colorful";
window.iconset = value;
} else if (key == "settings.mapprovider") {
if (value == "") value = "googlemaps";
window.mapprovider = value;
} else if (key == "settings.checkupdates") {
if (value == "") value = "none";
window.checkupdates = value;
}
}

Expand All @@ -66,8 +92,8 @@ Rectangle {
window.isPortrait = window.height > (window.width*2/3);//window.width<(window.height/2);

Storage.getKeyValue("settings.orientation", window.settingLoaded);
//Storage.getKeyValue("settings.iconset", window.settingLoaded);
Storage.getKeyValue("settings.mapprovider", window.settingLoaded);
Storage.getKeyValue("settings.checkupdates", window.settingLoaded);
}

onHeightChanged: {
Expand Down Expand Up @@ -127,7 +153,7 @@ Rectangle {
notificationsList.state = "hidden";
settings.state = "hidden";
photoShareDialog.state = "hidden";
shoutDialog.state = "hidden";
//shoutDialog.state = "hidden";
commentDialog.state = "hidden";
checkinDialog.state = "hidden";
tipDialog.state = "hidden";
Expand Down Expand Up @@ -511,20 +537,16 @@ Rectangle {
onOrientationChanged: {
window.settingChanged("settings.orientation",type);
}
/*onIconsetChanged: {
window.settingChanged("settings.iconset",type);
}*/
onCacheReseted: {
//dbg nothing here yet
onCheckUpdatesChanged: {
window.settingChanged("settings.checkupdates",type);
}

onMapProviderChanged: {
window.settingChanged("settings.mapprovider",type);
}
visible: false
}

ShoutDialog {
/*ShoutDialog {
id: shoutDialog
width: parent.width
state: "hidden"
Expand All @@ -538,7 +560,7 @@ Rectangle {
Script.addCheckin(null, realComment, true, facebook, twitter);
shoutDialog.state = "hidden";
}
}
}*/

CommentDialog {
id: commentDialog
Expand Down Expand Up @@ -587,6 +609,10 @@ Rectangle {
}
}

UpdateDialog {
id: updateDialog
}

Rectangle {
id: signalIcon
radius: 6
Expand Down
2 changes: 2 additions & 0 deletions qml/resources/build.info.js
@@ -0,0 +1,2 @@
var build = '201210231802';
var version = "0.4.3"
2 changes: 1 addition & 1 deletion qml/resources/components/EventBox.qml
Expand Up @@ -81,7 +81,7 @@ Item {
width: parent.width
text: userShout!="" ? userShout : (venueAddress + " " + venueCity)
wrapMode: Text.Wrap
visible: /*venuePhoto == "" &&*/ text.length > 1
visible: text.length > 1
}
Row {
width: parent.width
Expand Down
3 changes: 2 additions & 1 deletion qml/resources/components/PhotoAddPage.qml
Expand Up @@ -37,7 +37,7 @@ Rectangle {
photoUrl: model.filePath //real
//photoUrl: model.fileName //sim
photoSize: photoGrid.cellWidth
//photoSourceSize: photoGrid.cellWidth //commented due to sizing bug
photoSourceSize: photoGrid.cellWidth //commented due to sizing bug
photoBorder: 2
photoSmooth: false
photoAspect: Image.PreserveAspectFit
Expand All @@ -64,6 +64,7 @@ Rectangle {

onStateChanged: {
if (state == "shown") {
galleryModel.reload();
photoGrid.model = galleryModel;
} else {
photoGrid.model = emptyModel;
Expand Down
2 changes: 1 addition & 1 deletion qml/resources/components/ProfilePhoto.qml
Expand Up @@ -29,7 +29,7 @@ Rectangle {
fillMode: photoAspect
width: photoSize - 2*photoBorder + 1
height: photoSize - 2*photoBorder + 1
//sourceSize.width: width // photoSourceSize
sourceSize.width: width // photoSourceSize
//sourceSize.height: height //photoSourceSize
clip: true
onStatusChanged: {
Expand Down
74 changes: 70 additions & 4 deletions qml/resources/components/SettingsPage.qml
@@ -1,10 +1,14 @@
import Qt 4.7
import "../build.info.js" as BuildInfo

Rectangle {
signal authDeleted()
signal cacheReseted()
signal orientationChanged(string type)
signal mapProviderChanged(string type)
signal checkUpdatesChanged(string type)

property string cacheSize: "undefined"

id: settings
color: theme.backgroundSettings
Expand All @@ -23,7 +27,6 @@ Rectangle {
Flickable{

id: flickableArea

anchors.top: settingsLabel.bottom
width: parent.width
contentWidth: parent.width
Expand All @@ -36,7 +39,7 @@ Rectangle {

Column {
onHeightChanged: {
flickableArea.contentHeight = height;
flickableArea.contentHeight = height + y;
}

width: parent.width - 20
Expand Down Expand Up @@ -105,6 +108,44 @@ Rectangle {

}

Item {
height: 20
width: parent.width
}

//Check updates
Text {
color: theme.textColorOptions
text: "Check for updates"
font.pixelSize: theme.font.sizeSettigs
}
Row {
width: parent.width
spacing: 20

ToolbarTextButton {
height: 35
selected: window.checkupdates == "none"
label: "NONE"
onClicked: checkUpdatesChanged("none")
}
ToolbarTextButton {
height: 35
selected: window.checkupdates == "stable"
label: "STABLE"
onClicked: checkUpdatesChanged("stable")
}
ToolbarTextButton {
height: 35
selected: window.checkupdates == "developer"
label: "DEVELOPER"
onClicked: {
checkUpdatesChanged("developer")
}
}

}

Item{
height: 20
width: parent.width
Expand Down Expand Up @@ -147,7 +188,16 @@ Rectangle {
height: 35
selected: false
label: "RESET"
onClicked: cacheReseted()
onClicked: {
cache.reset();
cacheSize = cache.info();
}
}

ToolbarTextButton {
height: 35
selected: false
label: "Size: " + cacheSize;
}
}

Expand Down Expand Up @@ -185,6 +235,22 @@ Rectangle {
horizontalAlignment: Text.AlignHCenter
}

Text {
anchors.horizontalCenter: parent.horizontalCenter
text: theme.textVersionInfo + BuildInfo.version
color: theme.textColorOptions
font.pixelSize: theme.font.sizeHelp
horizontalAlignment: Text.AlignHCenter
}

Text {
anchors.horizontalCenter: parent.horizontalCenter
text: theme.textBuildInfo + BuildInfo.build
color: theme.textColorOptions
font.pixelSize: theme.font.sizeHelp
horizontalAlignment: Text.AlignHCenter
}

Text {
anchors.horizontalCenter: parent.horizontalCenter
text: theme.textHelp3
Expand All @@ -198,7 +264,7 @@ Rectangle {
}

onStateChanged: {

cacheSize = cache.info();
}

states: [
Expand Down
5 changes: 4 additions & 1 deletion qml/resources/components/ThemeStyle.qml
Expand Up @@ -36,9 +36,12 @@ Item {
property int menuFontSize: 20
property int menuSubFontSize: 14

property string textVersionInfo: "Version: "
property string textBuildInfo: "Build: "

property string textHelp1: "© Design by Kim Venetvirta\n© 2012 Basil Semuonov\n© 2011 Tommi Laukkanen"
property string textHelp2: "\nIf any problems, tweet @basil_s\n"
property string textHelp3: "www.nelisquare.com"
property string textHelp3: "http://github.com/custodian/nelisquare"

property string textSplash: "Loading..."

Expand Down

0 comments on commit e3743c9

Please sign in to comment.