Skip to content

Commit

Permalink
feat: 根据当前标签页更新窗口标题
Browse files Browse the repository at this point in the history
适配docker无特效模式下对应用窗口的标题显示

Log: 根据当前标签页更新窗口标题
Signed-off-by: Yutao Meng <mengyutao@deepin.org>
  • Loading branch information
ArchieMeng committed Jul 31, 2023
1 parent ef3fe9f commit f1fbdcf
Show file tree
Hide file tree
Showing 6 changed files with 338 additions and 321 deletions.
10 changes: 9 additions & 1 deletion src/main/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ inline void MainWindow::slotTabBarClicked(int index, QString tabIdentifier)

inline void MainWindow::slotTabCurrentChanged(int index)
{
focusPage(m_tabbar->identifier(index));
const QString identifier = m_tabbar->identifier(index);
focusPage(identifier);
updateWindowTitle();
}

inline void MainWindow::slotTabAddRequested()
Expand Down Expand Up @@ -932,6 +934,7 @@ void MainWindow::onTermTitleChanged(QString title)
const bool customName = tabPage->property("TAB_CUSTOM_NAME_PROPERTY").toBool();
if (!customName)
m_tabbar->setTabText(tabPage->identifier(), title);
updateWindowTitle();

// 判定第一次修改标题的时候,认为终端已经创建成功
// 以此认为第一次打开终端窗口结束,记录时间
Expand Down Expand Up @@ -2507,6 +2510,11 @@ void MainWindow::onCommandActionTriggered()
this->currentPage()->sendTextToCurrentTerm(command);
}

inline void MainWindow::updateWindowTitle()
{
setWindowTitle(QString("%1 - %2").arg(m_tabbar->tabText(m_tabbar->currentIndex())).arg(QObject::tr("Terminal")));
}

/////////////////////////////////////////////////////////////////////////////////////////////////////
/**
普通终端窗口
Expand Down
5 changes: 5 additions & 0 deletions src/main/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,11 @@ protected slots:
*/
void setTitlebarNoFocus(QWidget * titlebar);

/**
* @brief 根据当前标签页标题更新窗口名
*/
inline void updateWindowTitle();

protected:
// 初始化标题栏
virtual void initTitleBar() = 0;
Expand Down
Loading

0 comments on commit f1fbdcf

Please sign in to comment.