Skip to content

Commit

Permalink
Show wait cursor while applying transform
Browse files Browse the repository at this point in the history
Since with many layers or very large transforms, that can take a while.
  • Loading branch information
askmeaboutlo0m committed Aug 7, 2024
1 parent a4e8896 commit 940c0f6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/desktop/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#include "libclient/utils/customshortcutmodel.h"
#include "libclient/utils/images.h"
#include "libclient/utils/logging.h"
#include "libclient/utils/scopedoverridecursor.h"
#include "libclient/utils/selectionalteration.h"
#include "libclient/utils/shortcutdetector.h"
#include "libshared/util/networkaccess.h"
Expand Down
15 changes: 0 additions & 15 deletions src/desktop/utils/widgetutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@

namespace utils {

ScopedOverrideCursor::ScopedOverrideCursor()
: ScopedOverrideCursor(QCursor(Qt::WaitCursor))
{
}

ScopedOverrideCursor::ScopedOverrideCursor(const QCursor &cursor)
{
QApplication::setOverrideCursor(cursor);
}

ScopedOverrideCursor::~ScopedOverrideCursor()
{
QApplication::restoreOverrideCursor();
}

ScopedUpdateDisabler::ScopedUpdateDisabler(QWidget *widget)
: m_widget{widget}
, m_wasEnabled{widget && widget->updatesEnabled()}
Expand Down
7 changes: 0 additions & 7 deletions src/desktop/utils/widgetutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ class QWidget;

namespace utils {

class ScopedOverrideCursor {
public:
ScopedOverrideCursor(); // Uses Qt::WaitCursor.
ScopedOverrideCursor(const QCursor &cursor);
~ScopedOverrideCursor();
};

class ScopedUpdateDisabler {
public:
ScopedUpdateDisabler(QWidget *widget);
Expand Down
1 change: 1 addition & 0 deletions src/libclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ target_sources(dpclient PRIVATE
utils/listservermodel.h
utils/logging.cpp
utils/logging.h
utils/scopedoverridecursor.h
utils/selectionalteration.cpp
utils/selectionalteration.h
utils/selectionoutlinegenerator.cpp
Expand Down
2 changes: 2 additions & 0 deletions src/libclient/canvas/transformmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extern "C" {
#include "libclient/canvas/selectionmodel.h"
#include "libclient/canvas/transformmodel.h"
#include "libclient/drawdance/image.h"
#include "libclient/utils/scopedoverridecursor.h"
#include <QPainter>

namespace canvas {
Expand Down Expand Up @@ -166,6 +167,7 @@ QVector<net::Message> TransformModel::applyActiveTransform(
bool stamp, bool *outMovedSelection)
{
if(m_active && m_dstQuadValid) {
utils::ScopedOverrideCursor waitCursor;
if(m_pasted) {
return applyFloating(
contextId, layerId, interpolation, compatibilityMode, stamp,
Expand Down
21 changes: 21 additions & 0 deletions src/libclient/utils/scopedoverridecursor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <QCursor>
#include <QGuiApplication>

namespace utils {

class ScopedOverrideCursor {
public:
ScopedOverrideCursor()
: ScopedOverrideCursor(QCursor(Qt::WaitCursor))
{
}

ScopedOverrideCursor(const QCursor &cursor)
{
QGuiApplication::setOverrideCursor(cursor);
}

~ScopedOverrideCursor() { QGuiApplication::restoreOverrideCursor(); }
};

}

0 comments on commit 940c0f6

Please sign in to comment.