Skip to content

Commit

Permalink
src:fix hexviewer
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoming <2014500726@smail.xtu.edu.cn>
  • Loading branch information
QQxiaoming committed Oct 18, 2023
1 parent 1cd7446 commit 3b1e115
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/hexviewwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
#include <QMessageBox>
#include <QScrollBar>
#include <QMutexLocker>
#include "hexviewwindow.h"
#include "ui_hexviewwindow.h"

Expand Down Expand Up @@ -71,6 +72,7 @@ HexViewWindow::~HexViewWindow()
void HexViewWindow::setFont(const QFont &font)
{
ui->textEditHEX->setFont(font);
ui->textEditASCII->setFont(font);
}

void HexViewWindow::buttonBoxAccepted(void)
Expand All @@ -94,6 +96,7 @@ void HexViewWindow::buttonBoxRejected(void)

void HexViewWindow::recvData(const char *data,int size)
{
QMutexLocker locker(&m_mutex);
auto insertPlainText = [&](const char *data,int size){
if(size > 0) {
QByteArray ba(data,size);
Expand Down
2 changes: 2 additions & 0 deletions src/hexviewwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QDialog>
#include <QHideEvent>
#include <QFont>
#include <QMutex>

namespace Ui {
class HexViewWindow;
Expand Down Expand Up @@ -60,6 +61,7 @@ private slots:
private:
Ui::HexViewWindow *ui;
int m_type;
QMutex m_mutex;
};

#endif // HEXVIEWWINDOWS_H
18 changes: 17 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ MainWidgetGroup* MainWindow::findCurrentFocusGroup(void) {
return mainWidgetGroup;
}
}
foreach(MainWidgetGroup *mainWidgetGroup, mainWidgetGroupList) {
if(mainWidgetGroup->sessionTab->count() != 0) {
return mainWidgetGroup;
}
}
return mainWidgetGroupList[0];
}

Expand Down Expand Up @@ -1056,8 +1061,19 @@ void MainWindow::menuAndToolBarConnectSignals(void) {
}
);
connect(hexViewAction,&QAction::triggered,this,[=](){
if(hexViewAction->isChecked())
if(hexViewAction->isChecked()) {
hexViewWindow->show();
QTermWidget *termWidget = findCurrentFocusTermWidget();
if(termWidget == nullptr) return;
foreach(SessionsWindow *sessionsWindow, sessionList) {
disconnect(sessionsWindow,SIGNAL(hexDataDup(const char*,int)),
hexViewWindow,SLOT(recvData(const char*,int)));
if(sessionsWindow->getTermWidget() == termWidget) {
connect(sessionsWindow,SIGNAL(hexDataDup(const char*,int)),
hexViewWindow,SLOT(recvData(const char*,int)));
}
}
}
else
hexViewWindow->hide();
});
Expand Down

0 comments on commit 3b1e115

Please sign in to comment.