Skip to content

Commit

Permalink
Add about page
Browse files Browse the repository at this point in the history
  • Loading branch information
howie6879 committed Jun 7, 2018
1 parent ea1e7d3 commit 640c83f
Show file tree
Hide file tree
Showing 21 changed files with 1,947 additions and 169 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,27 @@ ps:在看QT,同样是练手项目~
#### 特性

- 小说监控
- 小说检索
- 最新章节搜索阅读


#### 截图

![demo01](./docs/images/demo01.jpg)
**主界面**

![home](./docs/images/home.jpg)

**搜索**

![search](./docs/images/search.jpg)

**托盘**

![sys_tray](./docs/images/sys_tray.jpg)

**关于**

![about](./docs/images/about.jpg)

### 协议

Expand Down
Binary file added docs/images/about.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/demo01.jpg
Binary file not shown.
Binary file added docs/images/home.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/search.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/sys_tray.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions owllook_gui/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Config:
APP_TITLE = 'owllook 小说监控'
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
LOGGER = logging.getLogger()
VERSION = 0.1

# Engine config
URL_PHONE = 'https://m.baidu.com/s'
Expand Down
1,648 changes: 1,612 additions & 36 deletions owllook_gui/owl_resource.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions owllook_gui/owl_resource.qrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource prefix="/resource">
<file alias="images/clean.png">./resource/images/clean.png</file>
<file alias="images/lcxs.jpg">./resource/images/lcxs.jpg</file>
<file alias="images/owl.png">./resource/images/owl.png</file>
<file alias="qss/about.qss.css">./resource/qss/about.qss.css</file>
<file alias="qss/main.qss.css">./resource/qss/main.qss.css</file>
<file alias="qss/search.qss.css">./resource/qss/search.qss.css</file>
</qresource>
</RCC>
Binary file added owllook_gui/resource/images/clean.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added owllook_gui/resource/images/lcxs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions owllook_gui/resource/qss/about.qss.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
QWidget#about {
background-color: #39668b;
}

QLabel {
color: #fff;
}
35 changes: 20 additions & 15 deletions owllook_gui/resource/qss/main.qss.css
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
QWidget {
background-color: #222222;
}
/*QWidget#home {*/
/*background-color: #222222;*/
/*}*/

QLabel {
background-color: #222222;
color: #fff;
}

QLabel.lbl3 {
font-size: 20px;
}

QLineEdit {
background-color: aliceblue;
color: #618b38;
font-weight: bold;
color: #474747;
}

QPushButton {
Expand All @@ -23,4 +12,20 @@ QPushButton {
border-radius: 5px;
border-style: none;
height: 25px;
font-size: 14px;
}

QTableView, QTableWidget {
selection-background-color: #dbdada;
font-size: 12px;
background-color: white;
border: 1px solid #E0DDDC;
gridline-color: lightgray;
}

QHeaderView::section {
background-color: white;
border: 0px solid #E0DDDC;
border-bottom: 1px solid #E0DDDC;
height: 20px;
}
23 changes: 23 additions & 0 deletions owllook_gui/resource/qss/search.qss.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
QLineEdit#line_novels_name {
border: 1px solid #AFB5BB;
border-radius: 5px;
height: 25px;
line-height: 25px;
font-size: 10px;
background: transparent;
}

QPushButton#btn_search {
background-color: #39668b;
color: #ffffff;
border-radius: 5px;
border-style: none;
width: 45px;
height: 25px;
font-size: 12px;
}

/*QLineEdit#line_novels_name:focus {*/
/*border: none;*/
/*outline: medium;*/
/*}*/
80 changes: 0 additions & 80 deletions owllook_gui/utils/tools.py

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion owllook_gui/wigdets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"""
Created by howie.hu at 2018/5/23.
"""
from .about import About
from .search import Search
from .system_tray import SystemTray
from .wigdets_tools import load_style_sheet
from .wigdets_tools import load_style_sheet, table_widget_item_center
59 changes: 59 additions & 0 deletions owllook_gui/wigdets/about.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python
"""
Created by howie.hu at 2018/6/6.
"""

from PyQt5 import QtWidgets, QtGui

from owllook_gui.config import Config
from owllook_gui.owl_resource import *

from owllook_gui.wigdets.wigdets_tools import load_style_sheet


class About(QtWidgets.QWidget):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.init_ui()

def init_ui(self):
# 加载样式
load_style_sheet(self, 'about')

self.setWindowTitle("关于")
self.setObjectName('about')
self.name_label = QtWidgets.QLabel("版本:owllook - v{}".format(Config.VERSION))
self.img_label = QtWidgets.QLabel()
self.img_label.setPixmap(QtGui.QPixmap(":/resource/images/lcxs.jpg"))
self.img_label.setAlignment(QtCore.Qt.AlignCenter)
self.author_label = QtWidgets.QLabel(
"作者:<a style='color:#78a5f1;' href='https://github.com/howie6879'>howie6879</a>")
self.author_label.setOpenExternalLinks(True)
self.home_label = QtWidgets.QLabel(
"项目地址:<a style='color:#78a5f1;' href='https://github.com/howie6879/owllook_gui'>owllook_gui</a>")
self.home_label.setOpenExternalLinks(True)
self.dept_label = QtWidgets.QLabel("简介:简洁优雅的小说监控工具 🎉,喜欢就微信扫一扫一起交流吧")
self.dept_label.setWordWrap(True)

self.box = QtWidgets.QVBoxLayout()
self.box.addWidget(self.img_label)
self.box.addWidget(self.name_label)
self.box.addWidget(self.author_label)
self.box.addWidget(self.home_label)
self.box.addWidget(self.dept_label)

self.setLayout(self.box)
self.resize(300, 400)

def closeEvent(self, event):
self.hide()
event.ignore()


if __name__ == '__main__':
import sys

app = QtWidgets.QApplication(sys.argv)
win = About()
win.show()
sys.exit(app.exec_())
105 changes: 75 additions & 30 deletions owllook_gui/wigdets/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,91 +4,136 @@
"""
import asyncio

from PyQt5 import QtGui
from PyQt5.QtWidgets import QApplication, QDesktopWidget, QHBoxLayout, QLabel, QMainWindow, QPushButton, QVBoxLayout, \
QWidget
from PyQt5 import QtCore, QtGui, QtWidgets

from owllook_gui.owl_resource import *
from owllook_gui.config import Config
from owllook_gui.spider import get_novels_info

from owllook_gui.wigdets import load_style_sheet, SystemTray
from owllook_gui.wigdets import About, Search, SystemTray, table_widget_item_center, load_style_sheet

MAC = hasattr(QtGui, "qt_mac_set_native_menubar")


class OwlHome(QMainWindow):
class OwlHome(QtWidgets.QMainWindow):

def __init__(self, event_loop=None, parents=None):
super(OwlHome, self).__init__(parent=parents)
self.icon_path = ':/resource/images/owl.png'

self.system_tray_ins = SystemTray(icon_path=self.icon_path, parent=self)
self.event_loop = event_loop if event_loop else asyncio.get_event_loop()

self.system_tray_ins.show()
self.init_ui()

def init_ui(self):
# 加载样式
load_style_sheet('main')
load_style_sheet(self, 'main')
# 设置图标以及标题
self.setWindowTitle(Config.APP_TITLE)
self.setWindowIcon(QtGui.QIcon(self.icon_path))
# 布局
self.label = QLabel('书架暂无数据')
self.label.setFont(QtGui.QFont('SansSerif', 13))
self.label.setAlignment(QtCore.Qt.AlignCenter)

self.v_box = QVBoxLayout()
self.bookshelf = QtWidgets.QLabel('书架暂无数据')
self.bookshelf.setFont(QtGui.QFont('SansSerif', 13))
self.bookshelf.setAlignment(QtCore.Qt.AlignCenter)

all_data = ''

if all_data:
# 表格布局
self.table_widget = QtWidgets.QTableWidget()
self.table_widget.setColumnCount(3)
self.table_widget.setRowCount(1)
self.table_widget.setObjectName('books_table')
# 表格100%填满窗口
self.table_widget.horizontalHeader().setStretchLastSection(True)
self.table_widget.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
# 设置选中表格整行
self.table_widget.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
# 设置表格不可编辑
self.table_widget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
# 设置字体
self.table_widget.setFont(QtGui.QFont('SansSerif', 12))

self.table_widget.setHorizontalHeaderLabels(["小说名", "目录", "最新章节"])

# for index in range(self.table_widget.columnCount()):
# head_item = self.table_widget.horizontalHeaderItem(index)
# # 设置字体
# head_item.setFont(QtGui.QFont('SansSerif', 12, QtGui.QFont.Bold))
# head_item.setForeground(QtGui.QBrush(QtCore.Qt.gray))
# head_item.setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
self.table_widget.setItem(0, 0, table_widget_item_center('牧神记'))
self.table_widget.setItem(0, 1, table_widget_item_center("查看目录"))
self.table_widget.setItem(0, 2, table_widget_item_center("第100章:Hello World"))

self.middle_widget = self.table_widget
self.resize(420, 200)
else:
self.middle_widget = self.bookshelf
self.resize(300, 200)

self.v_box = QtWidgets.QVBoxLayout()
self.v_box.addStretch()
self.v_box.addWidget(self.label)
self.v_box.addWidget(self.middle_widget)
self.v_box.addStretch()

self.search_book = QPushButton("搜书")
self.refresh = QPushButton("刷新")
self.about = QPushButton("关于")
self.btn_search_book = QtWidgets.QPushButton("搜书")
self.btn_refresh = QtWidgets.QPushButton("刷新")
self.btn_about = QtWidgets.QPushButton("关于")

self.search_book.clicked.connect(self.func_search_book)
self.refresh.clicked.connect(self.func_refresh)
self.about.clicked.connect(self.func_about)
self.btn_search_book.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
self.btn_refresh.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
self.btn_about.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))

self.h_box = QHBoxLayout()
self.h_box.addWidget(self.search_book)
self.h_box.addWidget(self.refresh)
self.h_box.addWidget(self.about)
self.btn_search_book.clicked.connect(self.func_search)
self.btn_refresh.clicked.connect(self.func_refresh)
self.btn_about.clicked.connect(self.func_about)

self.h_box = QtWidgets.QHBoxLayout()
self.h_box.addWidget(self.btn_search_book)
self.h_box.addWidget(self.btn_refresh)
self.h_box.addWidget(self.btn_about)

self.v_box.addLayout(self.h_box)

main_frame = QWidget()
main_frame = QtWidgets.QWidget()
main_frame.setObjectName('home')
main_frame.setLayout(self.v_box)
self.setCentralWidget(main_frame)

self.resize(300, 200)
self.func_win_center()

def func_about(self):
self.about_ins = About()
self.about_ins.setWindowIcon(QtGui.QIcon(self.icon_path))
self.about_ins.show()

def func_check_version(self):
pass

def func_refresh(self):
self.event_loop.create_task(get_novels_info(class_name='so', novels_name='intitle:雪中悍刀行 小说 阅读'))

def func_search_book(self):
self.event_loop.create_task(get_novels_info(class_name='baidu', novels_name='intitle:雪中悍刀行 小说 阅读'))
def func_search(self):
self.search_ins = Search()
self.search_ins.setWindowIcon(QtGui.QIcon(self.icon_path))
self.search_ins.show()

def func_win_center(self):
screen = QDesktopWidget().screenGeometry()
screen = QtWidgets.QDesktopWidget().screenGeometry()
size = self.geometry()
self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)

def closeEvent(self, event):
self.hide()
self.system_tray_ins.show()
event.ignore()


if __name__ == '__main__':
import sys

app = QApplication(sys.argv)
app = QtWidgets.QApplication(sys.argv)
# 关闭所有窗口也不关闭应用程序
# QApplication.setQuitOnLastWindowClosed(False)
win = OwlHome()
Expand Down
Loading

0 comments on commit 640c83f

Please sign in to comment.