Mercurial > octave-nkf
comparison libgui/src/main-window.cc @ 19612:c8cb111e727e
maint: Periodic merge of gui-release to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 14 Jan 2015 13:54:28 -0500 |
parents | cbd5d36c5472 6561179c6c22 |
children | 37d37297acf8 |
comparison
equal
deleted
inserted
replaced
19611:f64cdbe11621 | 19612:c8cb111e727e |
---|---|
1275 | 1275 |
1276 construct_menu_bar (); | 1276 construct_menu_bar (); |
1277 | 1277 |
1278 construct_tool_bar (); | 1278 construct_tool_bar (); |
1279 | 1279 |
1280 construct_warning_bar (); | |
1281 | |
1282 connect (qApp, SIGNAL (aboutToQuit ()), | 1280 connect (qApp, SIGNAL (aboutToQuit ()), |
1283 this, SLOT (prepare_to_exit ())); | 1281 this, SLOT (prepare_to_exit ())); |
1284 | 1282 |
1285 connect (qApp, SIGNAL (focusChanged (QWidget*, QWidget*)), | 1283 connect (qApp, SIGNAL (focusChanged (QWidget*, QWidget*)), |
1286 this, SLOT(focus_changed (QWidget*, QWidget*))); | 1284 this, SLOT(focus_changed (QWidget*, QWidget*))); |
1886 _release_notes_action = add_action (news_menu, QIcon (), | 1884 _release_notes_action = add_action (news_menu, QIcon (), |
1887 tr ("Release Notes"), SLOT (display_release_notes ())); | 1885 tr ("Release Notes"), SLOT (display_release_notes ())); |
1888 | 1886 |
1889 _current_news_action = add_action (news_menu, QIcon (), | 1887 _current_news_action = add_action (news_menu, QIcon (), |
1890 tr ("Community News"), SLOT (load_and_display_community_news ())); | 1888 tr ("Community News"), SLOT (load_and_display_community_news ())); |
1891 } | |
1892 | |
1893 void | |
1894 main_window::construct_warning_bar (void) | |
1895 { | |
1896 QSettings *settings = resource_manager::get_settings (); | |
1897 | |
1898 if (settings | |
1899 && settings->value ("General/hide_new_gui_warning", false).toBool ()) | |
1900 { | |
1901 construct_gui_info_button (); | |
1902 | |
1903 return; | |
1904 } | |
1905 | |
1906 _warning_bar = new QDockWidget (this); | |
1907 _warning_bar->setAttribute (Qt::WA_DeleteOnClose); | |
1908 | |
1909 QFrame *box = new QFrame (_warning_bar); | |
1910 | |
1911 QLabel *icon = new QLabel (box); | |
1912 QIcon warning_icon | |
1913 = QIcon::fromTheme ("dialog-warning", | |
1914 QIcon (":/actions/icons/warning.png")); | |
1915 QPixmap icon_pixmap = warning_icon.pixmap (QSize (32, 32)); | |
1916 icon->setPixmap (icon_pixmap); | |
1917 | |
1918 QTextBrowser *msg = new QTextBrowser (box); | |
1919 msg->setOpenExternalLinks (true); | |
1920 msg->setText | |
1921 (tr ("<strong>You are using a release candidate of Octave's experimental GUI.</strong> " | |
1922 "Octave is under continuous improvement and the GUI will be the " | |
1923 "default interface for the 4.0 release. For more information, " | |
1924 "select the \"Release Notes\" item in the \"News\" menu of the GUI, " | |
1925 "or visit <a href=\"http://octave.org\">http://octave.org</a>.")); | |
1926 | |
1927 msg->setStyleSheet ("background-color: #ffd97f; color: black; margin 4px;"); | |
1928 msg->setMinimumWidth (100); | |
1929 msg->setMinimumHeight (60); | |
1930 msg->setMaximumHeight (80); | |
1931 msg->setSizePolicy (QSizePolicy (QSizePolicy::Expanding, | |
1932 QSizePolicy::Minimum)); | |
1933 | |
1934 QPushButton *info_button = new QPushButton (tr ("More Info"), box); | |
1935 QPushButton *hide_button = new QPushButton (tr ("Hide"), box); | |
1936 | |
1937 connect (info_button, SIGNAL (clicked ()), | |
1938 this, SLOT (show_gui_info ())); | |
1939 | |
1940 connect (hide_button, SIGNAL (clicked ()), | |
1941 this, SLOT (hide_warning_bar ())); | |
1942 | |
1943 QVBoxLayout *button_layout = new QVBoxLayout; | |
1944 | |
1945 button_layout->addWidget (info_button); | |
1946 button_layout->addWidget (hide_button); | |
1947 | |
1948 QHBoxLayout *icon_and_message = new QHBoxLayout; | |
1949 | |
1950 icon_and_message->addWidget (icon); | |
1951 icon_and_message->addSpacing (10); | |
1952 icon_and_message->addWidget (msg); | |
1953 icon_and_message->addSpacing (10); | |
1954 icon_and_message->addLayout (button_layout); | |
1955 | |
1956 icon_and_message->setAlignment (hide_button, Qt::AlignTop); | |
1957 | |
1958 box->setFrameStyle (QFrame::Box); | |
1959 box->setLineWidth (2); | |
1960 box->setMaximumWidth (1000); | |
1961 box->adjustSize (); | |
1962 box->setLayout (icon_and_message); | |
1963 | |
1964 _warning_bar->setFeatures (QDockWidget::NoDockWidgetFeatures); | |
1965 _warning_bar->setObjectName ("WarningToolBar"); | |
1966 _warning_bar->setWidget (box); | |
1967 | |
1968 setCorner (Qt::TopLeftCorner, Qt::TopDockWidgetArea); | |
1969 setCorner (Qt::TopRightCorner, Qt::TopDockWidgetArea); | |
1970 | |
1971 addDockWidget (Qt::TopDockWidgetArea, _warning_bar); | |
1972 }; | |
1973 | |
1974 void | |
1975 main_window::construct_gui_info_button (void) | |
1976 { | |
1977 QIcon warning_icon | |
1978 = QIcon::fromTheme ("dialog-warning", | |
1979 QIcon (":/actions/icons/warning.png")); | |
1980 | |
1981 _gui_info_button | |
1982 = new QPushButton (warning_icon, tr ("Experimental GUI Info")); | |
1983 | |
1984 _main_tool_bar->addWidget (_gui_info_button); | |
1985 | |
1986 connect (_gui_info_button, SIGNAL (clicked ()), | |
1987 this, SLOT (show_gui_info ())); | |
1988 } | |
1989 | |
1990 void | |
1991 main_window::hide_warning_bar (void) | |
1992 { | |
1993 QSettings *settings = resource_manager::get_settings (); | |
1994 | |
1995 if (settings) | |
1996 { | |
1997 settings->setValue ("General/hide_new_gui_warning", true); | |
1998 | |
1999 settings->sync (); | |
2000 } | |
2001 | |
2002 removeDockWidget (_warning_bar); | |
2003 | |
2004 construct_gui_info_button (); | |
2005 } | |
2006 | |
2007 void | |
2008 main_window::show_gui_info (void) | |
2009 { | |
2010 QString gui_info | |
2011 (QObject::tr ("<p><strong>A Note about Octave's New GUI</strong></p>" | |
2012 "<p>One of the biggest new features for Octave 3.8 is a graphical " | |
2013 "user interface. It is the one thing that users have requested " | |
2014 "most often over the last few years and now it is almost ready. " | |
2015 "But because it is not quite as polished as we would like, we " | |
2016 "have decided to wait until the 4.0.x release series before " | |
2017 "making the GUI the default interface.</p>" | |
2018 "<p>Given the length of time and the number of bug fixes and " | |
2019 "improvements since the last major release, we also " | |
2020 "decided against delaying the release of all these new " | |
2021 "improvements any longer just to perfect the GUI. So please " | |
2022 "enjoy the 3.8 release of Octave and the preview of the new GUI. " | |
2023 "We believe it is working reasonably well, but we also know that " | |
2024 "there are some obvious rough spots and many things that could be " | |
2025 "improved.</p>" | |
2026 "<p><strong>We Need Your Help</strong></p>" | |
2027 "<p>There are many ways that you can help us fix the remaining " | |
2028 "problems, complete the GUI, and improve the overall user " | |
2029 "experience for both novices and experts alike (links will open " | |
2030 "an external browser):</p>" | |
2031 "<p><ul><li>If you are a skilled software developer, you can " | |
2032 "help by contributing your time to help " | |
2033 "<a href=\"http://octave.org/get-involved.html\">develop " | |
2034 "Octave</a>.</li>" | |
2035 "<li>If Octave does not work properly, you are encouraged to " | |
2036 "<a href=\"http://octave.org/bugs.html\">report problems </a> " | |
2037 "that you find.</li>" | |
2038 "<li>Whether you are a user or developer, you can " | |
2039 "<a href=\"http://octave.org/donate.html\">help to fund the " | |
2040 "project</a>. " | |
2041 "Octave development takes a lot of time and expertise. " | |
2042 "Your contributions help to ensure that Octave will continue " | |
2043 "to improve.</li></ul></p>" | |
2044 "<p>We hope you find Octave to be useful. Please help us make " | |
2045 "it even better for the future!</p>")); | |
2046 | |
2047 QMessageBox gui_info_dialog (QMessageBox::Warning, | |
2048 tr ("Experimental GUI Info"), | |
2049 QString (gui_info.length (),' '), QMessageBox::Close); | |
2050 QGridLayout *box_layout | |
2051 = qobject_cast<QGridLayout *>(gui_info_dialog.layout()); | |
2052 if (box_layout) | |
2053 { | |
2054 QTextEdit *text = new QTextEdit(gui_info); | |
2055 text->setReadOnly(true); | |
2056 box_layout->addWidget(text, 0, 1); | |
2057 } | |
2058 gui_info_dialog.exec (); | |
2059 } | 1889 } |
2060 | 1890 |
2061 void | 1891 void |
2062 main_window::construct_tool_bar (void) | 1892 main_window::construct_tool_bar (void) |
2063 { | 1893 { |