-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
66 lines (49 loc) · 2.04 KB
/
app.py
File metadata and controls
66 lines (49 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QDesktopWidget
from PyQt5.QtCore import QRect
from main_gui import *
from search_ui import *
from config import *
from utils import resource_path
MAIN_WINDOW_WIDTH = 800
MAIN_WINDOW_HEIGHT = 600
SEARCH_WINDOW_WIDTH = 1200
SEARCH_WINDOW_HEIGHT = 860
def on_found(path, start_index):
if not search_window.isVisible():
return False
else:
with open(path, "r", encoding="UTF-8") as f:
search_window.ui.addCodeEditor(f.read(), start_index, path)
return True
def search():
global search_window, search_thread
if ui.textEdit.toPlainText() != "":
#MainWindow.showMinimized()
screen = QDesktopWidget().screenGeometry()
search_window = SearchWindow(MainWindow, "CodeSleuth", "images/icon.png", QRect(screen.width()//2-SEARCH_WINDOW_WIDTH//2, screen.height()//2-SEARCH_WINDOW_HEIGHT//2+20, SEARCH_WINDOW_WIDTH, SEARCH_WINDOW_HEIGHT))
search_window.show()
extension = ui.comboBox.currentText()
if extension == "any":
extension = None
elif extension == ".cpp":
extension = [extension, ".h", ".hpp"]
elif extension == ".c":
extension = [extension, ".h"]
else:
extension = [extension]
search_thread = SearchThread(Ui_MainWindow.search_paths, Ui_MainWindow.search_exeption_paths, ui.textEdit.toPlainText(), extension, get_search_limits())
search_thread.found_signal.connect(on_found)
search_thread.start()
def main():
global app, MainWindow, ui
app = QApplication(sys.argv)
MainWindow = QMainWindow()
ui = Ui_MainWindow()
screen = QDesktopWidget().screenGeometry()
ui.setupUi(MainWindow, "CodeSleuth", resource_path("icon.png"), QRect(screen.width()//2-MAIN_WINDOW_WIDTH//2, screen.height()//2-MAIN_WINDOW_HEIGHT//2, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT))
ui.pushButton.clicked.connect(search)
MainWindow.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()