Example #1
0
 def accept(self):
     if not self.validate():
         return
     self.abort_disk_usage.set()
     if self.run_action():
         self.restart_needed = self.stack.currentIndex() == 2
         Dialog.accept(self)
Example #2
0
 def accept(self):
     name = self.sname.text().strip()
     if not name:
         return error_dialog(
             self,
             _('No search name'),
             _('You must specify a name for the Saved search'),
             show=True)
     expression = self.search.text().strip()
     if not expression:
         return error_dialog(
             self,
             _('No search expression'),
             _('You must specify a search expression for the Saved search'),
             show=True)
     self.accepted_data = name, expression
     if self.validate is not None:
         err = self.validate(name, expression)
         if err:
             return error_dialog(self, _('Invalid saved search'), err, show=True)
     Dialog.accept(self)
     if self.commit_changes:
         if icu_lower(name) in self.search_names:
             self.searches.pop(self.search_names[icu_lower(name)], None)
         self.searches[name] = expression
         commit_searches(self.searches)
Example #3
0
 def accept(self):
     r = self.rule
     for i, which in enumerate([_('Key'), _('Name'), _('Template')]):
         if not r[i]:
             return error_dialog(self, _('Value needed'), _(
                 'The %s field cannot be empty') % which, show=True)
     Dialog.accept(self)
Example #4
0
 def restore_defaults(self):
     if self.current_theme is not None:
         if not question_dialog(self, _('Are you sure?'), _(
                 'Are you sure you want to remove the <b>%s</b> icon theme'
                 ' and return to the stock icons?') % self.current_theme):
             return
     self.commit_changes = remove_icon_theme
     Dialog.accept(self)
Example #5
0
 def accept(self):
     rules = defaultdict(list)
     for r in range(self.table.rowCount()):
         def item(c):
             return self.table.item(r, c).text()
         rules[item(0)].append([item(1), item(2)])
     msprefs['id_link_rules'] = dict(rules)
     Dialog.accept(self)
Example #6
0
 def accept(self):
     mi = self.metadata
     if not mi.get('title'):
         return error_dialog(self, _('No title specified'), _(
             'You must specify a title for this icon theme'), show=True)
     if not mi.get('author'):
         return error_dialog(self, _('No author specified'), _(
             'You must specify an author for this icon theme'), show=True)
     return Dialog.accept(self)
Example #7
0
 def accept(self):
     fname = self.file_name.text().strip()
     if not fname:
         return error_dialog(self, _('No filename specified'), _(
             'You must specify a filename for the PDF file to generate'), show=True)
     if not fname.lower().endswith('.pdf'):
         return error_dialog(self, _('Incorrect filename specified'), _(
             'The filename for the PDF file must end with .pdf'), show=True)
     self.save_used_values()
     return Dialog.accept(self)
 def accept(self):
     Dialog.accept(self)
     name = self.sname.text().strip()
     if not name:
         return error_dialog(
             self,
             _('No search name'),
             _('You must specify a search name'),
             show=True)
     expression = self.search.text().strip()
     if not expression:
         return error_dialog(
             self,
             _('No search expression'),
             _('You must specify a search expression'),
             show=True)
     if icu_lower(name) in self.searches:
         self.searches.pop(icu_lower(name), None)
     self.searches[name] = expression
     commit_searches(self.searches)
Example #9
0
    def accept(self):
        if self.theme_list.currentIndex() < 0:
            return error_dialog(self, _('No theme selected'), _(
                'You must first select an icon theme'), show=True)
        theme = self.theme_list.currentItem().data(Qt.UserRole)
        url = BASE_URL + theme['icons-url']
        size = theme['compressed-size']
        theme = {k:theme.get(k, '') for k in 'name title version'.split()}
        self.keep_downloading = True
        d = DownloadProgress(self, size)
        d.canceled_signal.connect(lambda : setattr(self, 'keep_downloading', False))

        self.downloaded_theme = None

        def download():
            self.downloaded_theme = buf = BytesIO()
            try:
                response = get_https_resource_securely(url, get_response=True)
                while self.keep_downloading:
                    raw = response.read(1024)
                    if not raw:
                        break
                    buf.write(raw)
                    d.downloaded(buf.tell())
                d.queue_accept()
            except Exception:
                import traceback
                self.downloaded_theme = traceback.format_exc()
                d.queue_reject()

        t = Thread(name='DownloadIconTheme', target=download)
        t.daemon = True
        t.start()
        ret = d.exec_()

        if self.downloaded_theme and not isinstance(self.downloaded_theme, BytesIO):
            return error_dialog(self, _('Download failed'), _(
                'Failed to download icon theme, click "Show Details" for more information.'), show=True, det_msg=self.downloaded_theme)
        if ret == d.Rejected or not self.keep_downloading or d.canceled or self.downloaded_theme is None:
            return
        dt = self.downloaded_theme

        def commit_changes():
            dt.seek(0)
            f = decompress(dt)
            f.seek(0)
            remove_icon_theme()
            install_icon_theme(theme, f)
        self.commit_changes = commit_changes
        self.new_theme_title = theme['title']
        return Dialog.accept(self)
Example #10
0
 def accept(self):
     self.model.commit()
     return Dialog.accept(self)
Example #11
0
 def accept(self):
     ci = self.plist.currentItem()
     if ci is not None:
         self.selected_entry = ci.data(ENTRY_ROLE)
     return Dialog.accept(self)
Example #12
0
    def accept(self):
        if self.theme_list.currentIndex() < 0:
            return error_dialog(self,
                                _('No theme selected'),
                                _('You must first select an icon theme'),
                                show=True)
        theme = self.theme_list.currentItem().data(Qt.UserRole)
        url = BASE_URL + theme['icons-url']
        size = theme['compressed-size']
        theme = {k: theme.get(k, '') for k in 'name title version'.split()}
        self.keep_downloading = True
        d = DownloadProgress(self, size)
        d.canceled_signal.connect(
            lambda: setattr(self, 'keep_downloading', False))

        self.downloaded_theme = None

        def download():
            self.downloaded_theme = buf = BytesIO()
            try:
                response = get_https_resource_securely(url, get_response=True)
                while self.keep_downloading:
                    raw = response.read(1024)
                    if not raw:
                        break
                    buf.write(raw)
                    d.downloaded(buf.tell())
                d.queue_accept()
            except Exception:
                import traceback
                self.downloaded_theme = traceback.format_exc()
                d.queue_reject()

        t = Thread(name='DownloadIconTheme', target=download)
        t.daemon = True
        t.start()
        ret = d.exec_()

        if self.downloaded_theme and not isinstance(self.downloaded_theme,
                                                    BytesIO):
            return error_dialog(
                self,
                _('Download failed'),
                _('Failed to download icon theme, click "Show Details" for more information.'
                  ),
                show=True,
                det_msg=self.downloaded_theme)
        if ret == d.Rejected or not self.keep_downloading or d.canceled or self.downloaded_theme is None:
            return
        dt = self.downloaded_theme

        def commit_changes():
            dt.seek(0)
            f = decompress(dt)
            f.seek(0)
            remove_icon_theme()
            install_icon_theme(theme, f)

        self.commit_changes = commit_changes
        self.new_theme_title = theme['title']
        return Dialog.accept(self)
Example #13
0
 def accept(self):
     idx = self.stack.currentIndex()
     if idx > 0:
         self.editing_finished()
         return
     Dialog.accept(self)
Example #14
0
 def accept(self):
     commit_searches(self.searches)
     Dialog.accept(self)
Example #15
0
 def accept(self):
     self.model.commit()
     return Dialog.accept(self)
Example #16
0
 def accept(self):
     if not self.selected_recipe:
         return error_dialog(self, _('Choose recipe'), _(
             'You must choose a recipe to customize first'), show=True)
     return Dialog.accept(self)
Example #17
0
 def accept(self):
     ci = self.plist.currentItem()
     if ci is not None:
         self.selected_entry = ci.data(ENTRY_ROLE)
     return Dialog.accept(self)
Example #18
0
 def accept(self):
     if self.edit_widget.validate():
         Dialog.accept(self)
Example #19
0
 def accept(self):
     if self.edit_widget.validate():
         Dialog.accept(self)
Example #20
0
 def accept(self):
     commit_searches(self.searches)
     Dialog.accept(self)