Skip to content

Commit

Permalink
Make GalacteekStyle configurable
Browse files Browse the repository at this point in the history
Show human IP handles in the peers UI
  • Loading branch information
cipres authored and cipres committed Feb 15, 2021
1 parent 29a7691 commit 94da53c
Show file tree
Hide file tree
Showing 18 changed files with 185 additions and 79 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ This software incudes icons made by the following FlatIcon authors:
- `FreePik <https://www.flaticon.com/authors/freepik>`_
- `Pixel perfect <https://www.flaticon.com/authors/pixel-perfect>`_
- `Kiranshastry <https://www.flaticon.com/authors/Kiranshastry>`_
- `Smashicons <https://smashicons.com>`_

Some of the beautiful artwork (under the Creative Commons CC-BY-SA license)
from the ipfs-logo_ project's repository is included, unchanged.
Expand Down
5 changes: 1 addition & 4 deletions galacteek/core/iphandle.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ def username(self):
@property
def human(self):
if self.valid:
return ipHandleGen(
self.m.group('username'),
self.m.group('vplanet')
)
return f'{self.username}@{self.vPlanet}'

@property
def short(self):
Expand Down
7 changes: 4 additions & 3 deletions galacteek/i18n/blackhole.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ def iConfigurationEditor():
def iConfigurationEditorWarning():
return QCoreApplication.translate(
'GalacteekWindow',
'Change the settings <b>with caution</b>.'
'<p>Hit <b>Enter</b> after changing a setting.</p>'
'<p>Be careful with the settings you change. '
'Start the application with <b>--config-defaults</b> '
'if something goes wrong, to use the default configuration settings'
)
'if something goes wrong, to use the default '
'configuration settings</p>')


def iEventLog():
Expand Down
2 changes: 1 addition & 1 deletion galacteek/templates/ipfssearch.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
});

window.ipfssearch.searchTimeout.connect(function(timeout) {
document.getElementById('statusmessage').innerHTML = "<b>Search timeout</b>"
document.getElementById('statusmessage').innerHTML = '<b>Search timeout</b><a href="#" onclick="event.preventDefault(); window.ipfssearch.searchRetry();">Retry</a>'
statusWaiting()
})

Expand Down
23 changes: 22 additions & 1 deletion galacteek/ui/config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
envs:
default:
theme: moon3
# Theme used
theme: 'moon3'

objectOpener:
mimeTypes:
default:
slowObjectTimer: 6

styles:
# galacteek Qt style
galacteek:
styleType: 'desktopGeneric'

desktopGeneric:
# Pixel metrics
metrics:
toolBarIconSize: 32
toolBarItemSpacing: 2
toolBarItemMargin: 0
toolBarSeparatorExtent: 2

buttonDefaultIconSize: 16

tabBarIconSize: 16
textCursorWidth: 12

scrollBarExtent: 32
4 changes: 2 additions & 2 deletions galacteek/ui/dwebspace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ def __init__(self, parent=None):
hLayout = QHBoxLayout(self)
self.setLayout(hLayout)

self.toolBar = QToolBar(self)
self.toolBar = QToolBar()
self.toolBar.setSizePolicy(
QSizePolicy.Expanding, QSizePolicy.Expanding)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
hLayout.addItem(
QSpacerItem(20, 10, QSizePolicy.Maximum, QSizePolicy.Expanding))
QSpacerItem(40, 0, QSizePolicy.Expanding, QSizePolicy.Maximum))
hLayout.addWidget(self.toolBar)


Expand Down
18 changes: 9 additions & 9 deletions galacteek/ui/forms/mediaplaylist.ui
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="queueFromClipboard">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Load multimedia content from the current clipboard object (can be a multimedia file or a directory)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<widget class="QToolButton" name="playlistButton">
<property name="text">
<string>Queue from clipboard</string>
<string>Playlist</string>
</property>
<property name="icon">
<iconset resource="../galacteek.qrc">
<normaloff>:/share/icons/clipboard.png</normaloff>:/share/icons/clipboard.png</iconset>
<normaloff>:/share/icons/playlist.png</normaloff>:/share/icons/playlist.png</iconset>
</property>
<property name="iconSize">
<size>
Expand All @@ -42,13 +39,16 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="playlistButton">
<widget class="QToolButton" name="queueFromClipboard">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Load multimedia content from the current clipboard object (can be a multimedia file or a directory)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Playlist</string>
<string>Queue from clipboard</string>
</property>
<property name="icon">
<iconset resource="../galacteek.qrc">
<normaloff>:/share/icons/playlist.png</normaloff>:/share/icons/playlist.png</iconset>
<normaloff>:/share/icons/clipboard.png</normaloff>:/share/icons/clipboard.png</iconset>
</property>
<property name="iconSize">
<size>
Expand Down
24 changes: 23 additions & 1 deletion galacteek/ui/mediaplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ def __init__(self, gWindow):
self.savePlaylistAction = QAction(getIcon('save-file.png'),
'Save playlist', self,
triggered=self.onSavePlaylist)
self.clearPlaylistAction = QAction('Clear', self,
triggered=self.onClearPlaylist)
self.savePlaylistAction.setEnabled(False)
self.copyPathAction = QAction(getIconIpfsIce(),
iCopyPlaylistPath(), self,
Expand All @@ -232,6 +234,8 @@ def __init__(self, gWindow):
iLoadPlaylistFromPath(), self,
triggered=self.onLoadPlaylistPath)

self.pMenu.addAction(self.clearPlaylistAction)
self.pMenu.addSeparator()
self.pMenu.addAction(self.savePlaylistAction)
self.pMenu.addSeparator()

Expand Down Expand Up @@ -293,6 +297,8 @@ def __init__(self, gWindow):

self.togglePList = GLargeToolButton(parent=self)
self.togglePList.setIcon(getIcon('playlist.png'))
self.togglePList.setText('Playlist')
self.togglePList.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
self.togglePList.setCheckable(True)
self.togglePList.toggled.connect(self.onTogglePlaylist)

Expand Down Expand Up @@ -780,6 +786,20 @@ def endInsertItems(self):
def changeItems(self, start, end):
self.dataChanged.emit(self.index(start, 0), self.index(end, 1))

def basenameForIndex(self, index):
if index.column() == 0:
media = self.playlist.media(index.row())
if media is None:
return iUnknown()
location = media.canonicalUrl()
path = location.path()
basename = posixpath.basename(path)

if basename:
return basename
else:
return path

def data(self, index, role=Qt.DisplayRole):
if not index.isValid():
return
Expand All @@ -797,7 +817,9 @@ def data(self, index, role=Qt.DisplayRole):
else:
return path
return self.m_data[index]
elif role == Qt.FontRole:
elif role == Qt.ToolTipRole:
return self.basenameForIndex(index)
elif role == Qt.FontRole and 0:
curPlIndex = self.playlist.currentIndex()

font = QFont('Times', pointSize=12)
Expand Down
2 changes: 1 addition & 1 deletion galacteek/ui/peers.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def data(self, column, role):
if role == Qt.DisplayRole or role == Qt.EditRole:
if column == 0:
if handle.valid:
return handle.short
return handle.human
else:
return iUnknown()
if column == 1:
Expand Down
1 change: 1 addition & 0 deletions galacteek/ui/pyramids.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def __init__(self, *args, **kw):
)
self.menu.setTitle(iPyramidDropObject())
self.menu.setIcon(getIcon('pyramid-blue.png'))
self.setIconSize(QSize(32, 32))
self.setToolTip(iPyramidDropper())


Expand Down
71 changes: 66 additions & 5 deletions galacteek/ui/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,83 @@
from PyQt5.QtWidgets import QStyle
from PyQt5.QtWidgets import QProxyStyle

from galacteek import cached_property
from galacteek.config import cGet


class GalacteekStyle(QProxyStyle):
"""
Galacteek UI style (configurable)
The configuration and the properties are cached for fast lookup
(will need restart for changes to take effect)
"""
def __init__(self, baseStyle='Fusion'):
super().__init__(baseStyle)

@cached_property
def cStyle(self):
sType = cGet('styles.galacteek.styleType',
mod='galacteek.ui')
if not sType:
sType = 'desktopGeneric'

return cGet(f'styles.galacteek.{sType}',
mod='galacteek.ui')

@cached_property
def cToolBarIconSize(self):
return self.cStyle.metrics.toolBarIconSize

@cached_property
def cToolBarItemMargin(self):
return self.cStyle.metrics.toolBarItemMargin

@cached_property
def cToolBarItemSpacing(self):
return self.cStyle.metrics.toolBarItemSpacing

@cached_property
def cToolBarSeparatorExtent(self):
return self.cStyle.metrics.toolBarSeparatorExtent

@cached_property
def cTabBarIconSize(self):
return self.cStyle.metrics.tabBarIconSize

@cached_property
def cTbIconSize(self):
return self.cStyle.metrics.toolBarIconSize

@cached_property
def cTextCursorWidth(self):
return self.cStyle.metrics.textCursorWidth

@cached_property
def cScrollBarExtent(self):
return self.cStyle.metrics.scrollBarExtent

@cached_property
def cButtonDefaultIconSize(self):
return self.cStyle.metrics.buttonDefaultIconSize

def pixelMetric(self, metric, option, widget):
if metric == QStyle.PM_ToolBarIconSize:
return 24
return self.cToolBarIconSize
elif metric == QStyle.PM_ToolBarSeparatorExtent:
return self.cToolBarSeparatorExtent
elif metric == QStyle.PM_TextCursorWidth:
return 10
return self.cTextCursorWidth
elif metric == QStyle.PM_TabBarIconSize:
return 16
return self.cTabBarIconSize
elif metric == QStyle.PM_ToolBarItemSpacing:
return 0
return self.cToolBarItemSpacing
elif metric == QStyle.PM_ToolBarItemMargin:
return 0
return self.cToolBarItemMargin
elif metric == QStyle.PM_ScrollBarExtent:
return self.cScrollBarExtent
elif metric == QStyle.PM_ButtonIconSize:
return self.cButtonDefaultIconSize
elif metric == QStyle.PM_TreeViewIndentation:
return 25
else:
Expand Down
5 changes: 3 additions & 2 deletions galacteek/ui/themes/fonts.qss
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
font: 12pt "Segoe UI";
}

QTreeView, QListView
QTreeView::item, QListView::item, QTreeWidget::item, QListWidget::item
{
font-size: 14pt;
}

QListView::item:selected, QTreeView::item:selected {
QTreeView::item:selected, QListView::item:selected, QTreeWidget::item:selected, QListWidget::item:selected
{
font-size: 16pt;
}
1 change: 1 addition & 0 deletions galacteek/ui/themes/moon3/galacteek.qss
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ QMenu
color: #eff0f1;
margin: 2px;
border: 1px solid lightgray;
font-size: 14pt;
}

QMenu::icon
Expand Down
Binary file modified share/icons/playlist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions share/static/misc/welcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ Welcome to the dweb

**galacteek** is a browser for the distributed web (AKA the
dweb). It works with the [IPFS](ipns://ipfs.io) protocol,
which uses content-addressing to distribute content
more efficiently between people.
which uses the concept of content-addressing to distribute
information more efficiently.

Donate
------
Donations
---------

**galacteek** will always be opensource and hopefully free of charge.
If you use the software and want to contribute to its improvement,
please [make a donation](https://liberapay.com/galacteek/donate)
(also with [GitHub](https://github.com/sponsors/pinnaculum))
(also with [GitHub Sponsors](https://github.com/sponsors/pinnaculum))

You can also donate via Bitcoin at the following address:

Expand Down
Loading

0 comments on commit 94da53c

Please sign in to comment.