mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-22 19:02:17 +08:00
支持自定义选择导出聊天记录的日期
This commit is contained in:
parent
fe4e719012
commit
f418339e8d
@ -7,13 +7,15 @@ from PyQt5.QtWidgets import QApplication, QDialog, QCheckBox, QMessageBox, QCale
|
||||
|
||||
class CalendarDialog(QDialog):
|
||||
selected_date_signal = pyqtSignal(int)
|
||||
|
||||
def __init__(self, date_range=None, parent=None):
|
||||
"""
|
||||
|
||||
@param date_range: tuple[Union[QDate, datetime.date],Union[QDate, datetime.date]]
|
||||
@param date_range: tuple[Union[QDate, datetime.date],Union[QDate, datetime.date]] #限定的可选择范围
|
||||
@param parent:
|
||||
"""
|
||||
super().__init__(parent)
|
||||
self.setWindowTitle('选择日期')
|
||||
self.calendar = QCalendarWidget(self)
|
||||
self.calendar.clicked.connect(self.onDateChanged)
|
||||
if date_range:
|
||||
@ -36,6 +38,7 @@ class CalendarDialog(QDialog):
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
# 设置日期范围
|
||||
start_date = datetime(2023, 12, 11)
|
||||
|
@ -116,9 +116,11 @@ class ExportDialog(QDialog, Ui_Dialog):
|
||||
# "别急别急",
|
||||
# "马上就实现该功能"
|
||||
# )
|
||||
|
||||
def set_time_range(self, time_range):
|
||||
self.time_range = time_range
|
||||
self.comboBox_time.setCurrentIndex(2)
|
||||
|
||||
def export_data(self):
|
||||
self.btn_start.setEnabled(False)
|
||||
# 在这里获取用户选择的导出数据类型
|
||||
@ -141,7 +143,8 @@ class ExportDialog(QDialog, Ui_Dialog):
|
||||
select_contacts.append(self.contacts[i])
|
||||
# 在这里根据用户选择的数据类型执行导出操作
|
||||
print("选择的文件格式:", file_types)
|
||||
self.worker = Output(select_contacts, type_=Output.Batch, message_types=selected_types, sub_type=file_types,time_range=self.time_range)
|
||||
self.worker = Output(select_contacts, type_=Output.Batch, message_types=selected_types, sub_type=file_types,
|
||||
time_range=self.time_range)
|
||||
# self.worker.progressSignal.connect(self.update_progress)
|
||||
self.worker.okSignal.connect(self.export_finished)
|
||||
self.worker.rangeSignal.connect(self.set_total_msg_num)
|
||||
|
@ -11,18 +11,21 @@ QToolButton{
|
||||
color:#000000;
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
class TimeRangeDialog(QDialog, Ui_Dialog):
|
||||
date_range_signal = pyqtSignal(tuple)
|
||||
|
||||
def __init__(self, date_range=None, parent=None):
|
||||
"""
|
||||
|
||||
@param date_range: tuple[Union[QDate, datetime.date],Union[QDate, datetime.date]]
|
||||
@param date_range: tuple[Union[QDate, datetime.date],Union[QDate, datetime.date]] 限定的可选择范围
|
||||
@param parent:
|
||||
"""
|
||||
super().__init__(parent)
|
||||
self.calendar = None
|
||||
self.setupUi(self)
|
||||
self.setWindowTitle('选择日期范围')
|
||||
self.setStyleSheet(Stylesheet)
|
||||
self.toolButton_start_time.clicked.connect(self.select_date_start)
|
||||
self.toolButton_end_time.clicked.connect(self.select_date_end)
|
||||
@ -45,10 +48,12 @@ class TimeRangeDialog(QDialog, Ui_Dialog):
|
||||
str_start = date_object.strftime("%Y-%m-%d")
|
||||
self.end_timestamp = timestamp + 86399
|
||||
self.toolButton_end_time.setText(str_start)
|
||||
|
||||
def ok(self):
|
||||
date_range = (self.start_timestamp, self.end_timestamp)
|
||||
self.date_range_signal.emit(date_range)
|
||||
self.close()
|
||||
|
||||
def select_date_start(self):
|
||||
self.start_time_flag = True
|
||||
self.calendar.show()
|
||||
|
Loading…
Reference in New Issue
Block a user