Browse Source

Solves #159, added option to save project files on compile/run

merge-requests/365/head
eidheim 10 years ago
parent
commit
46bb7da234
  1. 1
      src/config.cc
  2. 1
      src/config.h
  3. 5
      src/files.h
  4. 13
      src/notebook.cc
  5. 1
      src/notebook.h
  6. 10
      src/window.cc

1
src/config.cc

@ -84,6 +84,7 @@ void Config::retrieve_config() {
window.theme_variant=cfg.get<std::string>("gtk_theme.variant"); window.theme_variant=cfg.get<std::string>("gtk_theme.variant");
window.version = cfg.get<std::string>("version"); window.version = cfg.get<std::string>("version");
window.default_size = {cfg.get<int>("default_window_size.width"), cfg.get<int>("default_window_size.height")}; window.default_size = {cfg.get<int>("default_window_size.width"), cfg.get<int>("default_window_size.height")};
window.save_on_compile_or_run=cfg.get<bool>("project.save_on_compile_or_run");
terminal.default_build_path=cfg.get<std::string>("project.default_build_path"); terminal.default_build_path=cfg.get<std::string>("project.default_build_path");
terminal.debug_build_path=cfg.get<std::string>("project.debug_build_path"); terminal.debug_build_path=cfg.get<std::string>("project.debug_build_path");

1
src/config.h

@ -20,6 +20,7 @@ public:
std::string theme_variant; std::string theme_variant;
std::string version; std::string version;
std::pair<int, int> default_size; std::pair<int, int> default_size;
bool save_on_compile_or_run;
}; };
class Terminal { class Terminal {

5
src/files.h

@ -2,7 +2,7 @@
#define JUCI_FILES_H_ #define JUCI_FILES_H_
#include <string> #include <string>
#define JUCI_VERSION "1.1.0-4" #define JUCI_VERSION "1.1.0-5"
const std::string configjson = const std::string configjson =
"{\n" "{\n"
@ -130,7 +130,8 @@ const std::string configjson =
#else #else
" \"cmake_command\": \"cmake\",\n" " \"cmake_command\": \"cmake\",\n"
#endif #endif
" \"make_command\": \"cmake --build .\"\n" " \"make_command\": \"cmake --build .\",\n"
" \"save_on_compile_or_run\": false"
" },\n" " },\n"
" \"documentation_searches\": {\n" " \"documentation_searches\": {\n"
" \"clang\": {\n" " \"clang\": {\n"

13
src/notebook.cc

@ -283,6 +283,19 @@ bool Notebook::save_current() {
return save(get_current_page()); return save(get_current_page());
} }
void Notebook::save_project_files() {
if(get_current_page()==-1)
return;
auto current_view=get_current_view();
for(int c=0;c<size();c++) {
auto view=get_view(c);
if(view->get_buffer()->get_modified()) {
if(current_view->project_path==view->project_path)
save(c);
}
}
}
bool Notebook::close(int page) { bool Notebook::close(int page) {
JDEBUG("start"); JDEBUG("start");
if (page!=-1) { if (page!=-1) {

1
src/notebook.h

@ -27,6 +27,7 @@ public:
void open(const boost::filesystem::path &file_path); void open(const boost::filesystem::path &file_path);
bool save(int page); bool save(int page);
bool save_current(); bool save_current();
void save_project_files();
void configure(int view_nr); void configure(int view_nr);
boost::filesystem::path get_current_folder(); boost::filesystem::path get_current_folder();

10
src/window.cc

@ -640,6 +640,9 @@ void Window::set_menu_actions() {
if(compiling) if(compiling)
return; return;
if(Config::get().window.save_on_compile_or_run)
notebook.save_project_files();
auto cmake=get_cmake(); auto cmake=get_cmake();
if(!cmake) if(!cmake)
return; return;
@ -687,6 +690,10 @@ void Window::set_menu_actions() {
menu.add_action("compile", [this]() { menu.add_action("compile", [this]() {
if(compiling) if(compiling)
return; return;
if(Config::get().window.save_on_compile_or_run)
notebook.save_project_files();
auto cmake=get_cmake(); auto cmake=get_cmake();
if(!cmake) if(!cmake)
return; return;
@ -789,6 +796,9 @@ void Window::set_menu_actions() {
return; return;
} }
if(Config::get().window.save_on_compile_or_run)
notebook.save_project_files();
auto cmake=get_cmake(); auto cmake=get_cmake();
if(!cmake) if(!cmake)
return; return;

Loading…
Cancel
Save