Mercurial > hg > octave-lojdl
changeset 16542:016073c0cb94
Add popdown toolbutton to files-dock-window toolbar.
* libgui/src/files-dock-widget.cc
(files_dock_widget::files_dock_widget): added popdown button to toolbar and
merged set current dir, show current dir into it as well as adding new dir
and new file option.
(files_dock_widget::display_directory): change to call process_set_current_dir
instead of emit.
(files_dock_widget::contextmenu_newfile): change to call process_new_file.
(files_dock_widget::contextmenu_newdir): Change to call process_new_dir.
(files_dock_widget::contextmenu_setcurrentdir): Change to call
process_set_current_dir.
(files_dock_widget::popdownmenu_newdir): New function.
(files_dock_widget::popdownmenu_newfile): New function.
(files_dock_widget::process_new_file): New function.
(files_dock_widget::process_new_dir): New function.
(iles_dock_widget::process_set_current_dir): New function.
* libgui/src/resource.qrc: Added icons/gear.png.
* libgui/src/module.mk: Added icons/gear.png.
* libgui/src/icons.png: New file.
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Tue, 16 Apr 2013 22:16:57 -0400 |
parents | 6afb29359968 |
children | c58069081439 |
files | libgui/src/files-dock-widget.cc libgui/src/files-dock-widget.h libgui/src/icons/gear.png libgui/src/module.mk libgui/src/resource.qrc |
diffstat | 5 files changed, 84 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/files-dock-widget.cc +++ b/libgui/src/files-dock-widget.cc @@ -39,6 +39,7 @@ #include <QMenu> #include <QInputDialog> #include <QMessageBox> +#include <QToolButton> files_dock_widget::files_dock_widget (QWidget *p) : octave_dock_widget (p) @@ -80,19 +81,35 @@ directory_up_action->setToolTip (tr ("Move up one directory")); _sync_browser_directory_action = new QAction (QIcon(":/actions/icons/reload.png"), - "", _navigation_tool_bar); + tr("Show octave directory"), _navigation_tool_bar); _sync_browser_directory_action->setToolTip (tr ("Goto current octave directory")); _sync_browser_directory_action->setEnabled ("false"); _sync_octave_directory_action = new QAction (QIcon(":/actions/icons/ok.png"), - "", _navigation_tool_bar); + tr("Set octave directory"), _navigation_tool_bar); _sync_octave_directory_action->setToolTip (tr ("Set octave directroy to current browser directory")); _sync_octave_directory_action->setEnabled ("false"); + QToolButton * popdown_button = new QToolButton(); + popdown_button->setToolTip(tr ("Actions on current directory")); + QMenu * popdown_menu = new QMenu(); + popdown_menu->addAction(_sync_browser_directory_action); + popdown_menu->addAction(_sync_octave_directory_action); + popdown_button->setMenu(popdown_menu); + popdown_button->setPopupMode(QToolButton::InstantPopup); + popdown_button->setDefaultAction(new QAction(QIcon(":/actions/icons/gear.png"),"", _navigation_tool_bar)); + + popdown_menu->addSeparator(); + popdown_menu->addAction(QIcon(":/actions/icons/filenew.png"), + tr ("New File"), + this, SLOT(popdownmenu_newfile(bool))); + popdown_menu->addAction(QIcon(":/actions/icons/folder_new.png"), + tr ("New Directory"), + this, SLOT(popdownmenu_newdir(bool))); + _navigation_tool_bar->addWidget (_current_directory); _navigation_tool_bar->addAction (directory_up_action); - _navigation_tool_bar->addAction (_sync_browser_directory_action); - _navigation_tool_bar->addAction (_sync_octave_directory_action); + _navigation_tool_bar->addWidget (popdown_button); connect (directory_up_action, SIGNAL (triggered ()), this, SLOT (change_directory_up ())); @@ -101,8 +118,6 @@ connect (_sync_browser_directory_action, SIGNAL (triggered ()), this, SLOT (do_sync_browser_directory ())); - // TODO: Add other buttons for creating directories - // Create the QFileSystemModel starting in the actual directory QDir curr_dir; _file_system_model = new QFileSystemModel (this); @@ -252,7 +267,7 @@ _file_system_model->setRootPath (fileInfo.absoluteFilePath ()); _file_system_model->sort (0, Qt::AscendingOrder); if (_sync_octave_dir && set_octave_dir) - emit displayed_directory_changed (fileInfo.absoluteFilePath ()); + process_set_current_dir(fileInfo.absoluteFilePath ()); // see if its in the list, and if it is, remove it and then, put at top of the list int index = _current_directory->findText(fileInfo.absoluteFilePath ()); @@ -449,18 +464,8 @@ QFileInfo info = _file_system_model->fileInfo(index); QString parent_dir = info.filePath(); - bool ok; - QString name = QInputDialog::getText (this, tr("Create File"), tr("Create file in\n") + parent_dir, - QLineEdit::Normal, "New File.txt", &ok); - if(ok && name.length()>0) - { - name = parent_dir + "/" + name; - - QFile file(name); - file.open(QIODevice::WriteOnly); - _file_system_model->revert(); - } + process_new_file(parent_dir); } } @@ -476,14 +481,8 @@ QFileInfo info = _file_system_model->fileInfo(index); QString parent_dir = info.filePath(); - bool ok; - QString name = QInputDialog::getText (this, tr("Create Directory"), tr("Create folder in\n") + parent_dir, - QLineEdit::Normal, "New Directory", &ok); - if(ok && name.length()>0) - { - _file_system_model->mkdir(index, name); - } + process_new_dir(parent_dir); } } @@ -501,7 +500,7 @@ if(info.isDir()) { - emit displayed_directory_changed (info.absoluteFilePath ()); + process_set_current_dir(info.absoluteFilePath ()); } } } @@ -535,3 +534,53 @@ display_directory (_octave_dir); // sync browser to octave dir } + +void +files_dock_widget::popdownmenu_newdir (bool) +{ + process_new_dir(_file_system_model->rootPath()); +} + +void +files_dock_widget::popdownmenu_newfile (bool) +{ + process_new_file(_file_system_model->rootPath()); +} + +void +files_dock_widget::process_new_file (const QString &parent_dir) +{ + bool ok; + + QString name = QInputDialog::getText (this, tr("Create File"), tr("Create file in\n") + parent_dir, + QLineEdit::Normal, "New File.txt", &ok); + if(ok && name.length()>0) + { + name = parent_dir + "/" + name; + + QFile file(name); + file.open(QIODevice::WriteOnly); + _file_system_model->revert(); + } +} + +void +files_dock_widget::process_new_dir (const QString &parent_dir) +{ + bool ok; + + QString name = QInputDialog::getText (this, tr("Create Directory"), tr("Create folder in\n") + parent_dir, + QLineEdit::Normal, "New Directory", &ok); + if(ok && name.length()>0) + { + QDir dir(parent_dir); + dir.mkdir(name); + _file_system_model->revert(); + } +} + +void files_dock_widget::process_set_current_dir(const QString & dir) +{ + emit displayed_directory_changed (dir); +} +
--- a/libgui/src/files-dock-widget.h +++ b/libgui/src/files-dock-widget.h @@ -93,6 +93,10 @@ void contextmenu_newdir (bool); void contextmenu_setcurrentdir (bool); + /* popdown menu options */ + void popdownmenu_newfile(bool); + void popdownmenu_newdir(bool); + signals: /** Emitted, whenever the user requested to open a file. */ @@ -108,8 +112,9 @@ void run_file_signal (const QString& fileName); private: - - // TODO: Add toolbar with buttons for navigating the path, creating dirs, etc + void process_new_file(const QString &parent_name); + void process_new_dir(const QString &parent_name); + void process_set_current_dir(const QString &parent_name); /** set a new directory or open a file **/ void display_directory (const QString& dir, bool set_octave_dir = true);
new file mode 100755 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..430a62341c613b35c9dddc9bfa359615b2e60b39 GIT binary patch literal 2373 zc$@)63A*-)P)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F800006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3labT3lag+-G2N4000McNliru(+U>~B^h21PFDZ`2+~PJ zK~#9!)mLe3T-6o+?!9lFeesO#7~Am{3~mCXNk~G{B0^dyEvPJ|i>NA9T~rl;P^GF; zDXj`ENTm`jC8(v)0zxzp$_|0BxdfclByr+8n={^*u|1n-dGoe=`(wtzAt4E<e|rAR z%$s}P`OZ1t`OduzXRxlX{e*DaQv7vGy`E@;X693ta2@=wjGbx0>hJ&dvI}qg=}nCr zZn&xG(yxEn%B6bKgCFFUU2~gf_05lLrcCiWW^vBUCHbcTKtB2)*whI^Da#HIxbd#_ zWc4q$y*#)ye#LZzAXWt0cOTwv92>Y#i??~pt*!T#H5O*a61$zz;d>8nz2mLi@SgG~ z0U&+!!4>zsyhK*LS08+S%iF{6y)f$7q4;D!LH-K_1qEO$+BO9nmn=s~Sfh37lF2$* ziq(B)Q;SJ+vK}}9U;=>nR3*6Z+qZ{m)^C1zxHf#N|NM(@Xk32TTEic_a5OCIZj?X} zARVA|DyI6!Yt&HA!)N-9t@<HUo37FpK9`vXlY_4aG-s)M8y3S)cuS(PBXw2OW5 zuIIj!Sk}5_Ux>&u2cl&mibNpor36AiowMLel%QozNUnhJO0eP@N;L|EBB5@~Flzcn zcDS-aT+J6O^>^QY@R4tA6Wn#rTmnKgs`=I>dLUaJfYl5X6+%D=XwgNidlsSL9Awu5 zNF^vjDWt;;vaZ5x3}B|kug_iD@f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