Browse Source

Moved project configs to Config::project

merge-requests/365/head
eidheim 10 years ago
parent
commit
1f6661aa56
  1. 10
      src/cmake.cc
  2. 14
      src/config.cc
  3. 11
      src/config.h
  4. 6
      src/project.cc
  5. 6
      src/window.cc

10
src/cmake.cc

@ -36,7 +36,7 @@ CMake::CMake(const boost::filesystem::path &path) {
} }
boost::filesystem::path CMake::get_default_build_path(const boost::filesystem::path &project_path) { boost::filesystem::path CMake::get_default_build_path(const boost::filesystem::path &project_path) {
boost::filesystem::path default_build_path=Config::get().terminal.default_build_path; boost::filesystem::path default_build_path=Config::get().project.default_build_path;
const std::string path_variable_project_directory_name="<project_directory_name>"; const std::string path_variable_project_directory_name="<project_directory_name>";
size_t pos=0; size_t pos=0;
@ -56,7 +56,7 @@ boost::filesystem::path CMake::get_default_build_path(const boost::filesystem::p
} }
boost::filesystem::path CMake::get_debug_build_path(const boost::filesystem::path &project_path) { boost::filesystem::path CMake::get_debug_build_path(const boost::filesystem::path &project_path) {
boost::filesystem::path debug_build_path=Config::get().terminal.debug_build_path; boost::filesystem::path debug_build_path=Config::get().project.debug_build_path;
const std::string path_variable_project_directory_name="<project_directory_name>"; const std::string path_variable_project_directory_name="<project_directory_name>";
size_t pos=0; size_t pos=0;
@ -72,7 +72,7 @@ boost::filesystem::path CMake::get_debug_build_path(const boost::filesystem::pat
const std::string path_variable_default_build_path="<default_build_path>"; const std::string path_variable_default_build_path="<default_build_path>";
pos=0; pos=0;
debug_build_path_string=debug_build_path.string(); debug_build_path_string=debug_build_path.string();
auto default_build_path=Config::get().terminal.default_build_path; auto default_build_path=Config::get().project.default_build_path;
while((pos=debug_build_path_string.find(path_variable_default_build_path, pos))!=std::string::npos) { while((pos=debug_build_path_string.find(path_variable_default_build_path, pos))!=std::string::npos) {
debug_build_path_string.replace(pos, path_variable_default_build_path.size(), default_build_path); debug_build_path_string.replace(pos, path_variable_default_build_path.size(), default_build_path);
pos+=default_build_path.size(); pos+=default_build_path.size();
@ -112,7 +112,7 @@ bool CMake::create_default_build(const boost::filesystem::path &project_path, bo
auto compile_commands_path=default_build_path/"compile_commands.json"; auto compile_commands_path=default_build_path/"compile_commands.json";
Dialog::Message message("Creating/updating default build"); Dialog::Message message("Creating/updating default build");
auto exit_status=Terminal::get().process(Config::get().terminal.cmake_command+" "+ auto exit_status=Terminal::get().process(Config::get().project.cmake_command+" "+
filesystem::escape_argument(project_path)+" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON", default_build_path); filesystem::escape_argument(project_path)+" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON", default_build_path);
message.hide(); message.hide();
if(exit_status==EXIT_SUCCESS) { if(exit_status==EXIT_SUCCESS) {
@ -162,7 +162,7 @@ bool CMake::create_debug_build(const boost::filesystem::path &project_path) {
std::unique_ptr<Dialog::Message> message; std::unique_ptr<Dialog::Message> message;
message=std::unique_ptr<Dialog::Message>(new Dialog::Message("Creating/updating debug build")); message=std::unique_ptr<Dialog::Message>(new Dialog::Message("Creating/updating debug build"));
auto exit_status=Terminal::get().process(Config::get().terminal.cmake_command+" "+ auto exit_status=Terminal::get().process(Config::get().project.cmake_command+" "+
filesystem::escape_argument(project_path)+" -DCMAKE_BUILD_TYPE=Debug", debug_build_path); filesystem::escape_argument(project_path)+" -DCMAKE_BUILD_TYPE=Debug", debug_build_path);
if(message) if(message)
message->hide(); message->hide();

14
src/config.cc

@ -84,15 +84,15 @@ 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"); project.save_on_compile_or_run=cfg.get<bool>("project.save_on_compile_or_run");
terminal.debug_build_path=cfg.get<std::string>("project.debug_build_path"); project.default_build_path=cfg.get<std::string>("project.default_build_path");
terminal.make_command=cfg.get<std::string>("project.make_command"); project.debug_build_path=cfg.get<std::string>("project.debug_build_path");
terminal.cmake_command=cfg.get<std::string>("project.cmake_command"); project.make_command=cfg.get<std::string>("project.make_command");
terminal.history_size=cfg.get<int>("terminal_history_size"); project.cmake_command=cfg.get<std::string>("project.cmake_command");
terminal.clang_format_command=cfg.get<std::string>("project.clang_format_command", "clang-format"); terminal.history_size=cfg.get<int>("terminal_history_size");
terminal.clang_format_command="clang-format";
#ifdef __linux #ifdef __linux
if(terminal.clang_format_command=="clang-format" && if(terminal.clang_format_command=="clang-format" &&
!boost::filesystem::exists("/usr/bin/clang-format") && !boost::filesystem::exists("/usr/local/bin/clang-format")) { !boost::filesystem::exists("/usr/bin/clang-format") && !boost::filesystem::exists("/usr/local/bin/clang-format")) {

11
src/config.h

@ -20,17 +20,21 @@ 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 {
public:
std::string clang_format_command;
int history_size;
};
class Project {
public: public:
std::string default_build_path; std::string default_build_path;
std::string debug_build_path; std::string debug_build_path;
std::string cmake_command; std::string cmake_command;
std::string make_command; std::string make_command;
std::string clang_format_command; bool save_on_compile_or_run;
int history_size;
}; };
class Source { class Source {
@ -74,6 +78,7 @@ public:
Menu menu; Menu menu;
Window window; Window window;
Terminal terminal; Terminal terminal;
Project project;
Source source; Source source;
const boost::filesystem::path& juci_home_path() const { return home; } const boost::filesystem::path& juci_home_path() const { return home; }

6
src/project.cc

@ -141,7 +141,7 @@ void Project::Clang::compile() {
return; return;
compiling=true; compiling=true;
Terminal::get().print("Compiling project "+cmake->project_path.string()+"\n"); Terminal::get().print("Compiling project "+cmake->project_path.string()+"\n");
Terminal::get().async_process(Config::get().terminal.make_command, default_build_path, [this](int exit_status) { Terminal::get().async_process(Config::get().project.make_command, default_build_path, [this](int exit_status) {
compiling=false; compiling=false;
}); });
} }
@ -178,7 +178,7 @@ void Project::Clang::compile_and_run() {
compiling=true; compiling=true;
Terminal::get().print("Compiling and running "+arguments+"\n"); Terminal::get().print("Compiling and running "+arguments+"\n");
Terminal::get().async_process(Config::get().terminal.make_command, default_build_path, [this, arguments, default_build_path](int exit_status){ Terminal::get().async_process(Config::get().project.make_command, default_build_path, [this, arguments, default_build_path](int exit_status){
compiling=false; compiling=false;
if(exit_status==EXIT_SUCCESS) { if(exit_status==EXIT_SUCCESS) {
Terminal::get().async_process(arguments, default_build_path, [this, arguments](int exit_status){ Terminal::get().async_process(arguments, default_build_path, [this, arguments](int exit_status){
@ -266,7 +266,7 @@ void Project::Clang::debug_start() {
debugging=true; debugging=true;
Terminal::get().print("Compiling and debugging "+run_arguments+"\n"); Terminal::get().print("Compiling and debugging "+run_arguments+"\n");
Terminal::get().async_process(Config::get().terminal.make_command, debug_build_path, [this, breakpoints, run_arguments, debug_build_path](int exit_status){ Terminal::get().async_process(Config::get().project.make_command, debug_build_path, [this, breakpoints, run_arguments, debug_build_path](int exit_status){
if(exit_status!=EXIT_SUCCESS) if(exit_status!=EXIT_SUCCESS)
debugging=false; debugging=false;
else { else {

6
src/window.cc

@ -534,7 +534,7 @@ void Window::set_menu_actions() {
if(Project::compiling || Project::debugging) if(Project::compiling || Project::debugging)
return; return;
if(Config::get().window.save_on_compile_or_run) if(Config::get().project.save_on_compile_or_run)
notebook.save_project_files(); notebook.save_project_files();
project_language=Project::get_language(); project_language=Project::get_language();
@ -544,7 +544,7 @@ void Window::set_menu_actions() {
if(Project::compiling || Project::debugging) if(Project::compiling || Project::debugging)
return; return;
if(Config::get().window.save_on_compile_or_run) if(Config::get().project.save_on_compile_or_run)
notebook.save_project_files(); notebook.save_project_files();
project_language=Project::get_language(); project_language=Project::get_language();
@ -619,7 +619,7 @@ void Window::set_menu_actions() {
return; return;
} }
if(Config::get().window.save_on_compile_or_run) if(Config::get().project.save_on_compile_or_run)
notebook.save_project_files(); notebook.save_project_files();
project_language=Project::get_language(); project_language=Project::get_language();

Loading…
Cancel
Save