-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from Integration-Automation/dev
Dev
- Loading branch information
Showing
9 changed files
with
124 additions
and
9 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from PySide6.QtCore import Qt | ||
from PySide6.QtWebEngineCore import QWebEngineDownloadRequest | ||
from PySide6.QtWidgets import QWidget, QBoxLayout, QPlainTextEdit | ||
|
||
|
||
class BrowserDownloadWindow(QWidget): | ||
|
||
def __init__(self, download_instance: QWebEngineDownloadRequest): | ||
super().__init__() | ||
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) | ||
self.box_layout = QBoxLayout(QBoxLayout.Direction.TopToBottom) | ||
self.show_download_detail_plaintext = QPlainTextEdit() | ||
self.show_download_detail_plaintext.setReadOnly(True) | ||
self.setWindowTitle("Download") | ||
self.download_instance = download_instance | ||
self.download_instance.isFinishedChanged.connect(self.print_finish) | ||
self.download_instance.interruptReasonChanged.connect(self.print_interrupt) | ||
self.download_instance.stateChanged.connect(self.print_state) | ||
self.download_instance.accept() | ||
self.box_layout.addWidget(self.show_download_detail_plaintext) | ||
self.setLayout(self.box_layout) | ||
|
||
def print_finish(self): | ||
self.show_download_detail_plaintext.appendPlainText(str(self.download_instance.isFinished())) | ||
|
||
def print_interrupt(self): | ||
self.show_download_detail_plaintext.appendPlainText(str(self.download_instance.interruptReason())) | ||
|
||
def print_state(self): | ||
self.show_download_detail_plaintext.appendPlainText(str(self.download_instance.state())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from typing import List | ||
|
||
from PySide6.QtCore import Qt | ||
from PySide6.QtWebEngineCore import QWebEngineDownloadRequest | ||
from PySide6.QtWebEngineWidgets import QWebEngineView | ||
|
||
from .browser_download_window import BrowserDownloadWindow | ||
|
||
|
||
class BrowserView(QWebEngineView): | ||
|
||
def __init__(self, start_url: str = "https://www.google.com/"): | ||
super().__init__() | ||
self.setUrl(start_url) | ||
self.download_list: List[QWebEngineDownloadRequest] = list() | ||
self.download_window_list: List[BrowserDownloadWindow] = list() | ||
self.page().profile().downloadRequested.connect(self.download_file) | ||
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) | ||
|
||
def download_file(self, download_instance: QWebEngineDownloadRequest): | ||
self.download_list.append(download_instance) | ||
download_detail_window = BrowserDownloadWindow(download_instance) | ||
self.download_window_list.append(download_detail_window) | ||
download_detail_window.show() | ||
|
||
def closeEvent(self, event) -> None: | ||
for download_instance in self.download_list: | ||
download_instance.cancel() | ||
for download_window in self.download_window_list: | ||
download_window.close() | ||
super().closeEvent(event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from PySide6.QtGui import QAction, Qt | ||
from PySide6.QtWidgets import QWidget, QGridLayout, QPushButton, QInputDialog | ||
|
||
from .browser_view import BrowserView | ||
|
||
|
||
class JEBrowser(QWidget): | ||
|
||
def __init__(self, start_url: str = "https://www.bing.com/chat"): | ||
super().__init__() | ||
# Browser setting | ||
self.browser = BrowserView(start_url) | ||
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) | ||
# Action | ||
self.find_action = QAction() | ||
self.find_action.setShortcut("Ctrl+f") | ||
self.find_action.triggered.connect(self.find_text) | ||
self.addAction(self.find_action) | ||
# Layout | ||
self.grid_layout = QGridLayout() | ||
self.grid_layout.addWidget(self.browser, 0, 0, -1, -1) | ||
self.setLayout(self.grid_layout) | ||
|
||
def find_text(self): | ||
search_box = QInputDialog(self) | ||
search_text, press_ok = search_box.getText(self, "Find text", "Find text") | ||
if press_ok: | ||
self.browser.findText(search_text) | ||
else: | ||
self.browser.findText("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sys | ||
|
||
from PySide6.QtCore import QCoreApplication | ||
from PySide6.QtWidgets import QMainWindow, QApplication | ||
from qt_material import apply_stylesheet | ||
|
||
from GPT_EXE.browser.browser_widget import JEBrowser | ||
|
||
|
||
class JustOpenGPTBrowser(QMainWindow): | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.browser_widget = JEBrowser() | ||
self.setCentralWidget(self.browser_widget) | ||
|
||
|
||
if __name__ == "__main__": | ||
new_editor = QCoreApplication.instance() | ||
if new_editor is None: | ||
new_editor = QApplication(sys.argv) | ||
window = JustOpenGPTBrowser() | ||
apply_stylesheet(new_editor, theme='dark_amber.xml') | ||
window.showMaximized() | ||
sys.exit(new_editor.exec()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,6 @@ prompt_toolkit | |
requests | ||
rich | ||
re_edge_gpt | ||
regex | ||
regex | ||
PySide6 | ||
qt-material |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters