comparison libgui/src/main-window.cc @ 17599:f5950975a172

community news dock widget and other user info in GUI * news-dock-widget.h, news-dock-widget.cc: New files. * libgui/src/module.mk: Update file lists. * configure.ac: Check for QtWebKit module. * default-qt-settings.in: Update default geometry. * main-window.cc, main-window.h (main_window::news_window): New data member. (main_window::dock_widget_list): Include it in the list. (main_window::display_release_notes, main_window::display_url_in_window, main_window::construct_news_menu): New functions. (main_window::construct): Add news_window dock widget. (main_window::construct_menu_bar): Call construct_news_menu. (main_window::construct_window_menu): New items for Showing news window and menu.
author John W. Eaton <jwe@octave.org>
date Mon, 07 Oct 2013 21:13:11 -0400
parents 387ecd448b30
children 9abb1422d60b
comparison
equal deleted inserted replaced
17598:d8d71c89fff2 17599:f5950975a172
38 #include <QDesktopWidget> 38 #include <QDesktopWidget>
39 #include <QFileDialog> 39 #include <QFileDialog>
40 #include <QMessageBox> 40 #include <QMessageBox>
41 #include <QIcon> 41 #include <QIcon>
42 42
43 #include <QWebView>
44
43 #include <utility> 45 #include <utility>
44 46
45 #ifdef HAVE_QSCINTILLA 47 #ifdef HAVE_QSCINTILLA
46 #include "file-editor.h" 48 #include "file-editor.h"
47 #endif 49 #endif
67 69
68 main_window::main_window (QWidget *p) 70 main_window::main_window (QWidget *p)
69 : QMainWindow (p), 71 : QMainWindow (p),
70 _workspace_model (new workspace_model ()), 72 _workspace_model (new workspace_model ()),
71 status_bar (new QStatusBar ()), 73 status_bar (new QStatusBar ()),
74 news_window (new news_dock_widget (this)),
72 command_window (new terminal_dock_widget (this)), 75 command_window (new terminal_dock_widget (this)),
73 history_window (new history_dock_widget (this)), 76 history_window (new history_dock_widget (this)),
74 file_browser_window (new files_dock_widget (this)), 77 file_browser_window (new files_dock_widget (this)),
75 doc_browser_window (new documentation_dock_widget (this)), 78 doc_browser_window (new documentation_dock_widget (this)),
76 editor_window (create_default_editor (this)), 79 editor_window (create_default_editor (this)),
91 { 94 {
92 // Destroy the terminal first so that STDERR stream is redirected back 95 // Destroy the terminal first so that STDERR stream is redirected back
93 // to its original pipe to capture error messages at exit. 96 // to its original pipe to capture error messages at exit.
94 97
95 delete editor_window; // first one for dialogs of modified editor-tabs 98 delete editor_window; // first one for dialogs of modified editor-tabs
99 delete news_window;
96 delete command_window; 100 delete command_window;
97 delete workspace_window; 101 delete workspace_window;
98 delete doc_browser_window; 102 delete doc_browser_window;
99 delete file_browser_window; 103 delete file_browser_window;
100 delete history_window; 104 delete history_window;
245 { 249 {
246 QDesktopServices::openUrl (QUrl ("http://octave.org/doc/interpreter")); 250 QDesktopServices::openUrl (QUrl ("http://octave.org/doc/interpreter"));
247 } 251 }
248 252
249 void 253 void
254 main_window::display_release_notes (void)
255 {
256 display_url_in_window (QUrl ("file://" OCTAVE_OCTETCDIR "/NEWS"));
257 }
258
259 void
260 main_window::display_url_in_window (const QUrl& url)
261 {
262 QWidget *w = new QWidget;
263
264 QTextBrowser *browser = new QTextBrowser (w);
265 browser->setSource (url);
266
267 QVBoxLayout *vlayout = new QVBoxLayout;
268 vlayout->addWidget (browser);
269
270 w->setLayout (vlayout);
271 w->show ();
272 w->raise ();
273 w->activateWindow ();
274 }
275
276 void
250 main_window::open_bug_tracker_page (void) 277 main_window::open_bug_tracker_page (void)
251 { 278 {
252 QDesktopServices::openUrl (QUrl ("http://octave.org/bugs.html")); 279 QDesktopServices::openUrl (QUrl ("http://octave.org/bugs.html"));
253 } 280 }
254 281
861 888
862 setDockOptions (QMainWindow::AnimatedDocks 889 setDockOptions (QMainWindow::AnimatedDocks
863 | QMainWindow::AllowNestedDocks 890 | QMainWindow::AllowNestedDocks
864 | QMainWindow::AllowTabbedDocks); 891 | QMainWindow::AllowTabbedDocks);
865 892
893 addDockWidget (Qt::RightDockWidgetArea, news_window);
866 addDockWidget (Qt::RightDockWidgetArea, command_window); 894 addDockWidget (Qt::RightDockWidgetArea, command_window);
867 addDockWidget (Qt::RightDockWidgetArea, doc_browser_window); 895 addDockWidget (Qt::RightDockWidgetArea, doc_browser_window);
868 tabifyDockWidget (command_window, doc_browser_window); 896 tabifyDockWidget (command_window, doc_browser_window);
869 897
870 #ifdef HAVE_QSCINTILLA 898 #ifdef HAVE_QSCINTILLA
1019 construct_debug_menu (menu_bar); 1047 construct_debug_menu (menu_bar);
1020 1048
1021 construct_window_menu (menu_bar); 1049 construct_window_menu (menu_bar);
1022 1050
1023 construct_help_menu (menu_bar); 1051 construct_help_menu (menu_bar);
1052
1053 construct_news_menu (menu_bar);
1024 } 1054 }
1025 1055
1026 void 1056 void
1027 main_window::construct_file_menu (QMenuBar *p) 1057 main_window::construct_file_menu (QMenuBar *p)
1028 { 1058 {
1264 (window_menu, tr ("Show Editor"), true, ctrl_shift + Qt::Key_4); 1294 (window_menu, tr ("Show Editor"), true, ctrl_shift + Qt::Key_4);
1265 1295
1266 QAction *show_documentation_action = construct_window_menu_item 1296 QAction *show_documentation_action = construct_window_menu_item
1267 (window_menu, tr ("Show Documentation"), true, ctrl_shift + Qt::Key_5); 1297 (window_menu, tr ("Show Documentation"), true, ctrl_shift + Qt::Key_5);
1268 1298
1299 QAction *show_news_action = construct_window_menu_item
1300 (window_menu, tr ("Show News Window"), true, ctrl_shift + Qt::Key_6);
1301
1269 window_menu->addSeparator (); 1302 window_menu->addSeparator ();
1270 1303
1271 QAction *command_window_action = construct_window_menu_item 1304 QAction *command_window_action = construct_window_menu_item
1272 (window_menu, tr ("Command Window"), false, ctrl + Qt::Key_0); 1305 (window_menu, tr ("Command Window"), false, ctrl + Qt::Key_0);
1273 1306
1283 QAction *editor_action = construct_window_menu_item 1316 QAction *editor_action = construct_window_menu_item
1284 (window_menu, tr ("Editor"), false, ctrl + Qt::Key_4); 1317 (window_menu, tr ("Editor"), false, ctrl + Qt::Key_4);
1285 1318
1286 QAction *documentation_action = construct_window_menu_item 1319 QAction *documentation_action = construct_window_menu_item
1287 (window_menu, tr ("Documentation"), false, ctrl + Qt::Key_5); 1320 (window_menu, tr ("Documentation"), false, ctrl + Qt::Key_5);
1321
1322 QAction *news_action = construct_window_menu_item
1323 (window_menu, tr ("News"), false, ctrl + Qt::Key_6);
1288 1324
1289 window_menu->addSeparator (); 1325 window_menu->addSeparator ();
1290 1326
1291 QAction *reset_windows_action 1327 QAction *reset_windows_action
1292 = window_menu->addAction (tr ("Reset Default Window Layout")); 1328 = window_menu->addAction (tr ("Reset Default Window Layout"));
1320 editor_window, SLOT (setVisible (bool))); 1356 editor_window, SLOT (setVisible (bool)));
1321 1357
1322 connect (editor_window, SIGNAL (active_changed (bool)), 1358 connect (editor_window, SIGNAL (active_changed (bool)),
1323 show_editor_action, SLOT (setChecked (bool))); 1359 show_editor_action, SLOT (setChecked (bool)));
1324 #endif 1360 #endif
1361
1362 connect (show_news_action, SIGNAL (toggled (bool)),
1363 news_window, SLOT (setVisible (bool)));
1325 1364
1326 connect (show_documentation_action, SIGNAL (toggled (bool)), 1365 connect (show_documentation_action, SIGNAL (toggled (bool)),
1327 doc_browser_window, SLOT (setVisible (bool))); 1366 doc_browser_window, SLOT (setVisible (bool)));
1328 1367
1329 connect (doc_browser_window, SIGNAL (active_changed (bool)), 1368 connect (doc_browser_window, SIGNAL (active_changed (bool)),
1344 #ifdef HAVE_QSCINTILLA 1383 #ifdef HAVE_QSCINTILLA
1345 connect (editor_action, SIGNAL (triggered ()), 1384 connect (editor_action, SIGNAL (triggered ()),
1346 editor_window, SLOT (focus ())); 1385 editor_window, SLOT (focus ()));
1347 #endif 1386 #endif
1348 1387
1388 connect (news_action, SIGNAL (triggered ()),
1389 news_window, SLOT (focus ()));
1390
1349 connect (documentation_action, SIGNAL (triggered ()), 1391 connect (documentation_action, SIGNAL (triggered ()),
1350 doc_browser_window, SLOT (focus ())); 1392 doc_browser_window, SLOT (focus ()));
1351 1393
1352 connect (reset_windows_action, SIGNAL (triggered ()), 1394 connect (reset_windows_action, SIGNAL (triggered ()),
1353 this, SLOT (reset_windows ())); 1395 this, SLOT (reset_windows ()));
1415 connect (ondisk_documentation_action, SIGNAL (triggered ()), 1457 connect (ondisk_documentation_action, SIGNAL (triggered ()),
1416 doc_browser_window, SLOT (focus ())); 1458 doc_browser_window, SLOT (focus ()));
1417 1459
1418 connect (online_documentation_action, SIGNAL (triggered ()), 1460 connect (online_documentation_action, SIGNAL (triggered ()),
1419 this, SLOT (open_online_documentation_page ())); 1461 this, SLOT (open_online_documentation_page ()));
1462 }
1463
1464 void
1465 main_window::construct_news_menu (QMenuBar *p)
1466 {
1467 QMenu *news_menu = p->addMenu (tr ("&News"));
1468
1469 QAction *release_notes_action
1470 = news_menu->addAction (tr ("Release Notes"));
1471
1472 QAction *current_news_action
1473 = news_menu->addAction (tr ("Community News"));
1474
1475 connect (release_notes_action, SIGNAL (triggered ()),
1476 this, SLOT (display_release_notes ()));
1477
1478 connect (current_news_action, SIGNAL (triggered ()),
1479 news_window, SLOT (show ()));
1420 } 1480 }
1421 1481
1422 void 1482 void
1423 main_window::construct_tool_bar (void) 1483 main_window::construct_tool_bar (void)
1424 { 1484 {