Exemplo n.º 1
0
 def inicio_splash(self, develop="false"):
     self.drawn_once = False
     self.develop = develop
     self.title_font = f = QFont()
     f.setPointSize(self.TITLE_SIZE)
     f.setBold(True)
     self.title_height = QFontMetrics(f).lineSpacing()
     self.body_font = f = QFont()
     f.setPointSize(self.BODY_SIZE)
     self.line_height = QFontMetrics(f).lineSpacing()
     self.total_height = max(self.LOGO_SIZE,
                             self.title_height + 3 * self.line_height)
     self.num_font = f = QFont()
     f.setPixelSize(self.total_height)
     f.setItalic(True), f.setBold(True)
     f = QFontMetrics(f)
     self.num_ch = str(max(3, numeric_version[0]))
     self.footer_font = f = QFont()
     f.setPointSize(self.FOOTER_SIZE)
     f.setItalic(True)
     self.dpr = QApplication.instance().devicePixelRatio()
     self.pmap = QPixmap(I('library.png', allow_user_override=False))
     self.pmap.setDevicePixelRatio(self.dpr)
     self.pmap = self.pmap.scaled(int(self.dpr * self.LOGO_SIZE),
                                  int(self.dpr * self.LOGO_SIZE),
                                  transformMode=Qt.SmoothTransformation)
     self.light_brush = QBrush(QColor('#F6F3E9'))
     self.dark_brush = QBrush(QColor('#39322B'))
     pmap = QPixmap(int(self.WIDTH * self.dpr), int(self.WIDTH * self.dpr))
     pmap.setDevicePixelRatio(self.dpr)
     pmap.fill(Qt.transparent)
     QSplashScreen.__init__(self, pmap)
     self.setWindowTitle('Sistema Biblioteca Nacional')
Exemplo n.º 2
0
 def __init__(self, develop=False):
     self.drawn_once = False
     self.develop = develop
     self.title_font = f = QFont()
     f.setPointSize(self.TITLE_SIZE)
     f.setBold(True)
     self.title_height = QFontMetrics(f).lineSpacing() + 2
     self.body_font = f = QFont()
     f.setPointSize(self.BODY_SIZE)
     self.line_height = QFontMetrics(f).lineSpacing()
     self.total_height = max(self.LOGO_SIZE, self.title_height + 3 * self.line_height)
     self.num_font = f = QFont()
     f.setPixelSize(self.total_height)
     f.setItalic(True), f.setBold(True)
     f = QFontMetrics(f)
     self.num_ch = str(max(3, numeric_version[0]))
     self.footer_font = f = QFont()
     f.setPointSize(self.FOOTER_SIZE)
     f.setItalic(True)
     self.dpr = QApplication.instance().devicePixelRatio()
     self.pmap = QPixmap(I('library.png', allow_user_override=False))
     self.pmap.setDevicePixelRatio(self.dpr)
     self.pmap = self.pmap.scaled(int(self.dpr * self.LOGO_SIZE), int(self.dpr * self.LOGO_SIZE), transformMode=Qt.SmoothTransformation)
     self.light_brush = QBrush(QColor('#F6F3E9'))
     self.dark_brush = QBrush(QColor('#39322B'))
     pmap = QPixmap(int(self.WIDTH * self.dpr), int(self.WIDTH * self.dpr))
     pmap.setDevicePixelRatio(self.dpr)
     pmap.fill(Qt.transparent)
     QSplashScreen.__init__(self, pmap)
     self.setWindowTitle(__appname__)
Exemplo n.º 3
0
def test_err_dialog(request, qapp):
    global dialog_result

    dialog_result = {}

    splash = QSplashScreen()
    splash.show()
    text = None

    try:
        file_name = "not_exist_file.txt"
        file_d = open(file_name, 'r')
        text = file_d.read()
        file_d.close()
    except (RuntimeError, IOError) as err:
        assert text is None
        err_dialog = gm_base.geomop_dialogs.GMErrorDialog(splash)
        timer = QTimer(splash)
        timer.timeout.connect(lambda: start_dialog(err_dialog))
        timer.start(1000)
        err_dialog.open_error_dialog("Can't open file", err)

    del splash

    #button tests
    assert dialog_result['button_count'] == 1
    assert dialog_result['button_text'] in ('&OK', 'OK')
    #text test
    assert dialog_result['text'] == "Can't open file"
    assert dialog_result['informativeText'][:12] == "FileNotFound"
    assert dialog_result['title'] == "GeoMop Error"
Exemplo n.º 4
0
 def __init__(self, develop=False):
     self.drawn_once = False
     self.develop = develop
     pmap = QIcon(I('library.png',
                    allow_user_override=False)).pixmap(512, 512)
     QSplashScreen.__init__(self, pmap)
     self.setWindowTitle(__appname__)
Exemplo n.º 5
0
 def show_splash_screen(self):
     self.splash_pixmap = QPixmap()
     self.splash_pixmap.load(I('library.png'))
     self.splash_screen = QSplashScreen(self.splash_pixmap)
     self.splash_screen.showMessage(
         _('Starting %s: Loading books...') % __appname__)
     self.splash_screen.show()
     QApplication.instance().processEvents()
Exemplo n.º 6
0
Arquivo: main.py Projeto: kba/calibre
 def show_splash_screen(self):
     self.splash_pixmap = QPixmap()
     self.splash_pixmap.load(I('library.png'))
     self.splash_screen = QSplashScreen(self.splash_pixmap)
     self.splash_screen.showMessage(_('Starting %s: Loading books...') %
             __appname__)
     self.splash_screen.show()
     QApplication.instance().processEvents()
Exemplo n.º 7
0
    def __init__(self):
        app = QApplication(sys.argv)
        app.setApplicationName("eKalappai")
        app.setApplicationVersion("4.0.0")
        shared = QSharedMemory("59698760-43bb-44d9-8121-181ecbb70e4d")

        if not shared.create(512, QSharedMemory.ReadWrite):
            qWarning("Cannot start more than one instance of eKalappai any time.")
            exit(0)
        splashImage = QPixmap(':intro/splash_screen')
        splashScreen = QSplashScreen(splashImage)
        splashScreen.show()
        time.sleep(2)
        splashScreen.hide()
        QApplication.setQuitOnLastWindowClosed(False)
        ekWindow = EKWindow()
        ekWindow.engine.start()
        sys.exit(app.exec_())
Exemplo n.º 8
0
    def __init__(self):
        # Initialize
        app = QApplication(sys.argv)
        app.setApplicationName("eKalappai")
        app.setApplicationVersion("4.0.0")
        shared = QSharedMemory("59698760-43bb-44d9-8121-181ecbb70e4d")

        # Check if already another instance of app is running and quit if it is
        if not shared.create(512, QSharedMemory.ReadWrite):
            qWarning("Cannot start more than one instance of eKalappai any time.")
            exit(0)

        # Splash Screen init
        splashImage = QPixmap(':intro/splash_screen')
        splashScreen = QSplashScreen(splashImage)
        splashScreen.show()
        # Time wait for splash screen to be shown
        time.sleep(2)
        splashScreen.hide()

        # Main application starting
        QApplication.setQuitOnLastWindowClosed(False)
        ekWindow = EKWindow(app)

        # EK Engine start
        ekWindow.engine.start()
        
        sys.exit(app.exec_())
Exemplo n.º 9
0
    def __init__(self, image):
        self.isRunning = True
        self.image = image
        self.frame = QPixmap(image.rect().size() + QSize(0, 20))
        self.frame.fill(Qt.transparent)
        QSplashScreen.__init__(self, self.frame,
                               QtCore.Qt.WindowStaysOnTopHint)

        # COMPARISON BETWEEN EASING CURVES
        easingCurve = QEasingCurve()
        easingCurve.setCustomType(self.funkyEasingFunc)
        self.anim = LoadingDotsWidget(None,
                                      ypos=110,
                                      xsize=self.image.rect().size().width() +
                                      10,
                                      sep=40,
                                      offsetx=0,
                                      speed=100,
                                      easingcurve=easingCurve,
                                      amount=3,
                                      loopingOn=3)
        self.anim.s_externalRepaint.connect(self.update)
        self.frameSize = self.rect().size() + QSize(0, 20)
Exemplo n.º 10
0
    def on_pushButton_clicked(self):  # 检索按钮
        """
        Slot documentation goes here.
        """

        if self.lineEdit.text() == '':  # 如果检索输入栏为空
            QMessageBox.information(self, "提示", "没有输入检索内容")
            return

        self.listWidget.clear()
        self.names.clear()
        self.sizes.clear()
        self.times.clear()
        self.mages.clear()
        # 开始检索

        # self.names,self.sizes,self.times,self.mages = GetInfo(self.lineEdit.text())
        if self.FindingThread.isAlive() is False:
            self.FindingThread = threading.Thread(target=GetInfo,
                                                  args=(self.lineEdit.text(),
                                                        self))
        self.pushButton.setDisabled(True)

        splash = QSplashScreen(QPixmap(":/pic/waiting.png"))
        splash.show()
        app.processEvents()
        self.FindingThread.start()
        while self.FindingThread.isAlive():
            continue
        self.pushButton.setDisabled(False)
        splash.finish(self)
        QMessageBox.information(self, "检索完毕",
                                "共检索到" + str(len(self.names)) + "个结果")

        # 添加结果到listWidget
        for i in self.names:
            self.listWidget.addItem(i)
Exemplo n.º 11
0
        elif self.iniSettings.value("shortcut_modifier") == "CTRL":
            self.engine.event_queue.register_event([['Lcontrol', self.shortcutKey], self.icon_activated, QSystemTrayIcon.Trigger])
            self.engine.event_queue.register_event([['Rcontrol', self.shortcutKey], self.icon_activated, QSystemTrayIcon.Trigger])
        elif self.iniSettings.value("shortcut_modifier") == "ALT":
            self.engine.event_queue.register_event([['LMenu', self.shortcutKey], self.icon_activated, QSystemTrayIcon.Trigger])
            self.engine.event_queue.register_event([['RMenu', self.shortcutKey], self.icon_activated, QSystemTrayIcon.Trigger])
        return True


if __name__ == "__main__":
    """
        Main Function which will initialize the app
    """
    app = QApplication(sys.argv)
    app.setApplicationName("eKalappai")
    app.setApplicationVersion("4.0.0")
    shared = QSharedMemory("59698760-43bb-44d9-8121-181ecbb70e4d")

    if not shared.create(512, QSharedMemory.ReadWrite):
        qWarning("Cannot start more than one instance of eKalappai any time.")
        exit(0)
    splashImage = QPixmap(':/images/intro.png')
    splashScreen = QSplashScreen(splashImage)
    splashScreen.show()
    time.sleep(2)
    splashScreen.hide()
    QApplication.setQuitOnLastWindowClosed(False)
    ekWindow = EKWindow()
    ekWindow.engine.start()
    sys.exit(app.exec_())
Exemplo n.º 12
0
 def __init__(self):
     self.drawn_once = False
     QSplashScreen.__init__(self, QPixmap(I('library.png')))
     self.setWindowTitle(__appname__)
Exemplo n.º 13
0
                      left,
                      top,
                      textColor=(0, 255, 0),
                      textSize=20):
        if (isinstance(img, numpy.ndarray)):  #判断是否OpenCV图片类型
            img = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
        draw = ImageDraw.Draw(img)
        fontText = ImageFont.truetype(
            # 参数1:字体文件路径,默认设定好,避免后期增加传参复杂度
            "msyh.ttf",
            textSize,
            encoding="utf-8")
        draw.text((left, top), text, textColor, font=fontText)
        return cv2.cvtColor(numpy.asarray(img), cv2.COLOR_RGB2BGR)


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    # 启动界面
    splash = QSplashScreen(QPixmap("./static/liuliuzhulogo.png"))
    splash.show()
    splash.showMessage(
        u'正在加载资源……\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t',
        Qt.AlignCenter, Qt.white)
    app.processEvents()
    ui = MainWindow()
    ui.show()
    splash.finish(ui)
    sys.exit(app.exec_())
Exemplo n.º 14
0
 def __init__(self):
     self.drawn_once = False
     QSplashScreen.__init__(self, QPixmap(I('library.png')))
Exemplo n.º 15
0
class GuiRunner(QObject):
    '''Make sure an event loop is running before starting the main work of
    initialization'''
    def __init__(self, opts, args, actions, listener, app, gui_debug=None):
        self.startup_time = time.time()
        self.opts, self.args, self.listener, self.app = opts, args, listener, app
        self.gui_debug = gui_debug
        self.actions = actions
        self.main = None
        QObject.__init__(self)
        self.splash_screen = None
        self.timer = QTimer.singleShot(1, self.initialize)
        if DEBUG:
            prints('Starting up...')

    def start_gui(self, db):
        from calibre.gui2.ui import Main
        main = self.main = Main(self.opts, gui_debug=self.gui_debug)
        if self.splash_screen is not None:
            self.splash_screen.showMessage(_('Initializing user interface...'))
        with gprefs:  # Only write gui.json after initialization is complete
            main.initialize(self.library_path, db, self.listener, self.actions)
        if self.splash_screen is not None:
            self.splash_screen.finish(main)
        if DEBUG:
            prints(
                'Started up in %.2f seconds' %
                (time.time() - self.startup_time), 'with', len(db.data),
                'books')
        add_filesystem_book = partial(
            main.iactions['Add Books'].add_filesystem_book, allow_device=False)
        sys.excepthook = main.unhandled_exception
        if len(self.args) > 1:
            files = [
                os.path.abspath(p) for p in self.args[1:]
                if not os.path.isdir(p)
            ]
            if len(files) < len(sys.argv[1:]):
                prints('Ignoring directories passed as command line arguments')
            if files:
                add_filesystem_book(files)
        for event in self.app.file_event_hook.events:
            add_filesystem_book(event)
        self.app.file_event_hook = add_filesystem_book

    def initialization_failed(self):
        print 'Catastrophic failure initializing GUI, bailing out...'
        QCoreApplication.exit(1)
        raise SystemExit(1)

    def initialize_db_stage2(self, db, tb):
        from calibre.db.legacy import LibraryDatabase

        if db is None and tb is not None:
            # DB Repair failed
            error_dialog(self.splash_screen,
                         _('Repairing failed'),
                         _('The database repair failed. Starting with '
                           'a new empty library.'),
                         det_msg=tb,
                         show=True)
        if db is None:
            candidate = choose_dir(
                self.splash_screen,
                'choose calibre library',
                _('Choose a location for your new calibre e-book library'),
                default_dir=get_default_library_path())
            if not candidate:
                self.initialization_failed()

            try:
                self.library_path = candidate
                db = LibraryDatabase(candidate)
            except:
                error_dialog(
                    self.splash_screen,
                    _('Bad database location'),
                    _('Bad database location %r. calibre will now quit.') %
                    self.library_path,
                    det_msg=traceback.format_exc(),
                    show=True)
                self.initialization_failed()

        try:
            self.start_gui(db)
        except Exception:
            error_dialog(
                self.main,
                _('Startup error'),
                _('There was an error during {0} startup.'
                  ' Parts of {0} may not function. Click Show details to learn more.'
                  ).format(__appname__),
                det_msg=traceback.format_exc(),
                show=True)

    def initialize_db(self):
        from calibre.db.legacy import LibraryDatabase
        db = None
        try:
            db = LibraryDatabase(self.library_path)
        except apsw.Error:
            repair = question_dialog(
                self.splash_screen,
                _('Corrupted database'),
                _('The library database at %s appears to be corrupted. Do '
                  'you want calibre to try and rebuild it automatically? '
                  'The rebuild may not be completely successful. '
                  'If you say No, a new empty calibre library will be created.'
                  ) % force_unicode(self.library_path, filesystem_encoding),
                det_msg=traceback.format_exc())
            if repair:
                if repair_library(self.library_path):
                    db = LibraryDatabase(self.library_path)
        except:
            error_dialog(self.splash_screen,
                         _('Bad database location'),
                         _('Bad database location %r. Will start with '
                           ' a new, empty calibre library') %
                         self.library_path,
                         det_msg=traceback.format_exc(),
                         show=True)

        self.initialize_db_stage2(db, None)

    def show_splash_screen(self):
        self.splash_pixmap = QPixmap()
        self.splash_pixmap.load(I('library.png'))
        self.splash_screen = QSplashScreen(self.splash_pixmap)
        self.splash_screen.showMessage(
            _('Starting %s: Loading books...') % __appname__)
        self.splash_screen.show()
        QApplication.instance().processEvents()

    def initialize(self, *args):
        if gprefs['show_splash_screen']:
            self.show_splash_screen()

        self.library_path = get_library_path(parent=self.splash_screen)
        if not self.library_path:
            self.initialization_failed()

        self.initialize_db()
Exemplo n.º 16
0
 def show(self):
     QSplashScreen.show(self)
Exemplo n.º 17
0
 def __init__(self):
     QSplashScreen.__init__(self, QPixmap(I('library.png')))
Exemplo n.º 18
0
    if getattr(sys, 'frozen', False):
        # running in a bundle
        imgDir = os.path.join(sys._MEIPASS, 'img')

    else:
        # running live
        imgDir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                              'img')

    ### -- style stuff
    spmtLogo_file = os.path.join(imgDir, 'splashscreen.png')
    labelstyle = "QLabel { font-size: 14px; color: purple; font-style: italic; text-align: center;}"
    barStyle = "QProgressBar::chunk {background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0,stop: 0 #372f43,stop: 0.6 #5c4c7a, stop: 0.8 #663399);border-bottom-right-radius: 7px;border-bottom-left-radius: 7px;border-top: 2px solid #8A2BE2;}"

    splash_pix = QPixmap(spmtLogo_file)
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)

    progressBar = QProgressBar(splash)
    progressBar.setGeometry(0,
                            splash_pix.height() - 13, splash_pix.width(), 13)
    progressBar.setStyleSheet(barStyle)
    progressBar.setAlignment(Qt.AlignRight)

    label = QLabel(splash)
    label.setStyleSheet(labelstyle)
    label.setGeometry((splash_pix.width() - 500) / 2,
                      splash_pix.height() - 40, 500, 20)
    label.setAlignment(Qt.AlignCenter)

    progressText = "loading..."
    label.setText(progressText)
Exemplo n.º 19
0
Arquivo: main.py Projeto: kba/calibre
class GuiRunner(QObject):
    '''Make sure an event loop is running before starting the main work of
    initialization'''

    def __init__(self, opts, args, actions, listener, app, gui_debug=None):
        self.startup_time = time.time()
        self.opts, self.args, self.listener, self.app = opts, args, listener, app
        self.gui_debug = gui_debug
        self.actions = actions
        self.main = None
        QObject.__init__(self)
        self.splash_screen = None
        self.timer = QTimer.singleShot(1, self.initialize)
        if DEBUG:
            prints('Starting up...')

    def start_gui(self, db):
        from calibre.gui2.ui import Main
        main = self.main = Main(self.opts, gui_debug=self.gui_debug)
        if self.splash_screen is not None:
            self.splash_screen.showMessage(_('Initializing user interface...'))
        with gprefs:  # Only write gui.json after initialization is complete
            main.initialize(self.library_path, db, self.listener, self.actions)
        if self.splash_screen is not None:
            self.splash_screen.finish(main)
        if DEBUG:
            prints('Started up in %.2f seconds'%(time.time() -
                self.startup_time), 'with', len(db.data), 'books')
        add_filesystem_book = partial(main.iactions['Add Books'].add_filesystem_book, allow_device=False)
        sys.excepthook = main.unhandled_exception
        if len(self.args) > 1:
            files = [os.path.abspath(p) for p in self.args[1:] if not
                    os.path.isdir(p)]
            if len(files) < len(sys.argv[1:]):
                prints('Ignoring directories passed as command line arguments')
            if files:
                add_filesystem_book(files)
        for event in self.app.file_event_hook.events:
            add_filesystem_book(event)
        self.app.file_event_hook = add_filesystem_book

    def initialization_failed(self):
        print 'Catastrophic failure initializing GUI, bailing out...'
        QCoreApplication.exit(1)
        raise SystemExit(1)

    def initialize_db_stage2(self, db, tb):
        from calibre.db.legacy import LibraryDatabase

        if db is None and tb is not None:
            # DB Repair failed
            error_dialog(self.splash_screen, _('Repairing failed'),
                    _('The database repair failed. Starting with '
                        'a new empty library.'),
                    det_msg=tb, show=True)
        if db is None:
            candidate = choose_dir(self.splash_screen, 'choose calibre library',
                _('Choose a location for your new calibre e-book library'),
                default_dir=get_default_library_path())
            if not candidate:
                self.initialization_failed()

            try:
                self.library_path = candidate
                db = LibraryDatabase(candidate)
            except:
                error_dialog(self.splash_screen, _('Bad database location'),
                    _('Bad database location %r. calibre will now quit.'
                     )%self.library_path,
                    det_msg=traceback.format_exc(), show=True)
                self.initialization_failed()

        try:
            self.start_gui(db)
        except Exception:
            error_dialog(self.main, _('Startup error'),
                         _('There was an error during {0} startup.'
                           ' Parts of {0} may not function. Click Show details to learn more.').format(__appname__),
                         det_msg=traceback.format_exc(), show=True)

    def initialize_db(self):
        from calibre.db.legacy import LibraryDatabase
        db = None
        try:
            db = LibraryDatabase(self.library_path)
        except apsw.Error:
            repair = question_dialog(self.splash_screen, _('Corrupted database'),
                    _('The library database at %s appears to be corrupted. Do '
                    'you want calibre to try and rebuild it automatically? '
                    'The rebuild may not be completely successful. '
                    'If you say No, a new empty calibre library will be created.')
                    % force_unicode(self.library_path, filesystem_encoding),
                    det_msg=traceback.format_exc()
                    )
            if repair:
                if repair_library(self.library_path):
                    db = LibraryDatabase(self.library_path)
        except:
            error_dialog(self.splash_screen, _('Bad database location'),
                    _('Bad database location %r. Will start with '
                    ' a new, empty calibre library')%self.library_path,
                    det_msg=traceback.format_exc(), show=True)

        self.initialize_db_stage2(db, None)

    def show_splash_screen(self):
        self.splash_pixmap = QPixmap()
        self.splash_pixmap.load(I('library.png'))
        self.splash_screen = QSplashScreen(self.splash_pixmap)
        self.splash_screen.showMessage(_('Starting %s: Loading books...') %
                __appname__)
        self.splash_screen.show()
        QApplication.instance().processEvents()

    def initialize(self, *args):
        if gprefs['show_splash_screen']:
            self.show_splash_screen()

        self.library_path = get_library_path(parent=self.splash_screen)
        if not self.library_path:
            self.initialization_failed()

        self.initialize_db()
Exemplo n.º 20
0
 def __init__(self):
     QSplashScreen.__init__(self, QPixmap(I('library.png')))
Exemplo n.º 21
0
 def keyPressEvent(self, ev):
     if not self.develop:
         return QSplashScreen.keyPressEvent(self, ev)
     ev.accept()
     QApplication.instance().quit()
Exemplo n.º 22
0
 def __init__(self):
     self.drawn_once = False
     QSplashScreen.__init__(self, QPixmap(I('library.png')))
     self.setWindowTitle(__appname__)
Exemplo n.º 23
0
 def __init__(self):
     self.drawn_once = False
     QSplashScreen.__init__(self, QPixmap(I('library.png')))
Exemplo n.º 24
0
 def keyPressEvent(self, ev):
     if not self.develop:
         return QSplashScreen.keyPressEvent(self, ev)
     ev.accept()
     QApplication.instance().quit()
Exemplo n.º 25
0
 def __init__(self, develop=False):
     self.drawn_once = False
     self.develop = develop
     pmap = QIcon(I('library.png', allow_user_override=False)).pixmap(512, 512)
     QSplashScreen.__init__(self, pmap)
     self.setWindowTitle(__appname__)