Mercurial > octave-nkf
diff 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 |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Mon Oct 07 22:35:55 2013 -0400 +++ b/libgui/src/main-window.cc Mon Oct 07 21:13:11 2013 -0400 @@ -40,6 +40,8 @@ #include <QMessageBox> #include <QIcon> +#include <QWebView> + #include <utility> #ifdef HAVE_QSCINTILLA @@ -69,6 +71,7 @@ : QMainWindow (p), _workspace_model (new workspace_model ()), status_bar (new QStatusBar ()), + news_window (new news_dock_widget (this)), command_window (new terminal_dock_widget (this)), history_window (new history_dock_widget (this)), file_browser_window (new files_dock_widget (this)), @@ -93,6 +96,7 @@ // to its original pipe to capture error messages at exit. delete editor_window; // first one for dialogs of modified editor-tabs + delete news_window; delete command_window; delete workspace_window; delete doc_browser_window; @@ -247,6 +251,29 @@ } void +main_window::display_release_notes (void) +{ + display_url_in_window (QUrl ("file://" OCTAVE_OCTETCDIR "/NEWS")); +} + +void +main_window::display_url_in_window (const QUrl& url) +{ + QWidget *w = new QWidget; + + QTextBrowser *browser = new QTextBrowser (w); + browser->setSource (url); + + QVBoxLayout *vlayout = new QVBoxLayout; + vlayout->addWidget (browser); + + w->setLayout (vlayout); + w->show (); + w->raise (); + w->activateWindow (); +} + +void main_window::open_bug_tracker_page (void) { QDesktopServices::openUrl (QUrl ("http://octave.org/bugs.html")); @@ -863,6 +890,7 @@ | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks); + addDockWidget (Qt::RightDockWidgetArea, news_window); addDockWidget (Qt::RightDockWidgetArea, command_window); addDockWidget (Qt::RightDockWidgetArea, doc_browser_window); tabifyDockWidget (command_window, doc_browser_window); @@ -1021,6 +1049,8 @@ construct_window_menu (menu_bar); construct_help_menu (menu_bar); + + construct_news_menu (menu_bar); } void @@ -1266,6 +1296,9 @@ QAction *show_documentation_action = construct_window_menu_item (window_menu, tr ("Show Documentation"), true, ctrl_shift + Qt::Key_5); + QAction *show_news_action = construct_window_menu_item + (window_menu, tr ("Show News Window"), true, ctrl_shift + Qt::Key_6); + window_menu->addSeparator (); QAction *command_window_action = construct_window_menu_item @@ -1286,6 +1319,9 @@ QAction *documentation_action = construct_window_menu_item (window_menu, tr ("Documentation"), false, ctrl + Qt::Key_5); + QAction *news_action = construct_window_menu_item + (window_menu, tr ("News"), false, ctrl + Qt::Key_6); + window_menu->addSeparator (); QAction *reset_windows_action @@ -1323,6 +1359,9 @@ show_editor_action, SLOT (setChecked (bool))); #endif + connect (show_news_action, SIGNAL (toggled (bool)), + news_window, SLOT (setVisible (bool))); + connect (show_documentation_action, SIGNAL (toggled (bool)), doc_browser_window, SLOT (setVisible (bool))); @@ -1346,6 +1385,9 @@ editor_window, SLOT (focus ())); #endif + connect (news_action, SIGNAL (triggered ()), + news_window, SLOT (focus ())); + connect (documentation_action, SIGNAL (triggered ()), doc_browser_window, SLOT (focus ())); @@ -1420,6 +1462,24 @@ } void +main_window::construct_news_menu (QMenuBar *p) +{ + QMenu *news_menu = p->addMenu (tr ("&News")); + + QAction *release_notes_action + = news_menu->addAction (tr ("Release Notes")); + + QAction *current_news_action + = news_menu->addAction (tr ("Community News")); + + connect (release_notes_action, SIGNAL (triggered ()), + this, SLOT (display_release_notes ())); + + connect (current_news_action, SIGNAL (triggered ()), + news_window, SLOT (show ())); +} + +void main_window::construct_tool_bar (void) { _main_tool_bar = addToolBar ("Main");