Mercurial > hg > octave-lyh
comparison libgui/src/files-dock-widget.cc @ 16507:8cb12cf9ca32
gui: add icons to the context menu of the the file browser
* files-dock-widget.cc(contextmenu_requested): add icons to some menu actions,
show all menu entries but disable entries that are not applicable
* icons/editdelete.png, icons/folder_new.png: new files
* libgui/src/module.mk,resource.qrc: added icons editdelete.png, folder_new.png
author | Torsten <ttl@justmail.de> |
---|---|
date | Fri, 12 Apr 2013 22:40:20 +0200 |
parents | 8a4960f2c7c3 |
children | 14045b872a3d |
comparison
equal
deleted
inserted
replaced
16506:8a4960f2c7c3 | 16507:8cb12cf9ca32 |
---|---|
283 | 283 |
284 if (index.isValid()) | 284 if (index.isValid()) |
285 { | 285 { |
286 QFileInfo info = _file_system_model->fileInfo(index); | 286 QFileInfo info = _file_system_model->fileInfo(index); |
287 | 287 |
288 menu.addAction(tr("Open"), this, SLOT(contextmenu_open(bool))); | 288 menu.addAction(QIcon(":/actions/icons/fileopen.png"), tr("Open"), |
289 menu.addAction(QIcon(":/actions/icons/artsbuilderexecute.png"), tr("Run"), this, SLOT(contextmenu_run(bool))); | 289 this, SLOT(contextmenu_open(bool))); |
290 menu.addAction(tr("Load Data"), this, SLOT(contextmenu_load(bool))); | 290 QAction *run_action = menu.addAction( |
291 QIcon(":/actions/icons/artsbuilderexecute.png"), tr("Run"), | |
292 this, SLOT(contextmenu_run(bool))); | |
293 run_action->setEnabled (info.isFile () && info.suffix () == "m"); | |
294 QAction *load_action = menu.addAction(tr("Load Data"), | |
295 this, SLOT(contextmenu_load(bool))); | |
296 load_action->setEnabled (info.isFile ()); | |
297 | |
291 menu.addSeparator(); | 298 menu.addSeparator(); |
292 menu.addAction(tr("Rename"), this, SLOT(contextmenu_rename(bool))); | 299 menu.addAction(tr("Rename"), this, SLOT(contextmenu_rename(bool))); |
293 menu.addAction(tr("Delete"), this, SLOT(contextmenu_delete(bool))); | 300 menu.addAction(QIcon(":/actions/icons/editdelete.png"), tr("Delete"), |
294 | 301 this, SLOT(contextmenu_delete(bool))); |
295 if(info.isDir()) | 302 |
296 { | 303 menu.addSeparator(); |
297 menu.addSeparator(); | 304 QAction *new_file_action = menu.addAction( |
298 menu.addAction(tr("New File"), this, SLOT(contextmenu_newfile(bool))); | 305 QIcon(":/actions/icons/filenew.png"), |
299 menu.addAction(tr("New Directory"), this, SLOT(contextmenu_newdir(bool))); | 306 tr("New File"), this, SLOT(contextmenu_newfile(bool))); |
300 } | 307 new_file_action->setEnabled (info.isDir()); |
308 QAction *new_dir_action = menu.addAction( | |
309 QIcon(":/actions/icons/folder_new.png"), | |
310 tr("New Directory"), this, SLOT(contextmenu_newdir(bool))); | |
311 new_dir_action->setEnabled (info.isDir()); | |
301 | 312 |
302 menu.exec(_file_tree_view->mapToGlobal(mpos)); | 313 menu.exec(_file_tree_view->mapToGlobal(mpos)); |
303 | 314 |
304 } | 315 } |
305 } | 316 } |
343 { | 354 { |
344 QModelIndex index = rows[0]; | 355 QModelIndex index = rows[0]; |
345 | 356 |
346 QFileInfo info = _file_system_model->fileInfo(index); | 357 QFileInfo info = _file_system_model->fileInfo(index); |
347 | 358 |
348 if (info.isFile() && info.suffix () == "m") | 359 QString function_name = info.fileName (); |
349 { | 360 // We have to cut off the suffix, because octave appends it. |
350 QString function_name = info.fileName (); | 361 function_name.chop (info.suffix ().length () + 1); |
351 // We have to cut off the suffix, because octave appends it. | 362 emit run_file_signal (QString ("cd \'%1\'\n%2\n") |
352 function_name.chop (info.suffix ().length () + 1); | |
353 emit run_file_signal (QString ("cd \'%1\'\n%2\n") | |
354 .arg(info.absolutePath ()).arg (function_name)); | 363 .arg(info.absolutePath ()).arg (function_name)); |
355 } | |
356 } | 364 } |
357 } | 365 } |
358 | 366 |
359 void | 367 void |
360 files_dock_widget::contextmenu_rename (bool) | 368 files_dock_widget::contextmenu_rename (bool) |