def __init__(self, song=None):
        super(Header, self).__init__()
        self.song = song
        self.settings = get_settings()

        self.layout = QGridLayout()
        self.layout.setMargin(0)
        self.layout.setContentsMargins(0, 0, 0, 25)

        self.setObjectName(u'header')
        self.setAttribute(Qt.WA_StyledBackground, True)
        self.setStyleSheet(
            css('''
            #header {
                border-bottom: 1px solid {{backgroundColor}};
            }
            ''',
                backgroundColor=colors.SECONDARY_COLOR))

        self.left_container = QWidget()
        self.left_container.setStyleSheet(
            css('color: {{color}};', color=colors.GREY_COLOR))
        self.left_container_layout = QHBoxLayout(alignment=Qt.AlignLeft)
        self.left_container_layout.setMargin(0)
        self.left_container.setLayout(self.left_container_layout)

        self.right_container = QWidget()
        self.right_container_layout = QHBoxLayout(alignment=Qt.AlignRight)
        self.right_container_layout.setMargin(0)
        self.right_container.setLayout(self.right_container_layout)

        self.layout.addWidget(self.left_container, 0, 0)
        self.layout.addWidget(self.right_container, 0, 1)

        # Info on the left
        songs_amount = len(
            self.song['songlist']) if self.song['full_release'] else len(
                [s for s in self.song['songlist'] if s['released']])
        songs_text = pluralize('song', 'songs', songs_amount)
        info_text = '{} · {}'.format(self.song['genre'], songs_text).upper()
        self.left_container_layout.addWidget(QLabel(info_text))

        # Download buttons on the right
        if 'download_links' in self.song:
            for item in self.song['download_links']:
                btn = IconButton(text=item['label'],
                                 icon='download',
                                 on_click=self.download(item))
                self.right_container_layout.addWidget(btn)

        self.setLayout(self.layout)
 def on_search_suggestions(self):
     logging.info('Received search suggestions for keywords: "{}"'.format(
         self.keywords))
     self.searchbar.setEnabled(True)
     self.searchbar.setFocus()
     if self.suggestions:
         suggestions = [
             suggestion['label'] for suggestion in self.suggestions
         ]
         completer = QCompleter(suggestions)
         completer.setCaseSensitivity(Qt.CaseInsensitive)
         self.searchbar.setCompleter(completer)
         self.searchbar.completer().complete()
         self.searchbar.completer().popup().setStyleSheet(
             css(
                 """
             QListView {
                 border: 1px solid {{borderColor}};
                 padding: 10px;
                 background: {{backgroundColor}};
             }
             QItemSelection {
                 padding: 10px;
             }
             """,
                 borderColor=colors.SECONDARY_COLOR,
                 backgroundColor=colors.PLACEHOLDER_COLOR,
             ))
    def __init__(self, **kwargs):
        super(SongPreview, self).__init__()
        self.artwork_content = None
        self.artwork_size = 300
        self.artwork = kwargs['artwork']
        self.title = kwargs['title']
        self.url = kwargs['url']

        if self.artwork is not None:
            self.thread = RunThread(self.fetch_artwork, self.on_artwork_loaded)

        self.layout = QVBoxLayout()

        self.artwork_label = QLabel()
        self.artwork_label.setStyleSheet(
            css('background-color: {{color}};',
                color=colors.PLACEHOLDER_COLOR))
        self.artwork_label.setFixedWidth(self.artwork_size)
        self.artwork_label.setFixedHeight(self.artwork_size)
        clickable(self.artwork_label).connect(self.on_click)
        self.layout.addWidget(self.artwork_label)

        title = QLabel(self.title)
        title.setWordWrap(True)
        title.setFixedWidth(300)
        self.layout.addWidget(title)

        self.setLayout(self.layout)
    def render_song_info(self):
        # Header
        self.page_layout.addWidget(Header(song=self.song))

        # Title
        title = H2(self.song['title'])
        title.setWordWrap(True)
        title.setStyleSheet('padding-top: 20px;')
        self.page_layout.addWidget(title)

        # Inner container that contains Image + Songlist
        inner_container = QWidget()
        inner_container_layout = QHBoxLayout(alignment=Qt.AlignTop
                                             | Qt.AlignLeft)
        inner_container_layout.setMargin(0)
        inner_container_layout.setSpacing(25)
        inner_container_layout.setContentsMargins(0, 25, 0, 0)
        inner_container.setLayout(inner_container_layout)
        self.page_layout.addWidget(inner_container)

        # Image
        self.artwork_label = QLabel()
        self.artwork_label.setStyleSheet(
            css('background-color: {{color}};',
                color=colors.PLACEHOLDER_COLOR))
        self.artwork_label.setFixedWidth(self.artwork_size)
        self.artwork_label.setFixedHeight(self.artwork_size)
        inner_container_layout.addWidget(self.artwork_label,
                                         alignment=Qt.AlignTop)
        self.get_artwork_thread = RunThread(self.fetch_artwork,
                                            self.on_artwork_loaded)

        # Songlist
        inner_container_layout.addWidget(
            Songlist(songlist=self.song['songlist']), alignment=Qt.AlignTop)
Beispiel #5
0
 def get_text(self):
     downloadColor = '#FF9800' if self.item['progress'] < 100 else '#4CAF50'
     return css(
         '<span style="color: {{downloadColor}};">({}%)</span> {}<br/><span style="color:#888;"><br/>Saved as {}/{}<br/>{} • {}</span>',
         downloadColor=downloadColor).format(self.item['progress'],
                                             self.item['title'],
                                             self.item['location'],
                                             self.item['filename'],
                                             self.item['quality'],
                                             timeago(self.item['created']))
    def __init__(self):
        super(SearchBar, self).__init__()
        self.layout = QVBoxLayout()
        self.layout.setMargin(0)
        self.setStyleSheet(
            css('border: 1px solid {{color}};', color=colors.SECONDARY_COLOR))

        self.searchbar = QLineEdit()
        self.searchbar.setPlaceholderText(
            'Try searching for an artist or album')
        self.searchbar.textChanged.connect(self.set_keywords)
        self.searchbar.returnPressed.connect(self.search)
        self.searchbar.setStyleSheet(
            css('''
            QLineEdit {
                padding: 10px;
                border-radius: 8px;
                background: {{backgroundColor}};
            }
            ''',
                backgroundColor=colors.PLACEHOLDER_COLOR))

        self.layout.addWidget(self.searchbar)
        self.setLayout(self.layout)
    def __init__(self, song=None, index=None):
        super(Song, self).__init__()
        self.song = song

        color = '#fff' if self.song['released'] else '#666'
        self.setStyleSheet(css('color: {{color}};', color=color))

        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.setSizePolicy(sizePolicy)

        self.layout = QHBoxLayout()
        self.layout.setMargin(0)
        label = '{}.  {}'.format(index, self.song['name'])
        self.layout.addWidget(QLabel(label))
        self.setLayout(self.layout)
Beispiel #8
0
    def __init__(self, item=None):
        super(DownloadItem, self).__init__()
        DownloadHistorySignal.put.connect(self.update)
        DownloadHistorySignal.progress.connect(self.update)
        self.artwork_size = 80
        self.item = item
        self.layout = QVBoxLayout()
        self.layout.setMargin(0)

        item_container = QWidget()
        item_container_layout = QHBoxLayout()
        item_container_layout.setMargin(0)
        item_container.setLayout(item_container_layout)

        self.artwork_label = QLabel(alignment=Qt.AlignLeft)
        self.artwork_label.setStyleSheet(
            css('background-color: {{color}};',
                color=colors.PLACEHOLDER_COLOR))
        self.artwork_label.setFixedWidth(self.artwork_size)
        self.artwork_label.setFixedHeight(self.artwork_size)
        item_container_layout.addWidget(self.artwork_label)
        self.render_artwork()

        self.item_label = QLabel(self.get_text())
        font = QFont()
        font.setKerning(False)
        self.item_label.setFont(font)
        self.item_label.setStyleSheet('padding: 0 10px;')
        item_container_layout.addWidget(self.item_label)

        self.retry_btn = IconButton(text='Retry', on_click=self.retry)
        self.retry_btn.setFixedHeight(40)
        self.retry_btn.setFixedWidth(60)
        item_container_layout.addWidget(self.retry_btn)
        if not self.item['retriable']:
            self.retry_btn.hide()

        delete_btn = IconButton(text='Delete', on_click=self.delete)
        delete_btn.setFixedHeight(40)
        delete_btn.setFixedWidth(70)
        item_container_layout.addWidget(delete_btn)

        self.layout.addWidget(item_container)

        self.progress_label = QLabel()
        self.layout.addWidget(self.progress_label)

        self.setLayout(self.layout)
Beispiel #9
0
 def add_total_downloads_widget(self):
     total_downloads_label_size = 19
     self.total_downloads_label = QLabel('1', self.downloads_menu_item)
     self.total_downloads_label.setAlignment(Qt.AlignCenter)
     self.total_downloads_label.hide()
     self.total_downloads_label.setFixedWidth(total_downloads_label_size)
     self.total_downloads_label.setFixedHeight(total_downloads_label_size)
     y = self.downloads_menu_item.sizeHint().height() / 2 - round(
         total_downloads_label_size / 2)
     x = self.sidebar_width - total_downloads_label_size * 3
     self.total_downloads_label.move(x, y)
     self.total_downloads_label.setStyleSheet(
         css('''
         text-align: center;
         background: {{backgroundColor}};
         padding: 2px;
         border-radius: 9px;
         ''',
             backgroundColor=colors.GREY_COLOR))
Beispiel #10
0
    def __init__(self,
                 text=None,
                 icon=None,
                 on_click=None,
                 defaultColor=colors.SECONDARY_COLOR,
                 hoverColor=colors.PRIMARY_COLOR):
        super(IconButton, self).__init__()
        clickable(self).connect(on_click)

        self.setAttribute(Qt.WA_StyledBackground, True)
        self.setObjectName(u'button')
        alignment = Qt.AlignLeft if icon is not None else Qt.AlignCenter
        self.layout = QHBoxLayout(alignment=alignment)

        icon_label = QLabel()
        icon_label.setPixmap(QIcon(':/icons/24x24/{}'.format(icon)).pixmap(24))

        if icon is not None:
            self.layout.addWidget(icon_label)
        self.layout.addWidget(QLabel(text))

        self.setStyleSheet(css(
            '''
            #button {
                border-radius: 8px;
                background-color: transparent;
                background-color: {{defaultColor}};
            }
            #button:hover {
                background-color: {{hoverColor}};
            }
            QLabel {
                background-color: transparent;
            }
            ''',
            defaultColor=defaultColor,
            hoverColor=hoverColor
        ))

        self.setLayout(self.layout)
 def __init__(self, text):
     super(FieldLabel, self).__init__(text.upper())
     self.setStyleSheet(css('color: {{color}};', color=colors.GREY_COLOR))