[chronojump] DB: 1.58 New feature: capture encoder show only n bars (see preferences).



commit 96823e45d40661585b39aa5b5d653ab06ddef41c
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue May 22 13:38:44 2018 +0200

    DB: 1.58 New feature: capture encoder show only n bars (see preferences).

 glade/preferences_win.glade |  142 ++++++++++++++++++++++++++++++++----------
 src/gui/encoder.cs          |    4 +-
 src/gui/preferences.cs      |   47 ++++++++++++---
 src/preferences.cs          |    1 +
 src/sqlite/main.cs          |   10 +++-
 src/sqlite/preferences.cs   |    3 +
 6 files changed, 160 insertions(+), 47 deletions(-)
---
diff --git a/glade/preferences_win.glade b/glade/preferences_win.glade
index 682b51b..68c687d 100644
--- a/glade/preferences_win.glade
+++ b/glade/preferences_win.glade
@@ -2003,10 +2003,10 @@ It starts before and arrives there with some speed.</property>
                                     <property name="can_focus">False</property>
                                     <property name="spacing">8</property>
                                     <child>
-                                      <widget class="GtkVBox" id="vbox33">
+                                      <widget class="GtkHBox" id="hbox30">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
-                                        <property name="spacing">4</property>
+                                        <property name="spacing">20</property>
                                         <child>
                                           <widget class="GtkCheckButton" 
id="check_appearance_encoder_only_bars">
                                             <property name="label" translatable="yes">Show only 
bars</property>
@@ -2023,45 +2023,38 @@ It starts before and arrives there with some speed.</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <widget class="GtkAlignment" id="alignment_restart">
+                                          <widget class="GtkHBox" id="hbox_restart">
                                             <property name="can_focus">False</property>
-                                            <property name="top_padding">4</property>
+                                            <property name="spacing">12</property>
                                             <child>
-                                              <widget class="GtkHBox" id="hbox25">
+                                              <widget class="GtkLabel" id="label73">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">False</property>
-                                                <property name="spacing">12</property>
-                                                <child>
-                                                  <widget class="GtkLabel" id="label73">
-                                                    <property name="visible">True</property>
-                                                    <property name="can_focus">False</property>
-                                                    <property name="xalign">0</property>
-                                                    <property name="label" translatable="yes">This change 
needs restarting Chronojump</property>
-                                                  </widget>
-                                                  <packing>
-                                                    <property name="expand">False</property>
-                                                    <property name="fill">False</property>
-                                                    <property name="position">0</property>
-                                                  </packing>
-                                                </child>
-                                                <child>
-                                                  <widget class="GtkImage" id="image2">
-                                                    <property name="visible">True</property>
-                                                    <property name="can_focus">False</property>
-                                                    <property name="stock">gtk-dialog-warning</property>
-                                                  </widget>
-                                                  <packing>
-                                                    <property name="expand">False</property>
-                                                    <property name="fill">False</property>
-                                                    <property name="position">1</property>
-                                                  </packing>
-                                                </child>
+                                                <property name="xalign">0</property>
+                                                <property name="label" translatable="yes">This change needs 
restarting Chronojump</property>
+                                              </widget>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="fill">False</property>
+                                                <property name="position">0</property>
+                                              </packing>
+                                            </child>
+                                            <child>
+                                              <widget class="GtkImage" id="image2">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">False</property>
+                                                <property name="stock">gtk-dialog-warning</property>
                                               </widget>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="fill">False</property>
+                                                <property name="position">1</property>
+                                              </packing>
                                             </child>
                                           </widget>
                                           <packing>
-                                            <property name="expand">True</property>
-                                            <property name="fill">True</property>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
                                             <property name="position">1</property>
                                           </packing>
                                         </child>
@@ -2073,6 +2066,87 @@ It starts before and arrives there with some speed.</property>
                                       </packing>
                                     </child>
                                     <child>
+                                      <widget class="GtkHBox" id="hbox26">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="spacing">20</property>
+                                        <child>
+                                          <widget class="GtkRadioButton" 
id="radio_encoder_capture_show_all_bars">
+                                            <property name="label" translatable="yes">Show all 
bars</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="active">True</property>
+                                            <property name="draw_indicator">True</property>
+                                            <signal name="toggled" 
handler="on_radio_encoder_capture_show_all_bars_toggled" swapped="no"/>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <widget class="GtkHBox" id="hbox29">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="spacing">4</property>
+                                            <child>
+                                              <widget class="GtkRadioButton" 
id="radio_encoder_capture_show_only_some_bars">
+                                                <property name="label" translatable="yes">Show only last 
bars</property>
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="receives_default">False</property>
+                                                <property name="active">True</property>
+                                                <property name="draw_indicator">True</property>
+                                                <property 
name="group">radio_encoder_capture_show_all_bars</property>
+                                                <signal name="toggled" 
handler="on_radio_encoder_capture_show_only_some_bars_toggled" swapped="no"/>
+                                              </widget>
+                                              <packing>
+                                                <property name="expand">True</property>
+                                                <property name="fill">True</property>
+                                                <property name="position">0</property>
+                                              </packing>
+                                            </child>
+                                            <child>
+                                              <widget class="GtkSpinButton" 
id="spin_encoder_capture_show_only_some_bars">
+                                                <property name="visible">True</property>
+                                                <property name="sensitive">False</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="has_tooltip">True</property>
+                                                <property name="invisible_char">●</property>
+                                                <property name="width_chars">2</property>
+                                                <property name="invisible_char_set">True</property>
+                                                <property name="primary_icon_activatable">False</property>
+                                                <property name="secondary_icon_activatable">False</property>
+                                                <property name="primary_icon_sensitive">True</property>
+                                                <property name="secondary_icon_sensitive">True</property>
+                                                <property name="adjustment">10 1 30 1 10 0</property>
+                                                <property name="climb_rate">1</property>
+                                                <property name="snap_to_ticks">True</property>
+                                                <property name="numeric">True</property>
+                                              </widget>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="fill">False</property>
+                                                <property name="position">1</property>
+                                              </packing>
+                                            </child>
+                                          </widget>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">False</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
                                       <widget class="GtkHBox" id="hbox36">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
@@ -2129,7 +2203,7 @@ It starts before and arrives there with some speed.</property>
                                       <packing>
                                         <property name="expand">False</property>
                                         <property name="fill">False</property>
-                                        <property name="position">1</property>
+                                        <property name="position">2</property>
                                       </packing>
                                     </child>
                                   </widget>
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 0699d6b..0b6a4b1 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -4876,9 +4876,7 @@ public partial class ChronoJumpWindow
        
                ArrayList data = new ArrayList (data6Variables.Count);
                int count = 0;
-               int showNRepetitions = -1; //default: -1: show all. 10: only display last 10 repetitions
-               if(configChronojump.PlaySoundsFromFile)
-                       showNRepetitions = 10; //TODO: put an option on preferences to allow any user use this
+               int showNRepetitions = preferences.encoderCaptureShowNRepetitions;
 
                foreach(EncoderBarsData ebd in data6Variables)
                {
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 54b5c6c..d89d851 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -51,9 +51,7 @@ public class PreferencesWindow
        [Widget] Gtk.CheckButton check_appearance_maximized_undecorated;
        [Widget] Gtk.CheckButton check_appearance_person_win_hide;
        [Widget] Gtk.CheckButton check_appearance_person_photo;
-       [Widget] Gtk.CheckButton check_appearance_encoder_only_bars;
        [Widget] Gtk.Alignment alignment_undecorated;
-       [Widget] Gtk.Alignment alignment_restart;
 
        //database tab
        [Widget] Gtk.Button button_data_folder_open;
@@ -107,11 +105,16 @@ public class PreferencesWindow
        [Widget] Gtk.VBox vbox_encoder_inertial; //change Visible param to not have a vertical big first page 
with only one row of info
        [Widget] Gtk.SpinButton spin_encoder_capture_min_height_gravitatory;
        [Widget] Gtk.SpinButton spin_encoder_capture_min_height_inertial;
+       [Widget] Gtk.CheckButton check_appearance_encoder_only_bars;
+       [Widget] Gtk.HBox hbox_restart;
+       [Widget] Gtk.SpinButton spin_encoder_capture_show_only_some_bars;
+       [Widget] Gtk.RadioButton radio_encoder_capture_show_all_bars;
+       [Widget] Gtk.RadioButton radio_encoder_capture_show_only_some_bars;
+       [Widget] Gtk.SpinButton spin_encoder_capture_barplot_font_size;
        [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_best;
        [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_4top;
        [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_all;
        [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_none;
-       [Widget] Gtk.SpinButton spin_encoder_capture_barplot_font_size;
        [Widget] Gtk.CheckButton check_show_start_and_duration;
        [Widget] Gtk.RadioButton radio_encoder_triggers_no;
        [Widget] Gtk.RadioButton radio_encoder_triggers_yes;
@@ -120,7 +123,7 @@ public class PreferencesWindow
        [Widget] Gtk.RadioButton radio_encoder_triggers_yes_start_at_first_trigger;
        [Widget] Gtk.Image image_encoder_inactivity_help;
        [Widget] Gtk.Image image_encoder_capture_cut_by_triggers_help;
-       
+
        //encoder other tab
        [Widget] Gtk.CheckButton checkbutton_encoder_propulsive;
        [Widget] Gtk.SpinButton spin_encoder_smooth_con;
@@ -260,6 +263,10 @@ public class PreferencesWindow
                else
                        PreferencesWindowBox.check_appearance_encoder_only_bars.Active = false;
 
+               if(preferences.encoderCaptureShowNRepetitions < 0)
+                       PreferencesWindowBox.radio_encoder_capture_show_all_bars.Active = true;
+               else
+                       PreferencesWindowBox.radio_encoder_capture_show_only_some_bars.Active = true;
 
                //multimedia tab
                if(preferences.volumeOn)  
@@ -487,6 +494,15 @@ public class PreferencesWindow
                return PreferencesWindowBox;
        }
 
+       private void on_radio_encoder_capture_show_all_bars_toggled (object o, EventArgs args)
+       {
+               spin_encoder_capture_show_only_some_bars.Sensitive = false;
+       }
+       private void on_radio_encoder_capture_show_only_some_bars_toggled (object o, EventArgs args)
+       {
+               spin_encoder_capture_show_only_some_bars.Sensitive = true;
+       }
+
        //private void on_notebook_encoder_capture_gi_change_current_page (object o, 
Gtk.ChangeCurrentPageArgs args)
        private void on_notebook_encoder_capture_gi_switch_page (object o, Gtk.SwitchPageArgs args)
        {
@@ -568,7 +584,7 @@ public class PreferencesWindow
 
        private void on_check_appearance_encoder_only_bars_toggled (object obj, EventArgs args) 
        {
-               alignment_restart.Visible = ! check_appearance_encoder_only_bars.Active;
+               hbox_restart.Visible = ! check_appearance_encoder_only_bars.Active;
        }
 
 
@@ -1145,10 +1161,6 @@ public class PreferencesWindow
                        SqlitePreferences.Update("personPhoto", 
PreferencesWindowBox.check_appearance_person_photo.Active.ToString(), true);
                        preferences.personPhoto = PreferencesWindowBox.check_appearance_person_photo.Active;
                }
-               if( preferences.encoderCaptureShowOnlyBars != 
PreferencesWindowBox.check_appearance_encoder_only_bars.Active ) {
-                       SqlitePreferences.Update("encoderCaptureShowOnlyBars", 
PreferencesWindowBox.check_appearance_encoder_only_bars.Active.ToString(), true);
-                       preferences.encoderCaptureShowOnlyBars = 
PreferencesWindowBox.check_appearance_encoder_only_bars.Active;
-               }
                
                if( preferences.digitsNumber != Convert.ToInt32(UtilGtk.ComboGetActive(combo_decimals)) ) {
                        SqlitePreferences.Update("digitsNumber", UtilGtk.ComboGetActive(combo_decimals), 
true);
@@ -1291,6 +1303,23 @@ public class PreferencesWindow
                                preferences.encoderCaptureMinHeightInertial,
                                (int) PreferencesWindowBox.spin_encoder_capture_min_height_inertial.Value);
 
+               if( preferences.encoderCaptureShowOnlyBars != 
PreferencesWindowBox.check_appearance_encoder_only_bars.Active ) {
+                       SqlitePreferences.Update("encoderCaptureShowOnlyBars", 
PreferencesWindowBox.check_appearance_encoder_only_bars.Active.ToString(), true);
+                       preferences.encoderCaptureShowOnlyBars = 
PreferencesWindowBox.check_appearance_encoder_only_bars.Active;
+               }
+
+               if( preferences.encoderCaptureShowNRepetitions > 0 && 
PreferencesWindowBox.radio_encoder_capture_show_all_bars.Active )
+               {
+                       SqlitePreferences.Update("encoderCaptureShowNRepetitions", "-1", true);
+                       preferences.encoderCaptureShowNRepetitions = -1;
+               }
+               else if( PreferencesWindowBox.radio_encoder_capture_show_only_some_bars.Active &&
+                               preferences.encoderCaptureShowNRepetitions != (int) 
PreferencesWindowBox.spin_encoder_capture_show_only_some_bars.Value) {
+                       SqlitePreferences.Update("encoderCaptureShowNRepetitions",
+                                       
PreferencesWindowBox.spin_encoder_capture_show_only_some_bars.Value.ToString(), true);
+                       preferences.encoderCaptureShowNRepetitions = (int) 
PreferencesWindowBox.spin_encoder_capture_show_only_some_bars.Value;
+               }
+
                if(PreferencesWindowBox.radio_encoder_auto_save_curve_best.Active) {
                        SqlitePreferences.Update("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.BEST.ToString(), true);
                        preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.BEST;
diff --git a/src/preferences.cs b/src/preferences.cs
index c2c8045..b59ff6c 100644
--- a/src/preferences.cs
+++ b/src/preferences.cs
@@ -33,6 +33,7 @@ public class Preferences
        public bool personWinHide;
        public bool personPhoto;
        public bool encoderCaptureShowOnlyBars;
+       public int encoderCaptureShowNRepetitions;
 
        public bool showPower;
        public bool showStiffness;
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index ca8d747..bfeb3fd 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -125,7 +125,7 @@ class Sqlite
        /*
         * Important, change this if there's any update to database
         */
-       static string lastChronojumpDatabaseVersion = "1.57";
+       static string lastChronojumpDatabaseVersion = "1.58";
 
        public Sqlite() {
        }
@@ -2346,7 +2346,14 @@ class Sqlite
 
                                currentVersion = updateVersion("1.57");
                        }
+                       if(currentVersion == "1.57")
+                       {
+                               LogB.SQL("Added to preferences: encoderCaptureShowNRepetitions");
+
+                               SqlitePreferences.Insert ("encoderCaptureShowNRepetitions", "-1");
 
+                               currentVersion = updateVersion("1.58");
+                       }
 
 
 
@@ -2534,6 +2541,7 @@ class Sqlite
                SqliteJson.createTableUploadSprintDataTemp ();
 
                //changes [from - to - desc]
+               //1.57 - 1.58 Converted DB to 1.58 Added to preferences: encoderCaptureShowNRepetitions
                //1.56 - 1.57 Converted DB to 1.57 Created table UploadEncoderDataTemp, UploadSprintDateTemp
                //1.55 - 1.56 Converted DB to 1.56 Added encoder rhythm restAfterEcc
                //1.54 - 1.55 Converted DB to 1.55 Added preferences: personPhoto
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index de31405..a9fa1cd 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -81,6 +81,7 @@ class SqlitePreferences : Sqlite
                                Insert ("personWinHide", "False", dbcmdTr);
                                Insert ("personPhoto", "True", dbcmdTr);
                                Insert ("encoderCaptureShowOnlyBars", "False", dbcmdTr);
+                               Insert ("encoderCaptureShowNRepetitions", "-1", dbcmdTr);
                                Insert ("digitsNumber", "3", dbcmdTr);
                                Insert ("showPower", "True", dbcmdTr);
                                Insert ("showStiffness", "True", dbcmdTr);
@@ -284,6 +285,8 @@ class SqlitePreferences : Sqlite
                                preferences.personPhoto = reader[1].ToString() == "True";
                        else if(reader[0].ToString() == "encoderCaptureShowOnlyBars")
                                preferences.encoderCaptureShowOnlyBars = reader[1].ToString() == "True";
+                       else if(reader[0].ToString() == "encoderCaptureShowNRepetitions")
+                               preferences.encoderCaptureShowNRepetitions = 
Convert.ToInt32(reader[1].ToString());
                        else if(reader[0].ToString() == "showPower")
                                preferences.showPower = reader[1].ToString() == "True";
                        else if(reader[0].ToString() == "showStiffness")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]