Commit 71f60fd3 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Fix removeWidget and activateWidget signals

Also, delete the widget afterwards to avoid stockpiling them forever
parent 6d56c513
Pipeline #230531 passed with stage
in 6 minutes and 23 seconds
......@@ -95,7 +95,7 @@ public:
Q_DECLARE_METATYPE(ResultNode)
static const ResultNode openWidgetsNode("Open Widgets", true);
static const ResultNode openWidgetsNode("Open Widgets", false);
namespace QTest
{
......
......@@ -1319,17 +1319,12 @@ bool KateMainWindow::addWidget(QWidget *widget)
auto vs = m_viewManager->activeViewSpace();
vs->addWidgetAsTab(widget);
Q_EMIT widgetAdded(widget);
Q_EMIT widgetActivated(widget);
return true;
}
bool KateMainWindow::removeWidget(QWidget *widget)
{
auto success = m_viewManager->removeWidget(widget);
if (success) {
Q_EMIT widgetRemoved(widget);
}
return success;
return m_viewManager->removeWidget(widget);
}
QWidget *KateMainWindow::activeWidget()
......@@ -1343,8 +1338,8 @@ QWidget *KateMainWindow::activeWidget()
void KateMainWindow::activateWidget(QWidget *widget)
{
if (m_viewManager->activateWidget(widget)) {
Q_EMIT widgetActivated(widget);
if (!m_viewManager->activateWidget(widget)) {
addWidget(widget);
}
}
......
......@@ -533,7 +533,7 @@ public Q_SLOTS:
QWidgetList widgets() const;
/**
* \brief remove this \p widget from this mainwindow.
* \brief remove this \p widget from this mainwindow. The widget will be deleted afterwards
* \param widget the widget to be removed
* \return true on success
*/
......@@ -546,7 +546,7 @@ public Q_SLOTS:
QWidget *activeWidget();
/**
* \brief activate @p widget
* \brief activate @p widget. If the widget is not present in the window, it will be added to the window
* \param widget the widget to activate
*/
void activateWidget(QWidget *widget);
......
......@@ -727,6 +727,8 @@ void KateViewSpace::closeTabRequest(int idx)
if (shouldClose) {
stack->removeWidget(widget);
m_tabBar->removeTab(idx);
widget->deleteLater();
Q_EMIT m_viewManager->mainWindow()->widgetRemoved(widget);
}
return;
}
......@@ -814,8 +816,7 @@ bool KateViewSpace::closeTabWithWidget(QWidget *widget)
bool KateViewSpace::activateWidget(QWidget *widget)
{
if (stack->indexOf(widget) == -1) {
addWidgetAsTab(widget);
return true;
return false;
}
stack->setCurrentWidget(widget);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment