A function to reset the window state (View menu)

This commit is contained in:
Matthias Koefferlein 2017-09-06 23:36:04 +02:00
parent 692b1e6c31
commit 41e8c58869
3 changed files with 34 additions and 1 deletions

View File

@ -366,6 +366,11 @@ Class<lay::MainWindow> decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "MainWind
"\n"
"This event has been added in version 0.25.\n"
) +
gsi::method ("cm_reset_window_state", &lay::MainWindow::cm_reset_window_state,
"@brief 'cm_reset_window_state' action (bound to a menu)"
"\n"
"This method has been added in version 0.25.\n"
) +
gsi::method ("cm_select_all", &lay::MainWindow::cm_select_all,
"@brief 'cm_select_all' action (bound to a menu)"
"\n"

View File

@ -817,6 +817,7 @@ MainWindow::init_menu ()
MenuLayoutEntry ("show_layer_panel", tl::to_string (QObject::tr ("Layers")), std::make_pair (cfg_show_layer_panel, "?")),
MenuLayoutEntry ("show_layer_toolbox", tl::to_string (QObject::tr ("Layer Toolbox")), std::make_pair (cfg_show_layer_toolbox, "?")),
MenuLayoutEntry ("show_hierarchy_panel", tl::to_string (QObject::tr ("Cells")), std::make_pair (cfg_show_hierarchy_panel, "?")),
MenuLayoutEntry ("reset_window_state", tl::to_string (QObject::tr ("Restore Window")), SLOT (cm_reset_window_state ())),
MenuLayoutEntry::separator ("selection_group"),
MenuLayoutEntry ("transient_selection", tl::to_string (QObject::tr ("Highlight Object Under Mouse")), std::make_pair (cfg_sel_transient_mode, "?")),
MenuLayoutEntry::last ()
@ -1159,6 +1160,14 @@ MainWindow::file_removed (const QString & /*path*/)
// .. nothing yet ..
}
void
MainWindow::show ()
{
QMainWindow::show ();
m_default_window_state = saveState ();
m_default_window_geometry = saveGeometry ();
}
void
MainWindow::close_all ()
{
@ -2261,7 +2270,14 @@ MainWindow::cm_unselect_all ()
END_PROTECTED
}
void
void
MainWindow::cm_reset_window_state ()
{
restoreState (m_default_window_state);
restoreGeometry (m_default_window_geometry);
}
void
MainWindow::cm_select_all ()
{
BEGIN_PROTECTED

View File

@ -32,6 +32,7 @@
#include <QPrinter>
#include <QDialog>
#include <QTimer>
#include <QByteArray>
#include <vector>
#include <memory>
@ -151,6 +152,14 @@ public:
return mp_menu;
}
/**
* @brief Shows the window
*
* This is the function that is called after the application has set up the window but
* before the window is populated and configured
*/
void show ();
/**
* @brief Close all views
*/
@ -661,6 +670,7 @@ public slots:
void view_title_changed ();
// menu callbacks for main window
void cm_reset_window_state ();
void cm_select_all ();
void cm_unselect_all ();
void cm_undo ();
@ -880,6 +890,8 @@ private:
QTimer m_file_changed_timer;
QTimer m_menu_update_timer;
std::string m_config_window_state;
QByteArray m_default_window_state;
QByteArray m_default_window_geometry;
std::string m_initial_technology;
double m_grid_micron;