diff --git a/src/common/utils.cpp b/src/common/utils.cpp index aca242abb..02a022a76 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -31,7 +31,7 @@ #include #include #include - +#include #include QHash Utils::m_imgCacheHash; @@ -45,6 +45,12 @@ Utils::~Utils() { } +#ifdef QT_DEBUG +Q_LOGGING_CATEGORY(LogCommon,"log.terminal.common.work") +#else +Q_LOGGING_CATEGORY(LogCommon,"log.terminal.common.work",QtInfoMsg) +#endif + QString Utils::getQssContent(const QString &filePath) { QFile file(filePath); @@ -330,7 +336,7 @@ void Utils::parseCommandLine(QStringList arguments, TermProperties &Properties, // 解析参数 Properties[KeepOpen] = false; if (!parser.parse(arguments)) - qInfo() << "parser error:" << parser.errorText(); + qCInfo(LogCommon) << "parser error:" << parser.errorText(); if (parser.isSet(optExecute)) { /************************ Add by sunchengxi 2020-09-15:Bug#42864 无法同时打开多个终端 Begin************************/ @@ -371,11 +377,11 @@ void Utils::parseCommandLine(QStringList arguments, TermProperties &Properties, // 处理相应参数,当遇到-v -h参数的时候,这里进程会退出。 parser.process(arguments); } else { - qInfo() << "Command line input args:" << qPrintable(arguments.join(" ")); - qInfo() << "The work directory :" << parser.value(optWorkDirectory); - qInfo() << QString("Execute %1 command in the terminal").arg(Properties[Execute].toStringList().join(" ")); - qInfo() << "Run in quake mode :" << parser.isSet(optQuakeMode); - qInfo() << "Set the window mode on starting :" << parser.isSet(optWindowState); + qCInfo(LogCommon) << "Command line input args:" << qPrintable(arguments.join(" ")); + qCInfo(LogCommon) << "The work directory :" << parser.value(optWorkDirectory); + qCInfo(LogCommon) << QString("Execute %1 command in the terminal").arg(Properties[Execute].toStringList().join(" ")); + qCInfo(LogCommon) << "Run in quake mode :" << parser.isSet(optQuakeMode); + qCInfo(LogCommon) << "Set the window mode on starting :" << parser.isSet(optWindowState); // 这个位置参数解析出来是无法匹配的,可是不带前面标识符,无法准确使用。 } return; @@ -431,7 +437,7 @@ QStringList Utils::parseExecutePara(QStringList &arguments) } arguments.removeOne("-e"); arguments.removeOne("--execute"); - qInfo() << "Remove the arguments after '-e',the arguments :" << arguments; + qCInfo(LogCommon) << "Remove the arguments after '-e',the arguments :" << arguments; } return paraList; @@ -455,7 +461,7 @@ QStringList Utils::parseNestedQString(QString str) //对路径带空格的脚本,右键执行时不进行拆分处理, //./deepin-terminal "-e" "/home/lx777/Desktop/a b/PerfTools_1.9.sh" QFileInfo fi(str); if (fi.isFile()) { - qWarning() << "this is file,not split."; + qCWarning(LogCommon) << "this is file,not split."; paraList.append(str); return paraList; } @@ -522,7 +528,7 @@ QList Utils::encodeList() } } if (!bFind) - qWarning() << "encode (name :" << name << ") not find!"; + qCWarning(LogCommon) << "encode (name :" << name << ") not find!"; else encodeList << encodename; @@ -593,12 +599,12 @@ bool Utils::isLoongarch() if(m_Arch.isEmpty()) { utsname utsbuf; if (uname(&utsbuf) == -1) { - qWarning() << "get Arch error"; + qCWarning(LogCommon) << "get Arch error"; return false; } m_Arch = QString::fromLocal8Bit(utsbuf.machine); } - qInfo() << "Current system architecture:" << m_Arch; + qCInfo(LogCommon) << "Current system architecture:" << m_Arch; return "mips64" == m_Arch || "loongarch64" == m_Arch; } @@ -627,7 +633,7 @@ void Utils::insertToDefaultConfigJson(QVariant &jsonVar, const QString &groups_k obj = objArrayFind(obj, "groups", "key", groups_key2); obj = objArrayFind(obj, "options", "key", options_key); if(!obj) { - qWarning() << QString("cannot find path %1/%2/%3").arg(groups_key).arg(groups_key2).arg(options_key); + qCWarning(LogCommon) << QString("cannot find path %1/%2/%3").arg(groups_key).arg(groups_key2).arg(options_key); return; } obj->insert(key, value); @@ -643,7 +649,7 @@ QVariant Utils::getValueInDefaultConfigJson(QVariant &jsonVar, const QString &gr obj = objArrayFind(obj, "groups", "key", groups_key2); obj = objArrayFind(obj, "options", "key", options_key); if(!obj) { - qWarning() << QString("cannot find path %1/%2/%3").arg(groups_key).arg(groups_key2).arg(options_key); + qCWarning(LogCommon) << QString("cannot find path %1/%2/%3").arg(groups_key).arg(groups_key2).arg(options_key); return QVariant(); } return obj->value(key); @@ -672,9 +678,9 @@ MainWindow *Utils::getMainWindow(QWidget *currWidget) MainWindow *main = nullptr; QWidget *pWidget = currWidget->parentWidget(); while (pWidget != nullptr) { - qInfo() << "Current Window Class Name :" << pWidget->metaObject()->className(); + qCInfo(LogCommon) << "Current Window Class Name :" << pWidget->metaObject()->className(); if (("NormalWindow" == pWidget->objectName()) || ("QuakeWindow" == pWidget->objectName())) { - qInfo() << "has find MainWindow"; + qCInfo(LogCommon) << "has find MainWindow"; main = static_cast(pWidget); break; } @@ -717,7 +723,7 @@ void FontFilter::handleWidthFont() m_thread->start(); return; } - //qInfo() << "m_thread is Running"; + //qCInfo(LogCommon) << "m_thread is Running"; } void FontFilter::setStop(bool stop) @@ -804,7 +810,7 @@ void FontFilter::compareWhiteList() else Blacklist.append(sfont); } - qInfo() << "Font whitelist obtained through the dbus interface :" << DBUSWhitelist; - qInfo() << "Whitelist of real available fonts :" << Whitelist; + qCInfo(LogCommon) << "Font whitelist obtained through the dbus interface :" << DBUSWhitelist; + qCInfo(LogCommon) << "Whitelist of real available fonts :" << Whitelist; } /******** Add by ut001000 renfeixiang 2020-06-15:增加 处理等宽字体的类 End***************/ diff --git a/src/customcommand/customcommandoptdlg.cpp b/src/customcommand/customcommandoptdlg.cpp index cbaa8fb4a..0d39a536d 100644 --- a/src/customcommand/customcommandoptdlg.cpp +++ b/src/customcommand/customcommandoptdlg.cpp @@ -27,6 +27,12 @@ #include #include +#ifdef QT_DEBUG +Q_LOGGING_CATEGORY(LogCustomCommand,"log.terminal.customcommand.work") +#else +Q_LOGGING_CATEGORY(LogCustomCommand,"log.terminal.customcommand.work",QtInfoMsg) +#endif + CustomCommandOptDlg::CustomCommandOptDlg(CustomCmdOptType type, CustomCommandData *currItemData, QWidget *parent) : DAbstractDialog(parent) , m_type(type) @@ -222,14 +228,14 @@ inline void CustomCommandOptDlg::slotShortCutLineEditingFinished(const QKeySeque { //删除 if ("Backspace" == sequence.toString()) { - qInfo() << "The KeySequenceE is Backspace"; + qCInfo(LogCustomCommand) << "The KeySequenceE is Backspace"; m_shortCutLineEdit->clear(); m_lastCmdShortcut = ""; return; } // 取消 if ("Esc" == sequence.toString()) { - qInfo() << "The KeySequenceE is Esc"; + qCInfo(LogCustomCommand) << "The KeySequenceE is Esc"; m_shortCutLineEdit->clear(); m_shortCutLineEdit->setKeySequence(QKeySequence(m_lastCmdShortcut)); /***add by ut001121 zhangmeng 20200521 在快捷键编辑框中按下ESC键时退出窗口 修复BUG27554***/ @@ -243,10 +249,10 @@ inline void CustomCommandOptDlg::slotShortCutLineEditingFinished(const QKeySeque QString reason; // 判断快捷键是否冲突 if (!ShortcutManager::instance()->checkShortcutValid(checkName, sequence.toString(), reason)) { - qWarning() << "Shortcut key conflict"; + qCWarning(LogCustomCommand) << "Shortcut key conflict"; // 冲突 if (sequence.toString() != "Esc") { - qWarning() << "The current shortcut key is not Esc! ("<< sequence <<")"; + qCWarning(LogCustomCommand) << "The current shortcut key is not Esc! ("<< sequence <<")"; showShortcutConflictMsgbox(reason); } m_shortCutLineEdit->clear(); @@ -375,21 +381,21 @@ void CustomCommandOptDlg::slotAddSaveButtonClicked() strName = strName.trimmed();//空格的名称是无效的,剔除名称前后的空格 if (strName.isEmpty()) { - qWarning() << "The name of the user-defined command is empty!"; + qCWarning(LogCustomCommand) << "The name of the user-defined command is empty!"; m_nameLineEdit->showAlertMessage(tr("Please enter a name"), m_nameLineEdit->parentWidget()); return; } /***add begin by ut001121 zhangmeng 20200615 限制名称字符长度 修复BUG31286***/ if (strName.length() > MAX_NAME_LEN) { - qWarning() << "The name should be no more than 32 characters"; + qCWarning(LogCustomCommand) << "The name should be no more than 32 characters"; m_nameLineEdit->showAlertMessage(QObject::tr("The name should be no more than 32 characters"), m_nameLineEdit->parentWidget()); return; } /***add end by ut001121***/ QString strCommandtemp = strCommand.trimmed();//空格的命令是无效的 if (strCommandtemp.isEmpty()) { - qWarning() << "The custom command is empty"; + qCWarning(LogCustomCommand) << "The custom command is empty"; m_commandLineEdit->showAlertMessage(tr("Please enter a command"), m_commandLineEdit->parentWidget()); return; } @@ -404,20 +410,20 @@ void CustomCommandOptDlg::slotAddSaveButtonClicked() QAction *existAction = nullptr; int icount = 0; if (CCT_MODIFY == m_type) { - qInfo() << "It is the modify type of custom command operation"; + qCInfo(LogCustomCommand) << "It is the modify type of custom command operation"; if (m_bRefreshCheck) { - qInfo() << "CustomCommand was refreshed"; + qCInfo(LogCustomCommand) << "CustomCommand was refreshed"; QAction *refreshExitAction = nullptr; refreshExitAction = ShortcutManager::instance()->checkActionIsExist(*m_newAction); if (refreshExitAction) { - qWarning() << "The custom command already exists"; + qCWarning(LogCustomCommand) << "The custom command already exists"; accept(); return; } } if (strName == m_currItemData->m_cmdName && strCommand == m_currItemData->m_cmdText && keytmp == QKeySequence(m_currItemData->m_cmdShortcut)) { - qInfo() << "The custom command don't need to save again."; + qCInfo(LogCustomCommand) << "The custom command don't need to save again."; accept(); return; } @@ -425,7 +431,7 @@ void CustomCommandOptDlg::slotAddSaveButtonClicked() existAction = ShortcutManager::instance()->checkActionIsExistForModify(*m_newAction); if (strName != m_currItemData->m_cmdName) { - qInfo() << "Custom commands have been changed."; + qCInfo(LogCustomCommand) << "Custom commands have been changed."; QList &customCommandActionList = ShortcutManager::instance()->getCustomCommandActionList(); for (int i = 0; i < customCommandActionList.size(); i++) { QAction *curAction = customCommandActionList[i]; @@ -435,12 +441,12 @@ void CustomCommandOptDlg::slotAddSaveButtonClicked() } } } else { - qInfo() << "It is the add type of custom command operation"; + qCInfo(LogCustomCommand) << "It is the add type of custom command operation"; existAction = ShortcutManager::instance()->checkActionIsExist(*m_newAction); } if (nullptr != existAction || icount) { - qInfo() << "The name already exists"; + qCInfo(LogCustomCommand) << "The name already exists"; QString strFistLine = tr("The name already exists,"); QString strSecondeLine = tr("please input another one."); Utils::showSameNameDialog(this, strFistLine, strSecondeLine); @@ -704,7 +710,7 @@ void CustomCommandOptDlg::closeEvent(QCloseEvent *event) void CustomCommandOptDlg::slotRefreshData(QString oldCmdName, QString newCmdName) { if (CCT_ADD == m_type) { - qWarning() << "Currently is the add operation interface"; + qCWarning(LogCustomCommand) << "Currently is the add operation interface"; return; } //不进行刷新操作 @@ -716,7 +722,7 @@ void CustomCommandOptDlg::slotRefreshData(QString oldCmdName, QString newCmdName return; } m_bRefreshCheck = true; - qInfo() << "Refresh custom command data.Curren command name is " << m_nameLineEdit->text(); + qCInfo(LogCustomCommand) << "Refresh custom command data.Curren command name is " << m_nameLineEdit->text(); QAction *currAction = new QAction(ShortcutManager::instance()); currAction->setText(newCmdName); diff --git a/src/customcommand/customcommandpanel.cpp b/src/customcommand/customcommandpanel.cpp index e56812405..6b846d20b 100644 --- a/src/customcommand/customcommandpanel.cpp +++ b/src/customcommand/customcommandpanel.cpp @@ -19,6 +19,8 @@ #include #include +Q_DECLARE_LOGGING_CATEGORY(LogCustomCommand) + CustomCommandPanel::CustomCommandPanel(QWidget *parent) : CommonPanel(parent) { Utils::set_Object_Name(this); @@ -44,10 +46,10 @@ void CustomCommandPanel::showCurSearchResult() void CustomCommandPanel::showAddCustomCommandDlg() { if (m_pushButton->hasFocus()) { - qInfo() << "The Add command button has focus to click on!"; + qCInfo(LogCustomCommand) << "The Add command button has focus to click on!"; m_bpushButtonHaveFocus = true; } else { - qInfo() << "The Add command button has no focus to prohibit clicking!"; + qCInfo(LogCustomCommand) << "The Add command button has no focus to prohibit clicking!"; m_bpushButtonHaveFocus = false; } @@ -84,13 +86,13 @@ void CustomCommandPanel::onFocusOut(Qt::FocusReason type) // 下一个 或 列表为空, 焦点定位到添加按钮上 m_pushButton->setFocus(); m_cmdListWidget->clearIndex(); - qInfo() << "Set the focus to the Add command button"; + qCInfo(LogCustomCommand) << "Set the focus to the Add command button"; } else if (Qt::BacktabFocusReason == type) { // 判断是否可见,可见设置焦点 if (m_searchEdit->isVisible()) { m_searchEdit->lineEdit()->setFocus(); m_cmdListWidget->clearIndex(); - qInfo() << "Set the focus to the Search edit"; + qCInfo(LogCustomCommand) << "Set the focus to the Search edit"; } } } @@ -171,7 +173,7 @@ void CustomCommandPanel::setFocusInPanel() // 添加按钮下 m_pushButton->setFocus(); } else { - qWarning() << "focus error unkown reason"; + qCWarning(LogCustomCommand) << "focus error unkown reason"; } } diff --git a/src/customcommand/customcommandplugin.cpp b/src/customcommand/customcommandplugin.cpp index 3041d2105..f60afe46c 100644 --- a/src/customcommand/customcommandplugin.cpp +++ b/src/customcommand/customcommandplugin.cpp @@ -14,6 +14,8 @@ //qt #include +#include +Q_DECLARE_LOGGING_CATEGORY(LogCustomCommand) CustomCommandPlugin::CustomCommandPlugin(QObject *parent) : MainWindowPluginInterface(parent) { @@ -76,7 +78,7 @@ void CustomCommandPlugin::doShowPlugin(const QString name, bool bSetFocus) if (MainWindow::PLUGIN_TYPE_CUSTOMCOMMAND != name) { // 若插件已经显示,则隐藏 if (m_isShow) { - qWarning() << "Command top panel hide"; + qCWarning(LogCustomCommand) << "Command top panel hide"; getCustomCommandTopPanel()->hideAnim(); m_isShow = false; } diff --git a/src/customcommand/customcommandsearchrstpanel.cpp b/src/customcommand/customcommandsearchrstpanel.cpp index 7f4387c04..7c3a24d77 100644 --- a/src/customcommand/customcommandsearchrstpanel.cpp +++ b/src/customcommand/customcommandsearchrstpanel.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +Q_DECLARE_LOGGING_CATEGORY(LogCustomCommand) CustomCommandSearchRstPanel::CustomCommandSearchRstPanel(QWidget *parent) : CommonPanel(parent) @@ -103,7 +105,7 @@ inline void CustomCommandSearchRstPanel::handleIconButtonFocusOut(Qt::FocusReaso // tab 进入 + QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Tab, Qt::MetaModifier); QApplication::sendEvent(Utils::getMainWindow(this), &keyPress); - qInfo() << "search panel focus to '+'"; + qCInfo(LogCustomCommand) << "search panel focus to '+'"; } } @@ -114,13 +116,13 @@ inline void CustomCommandSearchRstPanel::handleListViewFocusOut(Qt::FocusReason // tab 进入 + QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Tab, Qt::MetaModifier); QApplication::sendEvent(Utils::getMainWindow(this), &keyPress); - qInfo() << "search panel focus on '+'"; + qCInfo(LogCustomCommand) << "search panel focus on '+'"; m_cmdListWidget->clearIndex(); } else if (Qt::BacktabFocusReason == type || Qt::NoFocusReason == type) { // shift + tab 返回 返回键 // 列表为空,也返回到返回键上 m_rebackButton->setFocus(); m_cmdListWidget->clearIndex(); - qInfo() << "search panel type (" << type << ")"; + qCInfo(LogCustomCommand) << "search panel type (" << type << ")"; } } @@ -144,7 +146,7 @@ void CustomCommandSearchRstPanel::refreshData(const QString &strFilter) void CustomCommandSearchRstPanel::doCustomCommand(const QString &strKey) { - qInfo() << "Search for the current custom commonds based on the key (" << strKey << ")"; + qCInfo(LogCustomCommand) << "Search for the current custom commonds based on the key (" << strKey << ")"; QAction *item = ShortcutManager::instance()->findActionByKey(strKey); QString strCommand = item ? item->data().toString() : ""; if (!strCommand.endsWith('\n')) diff --git a/src/customcommand/customcommandtoppanel.cpp b/src/customcommand/customcommandtoppanel.cpp index d58139227..8c1d35202 100644 --- a/src/customcommand/customcommandtoppanel.cpp +++ b/src/customcommand/customcommandtoppanel.cpp @@ -14,6 +14,8 @@ #include #include +Q_DECLARE_LOGGING_CATEGORY(LogCustomCommand) + const int iAnimationDuration = 300; CustomCommandTopPanel::CustomCommandTopPanel(QWidget *parent) @@ -61,7 +63,7 @@ void CustomCommandTopPanel::showCustomCommandPanel() if (main != nullptr) { if (main->isFocusOnList()) { m_customCommandPanel->setFocusInPanel(); - qWarning() << "custom command panel has focus"; + qCWarning(LogCustomCommand) << "custom command panel has focus"; } } @@ -130,11 +132,11 @@ void CustomCommandTopPanel::show(bool bSetFocus) m_customCommandSearchPanel->hide(); m_bSetFocus = bSetFocus; if (m_bSetFocus) { - qInfo() << "Focus is in Custom panel"; + qCInfo(LogCustomCommand) << "Focus is in Custom panel"; // 将焦点设置在平面上 m_customCommandPanel->setFocusInPanel(); } else { - qInfo() << "Focus is in Current page"; + qCInfo(LogCustomCommand) << "Focus is in Current page"; // 将焦点落回终端 MainWindow *w = Utils::getMainWindow(this); if(w) diff --git a/src/encodeplugin/encodelistmodel.cpp b/src/encodeplugin/encodelistmodel.cpp index b868ae509..8bdbd9deb 100644 --- a/src/encodeplugin/encodelistmodel.cpp +++ b/src/encodeplugin/encodelistmodel.cpp @@ -14,6 +14,12 @@ DWIDGET_USE_NAMESPACE +#ifdef QT_DEBUG +Q_LOGGING_CATEGORY(LogEncodePlugin,"log.terminal.encodeplugin.work") +#else +Q_LOGGING_CATEGORY(LogEncodePlugin,"log.terminal.encodeplugin.work",QtInfoMsg) +#endif + EncodeListModel::EncodeListModel(QObject *parent) : QStandardItemModel(parent) { Utils::set_Object_Name(this); @@ -87,10 +93,10 @@ void EncodeListModel::initEncodeData() } } if (!bFind) - qWarning() << "The encoding(" << name << ") in the terminal encoding list is not found in the list of supported encodeings!"; + qCWarning(LogEncodePlugin) << "The encoding(" << name << ") in the terminal encoding list is not found in the list of supported encodeings!"; else m_encodeData << encodename; } - qInfo() << "The number("<< m_encodeData.count() << ") of system encoding formats supported by the terminal."; + qCInfo(LogEncodePlugin) << "The number("<< m_encodeData.count() << ") of system encoding formats supported by the terminal."; } diff --git a/src/encodeplugin/encodelistview.cpp b/src/encodeplugin/encodelistview.cpp index 1dfba8927..4bb4a7bf5 100644 --- a/src/encodeplugin/encodelistview.cpp +++ b/src/encodeplugin/encodelistview.cpp @@ -20,6 +20,8 @@ #include #include +Q_DECLARE_LOGGING_CATEGORY(LogEncodePlugin) + EncodeListView::EncodeListView(QWidget *parent) : DListView(parent), m_encodeModel(new EncodeListModel(this)) { /******** Add by ut001000 renfeixiang 2020-08-14:增加 Begin***************/ @@ -99,7 +101,7 @@ void EncodeListView::focusInEvent(QFocusEvent *event) // 判断焦点 if (Qt::TabFocusReason == m_foucusReason || Qt::BacktabFocusReason == m_foucusReason) { - qInfo() << "The reason(" << m_foucusReason << ") for the current focus." + qCInfo(LogEncodePlugin) << "The reason(" << m_foucusReason << ") for the current focus." << "The encoding format(" << m_modelIndexChecked.data().toString() <<") in which focus is currently obtained."; setCurrentIndex(m_modelIndexChecked); } @@ -195,14 +197,14 @@ void EncodeListView::mouseMoveEvent(QMouseEvent *event) void EncodeListView::onListViewClicked(const QModelIndex &index) { if (!index.isValid()) { - qWarning() << "The current encoding format("<< index << ") is incorrect."; + qCWarning(LogEncodePlugin) << "The current encoding format("<< index << ") is incorrect."; return; } QStandardItemModel *model = qobject_cast(this->model()); if (nullptr == model) return; - qInfo() << "The encoding format(" << m_modelIndexChecked.data().toString() << ") selected last time." + qCInfo(LogEncodePlugin) << "The encoding format(" << m_modelIndexChecked.data().toString() << ") selected last time." << "The encoding format(" << index.data().toString()<< ") selected this time."; //当前Checked子项改为Unchecked状态 diff --git a/src/encodeplugin/encodepanelplugin.cpp b/src/encodeplugin/encodepanelplugin.cpp index 467f5b104..9ceeb989d 100644 --- a/src/encodeplugin/encodepanelplugin.cpp +++ b/src/encodeplugin/encodepanelplugin.cpp @@ -15,6 +15,7 @@ #include #include +Q_DECLARE_LOGGING_CATEGORY(LogEncodePlugin) EncodePanelPlugin::EncodePanelPlugin(QObject *parent) : MainWindowPluginInterface(parent) { @@ -102,7 +103,7 @@ void EncodePanelPlugin::initEncodePanel() void EncodePanelPlugin::setCurrentTermEncode(TermWidget *term) { QString encode; - qInfo() <<"Whether to link remote?" << term->isConnectRemote(); + qCInfo(LogEncodePlugin) <<"Whether to link remote?" << term->isConnectRemote(); // 是否连接远程 if (term->isConnectRemote()) { // 远程编码 @@ -113,7 +114,7 @@ void EncodePanelPlugin::setCurrentTermEncode(TermWidget *term) } //更新编码 - qInfo() << "Update the encoding(" << encode << ") of the current terminal!"; + qCInfo(LogEncodePlugin) << "Update the encoding(" << encode << ") of the current terminal!"; m_encodePanel->updateEncode(encode); } diff --git a/src/main/dbusmanager.cpp b/src/main/dbusmanager.cpp index 6566bc531..081dfc6dd 100644 --- a/src/main/dbusmanager.cpp +++ b/src/main/dbusmanager.cpp @@ -14,6 +14,8 @@ #include #include +Q_DECLARE_LOGGING_CATEGORY(LogMain) + DBusManager::DBusManager() { Utils::set_Object_Name(this); @@ -25,7 +27,7 @@ DBusManager::~DBusManager() QDBusConnection conn = QDBusConnection::sessionBus(); if (conn.registerService(TERMINALSERVER)) { conn.unregisterService(TERMINALSERVER); - qInfo() << "Deregister the dbus service of the terminal!"; + qCInfo(LogMain) << "Deregister the dbus service of the terminal!"; } } @@ -35,12 +37,12 @@ bool DBusManager::initDBus() QDBusConnection conn = QDBusConnection::sessionBus(); if (!conn.registerService(TERMINALSERVER)) { - qWarning() << "The dbus service of the terminal has been registered or failed to be registered!"; + qCWarning(LogMain) << "The dbus service of the terminal has been registered or failed to be registered!"; return false; } if (!conn.registerObject(TERMINALINTERFACE, this, QDBusConnection::ExportAllSlots)) { - qWarning() << "The dbus service on the terminal fails to create an object!"; + qCWarning(LogMain) << "The dbus service on the terminal fails to create an object!"; return false; } @@ -54,12 +56,12 @@ int DBusManager::callKDECurrentDesktop() QDBusMessage response = QDBusConnection::sessionBus().call(msg); if (response.type() == QDBusMessage::ReplyMessage) { - qInfo() << "Calling the 'currentDesktop' interface successded!"; + qCInfo(LogMain) << "Calling the 'currentDesktop' interface successded!"; QList list = response.arguments(); return list.value(0).toInt(); } - qWarning() << "Failed to call the 'currentDesktop' interface'. msg: " << response.errorMessage(); + qCWarning(LogMain) << "Failed to call the 'currentDesktop' interface'. msg: " << response.errorMessage(); return -1; } @@ -72,9 +74,9 @@ void DBusManager::callKDESetCurrentDesktop(int index) QDBusMessage response = QDBusConnection::sessionBus().call(msg); if (response.type() == QDBusMessage::ReplyMessage) - qInfo() << "Calling the 'setCurrentDesktop' interface successded!"; + qCInfo(LogMain) << "Calling the 'setCurrentDesktop' interface successded!"; else - qWarning() << "Failed to call the 'setCurrentDesktop' interface'. msg: " << response.errorMessage(); + qCWarning(LogMain) << "Failed to call the 'setCurrentDesktop' interface'. msg: " << response.errorMessage(); } FontDataList DBusManager::callAppearanceFont(QString fontType) @@ -87,7 +89,7 @@ FontDataList DBusManager::callAppearanceFont(QString fontType) QDBusMessage response = QDBusConnection::sessionBus().call(msg); if (QDBusMessage::ReplyMessage == response.type()) { - qInfo() << "Calling the 'List' interface successded!"; + qCInfo(LogMain) << "Calling the 'List' interface successded!"; QList list = response.arguments(); QString fonts = list.value(list.count() - 1).toString(); // 原本的返回值为QDBusPendingReply => QString @@ -98,7 +100,7 @@ FontDataList DBusManager::callAppearanceFont(QString fontType) QStringList fontList = fonts.split(","); rList = callAppearanceFont(fontList, fontType); } else { - qWarning() << "Failed to call the 'List' interface'. msg: " << response.errorMessage(); + qCWarning(LogMain) << "Failed to call the 'List' interface'. msg: " << response.errorMessage(); } @@ -114,16 +116,16 @@ FontDataList DBusManager::callAppearanceFont(QStringList fontList, QString fontT msg << fontType << fontList; QDBusMessage response = QDBusConnection::sessionBus().call(msg); if (response.type() == QDBusMessage::ReplyMessage) { - qInfo() << "Calling the 'Show' interface successded!"; + qCInfo(LogMain) << "Calling the 'Show' interface successded!"; QByteArray fonts = response.arguments().value(0).toByteArray(); QJsonArray array = QJsonDocument::fromJson(fonts).array(); for (int i = 0; i < array.size(); i++) { QJsonObject object = array.at(i).toObject(); retList.append(FontData(object["Id"].toString(), object["Name"].toString())); } - qInfo() << "Show value" << retList.values(); + qCInfo(LogMain) << "Show value" << retList.values(); } else { - qWarning() << "Failed to call the 'Show' interface'. msg: " << response.errorMessage(); + qCWarning(LogMain) << "Failed to call the 'Show' interface'. msg: " << response.errorMessage(); } return retList; } @@ -137,9 +139,9 @@ void DBusManager::callTerminalEntry(QStringList args) QDBusMessage response = QDBusConnection::sessionBus().call(msg, QDBus::NoBlock); if (response.type() == QDBusMessage::ReplyMessage) - qInfo() << "Calling the 'callTerminalEntry' interface successded!"; + qCInfo(LogMain) << "Calling the 'callTerminalEntry' interface successded!"; else - qWarning() << "Failed to call the 'callTerminalEntry' interface'. msg: " << response.errorMessage(); + qCWarning(LogMain) << "Failed to call the 'callTerminalEntry' interface'. msg: " << response.errorMessage(); } void DBusManager::entry(QStringList args) @@ -221,9 +223,9 @@ void DBusManager::callSystemSound(const QString &sound) { QDBusMessage response = dbusPlaySound(sound); if (response.type() == QDBusMessage::ReplyMessage) - qInfo() << "Calling the 'dbusPlaySound' interface successded!"; + qCInfo(LogMain) << "Calling the 'dbusPlaySound' interface successded!"; else - qWarning() << "Failed to call the 'dbusPlaySound' interface'. msg: " << response.errorMessage(); + qCWarning(LogMain) << "Failed to call the 'dbusPlaySound' interface'. msg: " << response.errorMessage(); } void DBusManager::listenTouchPadSignal() @@ -231,9 +233,9 @@ void DBusManager::listenTouchPadSignal() // 注册监听触控板事件 bool isConnect = QDBusConnection::systemBus().connect(GESTURE_SERVICE, GESTURE_PATH, GESTURE_INTERFACE, GESTURE_SIGNAL, Service::instance(), SIGNAL(touchPadEventSignal(QString, QString, int))); if (isConnect) - qInfo() << "connect to Guest, listen touchPad!"; + qCInfo(LogMain) << "connect to Guest, listen touchPad!"; else - qWarning() << "disconnect to Guest, cannot listen touchPad!"; + qCWarning(LogMain) << "disconnect to Guest, cannot listen touchPad!"; } void DBusManager::listenDesktopSwitched() @@ -241,7 +243,7 @@ void DBusManager::listenDesktopSwitched() // 注册监听桌面工作区切换 bool isConnect = QDBusConnection::sessionBus().connect(WM_SERVICE, WM_PATH, WM_INTERFACE, WM_WORKSPACESWITCHED, Service::instance(), SLOT(onDesktopWorkspaceSwitched(int, int))); if (isConnect) - qInfo() << "connect to wm, listen workspaceswitched"; + qCInfo(LogMain) << "connect to wm, listen workspaceswitched"; else - qWarning() << "disconnect to wm,cannot listen workspaceswitched"; + qCWarning(LogMain) << "disconnect to wm,cannot listen workspaceswitched"; } diff --git a/src/main/main.cpp b/src/main/main.cpp index 9105d962b..8e8814fb4 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) DApplicationSettings set(&app); // 系统日志 -#if (DTK_VERSION >= DTK_VERSION_CHECK(5,6,5,0)) +#if (DTK_VERSION >= DTK_VERSION_CHECK(5,6,8,0)) DLogManager::registerJournalAppender(); #ifdef QT_DEBUG DLogManager::registerConsoleAppender(); diff --git a/src/main/mainwindow.cpp b/src/main/mainwindow.cpp index 7e9906796..5d3b675c8 100644 --- a/src/main/mainwindow.cpp +++ b/src/main/mainwindow.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -66,6 +67,12 @@ DWIDGET_USE_NAMESPACE // 定义雷神窗口边缘,接近边缘光标变化图标 #define QUAKE_EDGE 5 +#ifdef QT_DEBUG +Q_LOGGING_CATEGORY(LogMain,"log.terminal.main.work") +#else +Q_LOGGING_CATEGORY(LogMain,"log.terminal.main.work",QtInfoMsg) +#endif + SwitchThemeMenu::SwitchThemeMenu(const QString &title, QWidget *parent): QMenu(title, parent) { } @@ -124,14 +131,14 @@ MainWindow::MainWindow(TermProperties properties, QWidget *parent) // 主进程的启动时间存在APP中 TerminalApplication *app = static_cast(qApp); m_ReferedAppStartTime = app->getStartTime(); - qInfo() << "The time when the main program starts.[Start Time:" + qCInfo(LogMain) << "The time when the main program starts.[Start Time:" << QDateTime::fromMSecsSinceEpoch(m_ReferedAppStartTime).toString("yyyy-MM-dd hh:mm:ss:zzz") << "]"; } else { - qInfo() << "The time when the subroutine starts.[Start Time:" + qCInfo(LogMain) << "The time when the subroutine starts.[Start Time:" << QDateTime::fromMSecsSinceEpoch(m_ReferedAppStartTime).toString("yyyy-MM-dd hh:mm:ss:zzz") << "]"; } m_CreateWindowTime = Service::instance()->getEntryTime(); - qInfo() << "Time when the main window was created. [ Create Time:" + qCInfo(LogMain) << "Time when the main window was created. [ Create Time:" << QDateTime::fromMSecsSinceEpoch(m_CreateWindowTime).toString("yyyy-MM-dd hh:mm:ss:zzz") << "]";; } @@ -265,7 +272,7 @@ inline void MainWindow::slotOptionButtonPressed() inline void MainWindow::slotClickNewWindowTimeout() { // 创建新的窗口 - qInfo() << "Create a new window using the New Window button in the title bar menu."; + qCInfo(LogMain) << "Create a new window using the New Window button in the title bar menu."; TermWidgetPage *tabPage = currentPage(); TermWidget *term = tabPage->currentTerminal(); @@ -287,7 +294,7 @@ void MainWindow::initOptionButton() if (dtkbutton != nullptr) dtkbutton->hide(); else - qWarning() << "can not found DTitlebarDWindowQuitFullscreenButton in DTitlebar"; + qCWarning(LogMain) << "can not found DTitlebarDWindowQuitFullscreenButton in DTitlebar"; // option button DIconButton *optionBtn = titlebar()->findChild("DTitlebarDWindowOptionButton"); @@ -295,7 +302,7 @@ void MainWindow::initOptionButton() // mainwindow的设置按钮触发 connect(titlebar()->findChild("DTitlebarDWindowOptionButton"), &DIconButton::pressed, this, &MainWindow::slotOptionButtonPressed); } else { - qWarning() << "can not found DTitlebarDWindowOptionButton in DTitlebar"; + qCWarning(LogMain) << "can not found DTitlebarDWindowOptionButton in DTitlebar"; } } @@ -383,7 +390,7 @@ void MainWindow::singleFlagMove() { if (m_properties[SingleFlag].toBool()) { Dtk::Widget::moveToCenter(this); - qInfo() << "The window moves to the center of the screen" ; + qCInfo(LogMain) << "The window moves to the center of the screen" ; } } @@ -402,14 +409,14 @@ void MainWindow::addTab(TermProperties properties, bool activeTab) qint64 startTime = QDateTime::currentMSecsSinceEpoch(); //如果不允许新建标签,则返回 if (!beginAddTab()){ - qWarning() << "Cannot create new labels"; + qCWarning(LogMain) << "Cannot create new labels"; return; } TermWidgetPage *termPage = new TermWidgetPage(properties, this); // pageID存在 tab中,所以page增删改操作都要由tab发起。 int index = m_tabbar->addTab(termPage->identifier(), termPage->getCurrentTerminalTitle()); - qInfo() << "The associated index(" << index <<") of the newly added label."; + qCInfo(LogMain) << "The associated index(" << index <<") of the newly added label."; endAddTab(termPage, activeTab, index, startTime); } @@ -428,7 +435,7 @@ void MainWindow::addTabWithTermPage(const QString &tabName, bool activeTab, bool // pageID存在 tab中,所以page增删改操作都要由tab发起。 int index = m_tabbar->insertTab(insertIndex, page->identifier(), tabName); m_tabbar->setTabText(termPage->identifier(), tabName); - qInfo() << "Insert the associated index("<< index << ") of the label"; + qCInfo(LogMain) << "Insert the associated index("<< index << ") of the label"; //拖拽过程中存在一种标签预览模式,此时不需要真实添加 if (!isVirtualAdd) { @@ -446,7 +453,7 @@ bool MainWindow::beginAddTab() // 没有雷神,且是雷神让通过,不然不让通过 if (!(nullptr == WindowsManager::instance()->getQuakeWindow() && m_isQuakeWindow)) { // 非雷神窗口不得超过MAXWIDGETCOUNT - qInfo() << "addTab failed, can't create number more than " << MAXWIDGETCOUNT; + qCInfo(LogMain) << "addTab failed, can't create number more than " << MAXWIDGETCOUNT; return false; } } @@ -480,7 +487,7 @@ void MainWindow::endAddTab(TermWidgetPage *termPage, bool activeTab, int index, connect(termPage->currentTerminal(), &TermWidget::termIsIdle, this, &MainWindow::onTermIsIdle); qint64 endTime = QDateTime::currentMSecsSinceEpoch(); QString strNewTabTime = GRAB_POINT + LOGO_TYPE + CREATE_NEW_TAB_TIME + QString::number(endTime - startTime); - qInfo() << "Add label end.Takes Time: " << qPrintable(strNewTabTime); + qCInfo(LogMain) << "Add label end.Takes Time: " << qPrintable(strNewTabTime); QString expandThemeStr = ""; expandThemeStr = Settings::instance()->extendColorScheme(); @@ -498,10 +505,10 @@ bool MainWindow::hasRunningProcesses() //没有校验当前tab中是否有其它正在执行的分屏 if (tabPage->runningTerminalCount() != 0) { /******** Modify by nt001000 renfeixiang 2020-05-28:修改 判断当前tab中是否有其它分屏正在执行 End***************/ - qInfo() << "here are processes running in this terminal tab... " << tabPage->identifier() << endl; + qCInfo(LogMain) << "here are processes running in this terminal tab... " << tabPage->identifier() << endl; return true; } else { - qInfo() << "no processes running in this terminal tab... " << tabPage->identifier() << endl; + qCInfo(LogMain) << "no processes running in this terminal tab... " << tabPage->identifier() << endl; } } @@ -526,7 +533,7 @@ void MainWindow::closeTab(const QString &identifier, bool hasConfirmed) showExitConfirmDialog(Utils::CloseType_Tab, tabPage->runningTerminalCount(), this); return; } - qInfo() << "Close tab(" << identifier << ")"; + qCInfo(LogMain) << "Close tab(" << identifier << ")"; m_tabVisitMap.remove(identifier); m_tabChangeColorMap.remove(identifier); m_tabbar->removeTab(identifier); @@ -541,7 +548,7 @@ void MainWindow::closeTab(const QString &identifier, bool hasConfirmed) focusCurrentPage(); return; } - qInfo() << "Main window closed!"; + qCInfo(LogMain) << "Main window closed!"; close(); } @@ -562,7 +569,7 @@ void MainWindow::removeTermWidgetPage(const QString &identifier, bool isDelete) // 当所有tab标签页都关闭时,关闭整个MainWindow窗口 if (m_termWidgetPageMap.isEmpty()) { - qWarning() << "No other tabs exist and the main window is closed!"; + qCWarning(LogMain) << "No other tabs exist and the main window is closed!"; /******** Modify by ut000438 王亮 2020-11-23:fix bug 55552:拖动标签页移动窗口过程中异常最大化 ***************/ //当拖动标签过程中销毁窗口时,不保存销毁的窗口大小 m_IfUseLastSize = false; @@ -616,10 +623,10 @@ bool MainWindow::isFocusOnList() // 判断按钮是否有焦点 if (addButton->hasFocus()) { isFocus = false; - qInfo() << "focus on AddButton"; + qCInfo(LogMain) << "focus on AddButton"; } } else { - qInfo() << "can not found AddButton in DIconButton"; + qCInfo(LogMain) << "can not found AddButton in DIconButton"; } QList buttonList = {"DTitlebarDWindowOptionButton", "DTitlebarDWindowMinButton", "DTitlebarDWindowMaxButton", "DTitlebarDWindowCloseButton"}; @@ -630,13 +637,13 @@ bool MainWindow::isFocusOnList() // 判断按钮是否有焦点 if (button->hasFocus()) { isFocus = false; - qInfo() << "focus on " << objectName; + qCInfo(LogMain) << "focus on " << objectName; } } else { - qWarning() << "can not found objectName in DIconButton"; + qCWarning(LogMain) << "can not found objectName in DIconButton"; } } - qInfo() << "Is focus on list? " << isFocus; + qCInfo(LogMain) << "Is focus on list? " << isFocus; return isFocus; } @@ -662,7 +669,7 @@ void MainWindow::closeOtherTab(const QString &identifier, bool hasConfirmed) // 关闭其它窗口,需要检测 for (QString &id : closeTabIdList) { closeTab(id, true); - qDebug() << "Id(" << id << ") of the close tab? "; + qCDebug(LogMain) << "Id(" << id << ") of the close tab? "; } //如果是不关闭当前页的,最后回到当前页来. @@ -682,7 +689,7 @@ void MainWindow::closeAllTab() // 全部关闭时,不再检测了, for (QString &id : closeTabIdList) { closeTab(id, true); - qDebug() << "Id(" << id << ") of the close tab? "; + qCDebug(LogMain) << "Id(" << id << ") of the close tab? "; } return; @@ -696,9 +703,9 @@ inline void MainWindow::slotDDialogFinished(int result) DIconButton *closeBtn = titlebar()->findChild("DTitlebarDWindowCloseButton"); if (closeBtn != nullptr) { closeBtn->setFocus(); - qInfo() << "Close button to get focus!"; + qCInfo(LogMain) << "Close button to get focus!"; } else { - qWarning() << "Can not found DTitlebarDWindowCloseButton in DTitlebar"; + qCWarning(LogMain) << "Can not found DTitlebarDWindowCloseButton in DTitlebar"; } } /********************* Modify by n014361 wangpeili End ************************/ @@ -725,11 +732,11 @@ void MainWindow::showExitConfirmDialog(Utils::CloseType type, int count, QWidget DIconButton *closeBtn = titlebar()->findChild("DTitlebarDWindowCloseButton"); if ((closeBtn != nullptr) && closeBtn->hasFocus() && (Utils::CloseType_Window == type)) { closeBtnHasfocus = true; - qInfo() << "Before close window, focus widget is close button. "; + qCInfo(LogMain) << "Before close window, focus widget is close button. "; } if (nullptr == closeBtn) - qInfo() << "Can not found DTitlebarDWindowCloseButton in DTitlebar"; + qCInfo(LogMain) << "Can not found DTitlebarDWindowCloseButton in DTitlebar"; /********************* Modify by n014361 wangpeili End ************************/ @@ -772,7 +779,7 @@ void MainWindow::focusPage(const QString &identifier) tabPage->focusCurrentTerm(); return; } - qInfo() << "focusTab nullptr identifier" << identifier; + qCInfo(LogMain) << "focusTab nullptr identifier" << identifier; } void MainWindow::focusCurrentPage() @@ -792,7 +799,7 @@ TermWidgetPage *MainWindow::getPageByIdentifier(const QString &identifier) if (tabPage && tabPage->identifier() == identifier) return tabPage; } - qInfo() << "getPageByIdentifier nullptr identifier" << identifier; + qCInfo(LogMain) << "getPageByIdentifier nullptr identifier" << identifier; return nullptr; } @@ -899,7 +906,7 @@ void MainWindow::closeEvent(QCloseEvent *event) if ((!m_hasConfirmedClose) && (runningCount != 0)) { // 如果不能马上关闭,并且还在没有最小化. - qInfo() << "Minimal mode or not?" << isMinimized(); + qCInfo(LogMain) << "Minimal mode or not?" << isMinimized(); if ((runningCount != 0) && isMinimized()) { setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); } @@ -951,7 +958,7 @@ QString MainWindow::getConfigWindowState() // 启动参数配置的状态值优先于 内部配置的状态值 if (m_properties.contains(StartWindowState)) { QString state = m_properties[StartWindowState].toString(); - qInfo() << "State(" << state << ") of the start window."; + qCInfo(LogMain) << "State(" << state << ") of the start window."; if ("maximum" == state) windowState = "window_maximum"; else if (state == "splitscreen") @@ -961,7 +968,7 @@ QString MainWindow::getConfigWindowState() else if (state == "fullscreen") windowState = state; else - qWarning() << "Error line state set:" << state << "ignore it!"; + qCWarning(LogMain) << "Error line state set:" << state << "ignore it!"; } return windowState; } @@ -1099,8 +1106,8 @@ inline void MainWindow::slotShortcutSwitchActivated() { QShortcut *switchShortcut = qobject_cast(sender()); int i = switchShortcut->property("index").toInt(); - qDebug() << "Shortcut key selected label index(" << i - 1 << ")"; - qDebug() << "How many tabs exist in the current window?" << m_tabbar->count(); + qCDebug(LogMain) << "Shortcut key selected label index(" << i - 1 << ")"; + qCDebug(LogMain) << "How many tabs exist in the current window?" << m_tabbar->count(); TermWidgetPage *page = currentPage(); if (page) { assert(m_tabbar); @@ -1110,14 +1117,14 @@ inline void MainWindow::slotShortcutSwitchActivated() } if (i - 1 >= m_tabbar->count()) { - qWarning() <<"The index(" << i -1 << ") of the current tab exceeds the total number of the current windows tabs(" << m_tabbar->count() << ")"; + qCWarning(LogMain) <<"The index(" << i -1 << ") of the current tab exceeds the total number of the current windows tabs(" << m_tabbar->count() << ")"; return; } m_tabbar->setCurrentIndex(i - 1); return; } - qWarning() << "Current Page is Nullptr!"; + qCWarning(LogMain) << "Current Page is Nullptr!"; } inline void MainWindow::slotShortcutNewTab() @@ -1181,7 +1188,7 @@ inline void MainWindow::slotShortcutHorizonzalSplit() } } } - qInfo() << "Can't split horizonzal again"; + qCInfo(LogMain) << "Can't split horizonzal again"; } inline void MainWindow::slotShortcutVerticalSplit() @@ -1200,7 +1207,7 @@ inline void MainWindow::slotShortcutVerticalSplit() } } } - qInfo() << "Can't split vertical again"; + qCInfo(LogMain) << "Can't split vertical again"; } inline void MainWindow::slotShortcutSelectUpperWorkspace() @@ -1235,7 +1242,7 @@ inline void MainWindow::slotShortcutCloseWorkspace() { TermWidgetPage *page = currentPage(); if (page) { - qInfo() << "Close Works pace"; + qCInfo(LogMain) << "Close Works pace"; page->closeSplit(page->currentTerminal()); } } @@ -1309,7 +1316,7 @@ inline void MainWindow::slotShortcutSelectAll() { TermWidgetPage *page = currentPage(); if (page) { - qInfo() << "Select all pages using the shortcut keys"; + qCInfo(LogMain) << "Select all pages using the shortcut keys"; page->selectAll(); } } @@ -1350,17 +1357,17 @@ inline void MainWindow::slotShortcutRemoteManage() inline void MainWindow::slotShortcutFocusOut() { - qInfo() << "focusout timinal is activated!" << QKEYSEQUENCE_FOCUSOUT_TIMINAL; + qCInfo(LogMain) << "focusout timinal is activated!" << QKEYSEQUENCE_FOCUSOUT_TIMINAL; DIconButton *addButton = m_tabbar->findChild("AddButton"); if (addButton != nullptr) addButton->setFocus(); else - qInfo() << "can not found AddButton in DIconButton"; + qCInfo(LogMain) << "can not found AddButton in DIconButton"; } inline void MainWindow::slotShortcutBuiltinPaste() { - qInfo() << "built in paste shortcut is activated!" << QKEYSEQUENCE_PASTE_BUILTIN; + qCInfo(LogMain) << "built in paste shortcut is activated!" << QKEYSEQUENCE_PASTE_BUILTIN; TermWidgetPage *page = currentPage(); if (page) page->pasteClipboard(); @@ -1368,7 +1375,7 @@ inline void MainWindow::slotShortcutBuiltinPaste() inline void MainWindow::slotShortcutBuiltinCopy() { - qInfo() << "built in copy shortcut is activated!" << QKEYSEQUENCE_COPY_BUILTIN; + qCInfo(LogMain) << "built in copy shortcut is activated!" << QKEYSEQUENCE_COPY_BUILTIN; TermWidgetPage *page = currentPage(); if (page) page->copyClipboard(); @@ -1397,13 +1404,13 @@ void MainWindow::showPlugin(const QString &name) if ((name == m_CurrentShowPlugin) && (PLUGIN_TYPE_NONE == m_CurrentShowPlugin)) { // 目前没有列表显示,直接返回 - qInfo() << "no plugin show!"; + qCInfo(LogMain) << "no plugin show!"; return; } m_CurrentShowPlugin = name; if (name != PLUGIN_TYPE_NONE) - qInfo() << "show Plugin" << name << bSetFocus; + qCInfo(LogMain) << "show Plugin" << name << bSetFocus; emit showPluginChanged(name, bSetFocus); } @@ -1413,7 +1420,7 @@ void MainWindow::hidePlugin() if (PLUGIN_TYPE_NONE == m_CurrentShowPlugin) return; - qInfo() << "hide Plugin" << m_CurrentShowPlugin; + qCInfo(LogMain) << "hide Plugin" << m_CurrentShowPlugin; m_CurrentShowPlugin = PLUGIN_TYPE_NONE; emit quakeHidePlugin(); } @@ -1425,7 +1432,7 @@ QString MainWindow::selectedText() if (page->currentTerminal()) return page->currentTerminal()->selectedText(); } - qInfo() << "not point terminal??"; + qCInfo(LogMain) << "not point terminal??"; return ""; } @@ -1539,7 +1546,7 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event) } while (false); if (!filterReason.isEmpty()) { - qInfo() << "Esc is not effect, reason:" << filterReason; + qCInfo(LogMain) << "Esc is not effect, reason:" << filterReason; } else { focusCurrentPage(); showPlugin(PLUGIN_TYPE_NONE); @@ -1568,17 +1575,17 @@ void MainWindow::onWindowSettingChanged(const QString &keyName) m_winInfoConfig->setValue(CONFIG_WINDOW_WIDTH, WINDOW_DEFAULT_WIDTH); m_winInfoConfig->setValue(CONFIG_WINDOW_HEIGHT, WINDOW_DEFAULT_HEIGHT); /******** Modify by nt001000 renfeixiang 2020-05-25: 文件wininfo-config.conf中参数,使用定义更换window_width,window_height End***************/ - qInfo() << "change value change value change value"; + qCInfo(LogMain) << "change value change value change value"; } else { m_IfUseLastSize = false; } - qInfo() << "settingValue[" << keyName << "] changed to " << state + qCInfo(LogMain) << "settingValue[" << keyName << "] changed to " << state << ", auto effective when next start!"; return; } // auto_hide_raytheon_window在使用中自动读取生效 if ((QStringLiteral("advanced.window.auto_hide_raytheon_window") == keyName) || (QStringLiteral("advanced.window.use_on_starting") == keyName)) { - qInfo() << "settingValue[" << keyName << "] changed to " << Settings::instance()->OutputtingScroll() + qCInfo(LogMain) << "settingValue[" << keyName << "] changed to " << Settings::instance()->OutputtingScroll() << ", auto effective when happen"; /***mod begin by ut001121 zhangmeng 20200528 修复BUG28920***/ onAppFocusChangeForQuake(); @@ -1586,12 +1593,12 @@ void MainWindow::onWindowSettingChanged(const QString &keyName) return; } - qInfo() << "settingValue[" << keyName << "] changed is not effective"; + qCInfo(LogMain) << "settingValue[" << keyName << "] changed is not effective"; } void MainWindow::onShortcutSettingChanged(const QString &keyName) { - qInfo() << "Shortcut[" << keyName << "] changed"; + qCInfo(LogMain) << "Shortcut[" << keyName << "] changed"; if (m_builtInShortcut.contains(keyName)) { QString value = Settings::instance()->settings->option(keyName)->value().toString(); //m_builtInShortcut[keyName]->setKey(QKeySequence(value)); @@ -1600,13 +1607,13 @@ void MainWindow::onShortcutSettingChanged(const QString &keyName) return; } - qInfo() << "Shortcut[" << keyName << "] changed is unknown!"; + qCInfo(LogMain) << "Shortcut[" << keyName << "] changed is unknown!"; } void MainWindow::setNewTermPage(TermWidgetPage *termPage, bool activePage) { if (nullptr == termPage) { - qInfo() << "termPage is nullptr!"; + qCInfo(LogMain) << "termPage is nullptr!"; return; } @@ -1791,7 +1798,7 @@ inline void MainWindow::onUploadFileDialogFinished(int code) } remoteUploadFile(strTxt); } else { - qWarning() << "remoteUploadFile file name is Null"; + qCWarning(LogMain) << "remoteUploadFile file name is Null"; } } @@ -1879,13 +1886,13 @@ void MainWindow::OnHandleCloseType(int result, Utils::CloseType type) // 弹窗隐藏或消失 Service::instance()->setIsDialogShow(this, false); if (result != 1) { - qInfo() << "user cancle close"; + qCInfo(LogMain) << "user cancle close"; return; } TermWidgetPage *page = currentPage(); if (nullptr == page) { - qWarning() << "null pointer of currentPage ???"; + qCWarning(LogMain) << "null pointer of currentPage ???"; return; } @@ -1978,10 +1985,10 @@ void MainWindow::createWindowComplete() void MainWindow::firstTerminalComplete() { m_FirstTerminalCompleteTime = QDateTime::currentDateTime().toMSecsSinceEpoch(); - qInfo() << "app create all complete," << "MainWindowID = " << m_MainWindowID << ",all time use" << m_FirstTerminalCompleteTime - m_ReferedAppStartTime << "ms"; - qInfo() << "before entry use" << m_CreateWindowTime - m_ReferedAppStartTime << "ms"; + qCInfo(LogMain) << "app create all complete," << "MainWindowID = " << m_MainWindowID << ",all time use" << m_FirstTerminalCompleteTime - m_ReferedAppStartTime << "ms"; + qCInfo(LogMain) << "before entry use" << m_CreateWindowTime - m_ReferedAppStartTime << "ms"; // 创建mainwidow时间,这个时候terminal并没有创建好,不能代表什么。 - qInfo() << "cretae first Terminal use" << m_FirstTerminalCompleteTime - m_CreateWindowTime << "ms"; + qCInfo(LogMain) << "cretae first Terminal use" << m_FirstTerminalCompleteTime - m_CreateWindowTime << "ms"; } QObjectList MainWindow::getNamedChildren(QObject *obj) @@ -2505,7 +2512,7 @@ void MainWindow::onCommandActionTriggered() { QAction *commandAction = qobject_cast(sender()); - qInfo() << "commandAction->data().toString() is triggered" << this; + qCInfo(LogMain) << "commandAction->data().toString() is triggered" << this; if (!this->isActiveWindow()) return ; @@ -2561,37 +2568,37 @@ void NormalWindow::initTitleBar() if (addButton != nullptr) addButton->setFocusPolicy(Qt::TabFocus); else - qWarning() << "can not found AddButton in DIconButton"; + qCWarning(LogMain) << "can not found AddButton in DIconButton"; DIconButton *optionBtn = titlebar()->findChild("DTitlebarDWindowOptionButton"); if (optionBtn != nullptr) optionBtn->setFocusPolicy(Qt::TabFocus); else - qWarning() << "can not found DTitlebarDWindowOptionButton in DTitlebar"; + qCWarning(LogMain) << "can not found DTitlebarDWindowOptionButton in DTitlebar"; QWidget *quitFullscreenBtn = titlebar()->findChild("DTitlebarDWindowQuitFullscreenButton"); if (quitFullscreenBtn != nullptr) quitFullscreenBtn->setFocusPolicy(Qt::TabFocus); else - qWarning() << "can not found DTitlebarDWindowQuitFullscreenButton in DTitlebar"; + qCWarning(LogMain) << "can not found DTitlebarDWindowQuitFullscreenButton in DTitlebar"; DIconButton *minBtn = titlebar()->findChild("DTitlebarDWindowMinButton"); if (minBtn != nullptr) minBtn->setFocusPolicy(Qt::TabFocus); else - qWarning() << "can not found DTitlebarDWindowMinButton in DTitlebar"; + qCWarning(LogMain) << "can not found DTitlebarDWindowMinButton in DTitlebar"; DIconButton *maxBtn = titlebar()->findChild("DTitlebarDWindowMaxButton"); if (maxBtn != nullptr) maxBtn->setFocusPolicy(Qt::TabFocus); else - qWarning() << "can not found DTitlebarDWindowMaxButton in DTitlebar"; + qCWarning(LogMain) << "can not found DTitlebarDWindowMaxButton in DTitlebar"; DIconButton *closeBtn = titlebar()->findChild("DTitlebarDWindowCloseButton"); if (closeBtn != nullptr) closeBtn->setFocusPolicy(Qt::TabFocus); else - qWarning() << "can not found DTitlebarDWindowCloseButton in DTitlebar"; + qCWarning(LogMain) << "can not found DTitlebarDWindowCloseButton in DTitlebar"; if (addButton != nullptr && optionBtn != nullptr && quitFullscreenBtn != nullptr && minBtn != nullptr && maxBtn != nullptr && closeBtn != nullptr) { QWidget::setTabOrder(addButton, optionBtn); @@ -2621,8 +2628,8 @@ void NormalWindow::initWindowAttribute() m_IfUseLastSize = true; int saveWidth = m_winInfoConfig->value(CONFIG_WINDOW_WIDTH).toInt(); int saveHeight = m_winInfoConfig->value(CONFIG_WINDOW_HEIGHT).toInt(); - qInfo() << "load window_width: " << saveWidth; - qInfo() << "load window_height: " << saveHeight; + qCInfo(LogMain) << "load window_width: " << saveWidth; + qCInfo(LogMain) << "load window_height: " << saveHeight; // 如果配置文件没有数据 if (0 == saveWidth || 0 == saveHeight) { saveWidth = WINDOW_DEFAULT_WIDTH; @@ -2655,7 +2662,7 @@ void NormalWindow::saveWindowSize() // 记录最后一个正常窗口的大小 m_winInfoConfig->setValue(CONFIG_WINDOW_WIDTH, width()); m_winInfoConfig->setValue(CONFIG_WINDOW_HEIGHT, height()); - qInfo() << "save windows size:" << width() << height(); + qCInfo(LogMain) << "save windows size:" << width() << height(); /******** Modify by nt001000 renfeixiang 2020-05-25: 文件wininfo-config.conf中参数,使用定义更换window_width,window_height End***************/ } } @@ -2747,32 +2754,32 @@ void QuakeWindow::initTitleBar() if (addButton != nullptr) addButton->setFocusPolicy(Qt::TabFocus); else - qInfo() << "can not found AddButton in DIconButton"; + qCInfo(LogMain) << "can not found AddButton in DIconButton"; // 雷神下其它控件一律没有焦点 DIconButton *optionBtn = titlebar()->findChild("DTitlebarDWindowOptionButton"); if (optionBtn != nullptr) optionBtn->setFocusPolicy(Qt::NoFocus); else - qInfo() << "can not found DTitlebarDWindowOptionButton in DTitlebar"; + qCInfo(LogMain) << "can not found DTitlebarDWindowOptionButton in DTitlebar"; DIconButton *minBtn = titlebar()->findChild("DTitlebarDWindowMinButton"); if (minBtn != nullptr) minBtn->setFocusPolicy(Qt::NoFocus); else - qInfo() << "can not found DTitlebarDWindowMinButton in DTitlebar"; + qCInfo(LogMain) << "can not found DTitlebarDWindowMinButton in DTitlebar"; DIconButton *maxBtn = titlebar()->findChild("DTitlebarDWindowMaxButton"); if (maxBtn != nullptr) maxBtn->setFocusPolicy(Qt::NoFocus); else - qInfo() << "can not found DTitlebarDWindowMaxButton in DTitlebar"; + qCInfo(LogMain) << "can not found DTitlebarDWindowMaxButton in DTitlebar"; DIconButton *closeBtn = titlebar()->findChild("DTitlebarDWindowCloseButton"); if (closeBtn != nullptr) closeBtn->setFocusPolicy(Qt::NoFocus); else - qInfo() << "can not found DTitlebarDWindowCloseButton in DTitlebar"; + qCInfo(LogMain) << "can not found DTitlebarDWindowCloseButton in DTitlebar"; /*QWidget::setTabOrder(addButton, optionBtn); QWidget::setTabOrder(optionBtn, minBtn); @@ -2784,7 +2791,7 @@ void QuakeWindow::initTitleBar() void QuakeWindow::slotWorkAreaResized() { - qInfo() << "Workspace size change!"; + qCInfo(LogMain) << "Workspace size change!"; /******** Modify by nt001000 renfeixiang 2020-05-20:修改成只需要设置雷神窗口宽度,根据字体高度设置雷神最小高度 Begin***************/ setMinimumWidth(QApplication::desktop()->availableGeometry().width()); setWindowMinHeightForFont(); @@ -2851,7 +2858,7 @@ void QuakeWindow::saveWindowSize() //Modify by ut001000 renfeixiang 2020-11-16 非雷神动画时,在保存雷神窗口的高度到配置文件 if (isNotAnimation) { m_winInfoConfig->setValue(CONFIG_QUAKE_WINDOW_HEIGHT, height()); - qInfo() << "save quake_window_Height:" << height() << m_desktopMap[m_desktopIndex] << m_desktopIndex; + qCInfo(LogMain) << "save quake_window_Height:" << height() << m_desktopMap[m_desktopIndex] << m_desktopIndex; } /******** Modify by nt001000 renfeixiang 2020-05-25: 文件wininfo-config.conf中参数,使用定义更换quake_window_Height End***************/ } @@ -2908,7 +2915,7 @@ void QuakeWindow::setWindowMinHeightForFont() /******** Add by nt001000 renfeixiang 2020-05-20:增加雷神窗口根据字体和字体大小设置最小高度函数 End***************/ void QuakeWindow::updateMinHeight() { - qInfo() << "Start update min height"; + qCInfo(LogMain) << "Start update min height"; bool hasHorizontalSplit = false; int count = m_termStackWidget->count(); for (int i = 0; i < count; i++) { @@ -2982,7 +2989,7 @@ inline void QuakeWindow::onTopToBottomAnimationFinished() void QuakeWindow::bottomToTopAnimation() { if (!isNotAnimation || nullptr == currentPage()) { - qInfo() << "bottomToTopAnimation no need to execute."; + qCInfo(LogMain) << "bottomToTopAnimation no need to execute."; return; } @@ -3053,7 +3060,7 @@ xcb_atom_t QuakeWindow::internAtom(const char *name, bool only_if_exists) void QuakeWindow::sendWindowForhibitMove(bool forhibit) { if(!QX11Info::connection()){ - qWarning() << "QX11Info::connection() is " << QX11Info::connection(); + qCWarning(LogMain) << "QX11Info::connection() is " << QX11Info::connection(); return ; } diff --git a/src/main/service.cpp b/src/main/service.cpp index a79e00e23..3b2896780 100644 --- a/src/main/service.cpp +++ b/src/main/service.cpp @@ -25,6 +25,8 @@ Service *Service::g_pService = nullptr; +Q_DECLARE_LOGGING_CATEGORY(LogMain) + Service *Service::instance() { if(nullptr == g_pService) { @@ -129,7 +131,7 @@ void Service::showHideOpacityAndBlurOptions(bool isShow) { QWidget *rightFrame = m_settingDialog->findChild("RightFrame"); if (nullptr == rightFrame) { - qWarning() << "can not found RightFrame in QWidget"; + qCWarning(LogMain) << "can not found RightFrame in QWidget"; return; } @@ -209,14 +211,14 @@ bool Service::isWindowEffectEnabled() QList list = response.arguments(); QString wmName = list.first().toString(); if (wmName == "deepin wm") { - qInfo() << "The window effects is on"; + qCInfo(LogMain) << "The window effects is on"; return true; } } else { - qWarning() << "call CurrentWM Fail!" << response.errorMessage(); + qCWarning(LogMain) << "call CurrentWM Fail!" << response.errorMessage(); } - qWarning() << "The window effects is off"; + qCWarning(LogMain) << "The window effects is off"; return false; } @@ -264,7 +266,7 @@ QMap Service::getShells() } } while (!shellLine.isNull()); } else { - qWarning() << "read /etc/shells fail! error : " << shellsInfo.error(); + qCWarning(LogMain) << "read /etc/shells fail! error : " << shellsInfo.error(); } // 关闭文件 shellsInfo.close(); @@ -311,7 +313,7 @@ void Service::showSettingDialog(MainWindow *pOwner) Settings::instance()->reloadShellOptions(); m_settingDialog->show(); } else { - qWarning() << "No setting dialog."; + qCWarning(LogMain) << "No setting dialog."; return; } // 激活窗口 @@ -431,7 +433,7 @@ void Service::EntryTerminal(QStringList arguments, bool isMain) return; // 超出最大窗口数量 if(WindowsManager::instance()->widgetCount() >= MAXWIDGETCOUNT) { - qWarning() << QString("terminal cannot be created: %1/%2 ") + qCWarning(LogMain) << QString("terminal cannot be created: %1/%2 ") .arg(WindowsManager::instance()->widgetCount()) .arg(MAXWIDGETCOUNT) ; @@ -494,7 +496,7 @@ void Service::setIsDialogShow(QWidget *parent, bool isDialogShow) if(nullptr == window) return; if (window == WindowsManager::instance()->getQuakeWindow()) { - qInfo() << "QuakeWindow show or hide dialog " << isDialogShow; + qCInfo(LogMain) << "QuakeWindow show or hide dialog " << isDialogShow; m_isDialogShow = isDialogShow; } diff --git a/src/main/terminalapplication.cpp b/src/main/terminalapplication.cpp index 6b55bb2bf..958ac69f4 100644 --- a/src/main/terminalapplication.cpp +++ b/src/main/terminalapplication.cpp @@ -10,6 +10,7 @@ // qt #include +Q_DECLARE_LOGGING_CATEGORY(LogMain) TerminalApplication::TerminalApplication(int &argc, char *argv[]) : DApplication(argc, argv) { @@ -53,7 +54,7 @@ qint64 TerminalApplication::getStartTime() void TerminalApplication::handleQuitAction() { - qInfo() << "Handle quit action"; + qCInfo(LogMain) << "Handle quit action"; activeWindow()->close(); } @@ -74,7 +75,7 @@ bool TerminalApplication::notify(QObject *object, QEvent *event) // 包含edit if (m_keySequenceList.contains(edit)) { m_keySequenceList.removeOne(edit); - qInfo() << "remove editing when foucs out"; + qCInfo(LogMain) << "remove editing when foucs out"; } } if (QEvent::KeyPress == event->type()) { @@ -97,7 +98,7 @@ bool TerminalApplication::notify(QObject *object, QEvent *event) QMouseEvent mouseEvent(QEvent::MouseButtonPress, QPoint(0, 0), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QApplication::sendEvent(childern[0], &mouseEvent); // 记录当前KeySequence已经进入编辑状态 - qInfo() << "KeySequence in Editing"; + qCInfo(LogMain) << "KeySequence in Editing"; m_keySequenceList.append(edit); return true; } @@ -106,7 +107,7 @@ bool TerminalApplication::notify(QObject *object, QEvent *event) if (m_keySequenceList.contains(edit)) { // 其他情况的按键,移除edit m_keySequenceList.removeOne(edit); - qInfo() << "remove editing when others"; + qCInfo(LogMain) << "remove editing when others"; } } } @@ -205,7 +206,7 @@ bool TerminalApplication::notify(QObject *object, QEvent *event) #if 0 // 焦点检测 if (event->type() == QEvent::FocusIn) - qInfo() << "FocusIn:" << object; + qCInfo(LogMain) << "FocusIn:" << object; #endif diff --git a/src/main/windowsmanager.cpp b/src/main/windowsmanager.cpp index e83192858..343a38905 100644 --- a/src/main/windowsmanager.cpp +++ b/src/main/windowsmanager.cpp @@ -11,6 +11,8 @@ #include +Q_DECLARE_LOGGING_CATEGORY(LogMain) + WindowsManager *WindowsManager::pManager = new WindowsManager(); WindowsManager *WindowsManager::instance() { @@ -20,7 +22,7 @@ WindowsManager *WindowsManager::instance() void WindowsManager::runQuakeWindow(TermProperties properties) { if (nullptr == m_quakeWindow) { - qInfo() << "Create QuakeWindow!"; + qCInfo(LogMain) << "Create QuakeWindow!"; m_quakeWindow = new QuakeWindow(properties); //Add by ut001000 renfeixiang 2020-11-16 设置开始雷神动画效果标志 m_quakeWindow->setAnimationFlag(false); @@ -84,13 +86,13 @@ void WindowsManager::createNormalWindow(TermProperties properties, bool isShow) MainWindow *newWindow = new NormalWindow(newProperties); m_normalWindowList << newWindow; - qInfo() << "create NormalWindow, current count =" << m_normalWindowList.count() + qCInfo(LogMain) << "create NormalWindow, current count =" << m_normalWindowList.count() << ", SingleFlag" << newProperties[SingleFlag].toBool(); if(isShow) newWindow->show(); qint64 newMainWindowTime = newWindow->createNewMainWindowTime(); QString strNewMainWindowTime = GRAB_POINT + LOGO_TYPE + CREATE_NEW_MAINWINDOE + QString::number(newMainWindowTime); - qInfo() << "Create NormalWindow Time:" << qPrintable(strNewMainWindowTime); + qCInfo(LogMain) << "Create NormalWindow Time:" << qPrintable(strNewMainWindowTime); } void WindowsManager::onMainwindowClosed(MainWindow *window) @@ -110,7 +112,7 @@ void WindowsManager::onMainwindowClosed(MainWindow *window) m_normalWindowList.removeOne(window); } else { //Q_ASSERT(false); - qWarning() << "unkown windows closed " << window; + qCWarning(LogMain) << "unkown windows closed " << window; } window->deleteLater(); diff --git a/src/remotemanage/remotemanagementpanel.cpp b/src/remotemanage/remotemanagementpanel.cpp index 81b5e664a..8e324fa25 100644 --- a/src/remotemanage/remotemanagementpanel.cpp +++ b/src/remotemanage/remotemanagementpanel.cpp @@ -10,6 +10,12 @@ #include #include +#ifdef QT_DEBUG +Q_LOGGING_CATEGORY(LogRemoteManage,"log.terminal.RemoteManage.work") +#else +Q_LOGGING_CATEGORY(LogRemoteManage,"log.terminal.RemoteManage.work",QtInfoMsg) +#endif + RemoteManagementPanel::RemoteManagementPanel(QWidget *parent) : CommonPanel(parent) { Utils::set_Object_Name(this); @@ -28,7 +34,7 @@ void RemoteManagementPanel::refreshPanel() void RemoteManagementPanel::setFocusInPanel() { - qInfo() << "RemoteManagementPanel focus in Panel."; + qCInfo(LogRemoteManage) << "RemoteManagementPanel focus in Panel."; if (m_searchEdit->isVisible()) { // 搜索框显示 // 设置焦点 @@ -47,7 +53,7 @@ void RemoteManagementPanel::setFocusInPanel() void RemoteManagementPanel::setFocusBack(const QString &strGroup) { - qInfo() << "RemoteManagementPanel return from RemoteManageGroup"; + qCInfo(LogRemoteManage) << "RemoteManagementPanel return from RemoteManageGroup"; // 返回前判断之前是否要有焦点 if (m_listWidget->getFocusState()) { // 要有焦点 @@ -125,7 +131,7 @@ void RemoteManagementPanel::onItemClicked(const QString &key) if (nullptr != remote) emit doConnectServer(remote); else - qInfo() << "can't connect to remote" << key; + qCInfo(LogRemoteManage) << "can't connect to remote" << key; } void RemoteManagementPanel::showCurSearchResult() @@ -139,7 +145,7 @@ void RemoteManagementPanel::showCurSearchResult() void RemoteManagementPanel::showAddServerConfigDlg() { - qInfo() << "RemoteManagementPanel show add server config dialog."; + qCInfo(LogRemoteManage) << "RemoteManagementPanel show add server config dialog."; // 判断控件是否有焦点 bool focusState = m_pushButton->hasFocus(); // 弹窗显示 @@ -254,13 +260,13 @@ void RemoteManagementPanel::initUI() // 下一个 或 列表为空, 焦点定位到添加按钮上 m_pushButton->setFocus(); m_listWidget->clearIndex(); - qInfo() << "set focus on add pushButton"; + qCInfo(LogRemoteManage) << "set focus on add pushButton"; } else if (Qt::BacktabFocusReason == type) { // 判断是否可见,可见设置焦点 if (m_searchEdit->isVisible()) { m_searchEdit->lineEdit()->setFocus(); m_listWidget->clearIndex(); - qInfo() << "set focus on add search edit"; + qCInfo(LogRemoteManage) << "set focus on add search edit"; } } }); diff --git a/src/remotemanage/remotemanagementplugn.cpp b/src/remotemanage/remotemanagementplugn.cpp index 02492a54c..eb26db464 100644 --- a/src/remotemanage/remotemanagementplugn.cpp +++ b/src/remotemanage/remotemanagementplugn.cpp @@ -12,6 +12,8 @@ #include #include +Q_DECLARE_LOGGING_CATEGORY(LogRemoteManage) + RemoteManagementPlugin::RemoteManagementPlugin(QObject *parent) : MainWindowPluginInterface(parent) { Utils::set_Object_Name(this); @@ -20,7 +22,7 @@ RemoteManagementPlugin::RemoteManagementPlugin(QObject *parent) : MainWindowPlug void RemoteManagementPlugin::initPlugin(MainWindow *mainWindow) { - qInfo() << "RemoteManagementPlugin init Plugin."; + qCInfo(LogRemoteManage) << "RemoteManagementPlugin init Plugin."; m_mainWindow = mainWindow; //initRemoteManagementTopPanel(); connect(m_mainWindow, &MainWindow::showPluginChanged, this, [ = ](const QString name, bool bSetFocus) { @@ -64,7 +66,7 @@ void RemoteManagementPlugin::initPlugin(MainWindow *mainWindow) // 焦点在列表上,隐藏时,焦点现在当前窗口上 if (m_mainWindow->isFocusOnList()) { m_mainWindow->focusCurrentPage(); - qInfo() << "focus on remote list, hide remote list and set foucs on terminal"; + qCInfo(LogRemoteManage) << "focus on remote list, hide remote list and set foucs on terminal"; } getRemoteManagementTopPanel()->hide(); }); @@ -99,7 +101,7 @@ void RemoteManagementPlugin::initRemoteManagementTopPanel() void RemoteManagementPlugin::doCennectServer(ServerConfig *curServer) { - qInfo() << "RemoteManagementPlugin do connect server."; + qCInfo(LogRemoteManage) << "RemoteManagementPlugin do connect server."; if (nullptr != curServer) { QString shellFile = createShellFile(curServer); @@ -124,19 +126,19 @@ void RemoteManagementPlugin::doCennectServer(ServerConfig *curServer) TermWidget *term = m_mainWindow->currentActivatedTerminal(); if (!term) { // 若term为空 - qInfo() << "current terminal is null"; + qCInfo(LogRemoteManage) << "current terminal is null"; } // 判断是否连接服务器 if (!term->isInRemoteServer()) { // 没有连接上 - qWarning() << "disconnect to server"; + qCWarning(LogRemoteManage) << "disconnect to server"; return; } // 标记此term连接远程 term->setIsConnectRemote(true); // 设置远程主机 term->modifyRemoteTabTitle(*curServer); - qInfo() << "connect to server"; + qCInfo(LogRemoteManage) << "connect to server"; // 编码 setRemoteEncode(curServer->m_encoding); // 退格键 @@ -164,7 +166,7 @@ inline QString RemoteManagementPlugin::convertStringToAscii(const QString &strSr QString RemoteManagementPlugin::createShellFile(ServerConfig *curServer) { - qInfo() << "RemoteManagementPlugin create temporary shell file."; + qCInfo(LogRemoteManage) << "RemoteManagementPlugin create temporary shell file."; // 首先读取通用模板 QFile sourceFile(":/other/ssh_login.sh"); QString fileString; @@ -224,7 +226,7 @@ void RemoteManagementPlugin::setRemoteEncode(QString encode) if (!encode.isNull() && !encode.isEmpty()) { // 设置当前窗口的编码 term->setTextCodec(QTextCodec::codecForName(encode.toLocal8Bit())); - qInfo() << "Remote encode " << encode; + qCInfo(LogRemoteManage) << "Remote encode " << encode; } // 记录远程编码 term->setRemoteEncode(encode); @@ -245,7 +247,7 @@ void RemoteManagementPlugin::setBackspaceKey(TermWidget *term, QString backspace else if ("tty" == backspaceKey) term->setBackspaceMode(EraseMode_TTY); - qInfo() << "backspace mode " << backspaceKey; + qCInfo(LogRemoteManage) << "backspace mode " << backspaceKey; } void RemoteManagementPlugin::setDeleteKey(TermWidget *term, QString deleteKey) @@ -261,5 +263,5 @@ void RemoteManagementPlugin::setDeleteKey(TermWidget *term, QString deleteKey) else if ("tty" == deleteKey) term->setDeleteMode(EraseMode_TTY); - qInfo() << "delete mode " << deleteKey; + qCInfo(LogRemoteManage) << "delete mode " << deleteKey; } diff --git a/src/remotemanage/remotemanagementsearchpanel.cpp b/src/remotemanage/remotemanagementsearchpanel.cpp index 84778fa83..5b63f8ba8 100644 --- a/src/remotemanage/remotemanagementsearchpanel.cpp +++ b/src/remotemanage/remotemanagementsearchpanel.cpp @@ -15,6 +15,9 @@ #include #include #include +#include + +Q_DECLARE_LOGGING_CATEGORY(LogRemoteManage) RemoteManagementSearchPanel::RemoteManagementSearchPanel(QWidget *parent) : CommonPanel(parent) { @@ -82,13 +85,13 @@ inline void RemoteManagementSearchPanel::handleListViewFocusOut(Qt::FocusReason // tab 进入 + QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Tab, Qt::MetaModifier); QApplication::sendEvent(Utils::getMainWindow(this), &keyPress); - qInfo() << "search panel focus on '+'"; + qCInfo(LogRemoteManage) << "search panel focus on '+'"; m_listWidget->clearIndex(); } else if (Qt::BacktabFocusReason == type || Qt::NoFocusReason == type) { // shift + tab 返回 返回键 // 列表为空,也返回到返回键上 m_rebackButton->setFocus(); m_listWidget->clearIndex(); - qInfo() << "search panel type" << type; + qCInfo(LogRemoteManage) << "search panel type" << type; } } @@ -131,7 +134,7 @@ void RemoteManagementSearchPanel::onItemClicked(const QString &key) if (nullptr != remote) emit doConnectServer(remote); else - qInfo() << "can't connect to remote" << key; + qCInfo(LogRemoteManage) << "can't connect to remote" << key; } @@ -142,7 +145,7 @@ void RemoteManagementSearchPanel::onFocusOutList(Qt::FocusReason type) // tab 进入 + QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Tab, Qt::MetaModifier); QApplication::sendEvent(Utils::getMainWindow(this), &keyPress); - qInfo() << "search panel focus to '+'"; + qCInfo(LogRemoteManage) << "search panel focus to '+'"; } } @@ -170,7 +173,7 @@ void RemoteManagementSearchPanel::clearAllFocus() void RemoteManagementSearchPanel::setFocusBack(const QString &strGroup, bool isFocusOn, int prevIndex) { - qInfo() << "RemoteManagementSearchPanel return from RemoteManagementGroup."; + qCInfo(LogRemoteManage) << "RemoteManagementSearchPanel return from RemoteManagementGroup."; // 返回前判断之前是否要有焦点 if (isFocusOn) { // 要有焦点 diff --git a/src/remotemanage/remotemanagementtoppanel.cpp b/src/remotemanage/remotemanagementtoppanel.cpp index a3ad9e1a1..154b4e1fb 100644 --- a/src/remotemanage/remotemanagementtoppanel.cpp +++ b/src/remotemanage/remotemanagementtoppanel.cpp @@ -9,6 +9,8 @@ #include #include +#include +Q_DECLARE_LOGGING_CATEGORY(LogRemoteManage) const int animationDuration = 300; @@ -62,7 +64,7 @@ void RemoteManagementTopPanel::show() // 清空栈 m_filterStack.clear(); m_prevPanelStack.clear(); - qInfo() << "show remote panel! stack clear"; + qCInfo(LogRemoteManage) << "show remote panel! stack clear"; } void RemoteManagementTopPanel::setFocusInPanel() @@ -72,7 +74,7 @@ void RemoteManagementTopPanel::setFocusInPanel() void RemoteManagementTopPanel::showSearchPanel(const QString &strFilter) { - qInfo() << "RemoteManagementTopPanel show search panel."; + qCInfo(LogRemoteManage) << "RemoteManagementTopPanel show search panel."; // 记录搜索界面的搜索条件 m_filterStack.push_back(strFilter); // 设置搜索界面大小 @@ -104,7 +106,7 @@ void RemoteManagementTopPanel::showSearchPanel(const QString &strFilter) connect(animation, &QPropertyAnimation::finished, animation, &QPropertyAnimation::deleteLater); } else { animation1->deleteLater(); - qWarning() << "unknow current panel!"; + qCWarning(LogRemoteManage) << "unknow current panel!"; return; } // 执行动画 @@ -124,7 +126,7 @@ void RemoteManagementTopPanel::showSearchPanel(const QString &strFilter) void RemoteManagementTopPanel::showGroupPanel(const QString &strGroupName, bool isFocusOn) { - qInfo() << "RemoteManagementTopPanel show group panel."; + qCInfo(LogRemoteManage) << "RemoteManagementTopPanel show group panel."; // 记录当前分组 m_group = strGroupName; // 设置分组界面大小 @@ -149,7 +151,7 @@ void RemoteManagementTopPanel::showGroupPanel(const QString &strGroupName, bool connect(animation, &QPropertyAnimation::finished, m_remoteManagementPanel, &QWidget::hide); connect(animation, &QPropertyAnimation::finished, animation, &QPropertyAnimation::deleteLater); } else { - qWarning() << "unknow current panel!"; + qCWarning(LogRemoteManage) << "unknow current panel!"; animation1->deleteLater(); return; } @@ -167,7 +169,7 @@ void RemoteManagementTopPanel::showGroupPanel(const QString &strGroupName, bool MainWindow *w = Utils::getMainWindow(this); if(w) w->focusCurrentPage(); - qInfo() << "show group but not focus in group"; + qCInfo(LogRemoteManage) << "show group but not focus in group"; } // 记录当前窗口为前一个窗口 @@ -190,20 +192,20 @@ void RemoteManagementTopPanel::showGroupPanel(const QString &strGroupName, bool void RemoteManagementTopPanel::showPrevPanel() { - qInfo() << "RemoteManagementTopPanel show previous panel."; + qCInfo(LogRemoteManage) << "RemoteManagementTopPanel show previous panel."; PanelState state; ServerConfigManager::PanelType prevType; // 栈为空 if (m_prevPanelStack.isEmpty()) { // 返回 - qInfo() << "stack is empty! return to remote first panel"; + qCInfo(LogRemoteManage) << "stack is empty! return to remote first panel"; // 栈为空,返回主界面 prevType = ServerConfigManager::PanelType_Manage; } else { // 获取前一个界面的类型,此界面为现在要显示的界面 state = m_prevPanelStack.pop(); prevType = state.m_type; - qInfo() << "Gets the reality type of the previous interface: " << prevType; + qCInfo(LogRemoteManage) << "Gets the reality type of the previous interface: " << prevType; } // 动画效果 要隐藏的界面 @@ -219,7 +221,7 @@ void RemoteManagementTopPanel::showPrevPanel() connect(animation, &QPropertyAnimation::finished, m_serverConfigGroupPanel, &QWidget::hide); connect(animation, &QPropertyAnimation::finished, animation, &QPropertyAnimation::deleteLater); } else { - qWarning() << "unknow panel to hide!" << m_currentPanelType; + qCWarning(LogRemoteManage) << "unknow panel to hide!" << m_currentPanelType; } // 动画效果 要显示的界面 @@ -233,7 +235,7 @@ void RemoteManagementTopPanel::showPrevPanel() // 清空栈 m_prevPanelStack.clear(); m_filterStack.clear(); - qInfo() << "remote clear stack"; + qCInfo(LogRemoteManage) << "remote clear stack"; // 动画效果的设置 animation1 = new QPropertyAnimation(m_remoteManagementPanel, "geometry"); connect(animation1, &QPropertyAnimation::finished, animation1, &QPropertyAnimation::deleteLater); @@ -250,7 +252,7 @@ void RemoteManagementTopPanel::showPrevPanel() case ServerConfigManager::PanelType_Search: { // 刷新列表 => 搜索框能被返回,只能是全局搜索 if (m_filterStack.isEmpty()) { - qWarning() << "error: filter stack is empty!"; + qCWarning(LogRemoteManage) << "error: filter stack is empty!"; return; } // 取最上一个 @@ -268,7 +270,7 @@ void RemoteManagementTopPanel::showPrevPanel() break; } if (nullptr == animation || nullptr == animation1) { - qWarning() << "do not has animation"; + qCWarning(LogRemoteManage) << "do not has animation"; if (nullptr != animation1) animation1->deleteLater(); @@ -301,7 +303,7 @@ void RemoteManagementTopPanel::showPrevPanel() m_remoteManagementSearchPanel->setFocusBack(m_group, state.m_isFocusOn, state.m_currentListIndex); } } else { - qWarning() << "unknow panel"; + qCWarning(LogRemoteManage) << "unknow panel"; } } diff --git a/src/remotemanage/serverconfiggrouppanel.cpp b/src/remotemanage/serverconfiggrouppanel.cpp index 36c6db404..ca8b63cc3 100644 --- a/src/remotemanage/serverconfiggrouppanel.cpp +++ b/src/remotemanage/serverconfiggrouppanel.cpp @@ -14,9 +14,11 @@ #include #include #include - +#include #define GROUPSEARCHWIDTH 172 +Q_DECLARE_LOGGING_CATEGORY(LogRemoteManage) + ServerConfigGroupPanel::ServerConfigGroupPanel(QWidget *parent) : CommonPanel(parent) { Utils::set_Object_Name(this); @@ -80,7 +82,7 @@ inline void ServerConfigGroupPanel::onListViewFocusOut(Qt::FocusReason type) return; } if (Qt::TabFocusReason == type) { - qInfo() << "group focus out!"; + qCInfo(LogRemoteManage) << "group focus out!"; QKeyEvent keyPress(QEvent::KeyPress, Qt::Key_Tab, Qt::MetaModifier); QApplication::sendEvent(Utils::getMainWindow(this), &keyPress); m_listWidget->clearIndex(); @@ -93,7 +95,7 @@ inline void ServerConfigGroupPanel::onListViewFocusOut(Qt::FocusReason type) m_listWidget->clearIndex(); } else if (Qt::NoFocusReason == type) { - qInfo() << "group NoFocusReason"; + qCInfo(LogRemoteManage) << "group NoFocusReason"; int isFocus = false; // 列表没有内容,焦点返回到返回键上 if (m_listWidget->hasFocus() || m_rebackButton->hasFocus()) @@ -111,7 +113,7 @@ inline void ServerConfigGroupPanel::onListViewFocusOut(Qt::FocusReason type) inline void ServerConfigGroupPanel::onRefreshList() { - qInfo() << "group refresh list"; + qCInfo(LogRemoteManage) << "group refresh list"; if (m_isShow) { refreshData(m_groupName); QMap> &configMap = ServerConfigManager::instance()->getServerConfigs(); @@ -125,7 +127,7 @@ inline void ServerConfigGroupPanel::onRefreshList() void ServerConfigGroupPanel::refreshData(const QString &groupName) { - qInfo() << "Refresh Data!"; + qCInfo(LogRemoteManage) << "Refresh Data!"; m_groupName = groupName; m_listWidget->clearData(); ServerConfigManager::instance()->refreshServerList(ServerConfigManager::PanelType_Group, m_listWidget, "", groupName); @@ -185,5 +187,5 @@ void ServerConfigGroupPanel::onItemClicked(const QString &key) if (nullptr != remote) emit doConnectServer(remote); else - qWarning() << "can't connect to remote" << key; + qCWarning(LogRemoteManage) << "can't connect to remote" << key; } diff --git a/src/remotemanage/serverconfigmanager.cpp b/src/remotemanage/serverconfigmanager.cpp index c3e3ce3f8..297f1959c 100644 --- a/src/remotemanage/serverconfigmanager.cpp +++ b/src/remotemanage/serverconfigmanager.cpp @@ -10,10 +10,13 @@ #include #include +#include #undef signals #include +Q_DECLARE_LOGGING_CATEGORY(LogRemoteManage) + // 密码回调 struct PasswordReBack { QString key; @@ -52,7 +55,7 @@ void ServerConfigManager::settServerConfig(USettings &commandsSettings, const QS void ServerConfigManager::fillManagePanel(ListView *listview) { - qInfo() << "ServerConfigManager fill data to manage panel."; + qCInfo(LogRemoteManage) << "ServerConfigManager fill data to manage panel."; listview->clearData(); for (QString key : m_serverConfigs.keys()) { // key有效 @@ -72,7 +75,7 @@ void ServerConfigManager::fillManagePanel(ListView *listview) void ServerConfigManager::fillSearchPanel(ListView *listview, const QString &filter, const QString &group) { - qInfo() << "ServerConfigManager fill data to search panel."; + qCInfo(LogRemoteManage) << "ServerConfigManager fill data to search panel."; listview->clearData(); // 判断是否是组内搜索 if (group.isEmpty() || group.isNull()) { @@ -147,7 +150,7 @@ void ServerConfigManager::initServerConfig() return; QString serverConfigFilePath(serverConfigBasePath.filePath("server-config.conf")); - qInfo() << "load Server Config: " << serverConfigFilePath; + qCInfo(LogRemoteManage) << "load Server Config: " << serverConfigFilePath; if (!QFile::exists(serverConfigFilePath)) return; @@ -165,7 +168,7 @@ void ServerConfigManager::initServerConfig() QStringList strList = serverName.split("@"); ServerConfig *pServerConfig = new ServerConfig(); if (strList.count() < 3) { - qWarning() << "An unknoew error exists on the current server(" << serverName << ")"; + qCWarning(LogRemoteManage) << "An unknoew error exists on the current server(" << serverName << ")"; continue; } // 新版数据的读取方式 @@ -271,7 +274,7 @@ void ServerConfigManager::saveServerConfig(ServerConfig *config) // 添加密码 remoteStoreSecreats(config); - qInfo() << "The server configuration is added successfully.The Config group: " << config->m_group << ".The Server name:"<< config->m_serverName; + qCInfo(LogRemoteManage) << "The server configuration is added successfully.The Config group: " << config->m_group << ".The Server name:"<< config->m_serverName; } @@ -348,7 +351,7 @@ void ServerConfigManager::setModifyDialog(QString key, ServerConfigOptDlg *dlg) { // 添加编辑弹窗 m_serverConfigDialogMap[key].append(dlg); - qInfo() << "show edit dialog" << key << m_serverConfigDialogMap[key].count() << dlg; + qCInfo(LogRemoteManage) << "show edit dialog" << key << m_serverConfigDialogMap[key].count() << dlg; } void ServerConfigManager::removeDialog(ServerConfigOptDlg *dlg) @@ -368,17 +371,17 @@ void ServerConfigManager::removeDialog(ServerConfigOptDlg *dlg) } // 2.删除数据 if (nullptr != removeOne) { - qInfo() << "delete dialog from remote name : " << key; + qCInfo(LogRemoteManage) << "delete dialog from remote name : " << key; m_serverConfigDialogMap[key].removeOne(removeOne); } if (0 == m_serverConfigDialogMap[key].count()) { - qInfo() << "remote dialog is 0, remove remote name : " << key; + qCInfo(LogRemoteManage) << "remote dialog is 0, remove remote name : " << key; m_serverConfigDialogMap.remove(key); } if (nullptr != removeOne) { - qInfo() << "delete remote dialog" << removeOne; + qCInfo(LogRemoteManage) << "delete remote dialog" << removeOne; removeOne->deleteLater(); } removeOne = nullptr; @@ -386,7 +389,7 @@ void ServerConfigManager::removeDialog(ServerConfigOptDlg *dlg) void ServerConfigManager::SyncData(QString key, ServerConfig *newConfig) { - qInfo() <<"Sync Data! Key: " << key << ";Server Name:" << newConfig->m_serverName; + qCInfo(LogRemoteManage) <<"Sync Data! Key: " << key << ";Server Name:" << newConfig->m_serverName; //前提是key唯一 // serverName被修改 if (key != newConfig->m_serverName) { @@ -407,17 +410,17 @@ void ServerConfigManager::SyncData(QString key, ServerConfig *newConfig) void ServerConfigManager::closeAllDialog(QString key) { - qInfo() << "Close ALL Dialogs for the remote server! Remote name : " << key ; + qCInfo(LogRemoteManage) << "Close ALL Dialogs for the remote server! Remote name : " << key ; // 判读此时这个key是否存在 if (!m_serverConfigDialogMap.contains(key)) { // 不存在退出 - qWarning() << "The current remote(" << key <<") server does not exist!"; + qCWarning(LogRemoteManage) << "The current remote(" << key <<") server does not exist!"; return; } for (auto &item : m_serverConfigDialogMap[key]) { if (item != nullptr) { - qInfo() << "Reject the current remote window(" << item << ")!"; + qCInfo(LogRemoteManage) << "Reject the current remote window(" << item << ")!"; // reject就会把当前的窗口删除 item->reject(); } @@ -427,7 +430,7 @@ void ServerConfigManager::closeAllDialog(QString key) int ServerConfigManager::getServerCount(const QString &strGroupName) { if (strGroupName.isEmpty() || strGroupName.isNull()) { - qWarning() << "enter error group name:" << strGroupName << "! please confirm again!"; + qCWarning(LogRemoteManage) << "enter error group name:" << strGroupName << "! please confirm again!"; return -1; } if (m_serverConfigs.contains(strGroupName)) { @@ -450,7 +453,7 @@ ServerConfig *ServerConfigManager::getServerConfig(const QString &key) } } // 没找到返回空 - qWarning() << "can't find remote key : " << key; + qCWarning(LogRemoteManage) << "can't find remote key : " << key; return nullptr; } @@ -476,13 +479,13 @@ static void on_password_lookup(GObject *source, GAsyncResult *result, gpointer u if (error != NULL) { /* ... handle the failure here */ - qWarning() << "Failed to get password! error msg:" << error->message; + qCWarning(LogRemoteManage) << "Failed to get password! error msg:" << error->message; g_error_free(error); emit reback->manager->lookupSerceats(reback->key, ""); } else if (password == NULL) { /* password will be null, if no matching password found */ // 密码回调 - qInfo() << "password is Null server name : " << reback->key; + qCInfo(LogRemoteManage) << "password is Null server name : " << reback->key; emit reback->manager->lookupSerceats(reback->key, ""); } else { @@ -528,7 +531,7 @@ static void on_password_stored(GObject *source, GAsyncResult *result, gpointer u secret_password_store_finish(result, &error); if (error != NULL) { /* ... handle the failure here */ - qWarning() << "Failed to store password! error msg:" << error->message; + qCWarning(LogRemoteManage) << "Failed to store password! error msg:" << error->message; g_error_free(error); } else { /* ... do something now that the password has been stored */ @@ -566,12 +569,12 @@ static void on_password_cleared(GObject *source, GAsyncResult *result, gpointer if (error != NULL) { /* ... handle the failure here */ - qWarning() << "Failed to clear password! error msg:" << error->message; + qCWarning(LogRemoteManage) << "Failed to clear password! error msg:" << error->message; g_error_free(error); } else { /* removed will be TRUE if a password was removed */ - qInfo() << "remove result " << removed; + qCInfo(LogRemoteManage) << "remove result " << removed; } } diff --git a/src/remotemanage/serverconfigoptdlg.cpp b/src/remotemanage/serverconfigoptdlg.cpp index d4c74ae68..3647dc0f3 100644 --- a/src/remotemanage/serverconfigoptdlg.cpp +++ b/src/remotemanage/serverconfigoptdlg.cpp @@ -25,11 +25,12 @@ #include #include #include - +#include //c++ #include //added byq qinyaning DGUI_USE_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(LogRemoteManage) ServerConfigOptDlg::ServerConfigOptDlg(ServerConfigOptType type, ServerConfig *curServer, QWidget *parent) : DAbstractDialog(parent), @@ -434,7 +435,7 @@ ServerConfigOptDlg::~ServerConfigOptDlg() void ServerConfigOptDlg::updataData(ServerConfig *curServer) { - qInfo() << "ServerConfigOptDlg server configuration options updata data."; + qCInfo(LogRemoteManage) << "ServerConfigOptDlg server configuration options updata data."; // 读取配置 QList textCodeList = getTextCodec(); QList backSpaceKeyList = getBackSpaceKey(); @@ -564,7 +565,7 @@ void ServerConfigOptDlg::setAdvanceRegionVisible(bool isVisible) void ServerConfigOptDlg::slotAddSaveButtonClicked() { - qInfo() << "ServerConfigOptDlg add and save button clicled slot function."; + qCInfo(LogRemoteManage) << "ServerConfigOptDlg add and save button clicled slot function."; // 服务器名为空 if (m_serverName->text().trimmed().isEmpty()) { m_serverName->showAlertMessage(tr("Please enter a server name"), m_serverName); @@ -634,7 +635,7 @@ void ServerConfigOptDlg::slotAddSaveButtonClicked() ServerConfigManager::instance()->modifyServerConfig(config, m_curServer); } accept(); - qInfo() << "Add or save remote config finish"; + qCInfo(LogRemoteManage) << "Add or save remote config finish"; } void ServerConfigOptDlg::slotFileChooseDialog() diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp index 6d09c53ee..1d85c5d08 100644 --- a/src/settings/settings.cpp +++ b/src/settings/settings.cpp @@ -22,6 +22,7 @@ #include #include #include +#include DWIDGET_USE_NAMESPACE #define PRIVATE_PROPERTY_translateContext "_d_DSettingsWidgetFactory_translateContext" @@ -32,6 +33,8 @@ DComboBox *Settings::g_shellConfigCombox = nullptr; // 全局变量 变量定义的位置可以变,目前只有这边用,所以定义到这儿 const QString DEFAULT_SHELL = "$SHELL"; +Q_DECLARE_LOGGING_CATEGORY(LogCommon) + Settings::Settings() : QObject(qApp) { Utils::set_Object_Name(this); @@ -69,7 +72,7 @@ void Settings::init() // 默认配置 QFile configFile(":/other/default-config.json"); if(!configFile.open(QFile::ReadOnly)) { - qInfo() << "can not open default-config.json"; + qCInfo(LogCommon) << "can not open default-config.json"; } QByteArray json = configFile.readAll(); configFile.close(); @@ -128,7 +131,7 @@ void Settings::init() windowState->setData("items", windowStateMap); for (QString &key : settings->keys()) - qDebug() <<"Config' Key: " << key << " Config' Value: " << settings->value(key); + qCDebug(LogCommon) <<"Config' Key: " << key << " Config' Value: " << settings->value(key); /********************* Modify by n014361 wangpeili End ************************/ initConnection(); @@ -527,7 +530,7 @@ bool Settings::isShortcutConflict(const QString &Name, const QString &Key) // 例ctlr+shift+? => ctrl+shift+/ if (Utils::converUpToDown(strKey) == Utils::converUpToDown(Key)) { if (Name != tmpKey) { - qInfo() << Name << Key << "is conflict with Settings!" << tmpKey << settings->value(tmpKey); + qCInfo(LogCommon) << Name << Key << "is conflict with Settings!" << tmpKey << settings->value(tmpKey); return true; } } @@ -552,7 +555,7 @@ void Settings::handleWidthFont() int ret = base.addApplicationFont(fontpath); if (-1 == ret) - qWarning() << "load " << name << " font faild"; + qCWarning(LogCommon) << "load " << name << " font faild"; } } @@ -610,10 +613,10 @@ QPair Settings::createFontComBoBoxHandle(QObject *obj) return qc.compare(str1.value, str2.value) < 0; }); - qInfo() << "createFontComBoBoxHandle get system monospacefont"; + qCInfo(LogCommon) << "createFontComBoBoxHandle get system monospacefont"; if (Whitelist.size() <= 0) { //一般不会走这个分支,除非DBUS出现问题 - qInfo() << "DBusManager::callAppearanceFont failed, get control font failed."; + qCInfo(LogCommon) << "DBusManager::callAppearanceFont failed, get control font failed."; //DBUS获取字体失败后,设置系统默认的等宽字体 QStringList fontlist; fontlist << "Courier 10 Pitch" << "DejaVu Sans Mono" << "Liberation Mono" @@ -749,7 +752,7 @@ QPair Settings::createShortcutEditOptionHandle(/*DSettings // 配置修改 option->connect(option, &DTK_CORE_NAMESPACE::DSettingsOption::valueChanged, rightWidget, [ = ](const QVariant & value) { QString keyseq = value.toString(); - qInfo() << "Current configuration modification! Config's Key: " << rightWidget->option()->key() + qCInfo(LogCommon) << "Current configuration modification! Config's Key: " << rightWidget->option()->key() << "Config's Value: " << keyseq; if (SHORTCUT_VALUE == keyseq || keyseq.isEmpty()) { rightWidget->clear(); @@ -822,7 +825,7 @@ void Settings::setFontSize(const int size) void Settings::setFontName(const QString font) { FontDataList fontList = DBusManager::callAppearanceFont("monospacefont"); - qDebug() << font << fontList.size(); + qCDebug(LogCommon) << "current font name:" << font << "font size:" << fontList.size(); for (int k = 0; k < fontList.count(); k++) { if (font == fontList[k].key || font == fontList[k].value) { settings->option("basic.interface.font")->setValue(font); @@ -860,7 +863,7 @@ void Settings::setConsoleShell(const QString shellName) { QMap shellMap = Service::instance()->getShells(); for (auto itr = shellMap.begin(); itr != shellMap.end(); ++itr) { - qDebug() <<"Console Shell("<< shellName << ")! key:" << itr.key() << "value: " << itr.value(); + qCDebug(LogCommon) <<"Console Shell("<< shellName << ")! key:" << itr.key() << "value: " << itr.value(); if (shellName == itr.key() || shellName == itr.value()) { settings->option("advanced.shell.default_shell")->setValue(itr.value()); break; diff --git a/src/settings/shortcutmanager.cpp b/src/settings/shortcutmanager.cpp index 77a3d934a..055a1585c 100644 --- a/src/settings/shortcutmanager.cpp +++ b/src/settings/shortcutmanager.cpp @@ -15,6 +15,13 @@ #include #include #include +#include + +#ifdef QT_DEBUG +Q_LOGGING_CATEGORY(LogSettings,"log.terminal.settings.work") +#else +Q_LOGGING_CATEGORY(LogSettings,"log.terminal.main.settings",QtInfoMsg) +#endif /* del by ut001121 zhangmeng 20201221 修复BUG58747 #define INI_FILE_CODEC QTextCodec::codecForName("UTF-8")*/ @@ -88,7 +95,7 @@ void ShortcutManager::createCustomCommandsFromConfig() return ; QString customCommandConfigFilePath(customCommandBasePath.filePath("command-config.conf")); - qInfo() << "load Custom Commands Config: " << customCommandConfigFilePath; + qCInfo(LogSettings) << "load Custom Commands Config: " << customCommandConfigFilePath; if (!QFile::exists(customCommandConfigFilePath)) return ; @@ -122,7 +129,7 @@ void ShortcutManager::createCustomCommandsFromConfig() //删除自定义命令文件 QFile fileTemp(customCommandConfigFilePath); if(!fileTemp.remove()) - qWarning() << " remove file error" << customCommandConfigFilePath << fileTemp.errorString(); + qWarning(LogSettings) << " remove file error" << customCommandConfigFilePath << fileTemp.errorString(); //将内存数据写入配置文件 for (QAction *action : m_customCommandActionList) { @@ -180,12 +187,12 @@ QAction *ShortcutManager::findActionByKey(const QString &strKey) { for (QAction *action : m_customCommandActionList) { if (action->text() == strKey) { - qInfo() << "find action " << action; + qCInfo(LogSettings) << "find action " << action; return action; } } - qInfo() << "not find action name " << strKey; + qCInfo(LogSettings) << "not find action name " << strKey; return nullptr; } @@ -228,7 +235,7 @@ bool ShortcutManager::isShortcutConflictInCustom(const QString &Name, const QStr for (auto &currAction : m_customCommandActionList) { if (currAction->shortcut().toString() == Key) { if (Name != currAction->text()) { - qInfo() << Name << Key << "is conflict with custom shortcut!"; + qCInfo(LogSettings) << Name << Key << "is conflict with custom shortcut!"; return true; } } @@ -263,7 +270,7 @@ bool ShortcutManager::checkShortcutValid(const QString &Name, const QString &Key //F1-F12是允许的,这个正则不够精确,但是没关系。 QRegExp regexp("^F[0-9]{1,2}$"); if (!Key.contains(regexp)) { - qInfo() << Key << "is invalid!"; + qCInfo(LogSettings) << Key << "is invalid!"; Reason = tr("The shortcut %1 is invalid, ") .arg(style); return false; @@ -272,14 +279,14 @@ bool ShortcutManager::checkShortcutValid(const QString &Name, const QString &Key // 小键盘单键都不允许 QRegExp regexpNum("^Num+.*"); if (Key.contains(regexpNum)) { - qInfo() << Key << "is invalid!"; + qCInfo(LogSettings) << Key << "is invalid!"; Reason = tr("The shortcut %1 is invalid, ") .arg(style); return false; } // 内置快捷键都不允许 if (m_builtinShortcuts.contains(Key)) { - qInfo() << Key << "is conflict with builtin shortcut!"; + qCInfo(LogSettings) << Key << "is conflict with builtin shortcut!"; Reason = tr("The shortcut %1 was already in use, ") .arg(style); return false; diff --git a/src/views/customthemesettingdialog.cpp b/src/views/customthemesettingdialog.cpp index 92ea2d0d9..c125774c7 100644 --- a/src/views/customthemesettingdialog.cpp +++ b/src/views/customthemesettingdialog.cpp @@ -25,6 +25,9 @@ #include #include #include +#include + +Q_DECLARE_LOGGING_CATEGORY(LogViews) TitleStyleRadioButton::TitleStyleRadioButton(const QString &text, QWidget *parent): DRadioButton(text, parent) { @@ -569,7 +572,7 @@ void CustomThemeSettingDialog::loadConfiguration() QPalette palette; QStringList strList = Settings::instance()->themeSetting->value("Foreground/Color").toStringList(); - qInfo() << "Foreground color list number: " << strList.size(); + qCInfo(LogViews) << "Foreground color list number: " << strList.size(); if (strList.size() != 3) { palette.setColor(QPalette::Background, QColor(0, 255, 0)); foregroundColorParameter = QColor(0, 255, 0); @@ -582,7 +585,7 @@ void CustomThemeSettingDialog::loadConfiguration() QColor backgroundColorParameter; strList.clear(); strList = Settings::instance()->themeSetting->value("Background/Color").toStringList(); - qInfo() << "Background color list number: " << strList.size(); + qCInfo(LogViews) << "Background color list number: " << strList.size(); if (strList.size() != 3) { palette.setColor(QPalette::Background, QColor(37, 37, 37)); backgroundColorParameter = QColor(37, 37, 37); @@ -595,7 +598,7 @@ void CustomThemeSettingDialog::loadConfiguration() QColor ps1ColorParameter; strList.clear(); strList = Settings::instance()->themeSetting->value("Color2Intense/Color").toStringList(); - qInfo() << "Color2Intense color list number: " << strList.size(); + qCInfo(LogViews) << "Color2Intense color list number: " << strList.size(); if (strList.size() != 3) { palette.setColor(QPalette::Background, QColor(133, 153, 0)); ps1ColorParameter = QColor(133, 153, 0); @@ -608,7 +611,7 @@ void CustomThemeSettingDialog::loadConfiguration() QColor ps2ColorParameter; strList.clear(); strList = Settings::instance()->themeSetting->value("Color4Intense/Color").toStringList(); - qInfo() << "Color4Intense color list number: " << strList.size(); + qCInfo(LogViews) << "Color4Intense color list number: " << strList.size(); if (strList.size() != 3) { palette.setColor(QPalette::Background, QColor(52, 101, 164)); ps2ColorParameter = QColor(52, 101, 164); diff --git a/src/views/iconbutton.cpp b/src/views/iconbutton.cpp index d4a26eaf4..23577e223 100644 --- a/src/views/iconbutton.cpp +++ b/src/views/iconbutton.cpp @@ -8,7 +8,9 @@ //qt #include +#include +Q_DECLARE_LOGGING_CATEGORY(LogViews) IconButton::IconButton(QWidget *parent) : DIconButton(parent) { @@ -35,7 +37,7 @@ void IconButton::keyPressEvent(QKeyEvent *event) void IconButton::focusOutEvent(QFocusEvent *event) { - qInfo() << event->reason() << "IconButton" << this; + qCInfo(LogViews) << event->reason() << "IconButton" << this; emit focusOut(event->reason()); DIconButton::focusOutEvent(event); } diff --git a/src/views/itemwidget.cpp b/src/views/itemwidget.cpp index 54e733d3d..674113bce 100644 --- a/src/views/itemwidget.cpp +++ b/src/views/itemwidget.cpp @@ -13,7 +13,9 @@ // qt #include #include +#include +Q_DECLARE_LOGGING_CATEGORY(LogViews) // 不同布局模式配置 const int s_ItemHeight = 60; const QMargins s_ItemIconContentMargins = {8, 8, 8, 8}; @@ -107,7 +109,7 @@ void ItemWidget::setText(const QString &firstline, const QString &secondline) // 第二行 组内服务器个数 int serverCount = ServerConfigManager::instance()->getServerCount(firstline); if (serverCount <= 0) { - qWarning() << "get error count " << serverCount; + qCWarning(LogViews) << "get error count " << serverCount; serverCount = 0; } m_secondText = QString("%1 server").arg(serverCount); @@ -135,7 +137,7 @@ void ItemWidget::getFocus() if (ItemFuncType_Item == m_functType) { m_funcButton->show(); m_funcButton->setFocus(); - qInfo() << "edit button show"; + qCInfo(LogViews) << "edit button show"; } } @@ -186,13 +188,13 @@ void ItemWidget::onFuncButtonClicked() switch (m_functType) { case ItemFuncType_Group: // 显示分组 - qInfo() << "group show" << m_firstText; + qCInfo(LogViews) << "group show" << m_firstText; // 第一个参数是分组名,第二个参数是当前是否有焦点 emit groupClicked(m_firstText, m_isFocus); break; case ItemFuncType_Item: { // 修改项 - qInfo() << "modify item" << m_firstText; + qCInfo(LogViews) << "modify item" << m_firstText; bool isFocusOn = false; if (m_funcButton->hasFocus() || m_isFocus) { // 焦点在大框或者编辑按钮上 @@ -220,13 +222,13 @@ void ItemWidget::onIconButtonClicked() switch (m_functType) { case ItemFuncType_Group: // 显示分组 - qInfo() << "group show" << m_firstText; + qCInfo(LogViews) << "group show" << m_firstText; // 第一个参数是分组名,第二个参数是当前是否有焦点 emit groupClicked(m_firstText, m_isFocus); break; case ItemFuncType_Item: // 项被点击 - qInfo() << "item clicked" << m_firstText; + qCInfo(LogViews) << "item clicked" << m_firstText; emit itemClicked(m_firstText); break; } @@ -246,7 +248,7 @@ void ItemWidget::onFocusOut(Qt::FocusReason type) if (Qt::ActiveWindowFocusReason == type) { // 例如:super后返回都需要将焦点返回项 setFocus(); - qInfo() << "set focus back itemwidget"; + qCInfo(LogViews) << "set focus back itemwidget"; } // 项 if (ItemFuncType_Item == m_functType) { @@ -436,7 +438,7 @@ void ItemWidget::keyPressEvent(QKeyEvent *event) switch (event->key()) { case Qt::Key_Right: // 点击键盘右键 - qInfo() << "right key press"; + qCInfo(LogViews) << "right key press"; rightKeyPress(); break; case Qt::Key_Enter: @@ -497,7 +499,7 @@ void ItemWidget::setFontColor(DLabel *label, ItemTextColor colorType) fontPalette.setBrush(DPalette::Text, color); label->setPalette(fontPalette); } else { - qWarning() << "Can't get text color"; + qCWarning(LogViews) << "Can't get text color"; } } @@ -518,7 +520,7 @@ QColor ItemWidget::getColor(ItemTextColor colorType) } break; default: - qInfo() << "item widget text unknow color type!" << colorType; + qCInfo(LogViews) << "item widget text unknow color type!" << colorType; break; } return color; @@ -529,13 +531,13 @@ void ItemWidget::rightKeyPress() switch (m_functType) { case ItemFuncType_Group: { // 显示分组 - qInfo() << "group show" << m_firstText; + qCInfo(LogViews) << "group show" << m_firstText; emit groupClicked(m_firstText, true); } break; case ItemFuncType_Item: // 编辑按钮获得焦点 - qInfo() << "item get focus" << m_firstText; + qCInfo(LogViews) << "item get focus" << m_firstText; m_funcButton->show(); m_funcButton->setFocus(); break; @@ -556,13 +558,13 @@ void ItemWidget::onItemClicked() switch (m_functType) { case ItemFuncType_Group: // 显示分组 - qInfo() << "group show" << m_firstText; + qCInfo(LogViews) << "group show" << m_firstText; // 第一个参数是分组名,第二个参数是当前是否有焦点 emit groupClicked(m_firstText, m_isFocus); break; case ItemFuncType_Item: // 项被点击 - qInfo() << "item clicked" << m_firstText; + qCInfo(LogViews) << "item clicked" << m_firstText; emit itemClicked(m_firstText); break; } diff --git a/src/views/listview.cpp b/src/views/listview.cpp index 51f3b32b2..27bfb85f7 100644 --- a/src/views/listview.cpp +++ b/src/views/listview.cpp @@ -13,6 +13,9 @@ // qt #include #include +#include + +Q_DECLARE_LOGGING_CATEGORY(LogViews) ListView::ListView(ListType type, QWidget *parent) : QScrollArea(parent), @@ -172,7 +175,7 @@ int ListView::getNextIndex(int index) { if (index < 0) { // 输入错误的index - qWarning() << "input wrong index" << index; + qCWarning(LogViews) << "input wrong index" << index; return -1; } int count = m_itemList.count(); @@ -195,7 +198,7 @@ void ListView::setCurrentIndex(int currentIndex) // 首先判断currentIndex的有效性 if (!indexIsValid(currentIndex)) { // 无效,返回 - qInfo() << "index(" << currentIndex << ") is wrong"; + qCInfo(LogViews) << "index(" << currentIndex << ") is wrong"; emit focusOut(Qt::NoFocusReason); m_focusState = false; return; @@ -209,7 +212,7 @@ void ListView::setCurrentIndex(int currentIndex) ItemWidget *widget = item ? qobject_cast(item->widget()) : nullptr; if (widget != nullptr) { // 设置焦点 - qInfo() << widget << "get focus" << "current index" << currentIndex; + qCInfo(LogViews) << widget << "get focus" << "current index" << currentIndex; // Todo 让焦点不要进入主窗口 widget->setFocus(); m_focusState = true; @@ -244,17 +247,17 @@ void ListView::onRemoteItemModify(const QString &key, bool isFocusOn) m_currentIndex = curIndex; // 弹窗显示 ServerConfig *curItemServer = ServerConfigManager::instance()->getServerConfig(key); - qInfo() << "modify remote " << curItemServer->m_serverName; + qCInfo(LogViews) << "modify remote " << curItemServer->m_serverName; // 弹窗显示 Service::instance()->setIsDialogShow(window(), true); // 根据点击事件还是键盘事件设置焦点状态 if (isFocusOn) { // 键盘 m_focusState = true; - qInfo() << "keyboard clicked"; + qCInfo(LogViews) << "keyboard clicked"; } else { // 鼠标 - qInfo() << "mouse press"; + qCInfo(LogViews) << "mouse press"; m_focusState = false; m_currentIndex = -1; } @@ -270,7 +273,7 @@ void ListView::onRemoteItemModify(const QString &key, bool isFocusOn) inline void ListView::onServerConfigOptDlgFinished(int result) { // 弹窗隐藏或消失 - qInfo() << "focus state " << m_focusState; + qCInfo(LogViews) << "focus state " << m_focusState; // 3. 对弹窗操作进行分析 // 判断是否删除 if (ServerConfigOptDlg::Accepted == result) { @@ -297,7 +300,7 @@ inline void ListView::onServerConfigOptDlgFinished(int result) // 设置滚轮 // 关闭后及时将弹窗删除 // 记住修改前的位置 m_currentIndex - qInfo() << "index before modify " << m_currentIndex; + qCInfo(LogViews) << "index before modify " << m_currentIndex; ServerConfigManager::instance()->removeDialog(m_configDialog); // 刷新列表 emit ServerConfigManager::instance()->refreshList(); @@ -310,7 +313,7 @@ inline void ListView::onServerConfigOptDlgFinished(int result) } // 依旧没有找到啦 if (index < 0) { - qInfo() << "no next item"; + qCInfo(LogViews) << "no next item"; if (m_focusState) { // 有焦点,焦点出 emit focusOut(Qt::NoFocusReason); @@ -437,7 +440,7 @@ inline void ListView::onCustomCommandOptDlgFinished(int result) if (QDialog::Accepted == result) { //确认修改处理 - qInfo() << "Modify Custom Command"; + qCInfo(LogViews) << "Modify Custom Command"; QAction *newAction = m_pdlg->getCurCustomCmd(); CustomCommandData itemData = *(m_pdlg->m_currItemData); CustomCommandData itemDel = itemData; @@ -473,7 +476,7 @@ inline void ListView::onCustomCommandOptDlgFinished(int result) //Delete custom command 删除自定义命令处理 if (m_pdlg->isDelCurCommand()) { - qInfo() << "Delete Custom Command"; + qCInfo(LogViews) << "Delete Custom Command"; DDialog *dlgDelete = new DDialog(this); dlgDelete->setObjectName("CustomDeleteDialog"); dlgDelete->setAttribute(Qt::WA_DeleteOnClose); @@ -503,11 +506,11 @@ inline void ListView::onCustomCommandOptDlgFinished(int result) ItemWidget *itemWidget = m_itemList.at(m_currentIndex); itemWidget->getFocus(); } else { - qInfo() << "QDialog accepted result is:" << result; + qCInfo(LogViews) << "QDialog accepted result is:" << result; if (-1 != result) { setFocus(); } else { - qInfo() << "QDialog Rejected"; + qCInfo(LogViews) << "QDialog Rejected"; ItemWidget *itemWidget = m_itemList.at(m_currentIndex); itemWidget->getFocus(); } @@ -537,7 +540,7 @@ inline void ListView::onDeleteCustomCommandFinished(int result) setFocus(); } else { // 找不到 - qInfo() << "can't find index" << index; + qCInfo(LogViews) << "can't find index" << index; if (m_itemList.count() == 0) { emit focusOut(Qt::NoFocusReason); } @@ -579,7 +582,7 @@ void ListView::focusInEvent(QFocusEvent *event) else setCurrentIndex(m_currentIndex); - qInfo() << "ListView current index : " << m_currentIndex << event->reason(); + qCInfo(LogViews) << "ListView current index : " << m_currentIndex << event->reason(); m_focusState = true; QScrollArea::focusInEvent(event); } @@ -700,7 +703,7 @@ void ListView::setFocusFromeIndex(int currentIndex, ListFocusType focusType) else if (ListFocusEnd == focusType) index = this->count() - 1; else - qInfo() << "Type of current focus:" << focusType ; + qCInfo(LogViews) << "Type of current focus:" << focusType ; // index >= 0 < 最大数量 // 最上 @@ -754,11 +757,11 @@ void ListView::setFocusFromeIndex(int currentIndex, ListFocusType focusType) m_scrollPostion = 0; verticalScrollBar()->setValue(m_scrollPostion); - qInfo() << "up down scrollPostion : " << m_scrollPostion << verticalScrollBar()->value(); + qCInfo(LogViews) << "up down scrollPostion : " << m_scrollPostion << verticalScrollBar()->value(); // 需要让m_currentIndex于焦点所在位置同步 m_currentIndex = index; - qInfo() << "current index : " << m_currentIndex; + qCInfo(LogViews) << "current index : " << m_currentIndex; } void ListView::lostFocus(int preIndex) @@ -772,7 +775,7 @@ void ListView::lostFocus(int preIndex) if (widget != nullptr) { // 丢失焦点 widget->lostFocus(); - qInfo() << widget << "lost focus"; + qCInfo(LogViews) << widget << "lost focus"; } } diff --git a/src/views/pagesearchbar.cpp b/src/views/pagesearchbar.cpp index 6c40aad9e..0e69e7a66 100644 --- a/src/views/pagesearchbar.cpp +++ b/src/views/pagesearchbar.cpp @@ -19,6 +19,7 @@ #include #include #include +Q_DECLARE_LOGGING_CATEGORY(LogViews) PageSearchBar::PageSearchBar(QWidget *parent) : DFloatingWidget(parent) { @@ -188,7 +189,7 @@ void PageSearchBar::initSearchEdit() } } } else { - qWarning() << "can not found _q_qlineeditclearaction in QAction"; + qCWarning(LogViews) << "can not found _q_qlineeditclearaction in QAction"; } // 需求不让自动查找,这个接口预留 diff --git a/src/views/tabbar.cpp b/src/views/tabbar.cpp index 545be25f4..f79dcff92 100644 --- a/src/views/tabbar.cpp +++ b/src/views/tabbar.cpp @@ -29,7 +29,9 @@ #ifdef DTKWIDGET_CLASS_DSizeMode #include #endif +#include +Q_DECLARE_LOGGING_CATEGORY(LogViews) //TermTabStyle类开始,该类用于设置tab标签样式 TermTabStyle::TermTabStyle() : m_tabCount(0) { @@ -236,7 +238,7 @@ int TabBar::addTab(const QString &tabIdentifier, const QString &tabName) int TabBar::insertTab(const int &index, const QString &tabIdentifier, const QString &tabName) { - qInfo() << "insertTab at index: " << index << " with id::" << tabIdentifier << endl; + qCInfo(LogViews) << "insertTab at index: " << index << " with id::" << tabIdentifier << endl; int insertIndex = DTabBar::insertTab(index, tabName); setTabData(insertIndex, QVariant::fromValue(tabIdentifier)); @@ -708,7 +710,7 @@ void TabBar::handleTabReleased(int index) if (index < 0) index = 0; - qInfo() << "Indicates the index(" << index << ") of the released label!"; + qCInfo(LogViews) << "Indicates the index(" << index << ") of the released label!"; const QString tabName = tabText(index); MainWindow *window = static_cast(this->window()); @@ -724,7 +726,7 @@ void TabBar::handleTabReleased(int index) //从原窗口中移除TermWidgetPage。 window->removeTermWidgetPage(termIdentifer, false); - qInfo() << "Remove Term Widget Page termIdentifer: " << termIdentifer; + qCInfo(LogViews) << "Remove Term Widget Page termIdentifer: " << termIdentifer; updateTabDragMoveStatus(); } @@ -777,7 +779,7 @@ inline void TabBar::handleWindowClose() return; int windowIndex = WindowsManager::instance()->getNormalWindowList().indexOf(window); - qInfo() << "Close window at index: " << windowIndex; + qCInfo(LogViews) << "Close window at index: " << windowIndex; if (windowIndex >= 0) WindowsManager::instance()->getNormalWindowList().takeAt(windowIndex); @@ -811,7 +813,7 @@ void TabBar::handleTabDroped(int index, Qt::DropAction dropAction, QObject *targ { Q_UNUSED(dropAction) - qInfo() << "Handle Tab Droped! index:" << index << ", target:" << target << endl; + qCInfo(LogViews) << "Handle Tab Droped! index:" << index << ", target:" << target << endl; TabBar *tabbar = qobject_cast(target); //拖出的标签--需要新建窗口 diff --git a/src/views/tabrenamedlg.cpp b/src/views/tabrenamedlg.cpp index e011e3e93..424e9d1fe 100644 --- a/src/views/tabrenamedlg.cpp +++ b/src/views/tabrenamedlg.cpp @@ -13,7 +13,9 @@ #include #include #include +#include +Q_DECLARE_LOGGING_CATEGORY(LogViews) TabRenameDlg::TabRenameDlg(QWidget *parent) : DAbstractDialog(parent) { initUi(); @@ -177,7 +179,7 @@ void TabRenameDlg::initConnections() }); connect(m_confirmButton, &DSuggestButton::clicked, this, [ = ] { - qInfo() << "confirm rename title"; + qCInfo(LogViews) << "confirm rename title"; QString tabTitleFormat = getTabTitleEdit()->text(); QString remoteTabTitleFormat = getRemoteTabTitleEdit()->text(); emit tabTitleFormatRename(tabTitleFormat, remoteTabTitleFormat); diff --git a/src/views/termwidget.cpp b/src/views/termwidget.cpp index 917f81320..e27e9b116 100644 --- a/src/views/termwidget.cpp +++ b/src/views/termwidget.cpp @@ -35,6 +35,13 @@ DWIDGET_USE_NAMESPACE using namespace Konsole; + +#ifdef QT_DEBUG +Q_LOGGING_CATEGORY(LogViews,"log.terminal.views.work") +#else +Q_LOGGING_CATEGORY(LogViews,"log.terminal.views.work",QtInfoMsg) +#endif + TermWidget::TermWidget(const TermProperties &properties, QWidget *parent) : QTermWidget(0, parent), m_properties(properties) { Utils::set_Object_Name(this); @@ -48,7 +55,7 @@ TermWidget::TermWidget(const TermProperties &properties, QWidget *parent) : QTer QString strShellPath = Settings::instance()->shellPath(); // set shell program - qInfo() << "set shell program : " << strShellPath; + qCInfo(LogViews) << "set shell program : " << strShellPath; setShellProgram(strShellPath); /******** Modify by ut000610 daizhengwen 2020-07-08:初始化透明度 Begin***************/ // 若没有窗口特效,则不生效 @@ -93,7 +100,7 @@ TermWidget::TermWidget(const TermProperties &properties, QWidget *parent) : QTer //QString args = m_properties[Execute].toString(); //QStringList argList = args.split(QRegExp(QStringLiteral("\\s+")), QString::SkipEmptyParts); QStringList argList = m_properties[Execute].toStringList(); - qInfo() << "Execute args:" << argList; + qCInfo(LogViews) << "Execute args:" << argList; if (argList.count() > 0) { setShellProgram(argList.at(0)); argList.removeAt(0); @@ -142,7 +149,7 @@ TermWidget::TermWidget(const TermProperties &properties, QWidget *parent) : QTer // 增加可以自动运行脚本的命令,不需要的话,可以删除 if (m_properties.contains(Script)) { QString args = m_properties[Script].toString(); - qInfo() << "run cmd:" << args; + qCInfo(LogViews) << "run cmd:" << args; args.append("\n"); if (!m_properties[KeepOpen].toBool()) args.append("exit\n"); @@ -282,11 +289,11 @@ inline void TermWidget::onExitRemoteServer() { // 判断是否此时退出远程 if (!isInRemoteServer()) { - qInfo() << "exit remote"; + qCInfo(LogViews) << "exit remote"; setIsConnectRemote(false); // 还原编码 setTextCodec(QTextCodec::codecForName(encode().toLocal8Bit())); - qInfo() << "current encode " << encode(); + qCInfo(LogViews) << "current encode " << encode(); setBackspaceMode(m_backspaceMode); setDeleteMode(m_deleteMode); emit Service::instance()->checkEncode(encode()); @@ -301,7 +308,7 @@ inline void TermWidget::onUrlActivated(const QUrl &url, bool fromContextMenu) inline void TermWidget::onThemeTypeChanged(DGuiApplicationHelper::ColorType builtInTheme) { - qInfo() << "Theme Type Changed! Current Theme Type: " << builtInTheme; + qCInfo(LogViews) << "Theme Type Changed! Current Theme Type: " << builtInTheme; // ThemePanelPlugin *plugin = qobject_cast(getPluginByName("Theme")); QString theme = "Dark"; /************************ Mod by sunchengxi 2020-09-16:Bug#48226#48230#48236#48241 终端默认主题色应改为深色修改引起的系列问题修复 Begin************************/ @@ -669,7 +676,7 @@ inline QString TermWidget::getFormatFileName(QString selectedText) || (fileName.startsWith("\"") && fileName.endsWith("\""))) { fileName = fileName.remove(0, 1); fileName = fileName.remove(fileName.length() - 1, 1); - qInfo() << "Format fileName is " << fileName; + qCInfo(LogViews) << "Format fileName is " << fileName; } return fileName; @@ -745,7 +752,7 @@ void TermWidget::setBackspaceMode(const EraseMode &backspaceMode) case EraseMode_TTY: ch = getErase(); length = 1; - qInfo() << "tty erase : " << QByteArray(&ch, length).toHex(); + qCInfo(LogViews) << "tty erase : " << QByteArray(&ch, length).toHex(); break; case EraseMode_Escape_Sequeue: length = 4; @@ -772,7 +779,7 @@ void TermWidget::setDeleteMode(const EraseMode &deleteMode) case EraseMode_TTY: ch = getErase(); length = 1; - qInfo() << "tty erase : " << QByteArray(&ch, length).toHex(); + qCInfo(LogViews) << "tty erase : " << QByteArray(&ch, length).toHex(); break; case EraseMode_Auto: case EraseMode_Escape_Sequeue: @@ -887,7 +894,7 @@ void TermWidget::initTabTitleArgs() for (QString arg : strRemoteTabArgs) m_remoteTabArgs.insert(arg, " "); - qInfo() << "Tab args init! tab title count : " << m_tabArgs.count() << " remote title count : " << m_remoteTabArgs.count(); + qCInfo(LogViews) << "Tab args init! tab title count : " << m_tabArgs.count() << " remote title count : " << m_remoteTabArgs.count(); } QString TermWidget::getTabTitleFormat() @@ -1043,17 +1050,17 @@ void TermWidget::selectEncode(QString encode) if (!isConnectRemote()) { // 记录当前的encode setEncode(encode); - qInfo() << "current encode " << encode; + qCInfo(LogViews) << "current encode " << encode; } else { // 记录远程的encode setRemoteEncode(encode); - qInfo() << "Remote encode " << encode; + qCInfo(LogViews) << "Remote encode " << encode; } } void TermWidget::onSettingValueChanged(const QString &keyName) { - qInfo() << "Setting Value Changed! Current Config's key:" << keyName; + qCInfo(LogViews) << "Setting Value Changed! Current Config's key:" << keyName; if ("basic.interface.opacity" == keyName) { setTermOpacity(Settings::instance()->opacity()); return; @@ -1108,18 +1115,18 @@ void TermWidget::onSettingValueChanged(const QString &keyName) } if ("advanced.scroll.scroll_on_output" == keyName) { - qInfo() << "settingValue[" << keyName << "] changed to " << Settings::instance()->OutputtingScroll() + qCInfo(LogViews) << "settingValue[" << keyName << "] changed to " << Settings::instance()->OutputtingScroll() << ", auto effective when happen"; return; } - qInfo() << "settingValue[" << keyName << "] changed is not effective"; + qCInfo(LogViews) << "settingValue[" << keyName << "] changed is not effective"; } void TermWidget::onDropInUrls(const char *urls) { QString strUrls = QString::fromLocal8Bit(urls); - qInfo() << "recv urls:" << strUrls; + qCInfo(LogViews) << "recv urls:" << strUrls; if (isConnectRemote()) { // 远程管理连接中 QString strTxt = "sz "; diff --git a/src/views/termwidgetpage.cpp b/src/views/termwidgetpage.cpp index e1b2ac6d6..531efe03c 100644 --- a/src/views/termwidgetpage.cpp +++ b/src/views/termwidgetpage.cpp @@ -17,7 +17,9 @@ #include #include +#include +Q_DECLARE_LOGGING_CATEGORY(LogViews) TermWidgetPage::TermWidgetPage(const TermProperties &properties, QWidget *parent) : QWidget(parent), m_findBar(new PageSearchBar(this)) { @@ -125,12 +127,12 @@ void TermWidgetPage::split(Qt::Orientation orientation) parentMainWindow()->showPlugin(MainWindow::PLUGIN_TYPE_NONE); TermWidget *term = m_currentTerm; if (1 == getTerminalCount()) { - qInfo() << "first split"; + qCInfo(LogViews) << "first split"; QSplitter *firstSplit = createSubSplit(term, orientation); m_layout->addWidget(firstSplit); //return ; } else { - qInfo() << "not first split"; + qCInfo(LogViews) << "not first split"; QSplitter *upSplit = qobject_cast(term->parent()); int index = upSplit->indexOf(term); QList parentSizes = upSplit->sizes(); @@ -179,7 +181,7 @@ DSplitter *TermWidgetPage::createSubSplit(TermWidget *term, Qt::Orientation orie void TermWidgetPage::closeSplit(TermWidget *term, bool hasConfirmed) { - qInfo() << "TermWidgetPage::closeSplit:" << term->getSessionId(); + qCInfo(LogViews) << "TermWidgetPage::closeSplit:" << term->getSessionId(); if (getTerminalCount() > 1) { if (!hasConfirmed && term->hasRunningProcess()) { showExitConfirmDialog(Utils::CloseType_Terminal, 1, parentMainWindow()); @@ -199,16 +201,16 @@ void TermWidgetPage::closeSplit(TermWidget *term, bool hasConfirmed) } // 上级不是分屏控件,就是布局在控制了 else { - qWarning() << "TermWidgetPage only one term exist!"; + qCWarning(LogViews) << "TermWidgetPage only one term exist!"; m_layout->addWidget(brother); } // 子控件的变化会引起焦点的变化,控制焦点要放在最后 if (nextTerm != nullptr) { - qInfo() << "nextTerm change" << m_currentTerm->getSessionId(); + qCInfo(LogViews) << "nextTerm change" << m_currentTerm->getSessionId(); nextTerm->setFocus(); } else { - qWarning() << "can not found nextTerm in TermWidget"; + qCWarning(LogViews) << "can not found nextTerm in TermWidget"; } // 释放控件,并隐藏term、upSplit,避免出现闪现窗口bug#80809 @@ -219,7 +221,7 @@ void TermWidgetPage::closeSplit(TermWidget *term, bool hasConfirmed) upSplit->hide(); upSplit->setParent(nullptr); upSplit->deleteLater(); - qInfo() << "page terminal count =" << getTerminalCount(); + qCInfo(LogViews) << "page terminal count =" << getTerminalCount(); /******** Add by ut001000 renfeixiang 2020-08-07:关闭分屏时改变大小,bug#41436***************/ parentMainWindow()->updateMinHeight(); return; @@ -257,7 +259,7 @@ void TermWidgetPage::showExitConfirmDialog(Utils::CloseType type, int count, QWi // if (type == Utils::CloseType_Terminal) { // connect(dlg, &DDialog::finished, this, [this](int result) { -// qInfo() << result; +// qCInfo(LogViews) << result; // // 有弹窗消失 // Service::instance()->setIsDialogShow(window(), false); // if (result == 1) { @@ -269,7 +271,7 @@ void TermWidgetPage::showExitConfirmDialog(Utils::CloseType type, int count, QWi // if (type == Utils::CloseType_OtherTerminals) { // connect(dlg, &DDialog::finished, this, [this](int result) { -// qInfo() << result; +// qCInfo(LogViews) << result; // // 有弹窗消失 // Service::instance()->setIsDialogShow(window(), false); // if (result == 1) { @@ -303,7 +305,7 @@ void TermWidgetPage::closeOtherTerminal(bool hasConfirmed) QList termList = findChildren(); // 终端数量小于2,执行关闭其他窗口操作 if (termList.count() < 2) { - qInfo() << "current window doesn't have other terminal, can't close other terminals."; + qCInfo(LogViews) << "current window doesn't have other terminal, can't close other terminals."; return; } @@ -343,7 +345,7 @@ int TermWidgetPage::getTerminalCount() bool TermWidgetPage::hasHasHorizontalSplit() { - qInfo() << "start hasHasHorizontalSplit"; + qCInfo(LogViews) << "start hasHasHorizontalSplit"; QList splitList = findChildren(); for (QSplitter *split : splitList) { if (Qt::Vertical == split->orientation()) { @@ -358,7 +360,7 @@ QRect TermWidgetPage::GetRect(TermWidget *term) QPoint leftTop = term->mapTo(term->window(), QPoint(0, 0)); QPoint rightBottom = term->mapTo(term->window(), QPoint(term->width(), term->height())); QRect rec(leftTop, rightBottom); - qInfo() << "leftTop: " << leftTop.x() << leftTop.y() << "rightBottom: " << rightBottom.x() << rightBottom.y(); + qCInfo(LogViews) << "leftTop: " << leftTop.x() << leftTop.y() << "rightBottom: " << rightBottom.x() << rightBottom.y(); return rec; } @@ -610,7 +612,7 @@ void TermWidgetPage::onTermClosed() { TermWidget *w = qobject_cast(sender()); if (!w) { - qWarning() << "TermWidgetPage::onTermClosed: Unknown object to handle" << w; + qCWarning(LogViews) << "TermWidgetPage::onTermClosed: Unknown object to handle" << w; return; } closeSplit(w); @@ -712,7 +714,7 @@ void TermWidgetPage::setCurrentTerminal(TermWidget *term) m_currentTerm = term; if (oldTerm != m_currentTerm) { // 当前界面切换 - qInfo() << "Current terminal change" << m_currentTerm->getSessionId(); + qCInfo(LogViews) << "Current terminal change" << m_currentTerm->getSessionId(); QString tabTitle = term->getTabTitle(); // 当前标签为空,标签格式不为空 => 未得到term参数,暂不上传数据 if ((tabTitle == DEFAULT_TAB_TITLE) && !term->getCurrentTabTitleFormat().trimmed().isEmpty()) @@ -732,7 +734,7 @@ TermWidget *TermWidgetPage::createTerm(TermProperties properties) connect(term, &TermWidget::leftMouseClick, this, &TermWidgetPage::handleLeftMouseClick); connect(term, &TermWidget::finished, this, &TermWidgetPage::onTermClosed); - qInfo() << "create Terminal, sessionId = " << term->getSessionId(); + qCInfo(LogViews) << "create Terminal, sessionId = " << term->getSessionId(); // 对标签页重命名设置 connect(this, &TermWidgetPage::tabTitleFormatChanged, term, &TermWidget::renameTabFormat); return term;