Skip to content

Commit

Permalink
Added feature for restarting suspended timers.
Browse files Browse the repository at this point in the history
This feature will restart suspended timers when OpenCPN is started.
It is controlled by a checkbox in the Preferences page.
  • Loading branch information
ptulp committed Jan 19, 2018
1 parent 7f20ef1 commit 6dd7369
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 47,774 deletions.
4 changes: 2 additions & 2 deletions VERSION.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SET(PLUGIN_VERSION_MAJOR "1")
SET(PLUGIN_VERSION_MINOR "2")
SET(PLUGIN_VERSION_PATCH "027")
SET(PLUGIN_VERSION_DATE "2017-09-15")
SET(PLUGIN_VERSION_PATCH "028")
SET(PLUGIN_VERSION_DATE "2018-01-19")
4 changes: 2 additions & 2 deletions src/Logbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,9 +1295,9 @@ wxString Logbook::makeDateFromFile( wxString date, wxString dateformat )
{
wxStringTokenizer tkzd( date,_T( "/" ) );
wxDateTime dt;
wxDateTime::wxDateTime_t month = ( wxDateTime::wxDateTime_t ) wxAtoi( tkzd.GetNextToken() );
wxDateTime::Month month = ( wxDateTime::Month ) wxAtoi( tkzd.GetNextToken() );
wxDateTime::wxDateTime_t day = ( wxDateTime::wxDateTime_t ) wxAtoi( tkzd.GetNextToken() );
wxDateTime::wxDateTime_t year = ( wxDateTime::wxDateTime_t ) wxAtoi( tkzd.GetNextToken() );
int year = wxAtoi( tkzd.GetNextToken() );
dt.Set( day, month, year );

return dt.Format( dateformat );
Expand Down
12 changes: 9 additions & 3 deletions src/LogbookDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2911,14 +2911,19 @@ void LogbookDialog::OnStatusBulletCourse( wxCommandEvent& event )
}

void LogbookDialog::OnButtonClickStatusStartStop( wxCommandEvent& event )
{
AutoStatusStartStop();
}

void LogbookDialog::AutoStatusStartStop()
{
if ( checkBitmaps() == 2 )
logbookPlugIn->eventsEnabled = false;
else if ( checkBitmaps() == 1 )
logbookPlugIn->eventsEnabled = true;
else
return;

if ( logbookPlugIn->eventsEnabled )
{
m_buttonStartStop->SetLabel( _( "Stop" ) );
Expand Down Expand Up @@ -3869,8 +3874,9 @@ Backup Logbook(*.txt)|*.txt" );
}
#endif



if (logbookPlugIn->opt->autostarttimer == true)
AutoStatusStartStop();

#ifndef __WXMSW__ // wxWidgets won't set buttonwidth in Linux like in windows
m_buttonEditLayout->SetMinSize( wxSize( 25,-1 ) );
m_buttonReloadLayout->SetMinSize( wxSize( 25,-1 ) );
Expand Down
1 change: 1 addition & 0 deletions src/LogbookDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ class LogbookDialog : public wxDialog
void OnToggleButtonGenerator( wxCommandEvent& event );
void OnButtonClickResetSails( wxCommandEvent& event );
void OnCheckboxSails( wxCommandEvent& event );
void AutoStatusStartStop();

void OnComboUpService( wxCommandEvent& event );
void OnComboUpRepairs( wxCommandEvent& event );
Expand Down
26 changes: 15 additions & 11 deletions src/LogbookOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,17 @@ LogbookOptions::LogbookOptions( wxWindow* parent, Options* opt, logbookkonni_pi*
fgSizer14->Add( m_textCtrlChancedCourse, 0, wxALL|wxEXPAND, 0 );


fgSizer14->Add( 0, 0, 1, wxEXPAND, 5 );


fgSizer14->Add( 0, 0, 1, wxEXPAND, 5 );

m_checkBoxPopUp = new wxCheckBox( m_panel15, wxID_ANY, _( "Popup logbook on event" ), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxPopUp->SetValue( true );
fgSizer14->Add( m_checkBoxPopUp, 0, wxALL, 5 );
fgSizer14->Add( m_checkBoxPopUp, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );

m_checkBoxAutoStartTimer = new wxCheckBox( m_panel15, wxID_ANY, _( "Auto restart Timer(s)" ), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxAutoStartTimer->SetValue( false );
m_checkBoxAutoStartTimer->SetToolTip("This will automatically start the timer(s) if they were suspended when starting OpenCPN");

fgSizer14->Add( m_checkBoxAutoStartTimer, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );

fgSizer10->Add( fgSizer14, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );

Expand Down Expand Up @@ -2073,6 +2075,7 @@ void LogbookOptions::onChoicePositionFormat( wxCommandEvent &ev )
void LogbookOptions::setValues()
{
m_checkBoxPopUp->SetValue( opt->popup );
m_checkBoxAutoStartTimer->SetValue( opt->autostarttimer );

m_choiceDateFormat->Select( opt->dateformat );
m_textCtrlDateSeparator->SetValue( opt->dateseparatorindiv );
Expand Down Expand Up @@ -2223,6 +2226,7 @@ void LogbookOptions::OnChoiceNoEngines( wxCommandEvent& event )
void LogbookOptions::getValues()
{
opt->popup = m_checkBoxPopUp->GetValue();
opt->autostarttimer = m_checkBoxAutoStartTimer->GetValue();

opt->dateformat = m_choiceDateFormat->GetSelection();
opt->dateseparatorindiv = m_textCtrlDateSeparator->GetValue();
Expand Down Expand Up @@ -2340,19 +2344,19 @@ void LogbookOptions::getValues()
opt->bGenRPMIsChecked= m_checkBoxGenRPM->GetValue();
opt->NMEAUseERRPM = m_checkBoxNMEAUseRPM->GetValue();

//int row = 0;
wxString tempstr;
//int row = 0;
wxString tempstr;
opt->abrSails.Clear();
opt->sailsName.Clear();
opt->numberSails = 0;
for ( int row = 0; row < m_gridSailNames->GetNumberRows(); row++ )
{
tempstr = m_gridSailNames->GetCellValue( row,0 );
if ( !tempstr.IsEmpty() )
{
{
tempstr = m_gridSailNames->GetCellValue( row,0 );
if ( !tempstr.IsEmpty() )
{
opt->abrSails.Add( m_gridSailNames->GetCellValue( row,0 ) );
opt->sailsName.Add( m_gridSailNames->GetCellValue( row,1 ) );
opt->numberSails++;
opt->numberSails++;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/LogbookOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class LogbookOptions : public wxDialog
wxStaticText* m_staticText1231;
wxStaticText* m_staticText124;
wxCheckBox* m_checkBoxPopUp;
wxCheckBox* m_checkBoxAutoStartTimer;
wxStaticLine* m_staticline10;
wxStaticText* m_staticText731;
wxStaticText* m_staticText751;
Expand Down
1 change: 1 addition & 0 deletions src/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Options::Options( void )
dlgWidth = 1010;
dlgHeight = 535;
popup = true;
autostarttimer = false;
for ( int i = 0; i < 7; i++ )
{
layoutPrefix[i] = _T( "Label_" );
Expand Down
1 change: 1 addition & 0 deletions src/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Options
int dlgWidth;
int dlgHeight;
bool popup;
bool autostarttimer;
bool hourFormat;
bool statusbarGlobal;
bool layoutShow;
Expand Down
18 changes: 10 additions & 8 deletions src/logbook_pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ extern "C" DECL_EXP void destroy_pi( opencpn_plugin* p )
delete p;
}


#include "icons.h"

//---------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -135,7 +134,7 @@ int logbookkonni_pi::Init( void )
timer = new LogbookTimer( this );
m_timer = new wxTimer( timer,ID_LOGTIMER );
timer->Connect( wxEVT_TIMER, wxObjectEventFunction( &LogbookTimer::OnTimer ) );

SendPluginMessage( _T( "LOGBOOK_READY_FOR_REQUESTS" ), _T( "TRUE" ) );

return (
Expand Down Expand Up @@ -510,6 +509,7 @@ void logbookkonni_pi::startLogbook()
else
SendPluginMessage( _T( "LOGBOOK_WINDOW_HIDDEN" ), wxEmptyString );
}

}


Expand Down Expand Up @@ -902,6 +902,7 @@ void logbookkonni_pi::SaveConfig()
}

pConf->Write ( _T ( "Popup" ),opt->popup );
pConf->Write ( _T ( "AutoStartTimer" ),opt->autostarttimer );
pConf->Write ( _T ( "DateFormat" ), opt->dateformat );
pConf->Write ( _T ( "DateSepIndiv" ), opt->dateseparatorindiv );
pConf->Write ( _T ( "DateSepLocale" ), opt->dateseparatorlocale );
Expand Down Expand Up @@ -1117,6 +1118,7 @@ void logbookkonni_pi::LoadConfig()
#endif
pConf->Read ( _T( "DlgHeight" ), &opt->dlgHeight,535 );
pConf->Read ( _T( "Popup" ), &opt->popup,true );
pConf->Read ( _T( "AutoStartTimer" ), &opt->autostarttimer, false );

pConf->Read ( _T ( "DateFormat" ), &opt->dateformat,0 );
pConf->Read ( _T ( "DateSepIndiv" ), &opt->dateseparatorindiv );
Expand Down Expand Up @@ -1581,14 +1583,14 @@ void logbookkonni_pi::loadLayouts( wxWindow *parent )
}
wxString ok = wxString::Format( _( "Layouts %sinstalled at\n\n%s\n%s\n%s\n%s" ),
( !ret )?n.c_str():wxEmptyString,data.c_str(),data1.c_str(),data2.c_str(),data3.c_str() );
wxMessageBox( ok );

if (ret )
{
wxMessageBox( ok );

if (ret )
{
opt->navGridLayoutChoice = 0;
opt->crewGridLayoutChoice = 0;
opt->boatGridLayoutChoice = 0;
}
opt->boatGridLayoutChoice = 0;
}
}
}

Expand Down
Loading

0 comments on commit 6dd7369

Please sign in to comment.