-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-Save plugin is now functional and can be configured from: Plugin…
…s->Auto Save
- Loading branch information
Eran Ifrah
committed
Sep 13, 2016
1 parent
acdde88
commit d18cd2d
Showing
12 changed files
with
1,092 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "AutoSaveDlg.h" | ||
#include "AutoSaveSettings.h" | ||
|
||
AutoSaveDlg::AutoSaveDlg(wxWindow* parent) | ||
: AutoSaveDlgBase(parent) | ||
{ | ||
AutoSaveSettings conf = AutoSaveSettings::Load(); | ||
m_checkBoxEnabled->SetValue(conf.HasFlag(AutoSaveSettings::kEnabled)); | ||
m_spinCtrlInterval->SetValue(conf.GetCheckInterval()); | ||
} | ||
|
||
AutoSaveDlg::~AutoSaveDlg() {} | ||
|
||
void AutoSaveDlg::OnEnabledUI(wxUpdateUIEvent& event) { event.Enable(m_checkBoxEnabled->IsChecked()); } | ||
|
||
void AutoSaveDlg::OnOK(wxCommandEvent& event) | ||
{ | ||
AutoSaveSettings conf; | ||
conf.EnableFlag(AutoSaveSettings::kEnabled, m_checkBoxEnabled->IsChecked()); | ||
conf.SetCheckInterval(m_spinCtrlInterval->GetValue()); | ||
AutoSaveSettings::Save(conf); | ||
|
||
EndModal(wxID_OK); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
////////////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright : (C) 2016 The CodeLite Team | ||
// File name : AutoSaveDlg.h | ||
// | ||
// ------------------------------------------------------------------------- | ||
// A | ||
// _____ _ _ _ _ | ||
// / __ \ | | | | (_) | | ||
// | / \/ ___ __| | ___| | _| |_ ___ | ||
// | | / _ \ / _ |/ _ \ | | | __/ _ ) | ||
// | \__/\ (_) | (_| | __/ |___| | || __/ | ||
// \____/\___/ \__,_|\___\_____/_|\__\___| | ||
// | ||
// F i l e | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation; either version 2 of the License, or | ||
// (at your option) any later version. | ||
// | ||
////////////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef AUTOSAVEDLG_H | ||
#define AUTOSAVEDLG_H | ||
#include "AutoSaveUI.h" | ||
|
||
class AutoSaveDlg : public AutoSaveDlgBase | ||
{ | ||
public: | ||
AutoSaveDlg(wxWindow* parent); | ||
virtual ~AutoSaveDlg(); | ||
protected: | ||
virtual void OnOK(wxCommandEvent& event); | ||
virtual void OnEnabledUI(wxUpdateUIEvent& event); | ||
}; | ||
#endif // AUTOSAVEDLG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "AutoSaveSettings.h" | ||
|
||
AutoSaveSettings::AutoSaveSettings() | ||
: clConfigItem("auto-save") | ||
, m_flags(kEnabled) | ||
, m_checkInterval(5) | ||
{ | ||
} | ||
|
||
AutoSaveSettings::~AutoSaveSettings() {} | ||
|
||
void AutoSaveSettings::FromJSON(const JSONElement& json) | ||
{ | ||
m_flags = json.namedObject("m_flags").toSize_t(m_flags); | ||
m_checkInterval = json.namedObject("m_checkInterval").toSize_t(m_checkInterval); | ||
} | ||
|
||
JSONElement AutoSaveSettings::ToJSON() const | ||
{ | ||
JSONElement json = JSONElement::createObject(GetName()); | ||
json.addProperty("m_flags", m_flags); | ||
json.addProperty("m_checkInterval", m_checkInterval); | ||
return json; | ||
} | ||
|
||
AutoSaveSettings AutoSaveSettings::Load() | ||
{ | ||
AutoSaveSettings settings; | ||
clConfig config("auto-save.conf"); | ||
config.ReadItem(&settings); | ||
return settings; | ||
} | ||
|
||
void AutoSaveSettings::Save(const AutoSaveSettings& settings) | ||
{ | ||
clConfig config("auto-save.conf"); | ||
config.WriteItem(&settings); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
////////////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright : (C) 2016 The CodeLite Team | ||
// File name : AutoSaveSettings.h | ||
// | ||
// ------------------------------------------------------------------------- | ||
// A | ||
// _____ _ _ _ _ | ||
// / __ \ | | | | (_) | | ||
// | / \/ ___ __| | ___| | _| |_ ___ | ||
// | | / _ \ / _ |/ _ \ | | | __/ _ ) | ||
// | \__/\ (_) | (_| | __/ |___| | || __/ | ||
// \____/\___/ \__,_|\___\_____/_|\__\___| | ||
// | ||
// F i l e | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation; either version 2 of the License, or | ||
// (at your option) any later version. | ||
// | ||
////////////////////////////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef AUTOSAVESETTINGS_H | ||
#define AUTOSAVESETTINGS_H | ||
|
||
#include "cl_config.h" | ||
|
||
class AutoSaveSettings : public clConfigItem | ||
{ | ||
public: | ||
enum { | ||
kEnabled = (1 << 0), | ||
}; | ||
|
||
protected: | ||
size_t m_flags; | ||
size_t m_checkInterval; | ||
|
||
public: | ||
AutoSaveSettings(); | ||
~AutoSaveSettings(); | ||
|
||
virtual void FromJSON(const JSONElement& json); | ||
virtual JSONElement ToJSON() const; | ||
|
||
static AutoSaveSettings Load(); | ||
static void Save(const AutoSaveSettings& settings); | ||
|
||
AutoSaveSettings& EnableFlag(int flag, bool b = true) | ||
{ | ||
b ? (m_flags |= flag) : (m_flags &= ~flag); | ||
return *this; | ||
} | ||
|
||
bool HasFlag(int flag) const { return m_flags & flag; } | ||
AutoSaveSettings& SetFlags(size_t flags) | ||
{ | ||
this->m_flags = flags; | ||
return *this; | ||
} | ||
size_t GetFlags() const { return m_flags; } | ||
AutoSaveSettings& SetCheckInterval(size_t checkInterval) | ||
{ | ||
this->m_checkInterval = checkInterval; | ||
return *this; | ||
} | ||
size_t GetCheckInterval() const { return m_checkInterval; } | ||
}; | ||
|
||
#endif // AUTOSAVESETTINGS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
////////////////////////////////////////////////////////////////////// | ||
// This file was auto-generated by codelite's wxCrafter Plugin | ||
// wxCrafter project file: AutoSaveUI.wxcp | ||
// Do not modify this file by hand! | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
#include "AutoSaveUI.h" | ||
|
||
|
||
// Declare the bitmap loading function | ||
extern void wxCrafter7A2fyVInitBitmapResources(); | ||
|
||
static bool bBitmapLoaded = false; | ||
|
||
|
||
AutoSaveDlgBase::AutoSaveDlgBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) | ||
: wxDialog(parent, id, title, pos, size, style) | ||
{ | ||
if ( !bBitmapLoaded ) { | ||
// We need to initialise the default bitmap handler | ||
wxXmlResource::Get()->AddHandler(new wxBitmapXmlHandler); | ||
wxCrafter7A2fyVInitBitmapResources(); | ||
bBitmapLoaded = true; | ||
} | ||
|
||
wxBoxSizer* boxSizer2 = new wxBoxSizer(wxVERTICAL); | ||
this->SetSizer(boxSizer2); | ||
|
||
wxFlexGridSizer* flexGridSizer8 = new wxFlexGridSizer(0, 2, 0, 0); | ||
flexGridSizer8->SetFlexibleDirection( wxBOTH ); | ||
flexGridSizer8->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); | ||
flexGridSizer8->AddGrowableCol(1); | ||
|
||
boxSizer2->Add(flexGridSizer8, 1, wxALL|wxEXPAND, WXC_FROM_DIP(5)); | ||
|
||
m_checkBoxEnabled = new wxCheckBox(this, wxID_ANY, _("Enable Auto Save"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), 0); | ||
m_checkBoxEnabled->SetValue(true); | ||
|
||
flexGridSizer8->Add(m_checkBoxEnabled, 0, wxALL, WXC_FROM_DIP(5)); | ||
|
||
flexGridSizer8->Add(0, 0, 1, wxALL, WXC_FROM_DIP(5)); | ||
|
||
m_staticText14 = new wxStaticText(this, wxID_ANY, _("Save interval:"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), 0); | ||
m_staticText14->SetToolTip(_("Check and save modified files interval (in seconds)")); | ||
|
||
flexGridSizer8->Add(m_staticText14, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5)); | ||
|
||
m_spinCtrlInterval = new wxSpinCtrl(this, wxID_ANY, wxT("5"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), wxSP_WRAP|wxSP_ARROW_KEYS); | ||
m_spinCtrlInterval->SetToolTip(_("Check and save modified files interval (in seconds)")); | ||
m_spinCtrlInterval->SetRange(1, 100); | ||
m_spinCtrlInterval->SetValue(5); | ||
|
||
flexGridSizer8->Add(m_spinCtrlInterval, 0, wxALL, WXC_FROM_DIP(5)); | ||
|
||
m_stdBtnSizer4 = new wxStdDialogButtonSizer(); | ||
|
||
boxSizer2->Add(m_stdBtnSizer4, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, WXC_FROM_DIP(5)); | ||
|
||
m_button6 = new wxButton(this, wxID_OK, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0); | ||
m_button6->SetDefault(); | ||
m_stdBtnSizer4->AddButton(m_button6); | ||
m_stdBtnSizer4->Realize(); | ||
|
||
SetName(wxT("AutoSaveDlgBase")); | ||
SetSize(-1,-1); | ||
if (GetSizer()) { | ||
GetSizer()->Fit(this); | ||
} | ||
if(GetParent()) { | ||
CentreOnParent(wxBOTH); | ||
} else { | ||
CentreOnScreen(wxBOTH); | ||
} | ||
// Connect events | ||
m_staticText14->Connect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(AutoSaveDlgBase::OnEnabledUI), NULL, this); | ||
m_spinCtrlInterval->Connect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(AutoSaveDlgBase::OnEnabledUI), NULL, this); | ||
m_button6->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(AutoSaveDlgBase::OnOK), NULL, this); | ||
|
||
} | ||
|
||
AutoSaveDlgBase::~AutoSaveDlgBase() | ||
{ | ||
m_staticText14->Disconnect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(AutoSaveDlgBase::OnEnabledUI), NULL, this); | ||
m_spinCtrlInterval->Disconnect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(AutoSaveDlgBase::OnEnabledUI), NULL, this); | ||
m_button6->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(AutoSaveDlgBase::OnOK), NULL, this); | ||
|
||
} |
Oops, something went wrong.