eric6/WebBrowser/UrlBar/BookmarkInfoDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8218
7c09585bd960
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

# -*- coding: utf-8 -*-

# Copyright (c) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to show some bookmark info.
"""

from PyQt5.QtCore import pyqtSlot
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QDialog

from .Ui_BookmarkInfoDialog import Ui_BookmarkInfoDialog

import UI.PixmapCache


class BookmarkInfoDialog(QDialog, Ui_BookmarkInfoDialog):
    """
    Class implementing a dialog to show some bookmark info.
    """
    def __init__(self, bookmark, parent=None):
        """
        Constructor
        
        @param bookmark reference to the bookmark to be shown (Bookmark)
        @param parent reference to the parent widget (QWidget)
        """
        super(BookmarkInfoDialog, self).__init__(parent)
        self.setupUi(self)
        
        self.__bookmark = bookmark
        
        self.icon.setPixmap(UI.PixmapCache.getPixmap("bookmark32"))
        
        font = QFont()
        font.setPointSize(font.pointSize() + 2)
        self.title.setFont(font)
        
        if bookmark is None:
            self.titleEdit.setEnabled(False)
        else:
            self.titleEdit.setText(bookmark.title)
            self.titleEdit.setFocus()
        
        msh = self.minimumSizeHint()
        self.resize(max(self.width(), msh.width()), msh.height())
    
    @pyqtSlot()
    def on_removeButton_clicked(self):
        """
        Private slot to remove the current bookmark.
        """
        import WebBrowser.WebBrowserWindow
        (WebBrowser.WebBrowserWindow.WebBrowserWindow.bookmarksManager()
            .removeBookmark(self.__bookmark))
        self.close()
    
    def accept(self):
        """
        Public slot handling the acceptance of the dialog.
        """
        if (
            self.__bookmark is not None and
            self.titleEdit.text() != self.__bookmark.title
        ):
            import WebBrowser.WebBrowserWindow
            (WebBrowser.WebBrowserWindow.WebBrowserWindow.bookmarksManager()
                .setTitle(self.__bookmark, self.titleEdit.text()))
        self.close()

eric ide

mercurial