Skip to content

Commit

Permalink
Fix the issue that the target session object is inaccurate when locki…
Browse files Browse the repository at this point in the history
…ng/unlocking the session

Signed-off-by: xiaoming <2014500726@smail.xtu.edu.cn>
  • Loading branch information
QQxiaoming committed Aug 16, 2024
1 parent f07e1c0 commit 2e12aa1
Showing 6 changed files with 67 additions and 69 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ en-US:
- Allow editing the text to be pasted when confirming multiple lines of paste
- Fix the issue that clicking the new tab button in split screen mode may not create the session correctly or be located under the wrong tab group
- Fix the issue that the SSH connection cannot be reconnected by tapping the Enter key in some cases
- Fix the issue that the target session object is inaccurate when locking/unlocking the session

zh-CN:

@@ -23,6 +24,7 @@ zh-CN:
- 多行粘贴确认时允许编辑待粘贴文本
- 修复分屏模式下某些情况点击新标签按钮会话未正确创建或位于错误的标签页组下
- 修复ssh连接部分情况下无法通过敲击回车键发起重连的问题
- 修复锁定/解锁会话时目标会话对象不准确

## [[V0.4.8](https://github.com/QQxiaoming/quardCRT/releases/tag/V0.4.8)] - 2024-07-26

1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
- Allow editing the text to be pasted when confirming multiple lines of paste
- Fix the issue that clicking the new tab button in split screen mode may not create the session correctly or be located under the wrong tab group
- Fix the issue that the SSH connection cannot be reconnected by tapping the Enter key in some cases
- Fix the issue that the target session object is inaccurate when locking/unlocking the session

## [[V0.4.8](https://github.com/QQxiaoming/quardCRT/releases/tag/V0.4.8)] - 2024-07-26

6 changes: 4 additions & 2 deletions src/locksessionwindow/locksessionwindow.cpp
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ void LockSessionWindow::buttonBoxAccepted(void)
return;
}
ui->passwordLineEdit->clear();
emit this->sendUnLockSessionData(password, ui->lockAllSessionCheckBox->isChecked());
emit this->sendUnLockSessionData(password, ui->lockAllSessionCheckBox->isChecked(), ui->lockAllSessionGroupCheckBox->isChecked());
}

emit this->accepted();
@@ -83,6 +83,7 @@ void LockSessionWindow::showLock(void)
{
ui->headerLabel->setText(tr("Enter the password that will be used to unlock the session:"));
ui->lockAllSessionCheckBox->setText(tr("Lock all sessions"));
ui->lockAllSessionGroupCheckBox->setText(tr("Lock all sessions in tab group"));
ui->lockAllSessionCheckBox->setVisible(true);
ui->lockAllSessionGroupCheckBox->setVisible(true);
ui->passwordLineEdit->setVisible(true);
@@ -97,8 +98,9 @@ void LockSessionWindow::showUnlock(void)
{
ui->headerLabel->setText(tr("Enter the password that was used to lock the session:"));
ui->lockAllSessionCheckBox->setText(tr("Unlock all sessions"));
ui->lockAllSessionGroupCheckBox->setText(tr("Unlock all sessions in tab group"));
ui->lockAllSessionCheckBox->setVisible(true);
ui->lockAllSessionGroupCheckBox->setVisible(false);
ui->lockAllSessionGroupCheckBox->setVisible(true);
ui->passwordLineEdit->setVisible(true);
ui->passwordLabel->setVisible(true);
ui->reenterPasswordLineEdit->setVisible(false);
2 changes: 1 addition & 1 deletion src/locksessionwindow/locksessionwindow.h
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ class LockSessionWindow : public QDialog

signals:
void sendLockSessionData(QString password, bool lockAllSession, bool lockAllSessionGroup);
void sendUnLockSessionData(QString password, bool lockAllSession);
void sendUnLockSessionData(QString password, bool lockAllSession, bool lockAllSessionGroup);

private slots:
void buttonBoxAccepted(void);
123 changes: 58 additions & 65 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -371,7 +371,6 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
if(sessionsWindow->getMainWidget() == widget) {
logSessionAction->setChecked(sessionsWindow->isLog());
rawLogSessionAction->setChecked(sessionsWindow->isRawLog());
lockSessionAction->setChecked(sessionsWindow->isLocked());
if(hexViewAction->isChecked()) {
connect(sessionsWindow,&SessionsWindow::hexDataDup,
hexViewWindow,&HexViewWindow::recvData);
@@ -397,7 +396,8 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
QAction *unlockAction = new QAction(tr("Unlock Session"),this);
unlockAction->setStatusTip(tr("Unlock current session"));
menu->addAction(unlockAction);
connect(unlockAction,&QAction::triggered,this,[&](){
connect(unlockAction,&QAction::triggered,this,[=](){
willLockUnLockSessions = sessionsWindow;
lockSessionWindow->showUnlock();
});
} else {
@@ -420,8 +420,6 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
copyPathAction->setStatusTip(tr("Copy current session working folder path"));
menu->addAction(copyPathAction);
connect(copyPathAction,&QAction::triggered,this,[=](){
QWidget *widget = mainWidgetGroup->sessionTab->currentWidget();
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
QString dir = sessionsWindow->getWorkingDirectory();
if(!dir.isEmpty()) {
QFileInfo fileInfo(dir);
@@ -436,8 +434,6 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
addPathToBookmarkAction->setStatusTip(tr("Add current session working folder path to bookmark"));
menu->addAction(addPathToBookmarkAction);
connect(addPathToBookmarkAction,&QAction::triggered,this,[=](){
QWidget *widget = mainWidgetGroup->sessionTab->currentWidget();
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
QString dir = sessionsWindow->getWorkingDirectory();
if(!dir.isEmpty()) {
QFileInfo fileInfo(dir);
@@ -453,8 +449,6 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
menu->addAction(openWorkingFolderAction);
menu->addSeparator();
connect(openWorkingFolderAction,&QAction::triggered,this,[=](){
QWidget *widget = mainWidgetGroup->sessionTab->currentWidget();
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
QString dir = sessionsWindow->getWorkingDirectory();
if(!dir.isEmpty()) {
QFileInfo fileInfo(dir);
@@ -473,8 +467,6 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
menu->addAction(openSFtpAction);
menu->addSeparator();
connect(openSFtpAction,&QAction::triggered,this,[=](){
QWidget *widget = mainWidgetGroup->sessionTab->currentWidget();
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
SshSFtp *sftp = sessionsWindow->getSshSFtpChannel();
if(sftp == nullptr) {
QMessageBox::warning(this, tr("Warning"), tr("No SFTP channel!"));
@@ -495,8 +487,6 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
}
menu->addAction(addToBroadCastSessionListAction);
connect(addToBroadCastSessionListAction,&QAction::triggered,this,[=](){
QWidget *widget = mainWidgetGroup->sessionTab->currentWidget();
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
sessionsWindow->setInBroadCastList(!sessionsWindow->isInBroadCastList());
if(sessionsWindow->isInBroadCastList()) {
if(!broadCastSessionList.contains(sessionsWindow)){
@@ -506,12 +496,17 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
broadCastSessionList.removeOne(sessionsWindow);
}
});
QAction *lockAction = new QAction(tr("Lock Session"),this);
lockAction->setStatusTip(tr("Lock current session"));
menu->addAction(lockAction);
connect(lockAction,&QAction::triggered,this,[=](){
willLockUnLockSessions = sessionsWindow;
lockSessionWindow->showLock();
});
QAction *saveSessionAction = new QAction(tr("Save Session"),this);
saveSessionAction->setStatusTip(tr("Save current session to session manager"));
menu->addAction(saveSessionAction);
connect(saveSessionAction,&QAction::triggered,this,[=](){
QWidget *widget = mainWidgetGroup->sessionTab->currentWidget();
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
QString name = sessionsWindow->getName();
if(checkSessionName(name)) {
addSessionToSessionManager(sessionsWindow,name);
@@ -573,8 +568,6 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
tagMenu->addAction(cancelTagAction);

connect(tagGroup,&QActionGroup::triggered,this,[=](QAction *action){
QWidget *widget = mainWidgetGroup->sessionTab->currentWidget();
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
QString colorStr = action->text();
if(action == cancelTagAction) {
sessionsWindow->setTagColor(false);
@@ -597,8 +590,6 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
menu->addAction(propertiesAction);
menu->addSeparator();
connect(propertiesAction,&QAction::triggered,this,[=](){
QWidget *widget = mainWidgetGroup->sessionTab->currentWidget();
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
if(sessionsWindow->isLocked()) {
return;
}
@@ -1660,8 +1651,6 @@ void CentralWidget::menuAndToolBarRetranslateUi(void) {
cloneSessionAction->setText(tr("Clone Session"));
cloneSessionAction->setStatusTip(tr("Clone current session <Ctrl+Shift+T>"));
cloneSessionAction->setShortcut(QKeySequence(Qt::CTRL|Qt::SHIFT|Qt::Key_T));
lockSessionAction->setText(tr("Lock Session"));
lockSessionAction->setStatusTip(tr("Lock/Unlock current session"));
logSessionAction->setText(tr("Log Session"));
logSessionAction->setStatusTip(tr("Create a log file for current session"));
rawLogSessionAction->setText(tr("Raw Log Session"));
@@ -1990,10 +1979,6 @@ void CentralWidget::menuAndToolBarInit(void) {
cloneSessionAction = new QAction(this);
fileMenu->addAction(cloneSessionAction);
fileMenu->addSeparator();
lockSessionAction = new QAction(this);
lockSessionAction->setCheckable(true);
fileMenu->addAction(lockSessionAction);
fileMenu->addSeparator();
logSessionAction = new QAction(this);
logSessionAction->setCheckable(true);
logSessionAction->setChecked(false);
@@ -2559,7 +2544,6 @@ void CentralWidget::setSessionClassActionEnable(bool enable)
disconnectAction->setEnabled(enable);
disconnectAllAction->setEnabled(enable);
cloneSessionAction->setEnabled(enable);
lockSessionAction->setEnabled(enable);
logSessionAction->setEnabled(enable);
rawLogSessionAction->setEnabled(enable);

@@ -2627,47 +2611,65 @@ void CentralWidget::menuAndToolBarConnectSignals(void) {
if(!sessionsWindow->isLocked()) sessionsWindow->lockSession(password);
}
} else if(lockAllSessionGroup) {
SessionTab *sessionTab = findCurrentFocusGroup()->sessionTab;
if(sessionTab->count() == 0) return;
for(int i=0;i<sessionTab->count();i++) {
QWidget *widget = sessionTab->widget(i+1);
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
if(!sessionsWindow->isLocked()) sessionsWindow->lockSession(password);
if(!sessionList.contains(willLockUnLockSessions)) return;
SessionTab *sessionTab = nullptr;
foreach(MainWidgetGroup *mainWidgetGroup, mainWidgetGroupList) {
if(mainWidgetGroup->type() != MainWidgetGroup::EMBEDDED) {
continue;
}
if(mainWidgetGroup->size().width() == 0) {
continue;
}
if(mainWidgetGroup->sessionTab->indexOf(willLockUnLockSessions->getMainWidget()) > 0) {
sessionTab = mainWidgetGroup->sessionTab;
break;
}
}
if(sessionTab) {
if(sessionTab->count() == 0) return;
for(int i=0;i<sessionTab->count();i++) {
QWidget *widget = sessionTab->widget(i+1);
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
if(!sessionsWindow->isLocked()) sessionsWindow->lockSession(password);
}
}
} else {
QWidget *widget = findCurrentFocusWidget();
if(widget == nullptr) return;
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
if(!sessionsWindow->isLocked()) sessionsWindow->lockSession(password);
}
QWidget *widget = findCurrentFocusWidget();
if(widget == nullptr) return;
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
if(sessionsWindow->isLocked()) {
lockSessionAction->setChecked(true);
} else {
lockSessionAction->setChecked(false);
if(!sessionList.contains(willLockUnLockSessions)) return;
if(!willLockUnLockSessions->isLocked()) willLockUnLockSessions->lockSession(password);
}
});
connect(lockSessionWindow,&LockSessionWindow::sendUnLockSessionData,this,
[=](QString password, bool unlockAllSession){
[=](QString password, bool unlockAllSession, bool unlockAllSessionGroup){
if(unlockAllSession) {
foreach(SessionsWindow *sessionsWindow, sessionList) {
if(sessionsWindow->isLocked()) sessionsWindow->unlockSession(password);
}
} else if(unlockAllSessionGroup) {
if(!sessionList.contains(willLockUnLockSessions)) return;
SessionTab *sessionTab = nullptr;
foreach(MainWidgetGroup *mainWidgetGroup, mainWidgetGroupList) {
if(mainWidgetGroup->type() != MainWidgetGroup::EMBEDDED) {
continue;
}
if(mainWidgetGroup->size().width() == 0) {
continue;
}
if(mainWidgetGroup->sessionTab->indexOf(willLockUnLockSessions->getMainWidget()) > 0) {
sessionTab = mainWidgetGroup->sessionTab;
break;
}
}
if(sessionTab) {
if(sessionTab->count() == 0) return;
for(int i=0;i<sessionTab->count();i++) {
QWidget *widget = sessionTab->widget(i+1);
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
if(sessionsWindow->isLocked()) sessionsWindow->unlockSession(password);
}
}
} else {
QWidget *widget = findCurrentFocusWidget();
if(widget == nullptr) return;
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
if(sessionsWindow->isLocked()) sessionsWindow->unlockSession(password);
}
QWidget *widget = findCurrentFocusWidget();
if(widget == nullptr) return;
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
if(sessionsWindow->isLocked()) {
lockSessionAction->setChecked(true);
} else {
lockSessionAction->setChecked(false);
if(!sessionList.contains(willLockUnLockSessions)) return;
if(willLockUnLockSessions->isLocked()) willLockUnLockSessions->unlockSession(password);
}
});

@@ -2714,15 +2716,6 @@ void CentralWidget::menuAndToolBarConnectSignals(void) {
connect(cloneSessionAction,&QAction::triggered,this,[=](){
cloneCurrentSession(findCurrentFocusGroup());
});
connect(lockSessionAction,&QAction::triggered,this,[=](){
if(lockSessionAction->isChecked()) {
lockSessionWindow->showLock();
lockSessionAction->setChecked(false);
} else {
lockSessionWindow->showUnlock();
lockSessionAction->setChecked(true);
}
});
connect(logSessionAction,&QAction::triggered,this,
[&](void) {
QWidget *widget = findCurrentFocusWidget();
2 changes: 1 addition & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
@@ -289,7 +289,6 @@ private slots:
QAction *connectAddressEditAction;
QAction *disconnectAllAction;
QAction *cloneSessionAction;
QAction *lockSessionAction;
QAction *logSessionAction;
QAction *rawLogSessionAction;
QAction *hexViewAction;
@@ -417,6 +416,7 @@ private slots:
KeyChainClass keyChainClass;
QList<SessionsWindow *> sessionList;
QList<SessionsWindow *> broadCastSessionList;
SessionsWindow *willLockUnLockSessions = nullptr;
struct pluginState_t {
PluginInterface *iface;
bool state;

0 comments on commit 2e12aa1

Please sign in to comment.