Skip to content

Commit 780d2ed

Browse files
committed
App: add "stop all" and "stop othre"
1 parent 20fd881 commit 780d2ed

3 files changed

Lines changed: 67 additions & 4 deletions

File tree

App/Client/mainwindow.cpp

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,8 @@ void MainWindow::slotCurrentViewChanged(const QWidget* pView)
783783
if(a->data().value<COperate*>() == o)
784784
a->setChecked(true);
785785
}
786+
ui->actionStop_other->setText(
787+
tr("Stop other except the current \"%1\"").arg(o->Name()));
786788
}
787789
}
788790
}
@@ -793,6 +795,16 @@ void MainWindow::EnableMenu(bool bEnable)
793795
ui->actionClone->setEnabled(bEnable);
794796
ui->actionAdd_to_favorite->setEnabled(bEnable);
795797
ui->actionStop->setEnabled(bEnable);
798+
ui->actionStop_All->setEnabled(bEnable);
799+
ui->actionStop_other->setEnabled(bEnable);
800+
if(bEnable) {
801+
if(m_Operates.size() > 1)
802+
ui->actionStop_other->setEnabled(true);
803+
else
804+
ui->actionStop_other->setEnabled(false);
805+
} else {
806+
ui->actionStop_other->setText(tr("Stop other"));
807+
}
796808
ui->actionTabBar_B->setEnabled(bEnable);
797809
ui->menuActivity->setEnabled(bEnable);
798810
m_ptbMenuActivity->setEnabled(bEnable);
@@ -1119,16 +1131,17 @@ void MainWindow::slotRunning()
11191131
}
11201132
//*/
11211133

1122-
SetSecureLevel(p);
1134+
slotCurrentViewChanged(p->GetViewer());
11231135

11241136
auto m = p->GetMenu();
11251137
if(m) {
11261138
m->addSeparator();
11271139
m->addAction(ui->actionClone);
1140+
m->addAction(ui->actionStop_All);
1141+
m->addAction(ui->actionStop_other);
11281142
}
1129-
slotLoadOperateMenu();
11301143

1131-
slotInformation(tr("Connected to ") + p->Name());
1144+
slotInformation(tr("Connected to ") + "\"" + p->Name() + "\"");
11321145
qDebug(log) << Q_FUNC_INFO << p->Name();
11331146
}
11341147
//! [MainWindow slotRunning]
@@ -1148,11 +1161,35 @@ void MainWindow::slotCloseView(const QWidget* pView)
11481161
}
11491162
}
11501163

1164+
void MainWindow::on_actionStop_other_triggered()
1165+
{
1166+
if(!m_pView) return;
1167+
foreach(auto p, m_Operates)
1168+
{
1169+
if(p->GetViewer() != m_pView->GetCurrentView())
1170+
{
1171+
//TODO: Whether to save the setting
1172+
emit p->sigUpdateParameters(p);
1173+
p->Stop();
1174+
}
1175+
}
1176+
}
1177+
1178+
void MainWindow::on_actionStop_All_triggered()
1179+
{
1180+
foreach(auto p, m_Operates)
1181+
{
1182+
//TODO: Whether to save the setting
1183+
emit p->sigUpdateParameters(p);
1184+
p->Stop();
1185+
}
1186+
}
1187+
11511188
void MainWindow::on_actionStop_triggered()
11521189
{
11531190
qDebug(log) << Q_FUNC_INFO;
11541191
if(!m_pView) return;
1155-
1192+
11561193
QWidget* pView = m_pView->GetCurrentView();
11571194
slotCloseView(pView);
11581195
}

App/Client/mainwindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ private Q_SLOTS:
9292
///////// Stop /////////
9393
private Q_SLOTS:
9494
void on_actionStop_triggered();
95+
void on_actionStop_All_triggered();
96+
void on_actionStop_other_triggered();
9597
void slotCloseView(const QWidget* pView);
9698
void slotStop();
9799
void slotFinished();

App/Client/mainwindow.ui

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
</widget>
115115
<addaction name="menuStart"/>
116116
<addaction name="actionStop"/>
117+
<addaction name="actionStop_All"/>
118+
<addaction name="actionStop_other"/>
117119
<addaction name="actionOpenListRecent"/>
118120
<addaction name="actionOpenRRCFile"/>
119121
<addaction name="separator"/>
@@ -547,6 +549,28 @@
547549
<string>Show keyboard</string>
548550
</property>
549551
</action>
552+
<action name="actionStop_All">
553+
<property name="icon">
554+
<iconset theme="media-playback-stop"/>
555+
</property>
556+
<property name="text">
557+
<string>Stop All</string>
558+
</property>
559+
<property name="toolTip">
560+
<string>Stop All</string>
561+
</property>
562+
</action>
563+
<action name="actionStop_other">
564+
<property name="icon">
565+
<iconset theme="media-playback-stop"/>
566+
</property>
567+
<property name="text">
568+
<string>Stop other</string>
569+
</property>
570+
<property name="toolTip">
571+
<string>Stop other</string>
572+
</property>
573+
</action>
550574
</widget>
551575
<resources/>
552576
<connections/>

0 commit comments

Comments
 (0)