Ejemplo n.º 1
0
    def __init__(self):
        QMainWindow.__init__(self)
        
        self.setWindowTitle(cons.APP_TITLE)
        self.setWindowIcon(QIcon(os.path.join(cons.MEDIA_PATH, "misc", "ochd.ico")))
        self.resize(MIN_WIDTH, MIN_HEIGHT)
        self.center()
        
        self.restore_wnd_geometry()

        self.downloads = Downloads(self)
        self.add_downloads = AddDownloads(self)
        self.log = Log(self)
        
        self.stop = (QToolButton(), media.get_icon(media.STOP, media.MEDIUM), _('Stop Download'), self.on_stop_download, False)
        self.start = (QToolButton(), media.get_icon(media.START, media.MEDIUM), _('Start Download'), self.on_start_download, False)
        self.accounts = (QToolButton(), media.get_icon(media.ACCOUNTS, media.MEDIUM), _('Accounts'), self.on_accounts, True)
        self.preferences = (QToolButton(), media.get_icon(media.PREFERENCES, media.MEDIUM), _('Preferences'), self.on_preferences, True)
        self.about = (QToolButton(), media.get_icon(media.ABOUT, media.MEDIUM), _('About'), self.on_about, True)
        
        self.menu = QMenu()
        self.preferences[BTN].setPopupMode(QToolButton.MenuButtonPopup)
        self.preferences[BTN].setMenu(self.menu)
        
        self.toolbar = Toolbar(self, [self.start, self.stop, None, self.accounts, self.preferences, None, self.about])

        self.addToolBar(self.toolbar)

        #tabs
        self.previous_tab = None
        self.tab = QTabWidget()
        #
        self.tab.addTab(self.downloads, _('Downloads'))
        #
        self.tab_add_downloads = QWidget()
        self.tab_add_downloads.setLayout(self.add_downloads)
        self.tab.addTab(self.tab_add_downloads, _('Add downloads'))
        #
        #addons
        self.addons_manager = AddonsManager(self)
        self.addons_list = self.addons_manager.addons_list
        #...tabs
        self.addon_tab_widgets = []
        self.load_addon_tabs()
        #
        self.tab_log = QWidget()
        self.tab_log.setLayout(self.log)
        self.tab.addTab(self.tab_log, _('Log'))
        #
        self.preferences = Preferences(self.addons_list)
        #self.tab.addTab(self.preferences, 'Preferences')
        #
        self.tab.currentChanged.connect(self.on_tab_switch)
        #
        self.setCentralWidget(self.tab)

        #status bar
        self.status_bar = StatusBar(self)
        self.setStatusBar(self.status_bar)

        #drop down menu
        [addon.set_menu_item() for addon in self.addons_list]
        #self.menu.addSeparator()
        #self.menu.addAction('Preferences', self.on_preferences)

        #system tray icon
        self.tray = Tray(self)
        self.show_or_hide_tray()

        #load session.
        self.load_session()

        #add core's event loop
        self.dispatcher = ThreadDispatcher(self)
        self.dispatcher.start()

        #quit event
        events.quit.connect(self.event_close)

        #custom qt signals
        signals.switch_tab.connect(self.switch_tab)
        signals.show_or_hide_tray.connect(self.show_or_hide_tray)

        self.show()
Ejemplo n.º 2
0
    def __init__(self, parent):
        QVBoxLayout.__init__(self)
        self.setContentsMargins(0, 0, 0, 0)
        self.setSpacing(5)

        self.weak_parent = weakref.ref(parent)
        
        self.tree_view = QTreeView()

        self.tree_view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.tree_view.customContextMenuRequested.connect(self.context_menu)

        #listview look
        self.tree_view.setWordWrap(True) #search textElideMode
        self.tree_view.setRootIsDecorated(False)
        self.tree_view.setIndentation(0)
        self.tree_view.setAlternatingRowColors(True)

        self.icons_dict = self.get_icons()
        self.items = []
        self.rows_buffer = {} #{id_item: row_obj, }

        bool_cols = [1, ]
        image_cols = [2, ]
        headers = ["hidden_id_item", "", "", _("File Name"), _("Host"), _("Size"), _("Status Message")]

        self.__model = SimpleListModel(headers, self.items, bool_cols, image_cols)
        self.tree_view.setModel(self.__model)
        self.addWidget(self.tree_view)

        self.tree_view.setColumnHidden(0, True)
        self.tree_view.setColumnWidth(1, 27)
        self.tree_view.setColumnWidth(2, 27)
        self.tree_view.header().setResizeMode(1, QHeaderView.Fixed)
        
        hbox = QHBoxLayout()
        hbox.setContentsMargins(0, 0, 0, 0)
        hbox.setSpacing(10)
        
        self.cb = QComboBox()
        #self.cb.setFixedWidth(100)
        self.cb.setEditable(True)
        self.cb.setFixedHeight(35)
        self.cb.setMinimumWidth(1)
        cb_view = self.cb.view()
        cb_view.setAlternatingRowColors(True)

        self.paths_list = conf.get_save_dl_paths()

        if not self.paths_list:
            self.cb.addItem(cons.DLFOLDER_PATH)
        else:
            [self.cb.addItem(path) for path in reversed(self.paths_list)]

        hbox.addWidget(self.cb)
        
        btn_examine = QPushButton('...')
        btn_examine.clicked.connect(self.on_examine)
        btn_examine.setFixedHeight(35)
        btn_examine.setMaximumWidth(80)
        hbox.addWidget(btn_examine)
        
        hbox.addSpacing(40) #index, size
        
        btn_download = QPushButton()
        btn_download.setIcon(media.get_icon(media.DOWN, media.MEDIUM))
        btn_download.setIconSize(QSize(24, 24))
        btn_download.clicked.connect(self.on_download_selected)
        btn_download.setFixedHeight(35)
        btn_download.setMaximumWidth(40)
        hbox.addWidget(btn_download)
        
        btn_add = QPushButton()
        btn_add.setIcon(media.get_icon(media.ADD, media.MEDIUM))
        btn_add.setIconSize(QSize(24, 24))
        btn_add.clicked.connect(self.on_add_links)
        btn_add.setFixedHeight(35)
        btn_add.setMaximumWidth(40)
        hbox.addWidget(btn_add)
        
        self.menu = QMenu()
        import_action = self.menu.addAction(_("Import Container"), self.on_import_container)
        self.menu.addSeparator()
        recheck_action = self.menu.addAction(_("Re-check"), self.on_recheck)
        clear_action = self.menu.addAction(_("Clear list"), self.on_clear_list)

        btn_menu = QPushButton()
        btn_menu.setMenu(self.menu)
        btn_menu.setFixedHeight(35)
        btn_menu.setMaximumWidth(22)
        btn_menu.setFlat(True)
        hbox.addWidget(btn_menu)
        
        self.addLayout(hbox)

        #custom signals
        signals.add_downloads_to_check.connect(self.add_downloads_to_check)
        
        #update list
        self.timer = parent.idle_timeout(1000, self.update_)
Ejemplo n.º 3
0
    def __init__(self, downloads, parent=None):
        QVBoxLayout.__init__(self)
        self.setContentsMargins(0, 0, 0, 0)
        self.setSpacing(5)

        self.downloads = downloads
        self.parent = parent

        self.tree_view = QTreeView(parent)
        #
        self.tree_view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.tree_view.customContextMenuRequested.connect(self.context_menu)
        #
        #listview look
        self.tree_view.setWordWrap(True)  #search textElideMode
        self.tree_view.setRootIsDecorated(False)
        self.tree_view.setIndentation(0)
        self.tree_view.setAlternatingRowColors(True)
        #
        self.items = []
        self.rows_buffer = {}  #{id_item: row_obj, }
        #self.items = [[True, "1", "11", "t5est", "t3est"], [True, "1", "11", "t5est", "t3est"], [True, "1", "11", "t5est", "t3est"]]
        bool_cols = [
            1,
        ]
        headers = [
            "hidden_id_item", "",
            _("Status"),
            _("File Name"),
            _("Host"),
            _("Size"),
            _("Status Message")
        ]
        #
        self.__model = SimpleListModel(headers, self.items, bool_cols)
        self.tree_view.setModel(self.__model)
        self.addWidget(self.tree_view)
        #
        self.tree_view.setColumnHidden(0, True)
        self.tree_view.setColumnWidth(1, 27)
        self.tree_view.header().setResizeMode(1, QHeaderView.Fixed)

        hbox = QHBoxLayout()
        hbox.setContentsMargins(0, 0, 0, 0)
        hbox.setSpacing(10)

        self.cb = QComboBox()
        #self.cb.setFixedWidth(100)
        self.cb.setEditable(True)
        self.cb.setFixedHeight(35)
        self.cb.setMinimumWidth(1)
        cb_view = self.cb.view()
        cb_view.setAlternatingRowColors(True)
        #
        self.paths_list = conf.get_save_dl_paths()
        if not self.paths_list:
            self.cb.addItem(cons.DLFOLDER_PATH)
        else:
            [self.cb.addItem(path) for path in reversed(self.paths_list)]
        #
        hbox.addWidget(self.cb)

        btn_examine = QPushButton('...')
        btn_examine.clicked.connect(self.on_examine)
        btn_examine.setFixedHeight(35)
        btn_examine.setMaximumWidth(80)
        hbox.addWidget(btn_examine)

        hbox.addSpacing(40)  #index, size

        btn_download = QPushButton()
        btn_download.setIcon(media.get_icon(media.DOWN, media.MEDIUM))
        btn_download.setIconSize(QSize(24, 24))
        btn_download.clicked.connect(self.on_download_selected)
        btn_download.setFixedHeight(35)
        btn_download.setMaximumWidth(40)
        hbox.addWidget(btn_download)

        btn_add = QPushButton()
        btn_add.setIcon(media.get_icon(media.ADD, media.MEDIUM))
        btn_add.setIconSize(QSize(24, 24))
        btn_add.clicked.connect(self.on_add_links)
        btn_add.setFixedHeight(35)
        btn_add.setMaximumWidth(40)
        hbox.addWidget(btn_add)

        self.menu = QMenu(parent)
        import_action = self.menu.addAction(_("Import Container"),
                                            self.on_import_container)
        self.menu.addSeparator()
        recheck_action = self.menu.addAction(_("Re-check"), self.on_recheck)
        clear_action = self.menu.addAction(_("Clear list"), self.on_clear_list)
        #
        btn_menu = QPushButton()
        btn_menu.setMenu(self.menu)
        btn_menu.setFixedHeight(35)
        btn_menu.setMaximumWidth(22)
        btn_menu.setFlat(True)
        hbox.addWidget(btn_menu)

        self.addLayout(hbox)

        #update list
        parent.idle_timeout(1000, self.update)
Ejemplo n.º 4
0
    def __init__(self):
        QMainWindow.__init__(self)

        self.setWindowTitle(cons.APP_TITLE)
        self.setWindowIcon(
            QIcon(os.path.join(cons.MEDIA_PATH, "misc", "ochd.ico")))
        self.resize(MIN_WIDTH, MIN_HEIGHT)
        self.center()

        self.restore_wnd_geometry()

        self.stop = (QToolButton(), media.get_icon(media.STOP, media.MEDIUM),
                     _('Stop Download'), self.on_stop_download, False)
        self.start = (QToolButton(), media.get_icon(media.START, media.MEDIUM),
                      _('Start Download'), self.on_start_download, False)
        accounts = (QToolButton(), media.get_icon(media.ACCOUNTS,
                                                  media.MEDIUM), _('Accounts'),
                    self.on_accounts, True)
        preferences = (QToolButton(),
                       media.get_icon(media.PREFERENCES, media.MEDIUM),
                       _('Preferences'), self.on_preferences, True)
        about = (QToolButton(), media.get_icon(media.ABOUT, media.MEDIUM),
                 _('About'), self.on_about, True)

        self.menu = QMenu()
        preferences[BTN].setPopupMode(QToolButton.MenuButtonPopup)
        preferences[BTN].setMenu(self.menu)

        toolbar = Toolbar(
            self,
            [self.start, self.stop, None, accounts, preferences, None, about])

        self.toolbar = self.addToolBar(toolbar)

        #self.vbox = QVBoxLayout(self)

        #tabs
        self.previous_tab = None
        self.tab = QTabWidget(self)
        #
        self.downloads = Downloads(self)
        self.tab.addTab(self.downloads, _('Downloads'))
        #
        self.add_downloads = AddDownloads(self.downloads, self)
        self.tab_add_downloads = QWidget()
        self.tab_add_downloads.setLayout(self.add_downloads)
        self.tab.addTab(self.tab_add_downloads, _('Add downloads'))
        #
        #addons
        self.addons_manager = AddonsManager(self)
        self.addons_list = self.addons_manager.addons_list
        #...tabs
        self.addon_tab_widgets = []
        self.load_addon_tabs()
        #
        self.log = Log()
        self.tab_log = QWidget()
        self.tab_log.setLayout(self.log)
        self.tab.addTab(self.tab_log, _('Log'))
        #
        self.preferences = Preferences(self.addons_list, self)
        #self.tab.addTab(self.preferences, 'Preferences')
        #
        self.tab.currentChanged.connect(self.on_tab_switch)
        #
        self.setCentralWidget(self.tab)

        #status bar
        self.status_bar = StatusBar(self)
        self.setStatusBar(self.status_bar)

        #drop down menu
        [addon.set_menu_item() for addon in self.addons_list]
        #self.menu.addSeparator()
        #self.menu.addAction('Preferences', self.on_preferences)

        #system tray icon
        self.tray = Tray(self)
        if self.tray.available:
            self.can_close = False
        else:
            self.can_close = True

        #on select button state
        self.downloads.selectionModel().selectionChanged.connect(
            self.on_selected)

        #load session.
        self.load_session()

        #add core's event loop
        self.idle_timeout(500, self.queue_loop)

        #quit event
        events.connect(cons.EVENT_QUIT, self.event_close)

        self.show()