| 1 | /* |
| 2 | * Copyright (C) 2021 Damir Porobic <[email protected]> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | #include "Action.h" |
| 21 | |
| 22 | Action::Action() : |
| 23 | mIsCaptureEnabled(false), |
| 24 | mCaptureDelay(0), |
| 25 | mCaptureMode(CaptureModes::RectArea), |
| 26 | mIsPinImageEnabled(false), |
| 27 | mIsUploadEnabled(false), |
| 28 | mIsSaveEnabled(false), |
| 29 | mIsCopyToClipboardEnabled(false), |
| 30 | mIsOpenDirectoryEnabled(false), |
| 31 | mIncludeCursor(false), |
| 32 | mIsHideMainWindowEnabled(false), |
| 33 | mIsGlobalShortcut(false) |
| 34 | { |
| 35 | |
| 36 | } |
| 37 | |
| 38 | QString Action::name() const |
| 39 | { |
| 40 | return mName; |
| 41 | } |
| 42 | |
| 43 | void Action::setName(const QString &name) |
| 44 | { |
| 45 | mName = name; |
| 46 | } |
| 47 | |
| 48 | QKeySequence Action::shortcut() const |
| 49 | { |
| 50 | return mShortcut; |
| 51 | } |
| 52 | |
| 53 | void Action::setShortcut(const QKeySequence &keySequence) |
| 54 | { |
| 55 | mShortcut = keySequence; |
| 56 | } |
| 57 | |
| 58 | bool Action::isCaptureEnabled() const |
| 59 | { |
| 60 | return mIsCaptureEnabled; |
| 61 | } |
| 62 | |
| 63 | void Action::setIsCaptureEnabled(bool enabled) |
| 64 | { |
| 65 | mIsCaptureEnabled = enabled; |
| 66 | } |
| 67 | |
| 68 | int Action::captureDelay() const |
| 69 | { |
| 70 | return mCaptureDelay; |
| 71 | } |
| 72 | |
| 73 | void Action::setCaptureDelay(int delayInMs) |
| 74 | { |
| 75 | mCaptureDelay = delayInMs; |
| 76 | } |
| 77 | |
| 78 | bool Action::includeCursor() const |
| 79 | { |
| 80 | return mIncludeCursor; |
| 81 | } |
| 82 | |
| 83 | void Action::setIncludeCursor(bool enabled) |
| 84 | { |
| 85 | mIncludeCursor = enabled; |
| 86 | } |
| 87 | |
| 88 | CaptureModes Action::captureMode() const |
| 89 | { |
| 90 | return mCaptureMode; |
| 91 | } |
| 92 | |
| 93 | void Action::setCaptureMode(CaptureModes mode) |
| 94 | { |
| 95 | mCaptureMode = mode; |
| 96 | } |
| 97 | |
| 98 | bool Action::isPinImageEnabled() const |
| 99 | { |
| 100 | return mIsPinImageEnabled; |
| 101 | } |
| 102 | |
| 103 | void Action::setIsPinImageEnabled(bool enabled) |
| 104 | { |
| 105 | mIsPinImageEnabled = enabled; |
| 106 | } |
| 107 | |
| 108 | bool Action::isUploadEnabled() const |
| 109 | { |
| 110 | return mIsUploadEnabled; |
| 111 | } |
| 112 | |
| 113 | void Action::setIsUploadEnabled(bool enabled) |
| 114 | { |
| 115 | mIsUploadEnabled = enabled; |
| 116 | } |
| 117 | |
| 118 | bool Action::isSaveEnabled() const |
| 119 | { |
| 120 | return mIsSaveEnabled; |
| 121 | } |
| 122 | |
| 123 | void Action::setIsSaveEnabled(bool enabled) |
| 124 | { |
| 125 | mIsSaveEnabled = enabled; |
| 126 | } |
| 127 | |
| 128 | bool Action::isCopyToClipboardEnabled() const |
| 129 | { |
| 130 | return mIsCopyToClipboardEnabled; |
| 131 | } |
| 132 | |
| 133 | void Action::setIsCopyToClipboardEnabled(bool enabled) |
| 134 | { |
| 135 | mIsCopyToClipboardEnabled = enabled; |
| 136 | } |
| 137 | |
| 138 | bool Action::isOpenDirectoryEnabled() const |
| 139 | { |
| 140 | return mIsOpenDirectoryEnabled; |
| 141 | } |
| 142 | |
| 143 | void Action::setIsOpenDirectoryEnabled(bool enabled) |
| 144 | { |
| 145 | mIsOpenDirectoryEnabled = enabled; |
| 146 | } |
| 147 | |
| 148 | bool Action::isHideMainWindowEnabled() const |
| 149 | { |
| 150 | return mIsHideMainWindowEnabled; |
| 151 | } |
| 152 | |
| 153 | void Action::setIsHideMainWindowEnabled(bool enabled) |
| 154 | { |
| 155 | mIsHideMainWindowEnabled = enabled; |
| 156 | } |
| 157 | |
| 158 | bool Action::isGlobalShortcut() const |
| 159 | { |
| 160 | return mIsGlobalShortcut; |
| 161 | } |
| 162 | |
| 163 | void Action::setIsGlobalShortcut(bool isGlobal) |
| 164 | { |
| 165 | mIsGlobalShortcut = isGlobal; |
| 166 | } |
| 167 | |
| 168 | bool operator==(const Action &left, const Action &right) |
| 169 | { |
| 170 | return left.name() == right.name() |
| 171 | && left.shortcut() == right.shortcut() |
| 172 | && left.isGlobalShortcut() == right.isGlobalShortcut() |
| 173 | && left.isCaptureEnabled() == right.isCaptureEnabled() |
| 174 | && left.includeCursor() == right.includeCursor() |
| 175 | && left.captureDelay() == right.captureDelay() |
| 176 | && left.captureMode() == right.captureMode() |
| 177 | && left.isSaveEnabled() == right.isSaveEnabled() |
| 178 | && left.isCopyToClipboardEnabled() == right.isCopyToClipboardEnabled() |
| 179 | && left.isPinImageEnabled() == right.isPinImageEnabled() |
| 180 | && left.isOpenDirectoryEnabled() == right.isOpenDirectoryEnabled() |
| 181 | && left.isUploadEnabled() == right.isUploadEnabled() |
| 182 | && left.isHideMainWindowEnabled() == right.isHideMainWindowEnabled(); |
| 183 | } |