Skip to content

Commit

Permalink
afwatch uses "open_folder_cmd" from config.
Browse files Browse the repository at this point in the history
Closes #529.
  • Loading branch information
timurhai committed Feb 27, 2023
1 parent 1aa3cb0 commit b71e0a4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
9 changes: 4 additions & 5 deletions afanasy/src/include/afanasy.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ namespace AFGENERAL
{
#ifdef WINNT
const char STORE_FOLDER[] = "\\afanasy";
const char OPEN_FOLDER_CMD[] = "explorer";
const char PATH_SEPARATOR = '\\';
#else
const char STORE_FOLDER[] = "/var/tmp/afanasy";
const char OPEN_FOLDER_CMD[] = "openfolder";
const char PATH_SEPARATOR = '/';
#endif

const char TIME_FORMAT[] = "%a %d %b %H:%M.%S"; ///< Default time output format.
Expand All @@ -36,11 +40,6 @@ const int MAX_RUNNING_TASKS = -1; ///< Default maximum running tasks numbe
const int MAX_RUN_TASKS_PER_HOST = -1; ///< Default maximum running tasks per host.
const int JOBS_LIFE_TIME = -1; ///< Default user jobs life time.
const int FILE_NAME_SIZE_MAX = 250; ///< Maximum filename size.
#ifdef WINNT
const char PATH_SEPARATOR = '\\';
#else
const char PATH_SEPARATOR = '/';
#endif
const char FILENAME_INVALID_CHARACTERS[] = "\"\\ /|!$&?()[]{}*^<>%`',:;";
const size_t FILENAME_INVALID_CHARACTERS_LENGTH = strlen(FILENAME_INVALID_CHARACTERS);
const char FILENAME_INVALID_CHARACTER_REPLACE = '_';
Expand Down
3 changes: 3 additions & 0 deletions afanasy/src/libafanasy/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ std::string Environment::rules_url;
std::vector<std::string> Environment::projects_root;
std::vector<std::string> Environment::render_windowsmustdie;

std::string Environment::open_folder_cmd = AFGENERAL::OPEN_FOLDER_CMD;

std::string Environment::cmd_shell = AFRENDER::CMD_SHELL;

std::string Environment::render_cmd_reboot = AFRENDER::CMD_REBOOT;
Expand Down Expand Up @@ -239,6 +241,7 @@ void Environment::getVars( const JSON * i_obj)
getVar( i_obj, timeformat, "timeformat" );
getVar( i_obj, previewcmds, "previewcmds" );
getVar( i_obj, annotations, "annotations" );
getVar( i_obj, open_folder_cmd, "open_folder_cmd" );
getVar( i_obj, cmd_shell, "cmd_shell" );
getVar( i_obj, icons_path, "icons_path" );

Expand Down
4 changes: 4 additions & 0 deletions afanasy/src/libafanasy/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ class Environment

static inline int getWOLWakeInterval() { return wolwake_interval; }

static inline std::string & getOpenFolderCmd() {return open_folder_cmd;}

static inline std::string & getCmdShell() { return cmd_shell;}

static inline int getRenderNice() { return render_nice; }
Expand Down Expand Up @@ -334,6 +336,8 @@ class Environment
static int render_nice; ///< Render task process nice factor.
static std::vector<std::string> render_windowsmustdie;

static std::string open_folder_cmd;

static std::string cmd_shell;
static std::string render_cmd_reboot;
static std::string render_cmd_shutdown;
Expand Down
10 changes: 4 additions & 6 deletions afanasy/src/watch/watch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,10 @@ void Watch::browseFolder( const QString & i_folder, const QString & i_wdir)
}

Watch::displayInfo( QString("Opening '%1'").arg( dir.path().toUtf8().data()));
#ifdef WINNT
QString cmd = "explorer";
#else
QString cmd = "openfolder";
#endif
cmd += " \"" + i_folder + "\"";

QString cmd = afqt::stoq(af::Environment::getOpenFolderCmd());
cmd = cmd.replace("@PATH@", i_folder);

Watch::startProcess( cmd, i_wdir);
}

Expand Down

0 comments on commit b71e0a4

Please sign in to comment.