Commit 624625cc authored by Dmitry Kazakov's avatar Dmitry Kazakov Committed by Emmet O'Neill
Browse files

Fix extra call to tool->popupWidget() if tool->popupActionsMenu() returned something

By a common convention, the newer version function should not be
called when the other version has returned something.

It is quite disputable, what version should be called first, but
that is mostly a "theoretical" question in our case (since it is
not a public API).

(Squashed with some other miscellaneous cleanup changes. - Emmet)
parent 4894cc72
......@@ -306,7 +306,7 @@ set(kritaui_LIB_SRCS
input/kis_zoom_action.cpp
input/kis_change_frame_action.cpp
input/kis_gamma_exposure_action.cpp
input/kis_show_palette_action.cpp
input/KisPopupWidgetAction.cpp
input/kis_change_primary_setting_action.cpp
input/kis_abstract_shortcut.cpp
input/kis_native_gesture_shortcut.cpp
......
/*
* SPDX-FileCopyrightText: 2021 Emmet O 'Neill <emmetoneill.pdx@gmail.com>
* SPDX-FileCopyrightText: 2021 Eoin O 'Neill <eoinoneill1991@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KISPOPUPWIDGETINTERFACE_H
#define KISPOPUPWIDGETINTERFACE_H
......
/* This file is part of the KDE project
* SPDX-FileCopyrightText: 2012 Arjen Hiemstra <ahiemstra@heimr.nl>
* SPDX-FileCopyrightText: 2021 Emmet O 'Neill <emmetoneill.pdx@gmail.com>
* SPDX-FileCopyrightText: 2021 Eoin O 'Neill <eoinoneill1991@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kis_show_palette_action.h"
#include "KisPopupWidgetAction.h".h"
#include <QCursor>
#include <QMenu>
......@@ -49,10 +51,7 @@ KisPopupWidgetAction::~KisPopupWidgetAction()
void KisPopupWidgetAction::begin(int, QEvent *event)
{
QMenu *popupMenu = inputManager()->toolProxy()->popupActionsMenu();
KisPopupWidgetInterface *popupWidget = inputManager()->toolProxy()->popupWidget();
if (popupMenu) { // Handle popup menus...
if (QMenu *popupMenu = inputManager()->toolProxy()->popupActionsMenu()) { // Handle popup menus...
m_requestedWithStylus = event && event->type() == QEvent::TabletPress;
/**
......@@ -74,7 +73,7 @@ void KisPopupWidgetAction::begin(int, QEvent *event)
popupMenu->clear();
}
});
} else if (popupWidget) { // Handle other popup widgets...
} else if (KisPopupWidgetInterface *popupWidget = inputManager()->toolProxy()->popupWidget()) { // Handle other popup widgets...
QPoint pos = eventPos(event);
if (pos.isNull()) {
......
/* This file is part of the KDE project
* SPDX-FileCopyrightText: 2012 Arjen Hiemstra <ahiemstra@heimr.nl>
* SPDX-FileCopyrightText: 2021 Emmet O 'Neill <emmetoneill.pdx@gmail.com>
* SPDX-FileCopyrightText: 2021 Eoin O 'Neill <eoinoneill1991@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KIS_POPUP_WIDGET_ACTION_H
......
......@@ -33,7 +33,7 @@
#include "kis_alternate_invocation_action.h"
#include "kis_rotate_canvas_action.h"
#include "kis_zoom_action.h"
#include "kis_show_palette_action.h"
#include "KisPopupWidgetAction.h"
#include "kis_change_primary_setting_action.h"
#include "kis_shortcut_matcher.h"
......@@ -343,9 +343,10 @@ bool KisInputManager::eventFilterImpl(QEvent * event)
//TEMP WORKAROUND TEMP WORKAROUND TEMP WORKAROUND//
QWidget* popup = dynamic_cast<QWidget*>(d->popupWidget);
// KisPopupWidgetInterface will need additional features to eliminate this.
//TEMP WORKAROUND TEMP WORKAROUND TEMP WORKAROUND//
if (popup) { //TEMP
if (popup) {
QEvent::Type type = event->type();
bool wasVisible = popup->isVisible();
......@@ -363,7 +364,7 @@ bool KisInputManager::eventFilterImpl(QEvent * event)
}
}
} //TEMP
}
}
......
......@@ -22,7 +22,7 @@
#include "kis_change_primary_setting_action.h"
#include "kis_pan_action.h"
#include "kis_rotate_canvas_action.h"
#include "kis_show_palette_action.h"
#include "KisPopupWidgetAction.h".h"
#include "kis_tool_invocation_action.h"
#include "kis_zoom_action.h"
#include "kis_shortcut_configuration.h"
......
......@@ -432,8 +432,7 @@ QList<QPointer<QWidget>> KarbonCalligraphyTool::createOptionWidgets()
KisPopupWidgetInterface *KarbonCalligraphyTool::popupWidget()
{
/**** HACK PROOF OF CONCEPT, DONT WORRY 'BOUT IT! ****/
return new KisPopupWidget(new KarbonCalligraphyOptionWidget(), canvas());
return nullptr;
}
void KarbonCalligraphyTool::setStrokeWidth(double width)
......
......@@ -49,7 +49,7 @@ private Q_SLOTS:
void setAngle(int angle); // set theangle in degrees
void setFixation(double fixation);
void setCaps(double caps);
void setMass(double mass); // set the mass in user friendly format
void setMass(double mass); // set the mass in user friendly format
void setDrag(double drag);
void updateSelectedPath();
......
Markdown is supported
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