Preferences - - None Saved: Am I doing something wrong

Questions regarding syntax

Preferences - - None Saved: Am I doing something wrong

Postby elgunvo » Sat Sep 04, 2010 10:01 pm

Okay, This is Confusing

Whilst the application is running it can save and load settings. Once its closed and reopened it sets back to defaults?!?

Form Load - Code:

if Preferences.integer("FontSize") = 0 then
SetPreferences()
else
GetPreferences()
end if

Module Code (For Setting and Getting Preferences)

Sub SetPreferences()
Preferences.SetString("FontName", "Arial")
Preferences.SetInteger("FontSize", 10)
Preferences.SetBoolean("FontBold", False)
Preferences.SetBoolean("FontItalic", False)
Preferences.SetBoolean("FontUnderline", False)
Preferences.SetString("TagColor", "&H00557F")
Preferences.SetString("CommentColor", "&HAAAA7F")
Preferences.SetString("CommandColor", "&HFFAA00")
Preferences.SetBoolean("AutoCheck", False)
End Sub

Sub GetPreferences()
FMain.rtfBox.FontName= Preferences.String("FontName")
FMain.rtfBox.FontSize = Preferences.Integer("FontSize")
FMain.rtfBox.FontBold= Preferences.Boolean("FontBold")
FMain.rtfBox.FontItalic= Preferences.Boolean("FontItalic")
FMain.rtfBox.FontUnderline= Preferences.Boolean("FontUnderline")
FMain.rtfBox.KeywordColor = Preferences.String("CommandColor")
FMain.rtfBox.CommandColor = Preferences.String("TagColor")
FMain.rtfBox.CommentColor = Preferences.String("CommentColor")
if Preferences.Boolean("AutoCheck") = True then
Dim UptodateVersion as string = Application.LoadURLAsString("elgunvo.de/Codie/version.ini")
dim MyVersion As String = Mid(Application.LoadProjectFileAsString("version.ini"), 0,5)

if MyVersion <> UpToDateVersion then
dim n as integer = msgbox ("Version " & UpToDateVersion & " is now available, please download it.", kbYesNo, "Update Message")
if n=6 then
Application.LoadExternalBrowserWithHTML("http://elgunvosoftware.com")
End if
End If
End If

End Sub

Settings Form- Code:


Private Sub Form_OnOpen()
lblFN.caption= Preferences.String("FontName")
lblFS.caption= Preferences.Integer("FontSize")
chkB.value= Preferences.Boolean("FontBold")
chkI.value= Preferences.Boolean("FontItalic")
chkU.value= Preferences.Boolean("FontUnderline")
txtKeyColor.text= Preferences.String("CommandColor")
txtTagColor.text= Preferences.String("TagColor")
txtCommentColor.text= Preferences.String("CommentColor")
chkUpdate.value = Preferences.Boolean("AutoCheck")
End Sub



Private Sub CommandButton5_OnEvent()
Preferences.SetString("FontName", lblFN.caption)
Preferences.SetInteger("FontSize", CInt(lblFS.caption))
Preferences.SetBoolean("FontBold", chkB.value)
Preferences.SetBoolean("FontItalic", chkI.value)
Preferences.SetBoolean("FontUnderline", chkU.value)
Preferences.SetString("TagColor", txtTagColor.text)
Preferences.SetString("CommentColor", txtCommentColor.text)
Preferences.SetString("CommandColor", txtKeyColor.text)
Preferences.SetBoolean("AutoCheck", chkUpdate.value)
GetPreferences()
me.close
End Sub



Why does it reset after relaunch... none of the settings save?!?
elgunvo
 
Posts: 17
Joined: Wed Aug 18, 2010 9:47 am

Re: Preferences - - None Saved: Am I doing something wrong

Postby elgunvo » Sun Sep 05, 2010 1:16 am

The Strange thing is aswell. I Compiled the code under mac and the preferences save. The Problem must lie with Windows 7

Not sure why tho.
elgunvo
 
Posts: 17
Joined: Wed Aug 18, 2010 9:47 am

Re: Preferences - - None Saved: Am I doing something wrong

Postby Slowdown » Sun Sep 05, 2010 5:24 am

try to start your application as administrator, i don't know
where the preferences are saved under W7
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands

Re: Preferences - - None Saved: Am I doing something wrong

Postby elgunvo » Sun Sep 05, 2010 10:26 am

Strangely enough i found out what the problem was. The name of the app confused windows so i had to rename it and set the caption on Load
elgunvo
 
Posts: 17
Joined: Wed Aug 18, 2010 9:47 am

Re: Preferences - - None Saved: Am I doing something wrong

Postby berndnoetscher » Mon Sep 06, 2010 8:17 am

elgunvo wrote:Strangely enough i found out what the problem was. The name of the app confused windows so i had to rename it and set the caption on Load



If no project name is set "KBasic" is used as name for your preferences. The project name is set in the ide "projects properties.

The following C++ code is used:

Code: Select all
  settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, sProjectName.isNull() ? "KBasic" : sProjectName);
berndnoetscher
Site Admin
 
Posts: 1059
Joined: Tue Sep 25, 2007 9:37 am


Return to Coding Questions

cron