8000 Copy last selection instead of the previous selection by blueaxis · Pull Request #55 · blueaxis/Poricom · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Copy last selection instead of the previous selection #55

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

Merged
merged 1 commit into from
May 27, 2023
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
8000
Diff view
7 changes: 5 additions & 2 deletions app/components/views/ocr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
TEXT_LOGGING_DEFAULTS,
TEXT_LOGGING_TYPES,
)
from utils.scripts import logText, pixmapToText
from utils.scripts import copyToClipboard, logText, pixmapToText


class BaseOCRView(QGraphicsView, BaseSettings):
Expand Down Expand Up @@ -78,6 +78,7 @@ def handleTextResult(self, result):
def handleTextFinished(self):
try:
self.canvasText.adjustSize()
copyToClipboard(self.canvasText.text())
except RuntimeError:
pass
try:
Expand Down Expand Up @@ -111,7 +112,9 @@ def mouseMoveEvent(self, event):
def mouseReleaseEvent(self, event):
logPath = join(self.explorerPath, "text-log.txt")
tex 8000 t = self.canvasText.text()
logText(text, isLogFile=self.logToFile, path=logPath)
if self.logToFile:
logText(text, path=logPath)

try:
if not self.persistText:
self.canvasText.hide()
Expand Down
1 change: 1 addition & 0 deletions app/utils/scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""

from .combineTwoImages import combineTwoImages
from .copyToClipboard import copyToClipboard
from .editStylesheet import editStylesheet
from .logText import logText
from .mangaFileToImageDir import mangaFileToImageDir
Expand Down
28 changes: 28 additions & 0 deletions app/utils/scripts/copyToClipboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Poricom Helper Functions

Copyright (C) `2021-2022` `<Alarcon Ace Belen>`

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

from PyQt5.QtGui import QGuiApplication


def copyToClipboard(text: str):
"""
Copy input text to clipboard
"""
clipboard = QGuiApplication.clipboard()
clipboard.setText(text)
13 changes: 4 additions & 9 deletions app/utils/scripts/logText.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,12 @@
from PyQt5.QtGui import QGuiApplication


def logText(text: str, isLogFile: bool = False, path: str = "."):
"""Log text by copying to clipboard
def logText(text: str, path: str = "."):
"""Log by appending text to log file

Args:
text (str): Text to log.
isLogFile (bool, optional): Set flag to save copied text to clipboard. Defaults to False.
path (str, optional): Path to log file. Defaults to ".".
"""
clipboard = QGuiApplication.clipboard()
clipboard.setText(text)

if isLogFile:
with open(path, "a", encoding="utf-8") as fh:
fh.write(text + "\n")
with open(path, "a", encoding="utf-8") as fh:
fh.write(text + "\n")
0