comparison libgui/src/main-window.cc @ 15367:501a9cc2c68f

maint: whitespace cleanup in GUI code
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Wed, 12 Sep 2012 16:34:39 -0400
parents b4c32f245da7
children 36ececf69385
comparison
equal deleted inserted replaced
15366:d4e3f29aa499 15367:501a9cc2c68f
99 99
100 void 100 void
101 main_window::handle_save_workspace_request () 101 main_window::handle_save_workspace_request ()
102 { 102 {
103 QString selectedFile = 103 QString selectedFile =
104 QFileDialog::getSaveFileName (this, tr ("Save Workspace"), 104 QFileDialog::getSaveFileName (this, tr ("Save Workspace"),
105 resource_manager::get_home_path ()); 105 resource_manager::get_home_path ());
106 if (!selectedFile.isEmpty ()) 106 if (!selectedFile.isEmpty ())
107 { 107 {
108 octave_link::instance () 108 octave_link::instance ()
109 ->post_event (new octave_save_workspace_event (*this, 109 ->post_event (new octave_save_workspace_event (*this,
110 selectedFile.toStdString())); 110 selectedFile.toStdString()));
111 } 111 }
112 } 112 }
113 113
114 void 114 void
115 main_window::handle_load_workspace_request () 115 main_window::handle_load_workspace_request ()
116 { 116 {
117 QString selectedFile = 117 QString selectedFile =
118 QFileDialog::getOpenFileName (this, tr ("Load Workspace"), 118 QFileDialog::getOpenFileName (this, tr ("Load Workspace"),
119 resource_manager::get_home_path ()); 119 resource_manager::get_home_path ());
120 if (!selectedFile.isEmpty ()) 120 if (!selectedFile.isEmpty ())
121 { 121 {
122 octave_link::instance () 122 octave_link::instance ()
123 ->post_event (new octave_load_workspace_event (*this, 123 ->post_event (new octave_load_workspace_event (*this,
124 selectedFile.toStdString())); 124 selectedFile.toStdString()));
125 } 125 }
126 } 126 }
127 127
128 void 128 void
129 main_window::handle_clear_workspace_request () 129 main_window::handle_clear_workspace_request ()
130 { 130 {
131 octave_link::instance () 131 octave_link::instance ()
132 ->post_event (new octave_clear_workspace_event (*this)); 132 ->post_event (new octave_clear_workspace_event (*this));
133 } 133 }
134 134
135 void 135 void
136 main_window::handle_clear_history_request() 136 main_window::handle_clear_history_request()
137 { 137 {
138 octave_link::instance () 138 octave_link::instance ()
139 ->post_event (new octave_clear_history_event (*this)); 139 ->post_event (new octave_clear_history_event (*this));
140 } 140 }
141 141
142 void 142 void
143 main_window::handle_command_double_clicked (const QString& command) 143 main_window::handle_command_double_clicked (const QString& command)
144 { 144 {
231 231
232 void 232 void
233 main_window::change_current_working_directory () 233 main_window::change_current_working_directory ()
234 { 234 {
235 QString selectedDirectory = 235 QString selectedDirectory =
236 QFileDialog::getExistingDirectory(this, tr ("Set working direcotry")); 236 QFileDialog::getExistingDirectory(this, tr ("Set working direcotry"));
237 237
238 if (!selectedDirectory.isEmpty ()) 238 if (!selectedDirectory.isEmpty ())
239 { 239 {
240 octave_link::instance () 240 octave_link::instance ()
241 ->post_event (new octave_change_directory_event (*this, 241 ->post_event (new octave_change_directory_event (*this,
242 selectedDirectory.toStdString ())); 242 selectedDirectory.toStdString ()));
243 } 243 }
244 } 244 }
245 245
246 void 246 void
247 main_window::set_current_working_directory (const QString& directory) 247 main_window::set_current_working_directory (const QString& directory)
248 { 248 {
249 octave_link::instance () 249 octave_link::instance ()
250 ->post_event (new octave_change_directory_event (*this, 250 ->post_event (new octave_change_directory_event (*this,
251 directory.toStdString ())); 251 directory.toStdString ()));
252 } 252 }
253 253
254 void 254 void
255 main_window::current_working_directory_up () 255 main_window::current_working_directory_up ()
256 { 256 {
365 365
366 void 366 void
367 main_window::debug_continue () 367 main_window::debug_continue ()
368 { 368 {
369 octave_link::instance () 369 octave_link::instance ()
370 ->post_event (new octave_debug_continue_event (*this)); 370 ->post_event (new octave_debug_continue_event (*this));
371 } 371 }
372 372
373 void 373 void
374 main_window::debug_step_into () 374 main_window::debug_step_into ()
375 { 375 {
376 octave_link::instance () 376 octave_link::instance ()
377 ->post_event (new octave_debug_step_into_event (*this)); 377 ->post_event (new octave_debug_step_into_event (*this));
378 } 378 }
379 379
380 void 380 void
381 main_window::debug_step_over () 381 main_window::debug_step_over ()
382 { 382 {
383 octave_link::instance () 383 octave_link::instance ()
384 ->post_event (new octave_debug_step_over_event (*this)); 384 ->post_event (new octave_debug_step_over_event (*this));
385 } 385 }
386 386
387 void 387 void
388 main_window::debug_step_out () 388 main_window::debug_step_out ()
389 { 389 {
390 octave_link::instance () 390 octave_link::instance ()
391 ->post_event (new octave_debug_step_out_event (*this)); 391 ->post_event (new octave_debug_step_out_event (*this));
392 } 392 }
393 393
394 void 394 void
395 main_window::debug_quit () 395 main_window::debug_quit ()
396 { 396 {
397 octave_link::instance () 397 octave_link::instance ()
398 ->post_event (new octave_debug_quit_event (*this)); 398 ->post_event (new octave_debug_quit_event (*this));
399 } 399 }
400 400
401 void 401 void
402 main_window::show_about_octave () 402 main_window::show_about_octave ()
403 { 403 {
404 QString message = 404 QString message =
405 "GNU Octave\n" 405 "GNU Octave\n"
406 "Copyright (C) 2009 John W. Eaton and others.\n" 406 "Copyright (C) 2009 John W. Eaton and others.\n"
407 "This is free software; see the source code for copying conditions." 407 "This is free software; see the source code for copying conditions."
408 "There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or" 408 "There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or"
409 "FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.\n" 409 "FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.\n"
410 "\n" 410 "\n"
411 "Additional information about Octave is available at http://www.octave.org.\n" 411 "Additional information about Octave is available at http://www.octave.org.\n"
412 "\n" 412 "\n"
413 "Please contribute if you find this software useful." 413 "Please contribute if you find this software useful."
414 "For more information, visit http://www.octave.org/help-wanted.html\n" 414 "For more information, visit http://www.octave.org/help-wanted.html\n"
415 "\n" 415 "\n"
416 "Report bugs to <bug@octave.org> (but first, please read" 416 "Report bugs to <bug@octave.org> (but first, please read"
417 "http://www.octave.org/bugs.html to learn how to write a helpful report).\n" 417 "http://www.octave.org/bugs.html to learn how to write a helpful report).\n"
418 "\n" 418 "\n"
419 "For information about changes from previous versions, type `news'.\n"; 419 "For information about changes from previous versions, type `news'.\n";
420 420
421 QMessageBox::about (this, tr ("About Octave"), message); 421 QMessageBox::about (this, tr ("About Octave"), message);
422 } 422 }
423 423
424 void 424 void
425 main_window::closeEvent (QCloseEvent * closeEvent) 425 main_window::closeEvent (QCloseEvent * closeEvent)
426 { 426 {
427 closeEvent->ignore (); 427 closeEvent->ignore ();
428 octave_link::instance ()->post_event (new octave_exit_event (*this)); 428 octave_link::instance ()->post_event (new octave_exit_event (*this));
429 } 429 }
430 430
431 void 431 void
432 main_window::read_settings () 432 main_window::read_settings ()
433 { 433 {
434 QSettings *settings = resource_manager::get_settings (); 434 QSettings *settings = resource_manager::get_settings ();
445 { 445 {
446 QWidget *widget = qobject_cast<QWidget *> (obj); 446 QWidget *widget = qobject_cast<QWidget *> (obj);
447 QVariant val = settings->value (name); 447 QVariant val = settings->value (name);
448 widget->restoreGeometry (val.toByteArray ()); 448 widget->restoreGeometry (val.toByteArray ());
449 } 449 }
450 } 450 }
451 settings->endGroup(); 451 settings->endGroup();
452 restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ()); 452 restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ());
453 emit settings_changed (); 453 emit settings_changed ();
454 } 454 }
455 455
526 QMenu *file_menu = menuBar ()->addMenu (tr ("&File")); 526 QMenu *file_menu = menuBar ()->addMenu (tr ("&File"));
527 527
528 QMenu *new_menu = file_menu->addMenu(tr ("New")); 528 QMenu *new_menu = file_menu->addMenu(tr ("New"));
529 529
530 QAction *new_script_action 530 QAction *new_script_action
531 = new_menu->addAction (QIcon(":/actions/icons/filenew.png"), tr ("Script")); 531 = new_menu->addAction (QIcon(":/actions/icons/filenew.png"), tr ("Script"));
532 new_script_action->setShortcut (Qt::ControlModifier + Qt::Key_N); 532 new_script_action->setShortcut (Qt::ControlModifier + Qt::Key_N);
533 533
534 QAction *new_function_action = new_menu->addAction (tr ("Function")); 534 QAction *new_function_action = new_menu->addAction (tr ("Function"));
535 new_function_action->setEnabled (false); // TODO: Make this work. 535 new_function_action->setEnabled (false); // TODO: Make this work.
536 QAction *new_class_action = new_menu->addAction (tr ("Class")); 536 QAction *new_class_action = new_menu->addAction (tr ("Class"));
545 new_model_action->setEnabled (false); // TODO: Make this work. 545 new_model_action->setEnabled (false); // TODO: Make this work.
546 QAction *new_gui_action = new_menu->addAction (tr ("GUI")); 546 QAction *new_gui_action = new_menu->addAction (tr ("GUI"));
547 new_gui_action->setEnabled (false); // TODO: Make this work. 547 new_gui_action->setEnabled (false); // TODO: Make this work.
548 548
549 QAction *open_action 549 QAction *open_action
550 = file_menu->addAction (QIcon(":/actions/icons/fileopen.png"), tr ("Open...")); 550 = file_menu->addAction (QIcon(":/actions/icons/fileopen.png"), tr ("Open..."));
551 open_action->setShortcut (Qt::ControlModifier + Qt::Key_O); 551 open_action->setShortcut (Qt::ControlModifier + Qt::Key_O);
552 552
553 QAction *close_command_window_action 553 QAction *close_command_window_action
554 = file_menu->addAction (tr ("Close Command Window")); 554 = file_menu->addAction (tr ("Close Command Window"));
555 close_command_window_action->setShortcut (Qt::ControlModifier + Qt::Key_W); 555 close_command_window_action->setShortcut (Qt::ControlModifier + Qt::Key_W);
556 close_command_window_action->setEnabled (false); // TODO: Make this work. 556 close_command_window_action->setEnabled (false); // TODO: Make this work.
557 557
558 file_menu->addSeparator (); 558 file_menu->addSeparator ();
559 QAction *import_data_action 559 QAction *import_data_action
560 = file_menu->addAction (tr ("Import Data...")); 560 = file_menu->addAction (tr ("Import Data..."));
561 import_data_action->setEnabled (false); // TODO: Make this work. 561 import_data_action->setEnabled (false); // TODO: Make this work.
562 562
563 QAction *save_workspace_action 563 QAction *save_workspace_action
564 = file_menu->addAction (tr ("Save Workspace...")); 564 = file_menu->addAction (tr ("Save Workspace..."));
565 save_workspace_action->setShortcut (Qt::ControlModifier + Qt::Key_S); 565 save_workspace_action->setShortcut (Qt::ControlModifier + Qt::Key_S);
566 file_menu->addSeparator (); 566 file_menu->addSeparator ();
567 567
568 QAction *preferences_action 568 QAction *preferences_action
569 = file_menu->addAction (QIcon(":/actions/icons/configure.png"), 569 = file_menu->addAction (QIcon(":/actions/icons/configure.png"),
570 tr ("Preferences...")); 570 tr ("Preferences..."));
571 file_menu->addSeparator (); 571 file_menu->addSeparator ();
572 QAction *page_setup_action 572 QAction *page_setup_action
573 = file_menu->addAction (tr ("Page Setup...")); 573 = file_menu->addAction (tr ("Page Setup..."));
574 page_setup_action->setEnabled (false); // TODO: Make this work. 574 page_setup_action->setEnabled (false); // TODO: Make this work.
575 QAction *print_action 575 QAction *print_action
576 = file_menu->addAction (tr ("Print")); 576 = file_menu->addAction (tr ("Print"));
577 print_action->setShortcut (Qt::ControlModifier + Qt::Key_P); 577 print_action->setShortcut (Qt::ControlModifier + Qt::Key_P);
578 print_action->setEnabled (false); // TODO: Make this work. 578 print_action->setEnabled (false); // TODO: Make this work.
579 QAction *print_selection_action 579 QAction *print_selection_action
580 = file_menu->addAction (tr ("Print Selection...")); 580 = file_menu->addAction (tr ("Print Selection..."));
581 print_selection_action->setEnabled (false); // TODO: Make this work. 581 print_selection_action->setEnabled (false); // TODO: Make this work.
582 582
583 file_menu->addSeparator (); 583 file_menu->addSeparator ();
584 QAction *exit_action = file_menu->addAction (tr ("Exit")); 584 QAction *exit_action = file_menu->addAction (tr ("Exit"));
585 exit_action->setShortcut (Qt::ControlModifier + Qt::Key_Q); 585 exit_action->setShortcut (Qt::ControlModifier + Qt::Key_Q);
586 586
587 587
588 QMenu *edit_menu = menuBar ()->addMenu (tr ("&Edit")); 588 QMenu *edit_menu = menuBar ()->addMenu (tr ("&Edit"));
589 QAction *undo_action 589 QAction *undo_action
590 = edit_menu->addAction (QIcon(":/actions/icons/undo.png"), tr ("Undo")); 590 = edit_menu->addAction (QIcon(":/actions/icons/undo.png"), tr ("Undo"));
591 undo_action->setShortcut (QKeySequence::Undo); 591 undo_action->setShortcut (QKeySequence::Undo);
592 592
593 QAction *redo_action 593 QAction *redo_action
594 = edit_menu->addAction (QIcon(":/actions/icons/redo.png"), tr ("Redo")); 594 = edit_menu->addAction (QIcon(":/actions/icons/redo.png"), tr ("Redo"));
595 redo_action->setShortcut (QKeySequence::Redo); 595 redo_action->setShortcut (QKeySequence::Redo);
596 edit_menu->addSeparator (); 596 edit_menu->addSeparator ();
597 597
598 QAction *cut_action 598 QAction *cut_action
599 = edit_menu->addAction (QIcon(":/actions/icons/editcut.png"), tr ("Cut")); 599 = edit_menu->addAction (QIcon(":/actions/icons/editcut.png"), tr ("Cut"));
600 cut_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_X); 600 cut_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_X);
601 601
602 QAction *copy_action 602 QAction *copy_action
603 = edit_menu->addAction (QIcon(":/actions/icons/editcopy.png"), tr ("Copy")); 603 = edit_menu->addAction (QIcon(":/actions/icons/editcopy.png"), tr ("Copy"));
604 copy_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_C); 604 copy_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_C);
605 605
606 QAction *paste_action 606 QAction *paste_action
607 = edit_menu->addAction (QIcon(":/actions/icons/editpaste.png"), tr ("Paste")); 607 = edit_menu->addAction (QIcon(":/actions/icons/editpaste.png"), tr ("Paste"));
608 paste_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_V); 608 paste_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_V);
609 609
610 QAction *paste_to_workspace_action 610 QAction *paste_to_workspace_action
611 = edit_menu->addAction (tr ("Paste To Workspace...")); 611 = edit_menu->addAction (tr ("Paste To Workspace..."));
612 paste_to_workspace_action->setEnabled (false); // TODO: Make this work. 612 paste_to_workspace_action->setEnabled (false); // TODO: Make this work.
613 edit_menu->addSeparator (); 613 edit_menu->addSeparator ();
614 614
615 QAction *select_all_action 615 QAction *select_all_action
616 = edit_menu->addAction (tr ("Select All")); 616 = edit_menu->addAction (tr ("Select All"));
617 select_all_action->setEnabled (false); // TODO: Make this work. 617 select_all_action->setEnabled (false); // TODO: Make this work.
618 QAction *delete_action 618 QAction *delete_action
619 = edit_menu->addAction (tr ("Delete")); 619 = edit_menu->addAction (tr ("Delete"));
620 delete_action->setShortcut (Qt::Key_Delete); 620 delete_action->setShortcut (Qt::Key_Delete);
621 delete_action->setEnabled (false); // TODO: Make this work. 621 delete_action->setEnabled (false); // TODO: Make this work.
622 edit_menu->addSeparator (); 622 edit_menu->addSeparator ();
623 623
624 QAction *find_action 624 QAction *find_action
625 = edit_menu->addAction (tr ("Find...")); 625 = edit_menu->addAction (tr ("Find..."));
626 find_action->setEnabled (false); // TODO: Make this work. 626 find_action->setEnabled (false); // TODO: Make this work.
627 QAction *find_files_action 627 QAction *find_files_action
628 = edit_menu->addAction (tr ("Find Files...")); 628 = edit_menu->addAction (tr ("Find Files..."));
629 find_files_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier 629 find_files_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier
630 + Qt::Key_F); 630 + Qt::Key_F);
631 find_files_action->setEnabled (false); // TODO: Make this work. 631 find_files_action->setEnabled (false); // TODO: Make this work.
632 edit_menu->addSeparator (); 632 edit_menu->addSeparator ();
633 633
634 QAction *clear_command_window_action 634 QAction *clear_command_window_action
635 = edit_menu->addAction (tr ("Clear Command Window")); 635 = edit_menu->addAction (tr ("Clear Command Window"));
636 clear_command_window_action->setEnabled (false); // TODO: Make this work. 636 clear_command_window_action->setEnabled (false); // TODO: Make this work.
637 QAction *clear_command_history 637 QAction *clear_command_history
638 = edit_menu->addAction(tr ("Clear Command History")); 638 = edit_menu->addAction(tr ("Clear Command History"));
639 QAction * clear_workspace_action 639 QAction * clear_workspace_action
640 = edit_menu->addAction (tr ("Clear Workspace")); 640 = edit_menu->addAction (tr ("Clear Workspace"));
641 641
642 _debug_menu = menuBar ()->addMenu (tr ("De&bug")); 642 _debug_menu = menuBar ()->addMenu (tr ("De&bug"));
643 643
644 _debug_step_over = _debug_menu->addAction (QIcon (":/actions/icons/db_step.png"), tr ("Step")); 644 _debug_step_over = _debug_menu->addAction (QIcon (":/actions/icons/db_step.png"), tr ("Step"));
645 _debug_step_over->setEnabled (false); 645 _debug_step_over->setEnabled (false);
711 + Qt::Key_4); 711 + Qt::Key_4);
712 712
713 QAction * show_documentation_action = window_menu->addAction (tr ("Show Documentation")); 713 QAction * show_documentation_action = window_menu->addAction (tr ("Show Documentation"));
714 show_documentation_action->setCheckable (true); 714 show_documentation_action->setCheckable (true);
715 show_documentation_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier 715 show_documentation_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier
716 + Qt::Key_5); 716 + Qt::Key_5);
717 window_menu->addSeparator (); 717 window_menu->addSeparator ();
718 718
719 QAction * command_window_action 719 QAction * command_window_action
720 = window_menu->addAction (tr ("Command Window")); 720 = window_menu->addAction (tr ("Command Window"));
721 command_window_action->setShortcut (Qt::ControlModifier + Qt::Key_0); 721 command_window_action->setShortcut (Qt::ControlModifier + Qt::Key_0);
758 QAction * about_octave_action 758 QAction * about_octave_action
759 = help_menu->addAction (tr ("About Octave")); 759 = help_menu->addAction (tr ("About Octave"));
760 760
761 // Toolbars 761 // Toolbars
762 QToolBar *main_tool_bar = addToolBar ("Main"); 762 QToolBar *main_tool_bar = addToolBar ("Main");
763 main_tool_bar->addAction (new_script_action); 763 main_tool_bar->addAction (new_script_action);
764 main_tool_bar->addAction (open_action); 764 main_tool_bar->addAction (open_action);
765 main_tool_bar->addSeparator (); 765 main_tool_bar->addSeparator ();
766 main_tool_bar->addAction (cut_action); 766 main_tool_bar->addAction (cut_action);
767 main_tool_bar->addAction (copy_action); 767 main_tool_bar->addAction (copy_action);
768 main_tool_bar->addAction (paste_action); 768 main_tool_bar->addAction (paste_action);
769 main_tool_bar->addAction (undo_action); 769 main_tool_bar->addAction (undo_action);
770 main_tool_bar->addAction (redo_action); 770 main_tool_bar->addAction (redo_action);
771 main_tool_bar->addSeparator (); 771 main_tool_bar->addSeparator ();
772 main_tool_bar->addWidget (new QLabel (tr ("Current Directory:"))); 772 main_tool_bar->addWidget (new QLabel (tr ("Current Directory:")));
773 main_tool_bar->addWidget (_current_directory_combo_box); 773 main_tool_bar->addWidget (_current_directory_combo_box);
774 main_tool_bar->addWidget (_current_directory_tool_button); 774 main_tool_bar->addWidget (_current_directory_tool_button);
775 main_tool_bar->addWidget (_current_directory_up_tool_button); 775 main_tool_bar->addWidget (_current_directory_up_tool_button);
776 776
777 connect (qApp, SIGNAL (aboutToQuit ()), 777 connect (qApp, SIGNAL (aboutToQuit ()),
778 this, SLOT (prepare_for_quit ())); 778 this, SLOT (prepare_for_quit ()));
779 connect (preferences_action, SIGNAL (triggered ()), 779 connect (preferences_action, SIGNAL (triggered ()),
780 this, SLOT (process_settings_dialog_request ())); 780 this, SLOT (process_settings_dialog_request ()));