# HG changeset patch # User hassan Radi # Date 1369008492 -7200 # Node ID 2c68c1e49809016b44ca69f1095451254e932adb # Parent c19cc8c158b3c95174841020f05389db52beec8b - Added a new profiler button to the Main Window class. - Clicking on the Profiler button toggles between turning the profiler ON or OFF. - The user can choose whether to start a new profiling session or to resume the old one diff -r c19cc8c158b3 -r 2c68c1e49809 libgui/src/icons/profiler.png Binary file libgui/src/icons/profiler.png has changed diff -r c19cc8c158b3 -r 2c68c1e49809 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Sat May 18 23:00:19 2013 -0400 +++ b/libgui/src/main-window.cc Mon May 20 02:08:12 2013 +0200 @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -1328,6 +1329,37 @@ } void +main_window::set_profiler_state (void) +{ + if(_profiler_on == true) + { + // stop the profiler + _octave_qt_link->do_execute_command_in_terminal("profile off"); + // set the flag + _profiler_on = false; + }else{ + // display menu to let the user choose how to start the profiling session + _profiler_menu->popup(QCursor::pos()); + // set the flag + _profiler_on = true; + } +} + +void +main_window::start_new_profiling_session(void) +{ + // clear the previous profiling session data and turn on the profiler + _octave_qt_link->do_execute_command_in_terminal("profile clear\nprofile on"); +} + +void +main_window::append_to_previous_session(void) +{ + // resume the previous profiling session + _octave_qt_link->do_execute_command_in_terminal("profile resume"); +} + +void main_window::construct_tool_bar (void) { _main_tool_bar = addToolBar ("Main"); @@ -1364,6 +1396,25 @@ QAction *current_dir_search = _main_tool_bar->addAction ( QIcon (":/actions/icons/search.png"), tr ("Browse directories")); + + _profiler_menu = new QMenu("Turn profiler on/off", this); + _profiler_menu->setIcon(QIcon(":/actions/icons/profiler.png")); + _start_new_profiler_session = _profiler_menu->addAction("Start a new profiling session"); + _append_to_previous_profiler_session = _profiler_menu->addAction("Append to previous session"); + addAction(_profiler_menu->menuAction()); + + QAction *profiler_state = _main_tool_bar->addAction ( + QIcon (":/actions/icons/profiler.png"), + tr ("Turn profiler on/off")); + + connect (profiler_state, SIGNAL (triggered ()), + this, SLOT (set_profiler_state())); + + connect (_start_new_profiler_session, SIGNAL (triggered ()), + this, SLOT (start_new_profiling_session())); + + connect (_append_to_previous_profiler_session, SIGNAL (triggered ()), + this, SLOT (append_to_previous_session())); connect (_current_directory_combo_box, SIGNAL (activated (QString)), this, SLOT (set_current_working_directory (QString))); diff -r c19cc8c158b3 -r 2c68c1e49809 libgui/src/main-window.h --- a/libgui/src/main-window.h Sat May 18 23:00:19 2013 -0400 +++ b/libgui/src/main-window.h Mon May 20 02:08:12 2013 +0200 @@ -117,6 +117,9 @@ void set_current_working_directory (const QString& dir); void change_directory_up (void); void accept_directory_line_edit (void); + void set_profiler_state (void); + void start_new_profiling_session(void); + void append_to_previous_session(void); void execute_command_in_terminal(const QString& dir); void run_file_in_terminal(const QFileInfo& info); @@ -252,6 +255,7 @@ QToolBar *_main_tool_bar; QMenu *_debug_menu; + QMenu *_profiler_menu; QAction *_debug_continue; QAction *_debug_step_into; @@ -265,6 +269,9 @@ QAction *_copy_action; QAction *_paste_action; QAction *_undo_action; + + QAction *_start_new_profiler_session; + QAction *_append_to_previous_profiler_session; // Toolbars. QComboBox *_current_directory_combo_box; @@ -280,6 +287,9 @@ octave_qt_link *_octave_qt_link; + // Flag for profiler state + bool _profiler_on = false; + // Flag for closing whole application. bool _closing; }; diff -r c19cc8c158b3 -r 2c68c1e49809 libgui/src/resource.qrc --- a/libgui/src/resource.qrc Sat May 18 23:00:19 2013 -0400 +++ b/libgui/src/resource.qrc Mon May 20 02:08:12 2013 +0200 @@ -1,5 +1,6 @@ + icons/profiler.png icons/artsbuilderexecute.png icons/editcopy.png icons/editcut.png