ui bug fixes.
This commit is contained in:
		
							parent
							
								
									c02da14d01
								
							
						
					
					
						commit
						d9da91e156
					
				@ -17,14 +17,14 @@
 | 
				
			|||||||
# You should have received a copy of the GNU General Public License
 | 
					# You should have received a copy of the GNU General Public License
 | 
				
			||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
					# along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from PyQt4 import QtCore, QtGui
 | 
					from aqt.qt import *
 | 
				
			||||||
from ..context import APP_ICON
 | 
					from ..context import APP_ICON
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__all__ = ['Dialog', 'WIDGET_SIZE']
 | 
					__all__ = ['Dialog', 'WIDGET_SIZE']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Dialog(QtGui.QDialog):
 | 
					class Dialog(QDialog):
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
    Base used for all dialog windows.
 | 
					    Base used for all dialog windows.
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
@ -42,7 +42,7 @@ class Dialog(QtGui.QDialog):
 | 
				
			|||||||
        self.setModal(True)
 | 
					        self.setModal(True)
 | 
				
			||||||
        self.setWindowFlags(
 | 
					        self.setWindowFlags(
 | 
				
			||||||
            self.windowFlags() &
 | 
					            self.windowFlags() &
 | 
				
			||||||
            ~QtCore.Qt.WindowContextHelpButtonHint
 | 
					            ~Qt.WindowContextHelpButtonHint
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        self.setWindowIcon(APP_ICON)
 | 
					        self.setWindowIcon(APP_ICON)
 | 
				
			||||||
        self.setWindowTitle(
 | 
					        self.setWindowTitle(
 | 
				
			||||||
@ -58,7 +58,7 @@ class WidgetSize(object):
 | 
				
			|||||||
    dialog_width = 700 
 | 
					    dialog_width = 700 
 | 
				
			||||||
    dialog_height_margin = 120 
 | 
					    dialog_height_margin = 120 
 | 
				
			||||||
    map_min_height = 0
 | 
					    map_min_height = 0
 | 
				
			||||||
    map_max_height = 31
 | 
					    map_max_height = 32
 | 
				
			||||||
    map_fld_width = 100
 | 
					    map_fld_width = 100
 | 
				
			||||||
    map_dictname_width = 150
 | 
					    map_dictname_width = 150
 | 
				
			||||||
    map_dictfield_width = 160
 | 
					    map_dictfield_width = 160
 | 
				
			||||||
 | 
				
			|||||||
@ -18,8 +18,8 @@
 | 
				
			|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
					# along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import types
 | 
					import types
 | 
				
			||||||
from PyQt4 import QtGui
 | 
					 | 
				
			||||||
from aqt import mw
 | 
					from aqt import mw
 | 
				
			||||||
 | 
					from aqt.qt import *
 | 
				
			||||||
from aqt.utils import showInfo
 | 
					from aqt.utils import showInfo
 | 
				
			||||||
from .options import OptionsDialog
 | 
					from .options import OptionsDialog
 | 
				
			||||||
from .foldermanager import FoldersManageDialog
 | 
					from .foldermanager import FoldersManageDialog
 | 
				
			||||||
@ -48,7 +48,7 @@ def show_fm_dialog(browser = None):
 | 
				
			|||||||
    fm_dialog = FoldersManageDialog(parent, u'Dictionary Folder Manager')
 | 
					    fm_dialog = FoldersManageDialog(parent, u'Dictionary Folder Manager')
 | 
				
			||||||
    fm_dialog.activateWindow()
 | 
					    fm_dialog.activateWindow()
 | 
				
			||||||
    fm_dialog.raise_()
 | 
					    fm_dialog.raise_()
 | 
				
			||||||
    if fm_dialog.exec_() == QtGui.QDialog.Accepted:
 | 
					    if fm_dialog.exec_() == QDialog.Accepted:
 | 
				
			||||||
        # update local services
 | 
					        # update local services
 | 
				
			||||||
        service_manager.update_services()
 | 
					        service_manager.update_services()
 | 
				
			||||||
    # reshow options window
 | 
					    # reshow options window
 | 
				
			||||||
@ -62,11 +62,11 @@ def show_options(browser = None, model_id = -1, callback = None, *args, **kwargs
 | 
				
			|||||||
    opt_dialog = OptionsDialog(parent, u'Options', model_id)
 | 
					    opt_dialog = OptionsDialog(parent, u'Options', model_id)
 | 
				
			||||||
    opt_dialog.activateWindow()
 | 
					    opt_dialog.activateWindow()
 | 
				
			||||||
    opt_dialog.raise_()
 | 
					    opt_dialog.raise_()
 | 
				
			||||||
    if opt_dialog.exec_() == QtGui.QDialog.Accepted:
 | 
					    if opt_dialog.exec_() == QDialog.Accepted:
 | 
				
			||||||
        if isinstance(callback, types.FunctionType):
 | 
					        if isinstance(callback, types.FunctionType):
 | 
				
			||||||
            callback(*args, **kwargs)
 | 
					            callback(*args, **kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def show_about_dialog(parent):
 | 
					def show_about_dialog(parent):
 | 
				
			||||||
    '''open about dialog'''
 | 
					    '''open about dialog'''
 | 
				
			||||||
    QtGui.QMessageBox.about(parent, _('ABOUT'), Template.tmpl_about)
 | 
					    QMessageBox.about(parent, _('ABOUT'), Template.tmpl_about)
 | 
				
			||||||
 | 
				
			|||||||
@ -17,7 +17,7 @@
 | 
				
			|||||||
# You should have received a copy of the GNU General Public License
 | 
					# You should have received a copy of the GNU General Public License
 | 
				
			||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
					# along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from PyQt4 import QtCore, QtGui
 | 
					from aqt.qt import *
 | 
				
			||||||
from .base import Dialog, WIDGET_SIZE
 | 
					from .base import Dialog, WIDGET_SIZE
 | 
				
			||||||
from ..context import config
 | 
					from ..context import config
 | 
				
			||||||
from ..lang import _, _sl
 | 
					from ..lang import _, _sl
 | 
				
			||||||
@ -37,24 +37,24 @@ class FoldersManageDialog(Dialog):
 | 
				
			|||||||
        self.build()
 | 
					        self.build()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def build(self):
 | 
					    def build(self):
 | 
				
			||||||
        layout = QtGui.QVBoxLayout()
 | 
					        layout = QVBoxLayout()
 | 
				
			||||||
        btn_layout = QtGui.QHBoxLayout()
 | 
					        btn_layout = QHBoxLayout()
 | 
				
			||||||
        add_btn = QtGui.QPushButton("+")
 | 
					        add_btn = QPushButton("+")
 | 
				
			||||||
        remove_btn = QtGui.QPushButton("-")
 | 
					        remove_btn = QPushButton("-")
 | 
				
			||||||
        btn_layout.addWidget(add_btn)
 | 
					        btn_layout.addWidget(add_btn)
 | 
				
			||||||
        btn_layout.addWidget(remove_btn)
 | 
					        btn_layout.addWidget(remove_btn)
 | 
				
			||||||
        add_btn.clicked.connect(self.add_folder)
 | 
					        add_btn.clicked.connect(self.add_folder)
 | 
				
			||||||
        remove_btn.clicked.connect(self.remove_folder)
 | 
					        remove_btn.clicked.connect(self.remove_folder)
 | 
				
			||||||
        self.folders_lst = QtGui.QListWidget()
 | 
					        self.folders_lst = QListWidget()
 | 
				
			||||||
        self.folders_lst.addItems(config.dirs)
 | 
					        self.folders_lst.addItems(config.dirs)
 | 
				
			||||||
        self.chk_use_filename = QtGui.QCheckBox(_('CHECK_FILENAME_LABEL'))
 | 
					        self.chk_use_filename = QCheckBox(_('CHECK_FILENAME_LABEL'))
 | 
				
			||||||
        self.chk_export_media = QtGui.QCheckBox(_('EXPORT_MEDIA'))
 | 
					        self.chk_export_media = QCheckBox(_('EXPORT_MEDIA'))
 | 
				
			||||||
        self.chk_use_filename.setChecked(config.use_filename)
 | 
					        self.chk_use_filename.setChecked(config.use_filename)
 | 
				
			||||||
        self.chk_export_media.setChecked(config.export_media)
 | 
					        self.chk_export_media.setChecked(config.export_media)
 | 
				
			||||||
        chk_layout = QtGui.QHBoxLayout()
 | 
					        chk_layout = QHBoxLayout()
 | 
				
			||||||
        chk_layout.addWidget(self.chk_use_filename)
 | 
					        chk_layout.addWidget(self.chk_use_filename)
 | 
				
			||||||
        chk_layout.addWidget(self.chk_export_media)
 | 
					        chk_layout.addWidget(self.chk_export_media)
 | 
				
			||||||
        btnbox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok, QtCore.Qt.Horizontal, self)
 | 
					        btnbox = QDialogButtonBox(QDialogButtonBox.Ok, Qt.Horizontal, self)
 | 
				
			||||||
        btnbox.accepted.connect(self.accept)
 | 
					        btnbox.accepted.connect(self.accept)
 | 
				
			||||||
        layout.addLayout(btn_layout)
 | 
					        layout.addLayout(btn_layout)
 | 
				
			||||||
        layout.addWidget(self.folders_lst)
 | 
					        layout.addWidget(self.folders_lst)
 | 
				
			||||||
@ -63,11 +63,11 @@ class FoldersManageDialog(Dialog):
 | 
				
			|||||||
        self.setLayout(layout)
 | 
					        self.setLayout(layout)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def add_folder(self):
 | 
					    def add_folder(self):
 | 
				
			||||||
        dir_ = QtGui.QFileDialog.getExistingDirectory(
 | 
					        dir_ = QFileDialog.getExistingDirectory(
 | 
				
			||||||
            self,
 | 
					            self,
 | 
				
			||||||
            caption=u"Select Folder", 
 | 
					            caption=u"Select Folder", 
 | 
				
			||||||
            directory=config.last_folder, 
 | 
					            directory=config.last_folder, 
 | 
				
			||||||
            options=QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontResolveSymlinks
 | 
					            options=QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        if dir_:
 | 
					        if dir_:
 | 
				
			||||||
            self.folders_lst.addItem(dir_)
 | 
					            self.folders_lst.addItem(dir_)
 | 
				
			||||||
 | 
				
			|||||||
@ -17,11 +17,12 @@
 | 
				
			|||||||
# You should have received a copy of the GNU General Public License
 | 
					# You should have received a copy of the GNU General Public License
 | 
				
			||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
					# along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from PyQt4 import QtCore, QtGui
 | 
					 | 
				
			||||||
import anki
 | 
					import anki
 | 
				
			||||||
import aqt
 | 
					import aqt
 | 
				
			||||||
import aqt.models
 | 
					import aqt.models
 | 
				
			||||||
 | 
					import sip
 | 
				
			||||||
from aqt import mw
 | 
					from aqt import mw
 | 
				
			||||||
 | 
					from aqt.qt import *
 | 
				
			||||||
from aqt.studydeck import StudyDeck
 | 
					from aqt.studydeck import StudyDeck
 | 
				
			||||||
from .base import Dialog, WIDGET_SIZE
 | 
					from .base import Dialog, WIDGET_SIZE
 | 
				
			||||||
from .setting import SettingDialog
 | 
					from .setting import SettingDialog
 | 
				
			||||||
@ -45,15 +46,16 @@ class OptionsDialog(Dialog):
 | 
				
			|||||||
        'begore_build',
 | 
					        'begore_build',
 | 
				
			||||||
        'after_build'
 | 
					        'after_build'
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 | 
					    _signal = pyqtSignal(str)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, parent, title=u'Options', model_id = -1):
 | 
					    def __init__(self, parent, title=u'Options', model_id = -1):
 | 
				
			||||||
        super(OptionsDialog, self).__init__(parent, title)
 | 
					        super(OptionsDialog, self).__init__(parent, title)
 | 
				
			||||||
        self.connect(self, QtCore.SIGNAL('before_build'), self._before_build, QtCore.Qt.QueuedConnection)
 | 
					        self._signal.connect(self._before_build)
 | 
				
			||||||
        self.connect(self, QtCore.SIGNAL('after_build'), self._after_build, QtCore.Qt.QueuedConnection)
 | 
					        self._signal.connect(self._after_build)
 | 
				
			||||||
        # initlizing info
 | 
					        # initlizing info
 | 
				
			||||||
        self.main_layout = QtGui.QVBoxLayout()
 | 
					        self.main_layout = QVBoxLayout()
 | 
				
			||||||
        self.loading_label = QtGui.QLabel(_('INITLIZING_DICT'))
 | 
					        self.loading_label = QLabel(_('INITLIZING_DICT'))
 | 
				
			||||||
        self.main_layout.addWidget(self.loading_label, 0, QtCore.Qt.AlignCenter)
 | 
					        self.main_layout.addWidget(self.loading_label, 0, Qt.AlignCenter)
 | 
				
			||||||
        #self.loading_layout.addLayout(models_layout)
 | 
					        #self.loading_layout.addLayout(models_layout)
 | 
				
			||||||
        self.setLayout(self.main_layout)
 | 
					        self.setLayout(self.main_layout)
 | 
				
			||||||
        #initlize properties
 | 
					        #initlize properties
 | 
				
			||||||
@ -63,53 +65,60 @@ class OptionsDialog(Dialog):
 | 
				
			|||||||
        self.current_model = None
 | 
					        self.current_model = None
 | 
				
			||||||
        # size and signal
 | 
					        # size and signal
 | 
				
			||||||
        self.resize(WIDGET_SIZE.dialog_width, 4 * WIDGET_SIZE.map_max_height + WIDGET_SIZE.dialog_height_margin)
 | 
					        self.resize(WIDGET_SIZE.dialog_width, 4 * WIDGET_SIZE.map_max_height + WIDGET_SIZE.dialog_height_margin)
 | 
				
			||||||
        self.emit(QtCore.SIGNAL('before_build'))
 | 
					        self._signal.emit('before_build')
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def _before_build(self):
 | 
					    def _before_build(self, s):
 | 
				
			||||||
 | 
					        if s != 'before_build':
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
        for cls in service_manager.services:
 | 
					        for cls in service_manager.services:
 | 
				
			||||||
            service = service_pool.get(cls.__unique__)
 | 
					            service = service_pool.get(cls.__unique__)
 | 
				
			||||||
            if service:
 | 
					            if service:
 | 
				
			||||||
                service_pool.put(service)
 | 
					                service_pool.put(service)
 | 
				
			||||||
        self.emit(QtCore.SIGNAL('after_build'))
 | 
					        self._signal.emit('after_build')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _after_build(self):
 | 
					    def _after_build(self, s):
 | 
				
			||||||
        self.main_layout.removeWidget(self.loading_label)
 | 
					        if s != 'after_build':
 | 
				
			||||||
        models_layout = QtGui.QHBoxLayout()
 | 
					            return
 | 
				
			||||||
 | 
					        if self.loading_label:
 | 
				
			||||||
 | 
					            self.main_layout.removeWidget(self.loading_label)
 | 
				
			||||||
 | 
					            sip.delete(self.loading_label)
 | 
				
			||||||
 | 
					            self.loading_label = None
 | 
				
			||||||
 | 
					        models_layout = QHBoxLayout()
 | 
				
			||||||
        # add buttons
 | 
					        # add buttons
 | 
				
			||||||
        mdx_button = QtGui.QPushButton(_('DICTS_FOLDERS'))
 | 
					        mdx_button = QPushButton(_('DICTS_FOLDERS'))
 | 
				
			||||||
        mdx_button.clicked.connect(self.show_fm_dialog)
 | 
					        mdx_button.clicked.connect(self.show_fm_dialog)
 | 
				
			||||||
        self.models_button = QtGui.QPushButton(_('CHOOSE_NOTE_TYPES'))
 | 
					        self.models_button = QPushButton(_('CHOOSE_NOTE_TYPES'))
 | 
				
			||||||
        self.models_button.clicked.connect(self.btn_models_pressed)
 | 
					        self.models_button.clicked.connect(self.btn_models_pressed)
 | 
				
			||||||
        models_layout.addWidget(mdx_button)
 | 
					        models_layout.addWidget(mdx_button)
 | 
				
			||||||
        models_layout.addWidget(self.models_button)
 | 
					        models_layout.addWidget(self.models_button)
 | 
				
			||||||
        self.main_layout.addLayout(models_layout)
 | 
					        self.main_layout.addLayout(models_layout)
 | 
				
			||||||
        # add dicts mapping
 | 
					        # add dicts mapping
 | 
				
			||||||
        dicts_widget = QtGui.QWidget()
 | 
					        dicts_widget = QWidget()
 | 
				
			||||||
        self.dicts_layout = QtGui.QGridLayout()
 | 
					        self.dicts_layout = QGridLayout()
 | 
				
			||||||
        self.dicts_layout.setSizeConstraint(QtGui.QLayout.SetMinAndMaxSize)
 | 
					        self.dicts_layout.setSizeConstraint(QLayout.SetMinAndMaxSize)
 | 
				
			||||||
        dicts_widget.setLayout(self.dicts_layout)
 | 
					        dicts_widget.setLayout(self.dicts_layout)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        scroll_area = QtGui.QScrollArea()
 | 
					        scroll_area = QScrollArea()
 | 
				
			||||||
        scroll_area.setWidgetResizable(True)
 | 
					        scroll_area.setWidgetResizable(True)
 | 
				
			||||||
        scroll_area.setWidget(dicts_widget)
 | 
					        scroll_area.setWidget(dicts_widget)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.main_layout.addWidget(scroll_area)
 | 
					        self.main_layout.addWidget(scroll_area)
 | 
				
			||||||
        # add description of radio buttons AND ok button
 | 
					        # add description of radio buttons AND ok button
 | 
				
			||||||
        bottom_layout = QtGui.QHBoxLayout()
 | 
					        bottom_layout = QHBoxLayout()
 | 
				
			||||||
        paras_btn = QtGui.QPushButton(_('SETTINGS'))
 | 
					        paras_btn = QPushButton(_('SETTINGS'))
 | 
				
			||||||
        paras_btn.clicked.connect(self.show_paras)
 | 
					        paras_btn.clicked.connect(self.show_paras)
 | 
				
			||||||
        about_btn = QtGui.QPushButton(_('ABOUT'))
 | 
					        about_btn = QPushButton(_('ABOUT'))
 | 
				
			||||||
        about_btn.clicked.connect(self.show_about)
 | 
					        about_btn.clicked.connect(self.show_about)
 | 
				
			||||||
        # about_btn.clicked.connect(self.show_paras)
 | 
					        # about_btn.clicked.connect(self.show_paras)
 | 
				
			||||||
        chk_update_btn = QtGui.QPushButton(_('UPDATE'))
 | 
					        chk_update_btn = QPushButton(_('UPDATE'))
 | 
				
			||||||
        chk_update_btn.clicked.connect(self.check_updates)
 | 
					        chk_update_btn.clicked.connect(self.check_updates)
 | 
				
			||||||
        home_label = QtGui.QLabel(
 | 
					        home_label = QLabel(
 | 
				
			||||||
            '<a href="{url}">User Guide</a>'.format(url=Endpoint.user_guide))
 | 
					            '<a href="{url}">User Guide</a>'.format(url=Endpoint.user_guide))
 | 
				
			||||||
        home_label.setOpenExternalLinks(True)
 | 
					        home_label.setOpenExternalLinks(True)
 | 
				
			||||||
        # shop_label = QLabel(
 | 
					        # shop_label = QLabel(
 | 
				
			||||||
        #     '<a href="{url}">Service Shop</a>'.format(url=Endpoint.service_shop))
 | 
					        #     '<a href="{url}">Service Shop</a>'.format(url=Endpoint.service_shop))
 | 
				
			||||||
        # shop_label.setOpenExternalLinks(True)
 | 
					        # shop_label.setOpenExternalLinks(True)
 | 
				
			||||||
        btnbox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok, QtCore.Qt.Horizontal, self)
 | 
					        btnbox = QDialogButtonBox(QDialogButtonBox.Ok, Qt.Horizontal, self)
 | 
				
			||||||
        btnbox.accepted.connect(self.accept)
 | 
					        btnbox.accepted.connect(self.accept)
 | 
				
			||||||
        bottom_layout.addWidget(paras_btn)
 | 
					        bottom_layout.addWidget(paras_btn)
 | 
				
			||||||
        bottom_layout.addWidget(chk_update_btn)
 | 
					        bottom_layout.addWidget(chk_update_btn)
 | 
				
			||||||
@ -183,12 +192,12 @@ class OptionsDialog(Dialog):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        labels = ['', '', 'DICTS', 'DICT_FIELDS', '']
 | 
					        labels = ['', '', 'DICTS', 'DICT_FIELDS', '']
 | 
				
			||||||
        for i, s in enumerate(labels):
 | 
					        for i, s in enumerate(labels):
 | 
				
			||||||
            label = QtGui.QLabel(_(s))
 | 
					            label = QLabel(_(s))
 | 
				
			||||||
            label.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
 | 
					            label.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
 | 
				
			||||||
            self.dicts_layout.addWidget(label, 0, i)
 | 
					            self.dicts_layout.addWidget(label, 0, i)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        maps = config.get_maps(model['id'])
 | 
					        maps = config.get_maps(model['id'])
 | 
				
			||||||
        self.radio_group = QtGui.QButtonGroup()
 | 
					        self.radio_group = QButtonGroup()
 | 
				
			||||||
        for i, fld in enumerate(model['flds']):
 | 
					        for i, fld in enumerate(model['flds']):
 | 
				
			||||||
            ord = fld['ord']
 | 
					            ord = fld['ord']
 | 
				
			||||||
            name = fld['name']
 | 
					            name = fld['name']
 | 
				
			||||||
@ -200,20 +209,22 @@ class OptionsDialog(Dialog):
 | 
				
			|||||||
                        self.add_dict_layout(j, **each)
 | 
					                        self.add_dict_layout(j, **each)
 | 
				
			||||||
                        break
 | 
					                        break
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    self.add_dict_layout(i, fld_name=name, fld_ord=ord)
 | 
					                    self.add_dict_layout(i, fld_name=name, fld_ord=ord, word_checked=i==0)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                self.add_dict_layout(i, fld_name=name, fld_ord=ord)
 | 
					                self.add_dict_layout(i, fld_name=name, fld_ord=ord, word_checked=i==0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #self.setLayout(self.main_layout)
 | 
					        #self.setLayout(self.main_layout)
 | 
				
			||||||
        self.resize(WIDGET_SIZE.dialog_width,
 | 
					        self.resize(
 | 
				
			||||||
                    max(3, (i + 1)) * WIDGET_SIZE.map_max_height + WIDGET_SIZE.dialog_height_margin)
 | 
					            WIDGET_SIZE.dialog_width,
 | 
				
			||||||
 | 
					            max(3, (i + 1)) * WIDGET_SIZE.map_max_height + WIDGET_SIZE.dialog_height_margin
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
        self.save()
 | 
					        self.save()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def show_models(self):
 | 
					    def show_models(self):
 | 
				
			||||||
        '''
 | 
					        '''
 | 
				
			||||||
        show choose note type window
 | 
					        show choose note type window
 | 
				
			||||||
        '''
 | 
					        '''
 | 
				
			||||||
        edit = QtGui.QPushButton(anki.lang._("Manage"),
 | 
					        edit = QPushButton(anki.lang._("Manage"),
 | 
				
			||||||
                           clicked=lambda: aqt.models.Models(mw, self))
 | 
					                           clicked=lambda: aqt.models.Models(mw, self))
 | 
				
			||||||
        ret = StudyDeck(mw, names=lambda: sorted(mw.col.models.allNames()),
 | 
					        ret = StudyDeck(mw, names=lambda: sorted(mw.col.models.allNames()),
 | 
				
			||||||
                        accept=anki.lang._("Choose"), title=anki.lang._("Choose Note Type"),
 | 
					                        accept=anki.lang._("Choose"), title=anki.lang._("Choose Note Type"),
 | 
				
			||||||
@ -276,7 +287,7 @@ class OptionsDialog(Dialog):
 | 
				
			|||||||
            text = dict_fld_name if dict_fld_name else 'http://'
 | 
					            text = dict_fld_name if dict_fld_name else 'http://'
 | 
				
			||||||
            field_combo.setEditable(True)
 | 
					            field_combo.setEditable(True)
 | 
				
			||||||
            field_combo.setEditText(text)
 | 
					            field_combo.setEditText(text)
 | 
				
			||||||
            field_combo.setFocus(QtCore.Qt.MouseFocusReason)  # MouseFocusReason
 | 
					            field_combo.setFocus(Qt.MouseFocusReason)  # MouseFocusReason
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            unique = dict_combo_itemdata
 | 
					            unique = dict_combo_itemdata
 | 
				
			||||||
            service = service_pool.get(unique)
 | 
					            service = service_pool.get(unique)
 | 
				
			||||||
@ -293,7 +304,7 @@ class OptionsDialog(Dialog):
 | 
				
			|||||||
        """
 | 
					        """
 | 
				
			||||||
        add dictionary fields row
 | 
					        add dictionary fields row
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        word_checked = i == 0
 | 
					        word_checked = kwargs.get('word_checked', False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        fld_name, fld_ord = (
 | 
					        fld_name, fld_ord = (
 | 
				
			||||||
            kwargs.get('fld_name', ''),                                 #笔记类型的字段名
 | 
					            kwargs.get('fld_name', ''),                                 #笔记类型的字段名
 | 
				
			||||||
@ -312,38 +323,38 @@ class OptionsDialog(Dialog):
 | 
				
			|||||||
            kwargs.get('skip_valued', True),                            #略过有值项标志
 | 
					            kwargs.get('skip_valued', True),                            #略过有值项标志
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        # check
 | 
					        # check
 | 
				
			||||||
        word_check_btn = QtGui.QRadioButton(fld_name)
 | 
					        word_check_btn = QRadioButton(fld_name)
 | 
				
			||||||
        word_check_btn.setMinimumSize(WIDGET_SIZE.map_fld_width, 0)
 | 
					        word_check_btn.setMinimumSize(WIDGET_SIZE.map_fld_width, 0)
 | 
				
			||||||
        word_check_btn.setMaximumSize(
 | 
					        word_check_btn.setMaximumSize(
 | 
				
			||||||
            WIDGET_SIZE.map_fld_width,
 | 
					            WIDGET_SIZE.map_fld_width,
 | 
				
			||||||
            WIDGET_SIZE.map_max_height
 | 
					            WIDGET_SIZE.map_max_height
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        word_check_btn.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
 | 
					        word_check_btn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
 | 
				
			||||||
        word_check_btn.setCheckable(True)
 | 
					        word_check_btn.setCheckable(True)
 | 
				
			||||||
        word_check_btn.setChecked(word_checked)
 | 
					        word_check_btn.setChecked(word_checked)
 | 
				
			||||||
        self.radio_group.addButton(word_check_btn)
 | 
					        self.radio_group.addButton(word_check_btn)
 | 
				
			||||||
        # dict combox
 | 
					        # dict combox
 | 
				
			||||||
        dict_combo = QtGui.QComboBox()
 | 
					        dict_combo = QComboBox()
 | 
				
			||||||
        dict_combo.setMinimumSize(WIDGET_SIZE.map_dictname_width, 0)
 | 
					        dict_combo.setMinimumSize(WIDGET_SIZE.map_dictname_width, 0)
 | 
				
			||||||
        dict_combo.setFocusPolicy(
 | 
					        dict_combo.setFocusPolicy(
 | 
				
			||||||
            QtCore.Qt.TabFocus | QtCore.Qt.ClickFocus | QtCore.Qt.StrongFocus | QtCore.Qt.WheelFocus
 | 
					            Qt.TabFocus | Qt.ClickFocus | Qt.StrongFocus | Qt.WheelFocus
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        dict_combo.setEnabled(not word_checked and not ignore)
 | 
					        dict_combo.setEnabled(not word_checked and not ignore)
 | 
				
			||||||
        self.fill_dict_combo_options(dict_combo, dict_unique)
 | 
					        self.fill_dict_combo_options(dict_combo, dict_unique)
 | 
				
			||||||
        dict_unique = dict_combo.itemData(dict_combo.currentIndex())
 | 
					        dict_unique = dict_combo.itemData(dict_combo.currentIndex())
 | 
				
			||||||
        # field combox
 | 
					        # field combox
 | 
				
			||||||
        field_combo = QtGui.QComboBox()
 | 
					        field_combo = QComboBox()
 | 
				
			||||||
        field_combo.setMinimumSize(WIDGET_SIZE.map_dictfield_width, 0)
 | 
					        field_combo.setMinimumSize(WIDGET_SIZE.map_dictfield_width, 0)
 | 
				
			||||||
        field_combo.setEnabled(not word_checked and not ignore)
 | 
					        field_combo.setEnabled(not word_checked and not ignore)
 | 
				
			||||||
        self.fill_field_combo_options(field_combo, dict_name, dict_unique, dict_fld_name, dict_fld_ord)
 | 
					        self.fill_field_combo_options(field_combo, dict_name, dict_unique, dict_fld_name, dict_fld_ord)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # ignore
 | 
					        # ignore
 | 
				
			||||||
        ignore_check_btn = QtGui.QCheckBox(_("NOT_DICT_FIELD"))
 | 
					        ignore_check_btn = QCheckBox(_("NOT_DICT_FIELD"))
 | 
				
			||||||
        ignore_check_btn.setEnabled(not word_checked)
 | 
					        ignore_check_btn.setEnabled(not word_checked)
 | 
				
			||||||
        ignore_check_btn.setChecked(ignore)
 | 
					        ignore_check_btn.setChecked(ignore)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Skip valued
 | 
					        # Skip valued
 | 
				
			||||||
        skip_check_btn = QtGui.QCheckBox(_("SKIP_VALUED"))
 | 
					        skip_check_btn = QCheckBox(_("SKIP_VALUED"))
 | 
				
			||||||
        skip_check_btn.setEnabled(not word_checked and not ignore)
 | 
					        skip_check_btn.setEnabled(not word_checked and not ignore)
 | 
				
			||||||
        skip_check_btn.setChecked(skip)
 | 
					        skip_check_btn.setChecked(skip)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -21,7 +21,7 @@
 | 
				
			|||||||
import time
 | 
					import time
 | 
				
			||||||
from collections import defaultdict
 | 
					from collections import defaultdict
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from PyQt4 import QtCore, QtGui
 | 
					from aqt.qt import *
 | 
				
			||||||
from ..lang import _
 | 
					from ..lang import _
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -44,7 +44,7 @@ class ProgressWindow(object):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def __init__(self, mw):
 | 
					    def __init__(self, mw):
 | 
				
			||||||
        self.mw = mw
 | 
					        self.mw = mw
 | 
				
			||||||
        self.app = QtGui.QApplication.instance()
 | 
					        self.app = QApplication.instance()
 | 
				
			||||||
        self._win = None
 | 
					        self._win = None
 | 
				
			||||||
        self._msg_count = defaultdict(int)
 | 
					        self._msg_count = defaultdict(int)
 | 
				
			||||||
        self._last_update = 0
 | 
					        self._last_update = 0
 | 
				
			||||||
@ -86,8 +86,8 @@ class ProgressWindow(object):
 | 
				
			|||||||
        # setup window
 | 
					        # setup window
 | 
				
			||||||
        label = label or _("Processing...")
 | 
					        label = label or _("Processing...")
 | 
				
			||||||
        parent = parent or self.app.activeWindow() or self.mw
 | 
					        parent = parent or self.app.activeWindow() or self.mw
 | 
				
			||||||
        self._win = QtGui.QProgressDialog(label, '', min, max, parent)
 | 
					        self._win = QProgressDialog(label, '', min, max, parent)
 | 
				
			||||||
        self._win.setWindowModality(QtCore.Qt.ApplicationModal)
 | 
					        self._win.setWindowModality(Qt.ApplicationModal)
 | 
				
			||||||
        self._win.setCancelButton(None)
 | 
					        self._win.setCancelButton(None)
 | 
				
			||||||
        self._win.canceled.connect(self.finish)
 | 
					        self._win.canceled.connect(self.finish)
 | 
				
			||||||
        self._win.setWindowTitle("Querying...")
 | 
					        self._win.setWindowTitle("Querying...")
 | 
				
			||||||
@ -121,12 +121,12 @@ class ProgressWindow(object):
 | 
				
			|||||||
        if value:
 | 
					        if value:
 | 
				
			||||||
            self._win.setValue(value)
 | 
					            self._win.setValue(value)
 | 
				
			||||||
        if process and elapsed >= 0.2:
 | 
					        if process and elapsed >= 0.2:
 | 
				
			||||||
            self.app.processEvents(QtCore.QEventLoop.ExcludeUserInputEvents)
 | 
					            self.app.processEvents(QEventLoop.ExcludeUserInputEvents)
 | 
				
			||||||
            self._last_update = time.time()
 | 
					            self._last_update = time.time()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _set_busy(self):
 | 
					    def _set_busy(self):
 | 
				
			||||||
        self._disabled = True
 | 
					        self._disabled = True
 | 
				
			||||||
        self.mw.app.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
 | 
					        self.mw.app.setOverrideCursor(QCursor(Qt.WaitCursor))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _unset_busy(self):
 | 
					    def _unset_busy(self):
 | 
				
			||||||
        self._disabled = False
 | 
					        self._disabled = False
 | 
				
			||||||
 | 
				
			|||||||
@ -17,7 +17,7 @@
 | 
				
			|||||||
# You should have received a copy of the GNU General Public License
 | 
					# You should have received a copy of the GNU General Public License
 | 
				
			||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
					# along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from PyQt4 import QtCore, QtGui
 | 
					from aqt.qt import *
 | 
				
			||||||
from .base import Dialog, WIDGET_SIZE
 | 
					from .base import Dialog, WIDGET_SIZE
 | 
				
			||||||
from ..context import config
 | 
					from ..context import config
 | 
				
			||||||
from ..lang import _
 | 
					from ..lang import _
 | 
				
			||||||
@ -39,31 +39,31 @@ class SettingDialog(Dialog):
 | 
				
			|||||||
        self.build()
 | 
					        self.build()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def build(self):
 | 
					    def build(self):
 | 
				
			||||||
        layout = QtGui.QVBoxLayout()
 | 
					        layout = QVBoxLayout()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        check_force_update = QtGui.QCheckBox(_("FORCE_UPDATE"))
 | 
					        check_force_update = QCheckBox(_("FORCE_UPDATE"))
 | 
				
			||||||
        check_force_update.setChecked(config.force_update)
 | 
					        check_force_update.setChecked(config.force_update)
 | 
				
			||||||
        layout.addWidget(check_force_update)
 | 
					        layout.addWidget(check_force_update)
 | 
				
			||||||
        layout.addSpacing(10)
 | 
					        layout.addSpacing(10)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        check_ignore_accents = QtGui.QCheckBox(_("IGNORE_ACCENTS"))
 | 
					        check_ignore_accents = QCheckBox(_("IGNORE_ACCENTS"))
 | 
				
			||||||
        check_ignore_accents.setChecked(config.ignore_accents)
 | 
					        check_ignore_accents.setChecked(config.ignore_accents)
 | 
				
			||||||
        layout.addWidget(check_ignore_accents)
 | 
					        layout.addWidget(check_ignore_accents)
 | 
				
			||||||
        layout.addSpacing(10)
 | 
					        layout.addSpacing(10)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        hbox = QtGui.QHBoxLayout()
 | 
					        hbox = QHBoxLayout()
 | 
				
			||||||
        input_thread_number = QtGui.QSpinBox(parent=self)
 | 
					        input_thread_number = QSpinBox(parent=self)
 | 
				
			||||||
        input_thread_number.setRange(1, 120)
 | 
					        input_thread_number.setRange(1, 120)
 | 
				
			||||||
        input_thread_number.setValue(config.thread_number)
 | 
					        input_thread_number.setValue(config.thread_number)
 | 
				
			||||||
        input_label = QtGui.QLabel(_("THREAD_NUMBER") + ":", parent=self)
 | 
					        input_label = QLabel(_("THREAD_NUMBER") + ":", parent=self)
 | 
				
			||||||
        hbox.addWidget(input_label)
 | 
					        hbox.addWidget(input_label)
 | 
				
			||||||
        hbox.setStretchFactor(input_label, 1)
 | 
					        hbox.setStretchFactor(input_label, 1)
 | 
				
			||||||
        hbox.addWidget(input_thread_number)
 | 
					        hbox.addWidget(input_thread_number)
 | 
				
			||||||
        hbox.setStretchFactor(input_thread_number, 2)
 | 
					        hbox.setStretchFactor(input_thread_number, 2)
 | 
				
			||||||
        layout.addLayout(hbox)
 | 
					        layout.addLayout(hbox)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        buttonBox = QtGui.QDialogButtonBox(parent=self)
 | 
					        buttonBox = QDialogButtonBox(parent=self)
 | 
				
			||||||
        buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
 | 
					        buttonBox.setStandardButtons(QDialogButtonBox.Ok)
 | 
				
			||||||
        buttonBox.accepted.connect(self.accept) # 确定
 | 
					        buttonBox.accepted.connect(self.accept) # 确定
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        layout.addSpacing(48)
 | 
					        layout.addSpacing(48)
 | 
				
			||||||
@ -73,7 +73,7 @@ class SettingDialog(Dialog):
 | 
				
			|||||||
        self.check_ignore_accents = check_ignore_accents
 | 
					        self.check_ignore_accents = check_ignore_accents
 | 
				
			||||||
        self.input_thread_number = input_thread_number
 | 
					        self.input_thread_number = input_thread_number
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        layout.setAlignment(QtCore.Qt.AlignTop|QtCore.Qt.AlignLeft)
 | 
					        layout.setAlignment(Qt.AlignTop|Qt.AlignLeft)
 | 
				
			||||||
        self.setLayout(layout)
 | 
					        self.setLayout(layout)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def accept(self):
 | 
					    def accept(self):
 | 
				
			||||||
 | 
				
			|||||||
@ -58,7 +58,7 @@ class WidgetSize(object):
 | 
				
			|||||||
    dialog_width = 700 
 | 
					    dialog_width = 700 
 | 
				
			||||||
    dialog_height_margin = 120 
 | 
					    dialog_height_margin = 120 
 | 
				
			||||||
    map_min_height = 0
 | 
					    map_min_height = 0
 | 
				
			||||||
    map_max_height = 31
 | 
					    map_max_height = 32
 | 
				
			||||||
    map_fld_width = 100
 | 
					    map_fld_width = 100
 | 
				
			||||||
    map_dictname_width = 150
 | 
					    map_dictname_width = 150
 | 
				
			||||||
    map_dictfield_width = 160
 | 
					    map_dictfield_width = 160
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,7 @@
 | 
				
			|||||||
import anki
 | 
					import anki
 | 
				
			||||||
import aqt
 | 
					import aqt
 | 
				
			||||||
import aqt.models
 | 
					import aqt.models
 | 
				
			||||||
 | 
					import sip
 | 
				
			||||||
from aqt import mw
 | 
					from aqt import mw
 | 
				
			||||||
from aqt.qt import *
 | 
					from aqt.qt import *
 | 
				
			||||||
from aqt.studydeck import StudyDeck
 | 
					from aqt.studydeck import StudyDeck
 | 
				
			||||||
@ -78,7 +79,10 @@ class OptionsDialog(Dialog):
 | 
				
			|||||||
    def _after_build(self, s):
 | 
					    def _after_build(self, s):
 | 
				
			||||||
        if s != 'after_build':
 | 
					        if s != 'after_build':
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        self.main_layout.removeWidget(self.loading_label)
 | 
					        if self.loading_label:
 | 
				
			||||||
 | 
					            self.main_layout.removeWidget(self.loading_label)
 | 
				
			||||||
 | 
					            sip.delete(self.loading_label)
 | 
				
			||||||
 | 
					            self.loading_label = None
 | 
				
			||||||
        models_layout = QHBoxLayout()
 | 
					        models_layout = QHBoxLayout()
 | 
				
			||||||
        # add buttons
 | 
					        # add buttons
 | 
				
			||||||
        mdx_button = QPushButton(_('DICTS_FOLDERS'))
 | 
					        mdx_button = QPushButton(_('DICTS_FOLDERS'))
 | 
				
			||||||
@ -205,13 +209,15 @@ class OptionsDialog(Dialog):
 | 
				
			|||||||
                        self.add_dict_layout(j, **each)
 | 
					                        self.add_dict_layout(j, **each)
 | 
				
			||||||
                        break
 | 
					                        break
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    self.add_dict_layout(i, fld_name=name, fld_ord=ord)
 | 
					                    self.add_dict_layout(i, fld_name=name, fld_ord=ord, word_checked=i==0)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                self.add_dict_layout(i, fld_name=name, fld_ord=ord)
 | 
					                self.add_dict_layout(i, fld_name=name, fld_ord=ord, word_checked=i==0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #self.setLayout(self.main_layout)
 | 
					        #self.setLayout(self.main_layout)
 | 
				
			||||||
        self.resize(WIDGET_SIZE.dialog_width,
 | 
					        self.resize(
 | 
				
			||||||
                    max(3, (i + 1)) * WIDGET_SIZE.map_max_height + WIDGET_SIZE.dialog_height_margin)
 | 
					            WIDGET_SIZE.dialog_width,
 | 
				
			||||||
 | 
					            max(3, (i + 1)) * WIDGET_SIZE.map_max_height + WIDGET_SIZE.dialog_height_margin
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
        self.save()
 | 
					        self.save()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def show_models(self):
 | 
					    def show_models(self):
 | 
				
			||||||
@ -298,7 +304,7 @@ class OptionsDialog(Dialog):
 | 
				
			|||||||
        """
 | 
					        """
 | 
				
			||||||
        add dictionary fields row
 | 
					        add dictionary fields row
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        word_checked = i == 0
 | 
					        word_checked = kwargs.get('word_checked', False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        fld_name, fld_ord = (
 | 
					        fld_name, fld_ord = (
 | 
				
			||||||
            kwargs.get('fld_name', ''),                                 #笔记类型的字段名
 | 
					            kwargs.get('fld_name', ''),                                 #笔记类型的字段名
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user