mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-10-30 10:12:25 -04:00 
			
		
		
		
	Cleanup previous PR
This commit is contained in:
		
							parent
							
								
									09b95e2706
								
							
						
					
					
						commit
						0cac76f515
					
				| @ -654,9 +654,8 @@ class MTP_DEVICE(BASE): | |||||||
| 
 | 
 | ||||||
|         try: |         try: | ||||||
|             pref = self.get_pref('apnx') |             pref = self.get_pref('apnx') | ||||||
| 
 |  | ||||||
|             custom_page_count = 0 |             custom_page_count = 0 | ||||||
|             cust_col_name = pref.get('custom_column_page_count', None) |             cust_col_name = pref.get('custom_column_page_count') | ||||||
|             if cust_col_name: |             if cust_col_name: | ||||||
|                 try: |                 try: | ||||||
|                     custom_page_count = int(mi.get(cust_col_name, 0)) |                     custom_page_count = int(mi.get(cust_col_name, 0)) | ||||||
| @ -665,7 +664,7 @@ class MTP_DEVICE(BASE): | |||||||
| 
 | 
 | ||||||
|             method = pref.get('method', 'fast') |             method = pref.get('method', 'fast') | ||||||
| 
 | 
 | ||||||
|             cust_col_method = pref.get('custom_column_method', None) |             cust_col_method = pref.get('custom_column_method') | ||||||
|             if cust_col_method: |             if cust_col_method: | ||||||
|                 try: |                 try: | ||||||
|                     method = str(mi.get(cust_col_method)).lower() |                     method = str(mi.get(cust_col_method)).lower() | ||||||
| @ -686,9 +685,8 @@ class MTP_DEVICE(BASE): | |||||||
|                 apnx_path = parent.name, f'{name}.sdr', apnx_filename |                 apnx_path = parent.name, f'{name}.sdr', apnx_filename | ||||||
|                 sdr_parent = self.ensure_parent(storage, apnx_path) |                 sdr_parent = self.ensure_parent(storage, apnx_path) | ||||||
|                 self.put_file(sdr_parent, apnx_filename, apnx_stream, apnx_size) |                 self.put_file(sdr_parent, apnx_filename, apnx_stream, apnx_size) | ||||||
| 
 |  | ||||||
|         except Exception: |         except Exception: | ||||||
|             print('Failed to generate APNX') |             print('Failed to generate APNX', file=sys.stderr) | ||||||
|             import traceback |             import traceback | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|         finally: |         finally: | ||||||
|  | |||||||
| @ -9,6 +9,7 @@ import weakref | |||||||
| 
 | 
 | ||||||
| from qt.core import ( | from qt.core import ( | ||||||
|     QApplication, |     QApplication, | ||||||
|  |     QCheckBox, | ||||||
|     QComboBox, |     QComboBox, | ||||||
|     QDialog, |     QDialog, | ||||||
|     QDialogButtonBox, |     QDialogButtonBox, | ||||||
| @ -31,7 +32,6 @@ from qt.core import ( | |||||||
|     QVBoxLayout, |     QVBoxLayout, | ||||||
|     QWidget, |     QWidget, | ||||||
|     pyqtSignal, |     pyqtSignal, | ||||||
|     QCheckBox, |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| from calibre.ebooks import BOOK_EXTENSIONS | from calibre.ebooks import BOOK_EXTENSIONS | ||||||
| @ -352,7 +352,8 @@ class FormatRules(QGroupBox): | |||||||
|                     yield r |                     yield r | ||||||
| # }}} | # }}} | ||||||
| 
 | 
 | ||||||
| class APNX(QWidget): | 
 | ||||||
|  | class APNX(QWidget):  # {{{ | ||||||
|     def __init__(self, apnx): |     def __init__(self, apnx): | ||||||
|         QWidget.__init__(self) |         QWidget.__init__(self) | ||||||
|         self.layout = l = QVBoxLayout() |         self.layout = l = QVBoxLayout() | ||||||
| @ -361,42 +362,45 @@ class APNX(QWidget): | |||||||
|         self.layout.setAlignment(Qt.AlignTop) |         self.layout.setAlignment(Qt.AlignTop) | ||||||
| 
 | 
 | ||||||
|         self.send = f1 = QCheckBox(_('Send page number information when sending books')) |         self.send = f1 = QCheckBox(_('Send page number information when sending books')) | ||||||
|         f1.setChecked(apnx.get('send', False)) |         f1.setChecked(bool(apnx.get('send'))) | ||||||
|         l.addWidget(f1) |         l.addWidget(f1) | ||||||
| 
 | 
 | ||||||
|         label2 = QLabel('<p>' + _('Page count calculation method') + '</p>') |         label2 = QLabel('<p>' + _('Page count calculation method') + '</p>') | ||||||
|         label2.setWordWrap(True) |         label2.setWordWrap(True) | ||||||
|         l.addWidget(label2) |         l.addWidget(label2) | ||||||
|         self.method = f2 = QComboBox(self) |         self.method = f2 = QComboBox(self) | ||||||
|         f2.addItem('fast', 'fast') |         f2.addItem(_('fast'), 'fast') | ||||||
|         f2.addItem('accurate', 'accurate') |         f2.addItem(_('accurate'), 'accurate') | ||||||
|         f2.addItem('pagebrek', 'pagebreak') |         f2.addItem(_('pagebreak'), 'pagebreak') | ||||||
|         f2.setCurrentIndex(f2.findText(apnx.get('method', 'fast'))) |         if (idx := f2.findData(apnx.get('method') or 'fast')) > -1: | ||||||
|  |             f2.setCurrentIndex(idx) | ||||||
|         l.addWidget(f2) |         l.addWidget(f2) | ||||||
| 
 | 
 | ||||||
|         label3 = QLabel('<p>' + _('Custom column name to retrieve page counts from') + '</p>') |         label3 = QLabel('<p>' + _('Custom column name to retrieve page counts from') + '</p>') | ||||||
|         label3.setWordWrap(True) |         label3.setWordWrap(True) | ||||||
|         l.addWidget(label3) |         l.addWidget(label3) | ||||||
|         self.column_page_count = f3 = QLineEdit(self) |         self.column_page_count = f3 = QLineEdit(self) | ||||||
|         f3.setText(apnx.get('custom_column_page_count', '')) |         f3.setText(apnx.get('custom_column_page_count') or '') | ||||||
|         l.addWidget(f3) |         l.addWidget(f3) | ||||||
| 
 | 
 | ||||||
|         label4 = QLabel('<p>' + _('Custom column name to retrieve calculation method from') + '</p>') |         label4 = QLabel('<p>' + _('Custom column name to retrieve calculation method from') + '</p>') | ||||||
|         label4.setWordWrap(True) |         label4.setWordWrap(True) | ||||||
|         l.addWidget(label4) |         l.addWidget(label4) | ||||||
|         self.column_method = f4 = QLineEdit(self) |         self.column_method = f4 = QLineEdit(self) | ||||||
|         f4.setText(apnx.get('custom_column_method', '')) |         f4.setText(apnx.get('custom_column_method') or '') | ||||||
|         l.addWidget(f4) |         l.addWidget(f4) | ||||||
| 
 | 
 | ||||||
|     @property |     @property | ||||||
|     def apnx(self): |     def apnx(self): | ||||||
|         result = { |         result = { | ||||||
|             'send': self.send.isChecked(), |             'send': bool(self.send.isChecked()), | ||||||
|             'method': str(self.method.currentData()).strip(), |             'method': str(self.method.currentData()).strip(), | ||||||
|             'custom_column_page_count': str(self.column_page_count.text()).strip(), |             'custom_column_page_count': str(self.column_page_count.text()).strip(), | ||||||
|             'custom_column_method': str(self.column_method.text()).strip(), |             'custom_column_method': str(self.column_method.text()).strip(), | ||||||
|         } |         } | ||||||
|         return result |         return result | ||||||
|  | # }}} | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| class MTPConfig(QTabWidget): | class MTPConfig(QTabWidget): | ||||||
| 
 | 
 | ||||||
| @ -467,9 +471,9 @@ class MTPConfig(QTabWidget): | |||||||
|             l.addWidget(r, 7, 0, 1, 2) |             l.addWidget(r, 7, 0, 1, 2) | ||||||
|             l.setRowStretch(7, 100) |             l.setRowStretch(7, 100) | ||||||
| 
 | 
 | ||||||
|             if self.device.is_kindle: |             if device.is_kindle: | ||||||
|               self.apnxTab = APNX(self.get_pref('apnx')) |                 self.apnx_tab = APNX(self.get_pref('apnx') or {}) | ||||||
|               self.addTab(self.apnxTab, _('Page numbering (APNX)')) |                 self.addTab(self.apnx_tab, _('Page numbering (APNX)')) | ||||||
| 
 | 
 | ||||||
|         self.igntab = IgnoredDevices(self.device.prefs['history'], |         self.igntab = IgnoredDevices(self.device.prefs['history'], | ||||||
|                 self.device.prefs['blacklist']) |                 self.device.prefs['blacklist']) | ||||||
| @ -560,7 +564,8 @@ class MTPConfig(QTabWidget): | |||||||
|                 p['ignored_folders'] = self.current_ignored_folders |                 p['ignored_folders'] = self.current_ignored_folders | ||||||
| 
 | 
 | ||||||
|             p.pop('apnx', None) |             p.pop('apnx', None) | ||||||
|             p['apnx'] = self.apnxTab.apnx |             if hasattr(self, 'apnx_tab'): | ||||||
|  |                 p['apnx'] = self.apnx_tab.apnx | ||||||
| 
 | 
 | ||||||
|             if self.current_device_key is not None: |             if self.current_device_key is not None: | ||||||
|                 self.device.prefs[self.current_device_key] = p |                 self.device.prefs[self.current_device_key] = p | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user