Clear current and selection when restoring default view

This is done for all top level windows - ports, stats, logs

At startup, the local portgroup would automatically become current with
the result that the welcome page would not be visible. Not sure why but
an explicit setFocus of ports window seems to avoid it.
This commit is contained in:
Srivats P 2020-05-07 18:40:31 +05:30
parent f309ce99cc
commit 1e1e0b0c48
7 changed files with 29 additions and 0 deletions

View File

@ -75,6 +75,12 @@ LogsWindow::~LogsWindow()
delete logsModelTest_;
}
void LogsWindow::clearCurrentSelection()
{
logs->selectionModel()->clearCurrentIndex();
logs->clearSelection();
}
void LogsWindow::when_visibilityChanged(bool visible)
{
if (visible) {

View File

@ -34,6 +34,9 @@ public:
LogsWindow(LogsModel *model, QWidget *parent = 0);
~LogsWindow();
public slots:
void clearCurrentSelection();
private slots:
void when_visibilityChanged(bool visible);
void when_rowsInserted(const QModelIndex &parent, int first, int last);

View File

@ -138,6 +138,8 @@ MainWindow::MainWindow(QWidget *parent)
resizeDocks({portsDock, statsDock}, {height()/2, height()/2}, Qt::Vertical);
#endif
portsWindow->setFocus();
// Save the default window geometry and layout ...
defaultGeometry_ = geometry();
defaultLayout_ = saveState(0);
@ -366,6 +368,10 @@ void MainWindow::on_actionViewRestoreDefaults_triggered()
statsDock->raise();
actionViewShowMyReservedPortsOnly->setChecked(false);
portsWindow->clearCurrentSelection();
statsWindow->clearCurrentSelection();
logsWindow_->clearCurrentSelection();
}
void MainWindow::on_actionHelpOnline_triggered()

View File

@ -89,6 +89,12 @@ PortStatsWindow::~PortStatsWindow()
/* ------------- SLOTS (public) -------------- */
void PortStatsWindow::clearCurrentSelection()
{
tvPortStats->selectionModel()->clearCurrentIndex();
tvPortStats->clearSelection();
}
void PortStatsWindow::showMyReservedPortsOnly(bool enabled)
{
if (!proxyStatsModel)

View File

@ -38,6 +38,7 @@ public:
~PortStatsWindow();
public slots:
void clearCurrentSelection();
void showMyReservedPortsOnly(bool enabled);
private slots:

View File

@ -298,6 +298,12 @@ bool PortsWindow::saveSession(
return true;
}
void PortsWindow::clearCurrentSelection()
{
tvPortList->selectionModel()->clearCurrentIndex();
tvPortList->clearSelection();
}
void PortsWindow::showMyReservedPortsOnly(bool enabled)
{
if (!proxyPortModel)

View File

@ -65,6 +65,7 @@ private:
ApplyMessage *applyMsg_;
public slots:
void clearCurrentSelection();
void showMyReservedPortsOnly(bool enabled);
private slots: