Skip to content

Commit

Permalink
Allow the tab title to display a custom session name
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoming <[email protected]>
  • Loading branch information
QQxiaoming committed Aug 20, 2024
1 parent 4979130 commit 2e6e91e
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ en-US:
- Add emphasized color border to the activated session in split screen mode
- Add custom color feature to the highlight
- Allow editing the text to be pasted when confirming multiple lines of paste
- Allow the tab title to display a custom session name
- 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
Expand All @@ -22,6 +23,7 @@ zh-CN:
- 分屏模式下激活的会话增加强调色边框
- 高亮功能增加自定义颜色功能
- 多行粘贴确认时允许编辑待粘贴文本
- 标签栏标题允许显示自定义会话名称
- 修复分屏模式下某些情况点击新标签按钮会话未正确创建或位于错误的标签页组下
- 修复ssh连接部分情况下无法通过敲击回车键发起重连的问题
- 修复锁定/解锁会话时目标会话对象不准确
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Add emphasized color border to the activated session in split screen mode
- Add custom color feature to the highlight
- Allow editing the text to be pasted when confirming multiple lines of paste
- Allow the tab title to display a custom session name
- 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
Expand Down
5 changes: 2 additions & 3 deletions lib/Qtftp/qtftp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,8 @@ void QTftp::nak(TftpError error)
pe->e_msg = strerror(error - 100);
th->data.block = EUNDEF; /* set 'undef' errorcode */
}

strcpy(th->data.data, pe->e_msg);
int length = strlen(pe->e_msg);
int length = strlen(pe->e_msg);
memcpy(th->data.data, pe->e_msg, length);
th->data.data[length] = 0;
length += 5;
sock->writeDatagram(buffer, length, rhost, rport);
Expand Down
21 changes: 21 additions & 0 deletions lib/qextserialport/qextserialport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@
#include <QReadLocker>
#include <QWriteLocker>

#ifdef __has_cpp_attribute
# define QEXTSP_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
#else
# define QEXTSP_HAS_CPP_ATTRIBUTE(x) 0
#endif
#if defined(__cplusplus)
#if QEXTSP_HAS_CPP_ATTRIBUTE(clang::fallthrough)
# define QEXTSPFALLTHROUGH() [[clang::fallthrough]]
#elif QEXTSP_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
# define QEXTSPFALLTHROUGH() [[gnu::fallthrough]]
#elif QEXTSP_HAS_CPP_ATTRIBUTE(fallthrough)
# define QEXTSPFALLTHROUGH() [[fallthrough]]
#endif
#endif
#ifndef QEXTSPFALLTHROUGH
# define QEXTSPFALLTHROUGH() (void)0
#endif

/*!
\class PortSettings
Expand Down Expand Up @@ -83,6 +101,7 @@ void QextSerialPortPrivate::setBaudRate(BaudRateType baudRate, bool update)
case BAUD128000:
case BAUD256000:
QESP_PORTABILITY_WARNING()<<"QextSerialPort Portability Warning: POSIX does not support baudRate:"<<baudRate;
QEXTSPFALLTHROUGH();
#elif defined(Q_OS_UNIX)
//Unix Special
case BAUD50:
Expand Down Expand Up @@ -110,6 +129,7 @@ void QextSerialPortPrivate::setBaudRate(BaudRateType baudRate, bool update)
case BAUD4000000:
# endif
QESP_PORTABILITY_WARNING()<<"QextSerialPort Portability Warning: Windows does not support baudRate:"<<baudRate;
QEXTSPFALLTHROUGH();
#endif
case BAUD110:
case BAUD300:
Expand All @@ -133,6 +153,7 @@ void QextSerialPortPrivate::setBaudRate(BaudRateType baudRate, bool update)
#if !(defined(Q_OS_WIN) || defined(Q_OS_MAC))
default:
QESP_WARNING()<<"QextSerialPort does not support baudRate:"<<baudRate;
break;
#endif
}
}
Expand Down
9 changes: 9 additions & 0 deletions lib/sqlite/carray.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ static int carrayConnect(
if( pNew==0 ) return SQLITE_NOMEM;
memset(pNew, 0, sizeof(*pNew));
}
(void)pAux;
(void)argc;
(void)argv;
(void)pzErr;
return rc;
}

Expand All @@ -173,6 +177,7 @@ static int carrayOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
if( pCur==0 ) return SQLITE_NOMEM;
memset(pCur, 0, sizeof(*pCur));
*ppCursor = &pCur->base;
(void)p;
return SQLITE_OK;
}

Expand Down Expand Up @@ -311,6 +316,8 @@ static int carrayFilter(
}
}
pCur->iRowid = 1;
(void)idxStr;
(void)argc;
return SQLITE_OK;
}

Expand Down Expand Up @@ -381,6 +388,7 @@ static int carrayBestIndex(
pIdxInfo->estimatedRows = 2147483647;
pIdxInfo->idxNum = 0;
}
(void)tab;
return SQLITE_OK;
}

Expand Down Expand Up @@ -557,5 +565,6 @@ SQLITE_API int sqlite3_carray_init(
}
#endif /* SQLITE_TEST */
#endif /* SQLITE_OMIT_VIRTUALTABLE */
(void)pzErrMsg;
return rc;
}
13 changes: 10 additions & 3 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,12 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
QWidget *widget = mainWidgetGroup->sessionTab->widget(index);
SessionsWindow *sessionsWindow = widget->property("session").value<SessionsWindow *>();
if(sessionsWindow->isLocked()) return;
sessionsWindow->setShowShortTitle(!sessionsWindow->getShowShortTitle());
SessionsWindow::ShowTitleType type = sessionsWindow->getShowTitleType();
type = static_cast<SessionsWindow::ShowTitleType>(type+1);
if(type == SessionsWindow::TitleTypeMax) {
type = static_cast<SessionsWindow::ShowTitleType>(0);
}
sessionsWindow->setShowTitleType(type);
mainWidgetGroup->sessionTab->setTabText(index,sessionsWindow->getTitle());
});
#if defined(Q_OS_MACOS)
Expand Down Expand Up @@ -1001,7 +1006,7 @@ CentralWidget::CentralWidget(QString dir, StartupUIMode mode, QLocale lang, bool
endOfLineSeqMenu->addAction(endOfLineSeqCRCRAction);
connect(endOfLineSeqGroup,&QActionGroup::triggered,this,[=](QAction *action){
int index = endOfLineSeqGroup->actions().indexOf(action);
sessionsWindow->setEndOfLineSeq((SessionsWindow::EndOfLineSeq)index);
sessionsWindow->setEndOfLineSeq(static_cast<SessionsWindow::EndOfLineSeq>(index));
});
endOfLineSeqMenu->popup(QCursor::pos());
}
Expand Down Expand Up @@ -4526,7 +4531,7 @@ int CentralWidget::cloneTargetSession(MainWidgetGroup *group, QString name,Sessi
setGlobalOptions(sessionsWindowClone);
sessionsWindowClone->setLongTitle(sessionsWindow->getLongTitle());
sessionsWindowClone->setShortTitle(sessionsWindow->getShortTitle());
sessionsWindowClone->setShowShortTitle(sessionsWindow->getShowShortTitle());
sessionsWindowClone->setShowTitleType(sessionsWindow->getShowTitleType());
int index = group->sessionTab->addTab(-1, sessionsWindowClone->getMainWidget(), group->sessionTab->tabTitle(group->sessionTab->indexOf(widget)));
connectSessionStateChange(group->sessionTab,index,sessionsWindowClone);
if(name.isEmpty()) {
Expand Down Expand Up @@ -4577,6 +4582,8 @@ int CentralWidget::cloneTargetSession(MainWidgetGroup *group, QString name,Sessi
group->sessionTab->setCurrentIndex(group->sessionTab->count()-1);
break;
}
default:
break;
}
return 0;
}
Expand Down
10 changes: 8 additions & 2 deletions src/sessionswindow/sessionswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SessionsWindow::SessionsWindow(SessionType tp, QWidget *parent)
: QObject(parent)
, type(tp)
, workingDirectory(QDir::homePath())
, showShortTitle(false)
, showTitleType(LongTitle)
, messageParentWidget(parent)
, term(nullptr)
, telnet(nullptr)
Expand Down Expand Up @@ -117,7 +117,7 @@ SessionsWindow::SessionsWindow(SessionType tp, QWidget *parent)

switch (type) {
case LocalShell: {
showShortTitle = true;
showTitleType = ShortTitle;
localShell = PtyQt::createPtyProcess();
connect(term, &QTermWidget::termSizeChange, this, [=](int lines, int columns){
localShell->resize(columns,lines);
Expand Down Expand Up @@ -470,6 +470,7 @@ SessionsWindow::SessionsWindow(SessionType tp, QWidget *parent)
break;
}
case VNC:
default:
break;
}

Expand Down Expand Up @@ -781,6 +782,8 @@ void SessionsWindow::cloneSession(SessionsWindow *src) {
case VNC:
startVNCSession(src->m_hostname, src->m_port, src->m_password);
break;
default:
break;
}
}
}
Expand Down Expand Up @@ -1039,6 +1042,8 @@ void SessionsWindow::disconnect(void) {
case VNC:
vncClient->disconnectFromVncServer();
break;
default:
break;
}
}

Expand Down Expand Up @@ -1758,6 +1763,7 @@ SessionsWindow::StateInfo SessionsWindow::getStateInfo(void) {
#endif
break;
case VNC:
default:
break;
}
return info;
Expand Down
37 changes: 30 additions & 7 deletions src/sessionswindow/sessionswindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,26 @@ class SessionsWindow : public QObject
Q_OBJECT
public:
enum SessionType {
Telnet,
Telnet = 0,
Serial,
LocalShell,
RawSocket,
NamePipe,
SSH2,
VNC,

SessionTypeMax,
};
enum ShellType {
UnixShell,
UnixShell = 0,
PowerShell,
WSL,
Unknown,

ShellTypeMax,
};
enum SessionsState {
Connected,
Connected = 0,
Disconnected,
Locked,
BroadCasted,
Expand All @@ -71,6 +75,15 @@ class SessionsWindow : public QObject
CR,
LFLF,
CRCR,

EndOfLineSeqMax,
};
enum ShowTitleType {
LongTitle = 0,
ShortTitle,
NameTitle,

TitleTypeMax,
};
struct StateInfo {
SessionType type;
Expand Down Expand Up @@ -179,11 +192,21 @@ class SessionsWindow : public QObject
SessionType getSessionType() const { return type; }
ShellType getShellType() const { return shellType; }
QString getWSLUserName() const { return m_wslUserName; }
QString getTitle() const { return showShortTitle ? shortTitle : longTitle; }
void setShowTitleType(ShowTitleType type) { showTitleType = type; }
ShowTitleType getShowTitleType() const { return showTitleType; }
QString getTitle() const {
switch(showTitleType) {
default:
case LongTitle:
return longTitle;
case ShortTitle:
return shortTitle;
case NameTitle:
return name;
}
}
QString getLongTitle() const { return longTitle; }
QString getShortTitle() const { return shortTitle; }
void setShowShortTitle(bool show) { showShortTitle = show; }
bool getShowShortTitle() const { return showShortTitle; }
void setLongTitle(const QString &title) { longTitle = title; }
void setShortTitle(const QString &title) { shortTitle = title; }
void setName(const QString &name) { this->name = name; }
Expand Down Expand Up @@ -433,7 +456,7 @@ class SessionsWindow : public QObject
QString longTitle;
QString shortTitle;
QString name;
bool showShortTitle;
ShowTitleType showTitleType;
QWidget *messageParentWidget;
QTermWidget *term;
QTelnet *telnet;
Expand Down
5 changes: 5 additions & 0 deletions src/statusbarwidget/statusbarwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ void StatusBarWidget::setEndOfLine(bool enable, SessionsWindow::EndOfLineSeq typ
case SessionsWindow::CRCR:
statusBarEndOfLine->setText("CRCR");
break;
default:
statusBarEndOfLine->setText("/");
statusBarEndOfLine->setEnabled(false);
statusBarEndOfLine->setVisible(false);
return;
}
if(!statusBarEndOfLine->isEnabled()) {
statusBarEndOfLine->setEnabled(true);
Expand Down

0 comments on commit 2e6e91e

Please sign in to comment.