Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: improve shortcut handling #1070

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/board/UBDrawingController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,16 @@ void UBDrawingController::setStylusTool(int tool)
}


bool UBDrawingController::isDrawingTool()
bool UBDrawingController::isDrawingTool(int tool)
{
return (stylusTool() == UBStylusTool::Pen)
|| (stylusTool() == UBStylusTool::Marker)
|| (stylusTool() == UBStylusTool::Line);
if (tool < 0)
{
tool = stylusTool();
}

return (tool == UBStylusTool::Pen)
|| (tool == UBStylusTool::Marker)
|| (tool == UBStylusTool::Line);
}


Expand Down
2 changes: 1 addition & 1 deletion src/board/UBDrawingController.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class UBDrawingController : public QObject
int stylusTool();
int latestDrawingTool();

bool isDrawingTool();
bool isDrawingTool(int tool = -1);

int currentToolWidthIndex();
qreal currentToolWidth();
Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ target_sources(${PROJECT_NAME} PRIVATE
UBSetting.h
UBSettings.cpp
UBSettings.h
UBShortcutManager.cpp
UBShortcutManager.h
UBTextTools.cpp
UBTextTools.h
)
14 changes: 12 additions & 2 deletions src/core/UBApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "UBPreferencesController.h"
#include "UBIdleTimer.h"
#include "UBApplicationController.h"
#include "UBShortcutManager.h"

#include "board/UBBoardController.h"
#include "board/UBDrawingController.h"
Expand Down Expand Up @@ -653,14 +654,14 @@ bool UBApplication::eventFilter(QObject *obj, QEvent *event)
}
}

if (event->type() == QEvent::TabletLeaveProximity)
else if (event->type() == QEvent::TabletLeaveProximity)
{
if (boardController && boardController->controlView())
boardController->controlView()->forcedTabletRelease();
}


if (event->type() == QEvent::ApplicationActivate)
else if (event->type() == QEvent::ApplicationActivate)
{
boardController->controlView()->setMultiselection(false);

Expand All @@ -678,6 +679,15 @@ bool UBApplication::eventFilter(QObject *obj, QEvent *event)
#endif
}

else if (event->type() == QEvent::KeyRelease)
{
// intercept key release events for shortcut handler
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);

return UBShortcutManager::shortcutManager()->handleKeyReleaseEvent(keyEvent)
|| result;
}

return result;
}

Expand Down
19 changes: 17 additions & 2 deletions src/core/UBSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,17 +540,32 @@ void UBSettings::save()
* We save the setting to the user settings if
* a) it is different from the (non-null) value stored in the user settings, or
* b) it doesn't currently exist in the user settings AND has changed from the app settings
* An invalid value indicates removal of the setting
*/
if (mUserSettings->contains(it.key())
&& it.value() != mUserSettings->value(it.key()))
{
mUserSettings->setValue(it.key(), it.value());
if (it.value().isValid())
{
mUserSettings->setValue(it.key(), it.value());
}
else
{
mUserSettings->remove(it.key());
}
}

else if (!mUserSettings->contains(it.key())
&& it.value() != mAppSettings->value(it.key()))
{
mUserSettings->setValue(it.key(), it.value());
if (it.value().isValid())
{
mUserSettings->setValue(it.key(), it.value());
}
else
{
mUserSettings->remove(it.key());
}
}

++it;
Expand Down
Loading