Feature: View Menu: Restore Defaults
Fixes issue 68
This commit is contained in:
parent
05b73a5390
commit
2c28433533
@ -82,6 +82,11 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
portsDock->setWidget(portsWindow);
|
||||
addDockWidget(Qt::TopDockWidgetArea, portsDock);
|
||||
|
||||
// Save the default window geometry and layout ...
|
||||
defaultGeometry_ = geometry();
|
||||
defaultLayout_ = saveState(0);
|
||||
|
||||
// ... before restoring the last used settings
|
||||
QRect geom = appSettings->value(kApplicationWindowGeometryKey).toRect();
|
||||
if (!geom.isNull())
|
||||
setGeometry(geom);
|
||||
@ -135,6 +140,17 @@ void MainWindow::on_actionPreferences_triggered()
|
||||
delete preferences;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionViewRestoreDefaults_triggered()
|
||||
{
|
||||
// Use the saved default geometry/layout, however keep the
|
||||
// window location same
|
||||
defaultGeometry_.moveTo(geometry().topLeft());
|
||||
setGeometry(defaultGeometry_);
|
||||
restoreState(defaultLayout_, 0);
|
||||
|
||||
actionViewShowMyReservedPortsOnly->setChecked(false);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionHelpAbout_triggered()
|
||||
{
|
||||
QDialog *aboutDialog = new QDialog;
|
||||
|
@ -40,12 +40,16 @@ private:
|
||||
QDockWidget *portsDock;
|
||||
QDockWidget *statsDock;
|
||||
|
||||
QRect defaultGeometry_;
|
||||
QByteArray defaultLayout_;
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
void on_actionPreferences_triggered();
|
||||
void on_actionViewRestoreDefaults_triggered();
|
||||
void on_actionHelpAbout_triggered();
|
||||
|
||||
private slots:
|
||||
|
@ -27,7 +27,7 @@
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile" >
|
||||
<property name="title" >
|
||||
<string>File</string>
|
||||
<string>&File</string>
|
||||
</property>
|
||||
<addaction name="separator" />
|
||||
<addaction name="actionPreferences" />
|
||||
@ -35,7 +35,7 @@
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp" >
|
||||
<property name="title" >
|
||||
<string>Help</string>
|
||||
<string>&Help</string>
|
||||
</property>
|
||||
<addaction name="actionHelpAbout" />
|
||||
<addaction name="actionAboutQt" />
|
||||
@ -45,6 +45,7 @@
|
||||
<string>&View</string>
|
||||
</property>
|
||||
<addaction name="actionViewShowMyReservedPortsOnly" />
|
||||
<addaction name="actionViewRestoreDefaults" />
|
||||
</widget>
|
||||
<addaction name="menuFile" />
|
||||
<addaction name="menuView" />
|
||||
@ -80,7 +81,7 @@
|
||||
<iconset resource="ostinato.qrc" >:/icons/qt.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>About Qt</string>
|
||||
<string>About &Qt</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewShowMyReservedPortsOnly" >
|
||||
@ -88,7 +89,12 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Show My &Reserved Ports Only</string>
|
||||
<string>Show &My Reserved Ports Only</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewRestoreDefaults" >
|
||||
<property name="text" >
|
||||
<string>Restore &Defaults</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user