Skip to content

Commit

Permalink
Merge pull request #8 from Lafcadia/master
Browse files Browse the repository at this point in the history
Moved to PyCharm; Rewrote the GUI, Fixed a bug; Added a usage message
  • Loading branch information
lilingfengdev authored Jun 28, 2024
2 parents deee44a + 5f36dd0 commit 6d14d17
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 30 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,6 @@ testing/
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
*.stackdump
*.stackdump
/pse.dist
*.exe
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/PluginSearchEngine.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@

* 搜索关键词不应该包含插件,比如我想搜索优化插件,我应该输入`优化`而不是`优化插件`
* 搜索的时候千万不可以开启 VPN。
* 由于搜索工具底层是基于 Bing,所以可能会搜索出来一些无关于插件或者与关键词没有太大关联的东西。
* 由于搜索工具底层是基于 Bing所以可能会搜索出来一些无关于插件或者与关键词没有太大关联的东西。
* 输出顺序为公平起见会被打乱。

## GUI

GUI 版本目前主要由[氿月](https://github.com/Lafcadia)进行维护,支持原版的所有功能,并且同步更新。对于萌新相对较友好。
1 change: 1 addition & 0 deletions compile.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nuitka --onefile --windows-icon-from-ico=o.ico pse.py --windows-console-mode=disable --enable-plugin=pyside6
2 changes: 1 addition & 1 deletion core/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def search(keyword: str) -> List[SearchResult]:
for future in future_list:
for result in future.result():
results.append(result)
return result
return results
1 change: 1 addition & 0 deletions dev.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PYTHONPATH={workspaceFolder}/core:{workspaceFolder}/gui:${PYTHONPATH}
28 changes: 16 additions & 12 deletions gui/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from core.search import search
from PySide6.QtWidgets import QMainWindow, QApplication, QMessageBox, QTreeWidgetItem
from PySide6.QtCore import QObject, QThread, Signal, Slot
# from PySide6 import QtCore
from PySide6.QtCore import QObject, QThread, Signal
import sys
from ui import Ui_MainWindow
import pyperclip
Expand All @@ -12,12 +11,16 @@ class Worker(QObject):

def __init__(self):
super().__init__()
print("000")
# print("000")

def work(self, keyword):
print(111)
results = search(keyword)
self._signal.emit(results)
try:
results = search(keyword)
print("searching...")
self._signal.emit(results)
print("emitted signal _")
except Exception as e:
print(e)


class MainWindow(QMainWindow):
Expand All @@ -32,28 +35,29 @@ def __init__(self):
self.worker._signal.connect(self.shower)
self.worker.moveToThread(self.worker_thread)
self.a.connect(self.worker.work)
self.ui.searchButton.clicked.connect(self.search)
self.ui.outputTreeWidget.itemDoubleClicked.connect(self.copyUrl)
self.ui.searchButton.clicked.connect(self.searcher)
self.ui.outputTreeWidget.itemDoubleClicked.connect(self.copyurl)
self.worker_thread.start()

def search(self):
def searcher(self):
keyword = self.ui.searchLine.text()
self.ui.outputTreeWidget.clear()
self.a.emit(keyword)

def shower(self, results):
for result in results:
num = results.index(result)
title = QTreeWidgetItem(self.ui.outputTreeWidget, [result.title, result.url, result.summary])

def copyUrl(self, item):
def copyurl(self, item):
# copy a text to the clipboard.
pyperclip.copy(item.text(1))
QMessageBox.information(self, "Copied!", "已将该插件链接复制到剪贴板。")
QMessageBox.information(self, "Copied!", "Copied the link to the clipboard!")


if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
QMessageBox.information(window, "Usage", """1. Enter a keyword in the search box and click the search button.
2. Double click on the link to copy it to the clipboard.""")
window.show()
sys.exit(app.exec())
27 changes: 14 additions & 13 deletions gui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,19 @@
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QAction, QBrush, QColor, QConicalGradient,
QCursor, QFont, QFontDatabase, QGradient,
QIcon, QImage, QKeySequence, QLinearGradient,
QPainter, QPalette, QPixmap, QRadialGradient,
QTransform)
from PySide6.QtWidgets import (QAbstractScrollArea, QApplication, QFrame, QGridLayout,
QGroupBox, QHBoxLayout, QHeaderView, QLineEdit,
QMainWindow, QPushButton, QSizePolicy, QTreeWidget,
QTreeWidgetItem, QVBoxLayout, QWidget)
from PySide6.QtCore import (QCoreApplication, QMetaObject, QSize, Qt)
from PySide6.QtGui import (QAction, QFont, QIcon)
from PySide6.QtWidgets import (QAbstractScrollArea, QFrame, QGridLayout,
QGroupBox, QHBoxLayout, QLineEdit, QProgressBar, QPushButton, QSizePolicy,
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget)

class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(779, 594)
icon = QIcon()
icon.addFile(u"icons/icon.png", QSize(), QIcon.Normal, QIcon.Off)
icon.addFile(u"o.ico", QSize(), QIcon.Normal, QIcon.Off)
MainWindow.setWindowIcon(icon)
MainWindow.setStyleSheet(u"QTreeView {\n"
" border:none\n"
Expand Down Expand Up @@ -104,6 +97,13 @@ def setupUi(self, MainWindow):

self.verticalLayout.addLayout(self.gridLayout)

self.progressBar = QProgressBar(self.groupBox)
self.progressBar.setObjectName(u"progressBar")
self.progressBar.setMaximum(100)
self.progressBar.setValue(0)

self.verticalLayout.addWidget(self.progressBar)


self.horizontalLayout.addWidget(self.groupBox)

Expand Down Expand Up @@ -183,6 +183,7 @@ def retranslateUi(self, MainWindow):
self.groupBox.setTitle("")
self.searchButton.setText(QCoreApplication.translate("MainWindow", u"\u641c\u7d22", None))
self.searchLine.setPlaceholderText(QCoreApplication.translate("MainWindow", u"\u8bf7\u8f93\u5165\u4f60\u60f3\u67e5\u8be2\u7684\u63d2\u4ef6", None))
self.progressBar.setFormat(QCoreApplication.translate("MainWindow", u" \u672a\u5f00\u59cb", None))
___qtreewidgetitem = self.outputTreeWidget.headerItem()
___qtreewidgetitem.setText(2, QCoreApplication.translate("MainWindow", u"\u7b80\u4ecb", None));
___qtreewidgetitem.setText(1, QCoreApplication.translate("MainWindow", u"URL", None));
Expand Down
15 changes: 14 additions & 1 deletion gui/ui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</property>
<property name="windowIcon">
<iconset>
<normaloff>icons/icon.png</normaloff>icons/icon.png</iconset>
<normaloff>o.ico</normaloff>o.ico</iconset>
</property>
<property name="styleSheet">
<string notr="true">QTreeView {
Expand Down Expand Up @@ -106,6 +106,19 @@
</item>
</layout>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="format">
<string> 未开始</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
Binary file added pse.exe
Binary file not shown.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ cn_bing_translator
pyperclip~=1.9.0
colorama~=0.4.6
requests~=2.32.3
lxml~=5.2.2
lxml~=5.2.2
PySide6

0 comments on commit 6d14d17

Please sign in to comment.