[chronojump] config accepts: OnlyEncoder, and SessionMode.UNIQUE
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] config accepts: OnlyEncoder, and SessionMode.UNIQUE
- Date: Mon, 15 Jun 2015 18:47:53 +0000 (UTC)
commit c150a819d025be91ccde164041331df96bb95352
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Jun 15 20:46:42 2015 +0200
config accepts: OnlyEncoder, and SessionMode.UNIQUE
chronojump_config.txt | 10 ++++++++++
src/config.cs | 12 ++++++++++++
src/gui/chronojump.cs | 16 +++++++++++-----
src/gui/networks.cs | 23 +++++++++++++++++++++--
src/session.cs | 1 +
src/sqlite/session.cs | 20 ++++++++++++++++----
6 files changed, 71 insertions(+), 11 deletions(-)
---
diff --git a/chronojump_config.txt b/chronojump_config.txt
index 44691f5..c6137ec 100644
--- a/chronojump_config.txt
+++ b/chronojump_config.txt
@@ -12,6 +12,7 @@
#CustomButtons=TRUE
#UseVideo=FALSE
#AutodetectPort=ACTIVE
+#OnlyEncoder=TRUE
#RunScriptOnExit=
#Recommendations for PIPO tablet (Windows)
@@ -19,6 +20,7 @@
#CustomButtons=TRUE
#UseVideo=TRUE
#AutodetectPort=DISCARDFIRST
+#OnlyEncoder=TRUE
#RunScriptOnExit=
# 2 ------- OPTIONS -------
@@ -35,5 +37,13 @@ UseVideo=TRUE
#PIPO windows tablet has COM1 and usually COM5. At COM1 it doesn't work, use DISCARDFIRST to use the other
AutodetectPort=DISCARDFIRST
+#Only Encoder. When connected to a machine and there's always encoder mode
+OnlyEncoder=TRUE
+
+#Session modes:
+#STANDARD: default mode where sessions are created by user
+#UNIQUE: there's only one session called "session". Menubar is hidden (use it only with OnlyEncoder = TRUE)
+SessionMode=UNIQUE
+
#To sync data
RunScriptOnExit=
diff --git a/src/config.cs b/src/config.cs
index 2bd7d35..a042da4 100644
--- a/src/config.cs
+++ b/src/config.cs
@@ -25,11 +25,14 @@ using System.IO;
public class Config
{
public enum AutodetectPortEnum { ACTIVE, DISCARDFIRST, INACTIVE }
+ public enum SessionModeEnum { STANDARD, UNIQUE }
public bool Maximized;
public bool CustomButtons;
public bool UseVideo;
public AutodetectPortEnum AutodetectPort;
+ public bool OnlyEncoder;
+ public SessionModeEnum SessionMode;
public string RunScriptOnExit;
public Config()
@@ -38,6 +41,8 @@ public class Config
CustomButtons = false;
UseVideo = true;
AutodetectPort = AutodetectPortEnum.ACTIVE;
+ OnlyEncoder = false;
+ SessionMode = SessionModeEnum.STANDARD;
RunScriptOnExit = "";
}
@@ -69,6 +74,11 @@ public class Config
else if(parts[0] == "AutodetectPort" &&
Enum.IsDefined(typeof(AutodetectPortEnum), parts[1]))
AutodetectPort = (AutodetectPortEnum)
Enum.Parse(typeof(AutodetectPortEnum), parts[1]);
+ else if(parts[0] == "OnlyEncoder" && Util.StringToBool(parts[1]))
+ OnlyEncoder = true;
+ else if(parts[0] == "SessionMode" &&
Enum.IsDefined(typeof(SessionModeEnum), parts[1]))
+ SessionMode = (SessionModeEnum)
+ Enum.Parse(typeof(SessionModeEnum), parts[1]);
else if(parts[0] == "RunScriptOnExit" && parts[1] != "")
RunScriptOnExit = parts[1];
} while(true);
@@ -82,6 +92,8 @@ public class Config
"CustomButtons = " + CustomButtons.ToString() + "\n" +
"UseVideo = " + UseVideo.ToString() + "\n" +
"AutodetectPort = " + AutodetectPort.ToString() + "\n" +
+ "OnlyEncoder = " + OnlyEncoder.ToString() + "\n" +
+ "SessionMode = " + SessionMode.ToString() + "\n" +
"RunScriptOnExit = " + RunScriptOnExit.ToString() + "\n"
);
}
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 625677e..3908510 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2492,16 +2492,22 @@ public partial class ChronoJumpWindow
}
}
- private void on_open_activate (object o, EventArgs args) {
+ private void on_open_activate (object o, EventArgs args)
+ {
LogB.Information("open session");
sessionLoadWin = SessionLoadWindow.Show(app1);
- sessionLoadWin.Button_accept.Clicked += new EventHandler(on_load_session_accepted);
- //on_load_session_accepted(o, args);
+ sessionLoadWin.Button_accept.Clicked += new EventHandler(on_load_session_accepted_from_open);
}
- private void on_load_session_accepted (object o, EventArgs args) {
+ //from open session
+ private void on_load_session_accepted_from_open (object o, EventArgs args)
+ {
currentSession = sessionLoadWin.CurrentSession;
- //currentSession = SqliteSession.Select("1");
+ on_load_session_accepted();
+ }
+ //called from open session OR from gui/networks configInit when config.SessionMode ==
Config.SessionModeEnum.UNIQUE
+ private void on_load_session_accepted ()
+ {
app1.Title = progName + " - " + currentSession.Name;
if(createdStatsWin) {
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 22aea28..9717a85 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -63,11 +63,30 @@ public partial class ChronoJumpWindow
useVideo = false;
alignment_video_encoder.Visible = false;
}
-
+
configAutodetectPort = config.AutodetectPort;
+
+ //show only power
+ if(config.OnlyEncoder)
+ select_menuitem_mode_toggled(menuitem_modes.POWER);
+
+ if(config.SessionMode == Config.SessionModeEnum.UNIQUE)
+ {
+ main_menu.Visible = false;
+
+ if(! Sqlite.Exists(false, Constants.SessionTable, "session")) {
+ //this creates the session and inserts at DB
+ currentSession = new Session(
+ "session", "", DateTime.Today, //name, place, dateTime
+ Constants.SportUndefinedID, Constants.SpeciallityUndefinedID,
Constants.LevelUndefinedID,
+ "", Constants.ServerUndefinedID); //comments, serverID
+ } else
+ currentSession = SqliteSession.SelectByName("session");
+
+ on_load_session_accepted();
+ }
//TODO
- //AutodetectPort
//RunScriptOnExit
/*
diff --git a/src/session.cs b/src/session.cs
index 6c687e1..8e48b0b 100644
--- a/src/session.cs
+++ b/src/session.cs
@@ -62,6 +62,7 @@ public partial class Session {
}
//typical constructor with personsSport stuff
+ //this inserts the session in SQL
public Session(string newName, string newPlace, DateTime newDate,
int personsSportID, int personsSpeciallityID, int personsPractice,
string comments, int serverUniqueID)
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index fa7e363..41e5427 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -114,9 +114,22 @@ class SqliteSession : Sqlite
Sqlite.Close();
}
-
+
+ //by name (only in gui/networks.cs configInit
+ //be careful because name is not unique
+ public static Session SelectByName(string name)
+ {
+ dbcmd.CommandText = "SELECT * FROM " + Constants.SessionTable + " WHERE name == '" + name +
"'";
+ return SelectDo(dbcmd);
+ }
+ //by ID (default
public static Session Select(string myUniqueID)
{
+ dbcmd.CommandText = "SELECT * FROM " + Constants.SessionTable + " WHERE uniqueID == " +
myUniqueID ;
+ return SelectDo(dbcmd);
+ }
+ public static Session SelectDo(SqliteCommand mydbcmd)
+ {
try {
Sqlite.Open();
} catch {
@@ -126,11 +139,10 @@ class SqliteSession : Sqlite
Sqlite.Open();
LogB.SQL("reopened again");
}
- dbcmd.CommandText = "SELECT * FROM " + Constants.SessionTable + " WHERE uniqueID == " +
myUniqueID ;
- LogB.SQL(dbcmd.CommandText.ToString());
+ LogB.SQL(mydbcmd.CommandText.ToString());
SqliteDataReader reader;
- reader = dbcmd.ExecuteReader();
+ reader = mydbcmd.ExecuteReader();
string [] values = new string[9];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]