From 39823e05cc4c5482190d993802731e12470d0887 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sun, 27 Nov 2016 18:20:06 +0100 Subject: [PATCH] Address status bar text boxes by pointer instead of "command IDs". With KF5, KStatusBar is deprecated. The replacement, QStatusBar, does not allow to address widgets on the status bar by ID, but the pointers themselves must be kept. So, let's do that. The implementation chosen here is based on KStatusBar::insertItem(). --- kdbg/commandids.h | 13 ------------- kdbg/dbgmainwnd.cpp | 18 +++++++++++++----- kdbg/dbgmainwnd.h | 3 +++ 3 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 kdbg/commandids.h diff --git a/kdbg/commandids.h b/kdbg/commandids.h deleted file mode 100644 index 57b276a..0000000 --- a/kdbg/commandids.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright Johannes Sixt - * This file is licensed under the GNU General Public License Version 2. - * See the file COPYING in the toplevel directory of the source directory. - */ - -#ifndef COMMANDIDS_H -#define COMMANDIDS_H - -// statusbar ids -#define ID_STATUS_MSG 191 -#define ID_STATUS_ACTIVE 193 -#endif // COMMANDIDS_H diff --git a/kdbg/dbgmainwnd.cpp b/kdbg/dbgmainwnd.cpp index dd5a609..6367596 100644 --- a/kdbg/dbgmainwnd.cpp +++ b/kdbg/dbgmainwnd.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -32,7 +33,6 @@ #include #include "dbgmainwnd.h" #include "debugger.h" -#include "commandids.h" #include "winstack.h" #include "brkpt.h" #include "threadlist.h" @@ -372,9 +372,17 @@ void DebuggerMainWnd::initAnimation() void DebuggerMainWnd::initStatusBar() { KStatusBar* statusbar = statusBar(); - statusbar->insertItem(m_statusActive, ID_STATUS_ACTIVE); + m_statusActiveLabel = new KSqueezedTextLabel(statusbar); + m_statusActiveLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + statusbar->addPermanentWidget(m_statusActiveLabel); + m_statusActiveLabel->show(); m_lastActiveStatusText = m_statusActive; - statusbar->insertItem("", ID_STATUS_MSG); /* message pane */ + + /* message pane */ + m_statusMsgLabel = new KSqueezedTextLabel(statusbar); + m_statusMsgLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + statusbar->addPermanentWidget(m_statusMsgLabel); + m_statusMsgLabel->show(); // reserve some translations i18n("Restart"); @@ -542,7 +550,7 @@ void DebuggerMainWnd::updateUI() if (m_debugger->isProgramActive()) newStatus = m_statusActive; if (newStatus != m_lastActiveStatusText) { - statusBar()->changeItem(newStatus, ID_STATUS_ACTIVE); + m_statusActiveLabel->setText(newStatus); m_lastActiveStatusText = newStatus; } } @@ -816,7 +824,7 @@ void DebuggerMainWnd::setAttachPid(const QString& pid) void DebuggerMainWnd::slotNewStatusMsg() { QString msg = m_debugger->statusMessage(); - statusBar()->changeItem(msg.trimmed(), ID_STATUS_MSG); + m_statusMsgLabel->setText(msg.trimmed()); } void DebuggerMainWnd::slotFileGlobalSettings() diff --git a/kdbg/dbgmainwnd.h b/kdbg/dbgmainwnd.h index 149446f..f85e3a6 100644 --- a/kdbg/dbgmainwnd.h +++ b/kdbg/dbgmainwnd.h @@ -16,6 +16,7 @@ class QDockWidget; class QProcess; class KAnimatedButton; class KRecentFilesAction; +class KSqueezedTextLabel; class KUrl; class WinStack; class QListWidget; @@ -168,7 +169,9 @@ protected: bool m_animRunning; // statusbar texts + KSqueezedTextLabel* m_statusActiveLabel; QString m_statusActive; + KSqueezedTextLabel* m_statusMsgLabel; signals: void setTabWidth(int tabWidth); -- 2.11.4.GIT