# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1351021287 14400 # Node ID 427020b2ceaf1e63bd72209771fa3e68173e7fce # Parent 17b04c4c268d973967bf921b9389751f543a3604# Parent 3c5553180dd15662bef68600236810272c7e6faf Merge in Erik's changes diff --git a/libgui/src/documentation-dockwidget.cc b/libgui/src/documentation-dockwidget.cc --- a/libgui/src/documentation-dockwidget.cc +++ b/libgui/src/documentation-dockwidget.cc @@ -30,10 +30,13 @@ : QDockWidget (p) { setObjectName ("DocumentationDockWidget"); + setWindowIcon (QIcon(":/actions/icons/logo.png")); setWindowTitle (tr ("Documentation")); connect (this, SIGNAL (visibilityChanged (bool)), this, SLOT (handle_visibility_changed (bool))); + // topLevelChanged is emitted when floating property changes (floating = true) + connect (this, SIGNAL (topLevelChanged(bool)), this, SLOT(top_level_changed(bool))); _webinfo = new webinfo (this); setWidget (_webinfo); @@ -52,3 +55,14 @@ emit active_changed (false); QDockWidget::closeEvent (e); } + +// slot for signal that is emitted when floating property changes +void +documentation_dock_widget::top_level_changed (bool floating) +{ + if(floating) + { + setWindowFlags(Qt::Window); // make a window from the widget when floating + show(); // make it visible again since setWindowFlags hides it + } +} diff --git a/libgui/src/documentation-dockwidget.h b/libgui/src/documentation-dockwidget.h --- a/libgui/src/documentation-dockwidget.h +++ b/libgui/src/documentation-dockwidget.h @@ -36,6 +36,8 @@ public slots: /** Slot to steer changing visibility from outside. */ void handle_visibility_changed (bool visible); + /** Slot when floating property changes */ + void top_level_changed (bool floating); signals: /** Custom signal that tells if a user has clicked away that dock widget. */ diff --git a/libgui/src/files-dockwidget.cc b/libgui/src/files-dockwidget.cc --- a/libgui/src/files-dockwidget.cc +++ b/libgui/src/files-dockwidget.cc @@ -39,6 +39,7 @@ : QDockWidget (p) { setObjectName ("FilesDockWidget"); + setWindowIcon (QIcon(":/actions/icons/logo.png")); setWindowTitle (tr ("Current Directory")); setWidget (new QWidget (this)); @@ -115,6 +116,8 @@ connect (this, SIGNAL (visibilityChanged (bool)), this, SLOT (handle_visibility_changed (bool))); + // topLevelChanged is emitted when floating property changes (floating = true) + connect (this, SIGNAL (topLevelChanged(bool)), this, SLOT(top_level_changed(bool))); setFocusProxy (_current_directory); } @@ -214,3 +217,14 @@ emit active_changed (false); QDockWidget::closeEvent (e); } + +// slot for signal that is emitted when floating property changes +void +files_dock_widget::top_level_changed (bool floating) +{ + if(floating) + { + setWindowFlags(Qt::Window); // make a window from the widget when floating + show(); // make it visible again since setWindowFlags hides it + } +} diff --git a/libgui/src/files-dockwidget.h b/libgui/src/files-dockwidget.h --- a/libgui/src/files-dockwidget.h +++ b/libgui/src/files-dockwidget.h @@ -71,6 +71,9 @@ /** Slot to steer changing visibility from outside. */ void handle_visibility_changed (bool visible); + /** Slot when floating property changes */ + void top_level_changed (bool floating); + signals: /** Emitted, whenever the user requested to open a file. */ void open_file (const QString& fileName); diff --git a/libgui/src/history-dockwidget.cc b/libgui/src/history-dockwidget.cc --- a/libgui/src/history-dockwidget.cc +++ b/libgui/src/history-dockwidget.cc @@ -61,6 +61,7 @@ _filter_line_edit->setStatusTip (tr ("Enter text to filter the command history.")); QVBoxLayout *vbox_layout = new QVBoxLayout (); + setWindowIcon (QIcon(":/actions/icons/logo.png")); setWindowTitle (tr ("Command History")); setWidget (new QWidget ()); @@ -85,6 +86,9 @@ this, SLOT (handle_visibility_changed (bool))); + // topLevelChanged is emitted when floating property changes (floating = true) + connect (this, SIGNAL (topLevelChanged(bool)), this, SLOT(top_level_changed(bool))); + _update_history_model_timer.setInterval (200); _update_history_model_timer.setSingleShot (true); @@ -163,6 +167,17 @@ QDockWidget::closeEvent (e); } +// slot for signal that is emitted when floating property changes +void +history_dock_widget::top_level_changed (bool floating) +{ + if(floating) + { + setWindowFlags(Qt::Window); // make a window from the widget when floating + show(); // make it visible again since setWindowFlags hides it + } +} + void history_dock_widget::update_history_callback (void) { diff --git a/libgui/src/history-dockwidget.h b/libgui/src/history-dockwidget.h --- a/libgui/src/history-dockwidget.h +++ b/libgui/src/history-dockwidget.h @@ -40,6 +40,8 @@ void handle_visibility_changed (bool visible); void request_history_model_update (); void reset_model (); + /** Slot when floating property changes */ + void top_level_changed (bool floating); signals: void information (const QString& message); diff --git a/libgui/src/m-editor/file-editor.cc b/libgui/src/m-editor/file-editor.cc --- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -352,6 +352,17 @@ } } +// slot for signal that is emitted when floating property changes +void +file_editor::top_level_changed (bool floating) +{ + if(floating) + { + setWindowFlags(Qt::Window); // make a window from the widget when floating + show(); // make it visible again since setWindowFlag hides it + } +} + void file_editor::active_tab_changed (int) { @@ -582,11 +593,12 @@ SIGNAL (tabCloseRequested (int)), this, SLOT (handle_tab_close_request (int))); connect (_tab_widget, SIGNAL (currentChanged(int)), this, SLOT (active_tab_changed (int))); + // topLevelChanged is emitted when floating property changes (floating = true) + connect (this, SIGNAL (topLevelChanged(bool)), this, SLOT(top_level_changed(bool))); resize (500, 400); - setWindowIcon (QIcon::fromTheme ("accessories-text-editor", - editor_style->standardIcon (QStyle::SP_FileIcon))); - setWindowTitle ("Octave Editor"); + setWindowIcon (QIcon(":/actions/icons/logo.png")); + setWindowTitle ("Editor"); //restore previous session QSettings *settings = resource_manager::get_settings (); diff --git a/libgui/src/m-editor/file-editor.h b/libgui/src/m-editor/file-editor.h --- a/libgui/src/m-editor/file-editor.h +++ b/libgui/src/m-editor/file-editor.h @@ -93,6 +93,8 @@ void handle_tab_close_request (); void active_tab_changed (int index); void handle_editor_state_changed (); + /** Slot when floating property changes */ + void top_level_changed (bool floating); /** Tells the editor to react on changed settings. */ void notice_settings (); diff --git a/libgui/src/main-window.cc b/libgui/src/main-window.cc --- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -397,15 +397,20 @@ restoreState (settings->value ("MainWindow/windowState").toByteArray ()); settings->beginGroup ("DockWidgets"); - // restoring the geometry of all widgets + // restoring the geometry of all dock-widgets foreach (QObject *obj, children ()) { QString name = obj->objectName (); - if (obj->isWidgetType () && ! name.isEmpty ()) + if (obj->inherits("QDockWidget") && ! name.isEmpty ()) { - QWidget *widget = qobject_cast (obj); + QDockWidget *widget = qobject_cast (obj); QVariant val = settings->value (name); widget->restoreGeometry (val.toByteArray ()); + bool floating = settings->value (name+"Floating",false).toBool (); + bool visible = settings->value (name+"Visible",true).toBool (); + if (floating) + widget->setWindowFlags (Qt::Window); // if floating, make window from widget + widget->setVisible (visible); // make widget visible if desired (setWindowFlags hides widget) } } settings->endGroup(); @@ -427,20 +432,25 @@ // FIXME -- what should happen if settings is 0? settings->setValue ("MainWindow/geometry", saveGeometry ()); - settings->setValue ("MainWindow/windowState", saveState ()); settings->beginGroup ("DockWidgets"); // saving the geometry of all widgets foreach (QObject *obj, children()) { QString name = obj->objectName (); - if (obj->isWidgetType () && ! name.isEmpty ()) + if (obj->inherits ("QDockWidget") && ! name.isEmpty ()) { - QWidget *widget = qobject_cast(obj); + QDockWidget *widget = qobject_cast (obj); settings->setValue (name, widget->saveGeometry ()); - } + bool floating = widget->isFloating (); + bool visible = widget->isVisible (); + settings->setValue (name+"Floating",floating); // store floating state + settings->setValue (name+"Visible",visible); // store visibility + if (floating) + widget->setWindowFlags(Qt::Widget); // if floating, recover the widget state such that the widget's + } // state is correctly saved by the saveSate () below } - settings->endGroup(); + settings->setValue ("MainWindow/windowState", saveState ()); // write the list of recent used directories QStringList curr_dirs; for (int i=0; i<_current_directory_combo_box->count (); i++) diff --git a/libgui/src/terminal-dockwidget.cc b/libgui/src/terminal-dockwidget.cc --- a/libgui/src/terminal-dockwidget.cc +++ b/libgui/src/terminal-dockwidget.cc @@ -30,8 +30,22 @@ : QDockWidget (p) { setObjectName ("TerminalDockWidget"); + setWindowIcon (QIcon(":/actions/icons/logo.png")); setWindowTitle (tr ("Command Window")); setWidget (terminal); connect (this, SIGNAL (visibilityChanged (bool)), this, SLOT (handle_visibility_changed (bool))); + // topLevelChanged is emitted when floating property changes (floating = true) + connect (this, SIGNAL (topLevelChanged(bool)), this, SLOT(top_level_changed(bool))); } + +// slot for signal that is emitted when floating property changes +void +terminal_dock_widget::top_level_changed (bool floating) +{ + if(floating) + { + setWindowFlags(Qt::Window); // make a window from the widget when floating + show(); // make it visible again since setWindowFlags hides it + } +} diff --git a/libgui/src/terminal-dockwidget.h b/libgui/src/terminal-dockwidget.h --- a/libgui/src/terminal-dockwidget.h +++ b/libgui/src/terminal-dockwidget.h @@ -41,6 +41,8 @@ if (visible) emit active_changed (true); } + /** Slot when floating property changes */ + void top_level_changed (bool floating); }; #endif // TERMINALDOCKWIDGET_H diff --git a/libgui/src/workspace-view.cc b/libgui/src/workspace-view.cc --- a/libgui/src/workspace-view.cc +++ b/libgui/src/workspace-view.cc @@ -35,6 +35,7 @@ : QDockWidget (p) { setObjectName ("WorkspaceView"); + setWindowIcon (QIcon(":/actions/icons/logo.png")); setWindowTitle (tr ("Workspace")); // Create a new workspace model. @@ -88,6 +89,9 @@ connect (_workspace_tree_view, SIGNAL (doubleClicked (QModelIndex)), this, SLOT (item_double_clicked (QModelIndex))); + // topLevelChanged is emitted when floating property changes (floating = true) + connect (this, SIGNAL (topLevelChanged(bool)), this, SLOT(top_level_changed(bool))); + } workspace_view::~workspace_view () @@ -215,3 +219,14 @@ emit active_changed (false); QDockWidget::closeEvent (e); } + +// slot for signal that is emitted when floating property changes +void +workspace_view::top_level_changed (bool floating) +{ + if(floating) + { + setWindowFlags(Qt::Window); // make a window from the widget when floating + show(); // make it visible again since setWindowFlags hides it + } +} diff --git a/libgui/src/workspace-view.h b/libgui/src/workspace-view.h --- a/libgui/src/workspace-view.h +++ b/libgui/src/workspace-view.h @@ -39,6 +39,8 @@ public slots: void handle_visibility_changed (bool visible); void model_changed (); + /** Slot when floating property changes */ + void top_level_changed (bool floating); signals: /** Custom signal that tells if a user has clicke away that dock widget. */