Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion dodo/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,26 @@
from __future__ import annotations
from PyQt6.QtCore import *
from PyQt6.QtWidgets import *
from PyQt6.QtGui import QIcon, QCloseEvent
from PyQt6.QtGui import QFontMetrics, QIcon, QCloseEvent
import logging
import os

from . import app
from . import commandbar
from . import panel
from . import settings

logger = logging.getLogger(__name__)

class TabBar(QTabBar):
def tabSizeHint(self, index: int) -> QSize:
size = super().tabSizeHint(index)
fm = QFontMetrics(self.font())
min_height = fm.height() + 16
if size.height() < min_height:
size.setHeight(min_height)
return size

class MainWindow(QMainWindow):
def __init__(self, a: app.Dodo):
super().__init__()
Expand All @@ -52,6 +62,15 @@ def __init__(self, a: app.Dodo):

self.tabs = QTabWidget()
self.tabs.setFocusPolicy(Qt.FocusPolicy.NoFocus)
tab_bar = TabBar()
self.tabs.setTabBar(tab_bar)
if settings.tab_font or settings.tab_font_size:
f = tab_bar.font()
if settings.tab_font:
f.setFamily(settings.tab_font)
if settings.tab_font_size:
f.setPointSize(settings.tab_font_size)
tab_bar.setFont(f)
# self.tabs.resize(1600, 800)
w.layout().addWidget(self.tabs)

Expand Down
24 changes: 21 additions & 3 deletions dodo/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from __future__ import annotations
from typing import Optional, Any, overload, Literal

from PyQt6.QtCore import Qt, QAbstractItemModel, QModelIndex, QObject, QSettings
from PyQt6.QtWidgets import QTreeView, QWidget, QAbstractSlider, QVBoxLayout, QLabel
from PyQt6.QtGui import QFont, QColor
from PyQt6.QtCore import Qt, QSize, QAbstractItemModel, QModelIndex, QObject, QSettings
from PyQt6.QtWidgets import QTreeView, QHeaderView, QWidget, QAbstractSlider, QVBoxLayout, QLabel
from PyQt6.QtGui import QFont, QFontMetrics, QColor
import subprocess
import json
import logging
Expand All @@ -36,6 +36,15 @@

columns = ['date', 'from', 'subject', 'tags']

class HeaderView(QHeaderView):
def sizeHint(self) -> QSize:
size = super().sizeHint()
fm = QFontMetrics(self.font())
min_height = fm.height() + 8
if size.height() < min_height:
size.setHeight(min_height)
return size

class SearchModel(QAbstractItemModel):
"""A model containing the results of a search"""

Expand Down Expand Up @@ -226,8 +235,17 @@ def __init__(self, a: app.Dodo, q: str, keep_open: bool=False, parent: Optional[
self.q = q
self.conf = QSettings("dodo", "dodo")
self.tree = QTreeView()
header = HeaderView(Qt.Orientation.Horizontal, self.tree)
self.tree.setHeader(header)
self.error_view = QLabel()
self.tree.setFocusPolicy(Qt.FocusPolicy.NoFocus)
if settings.header_font or settings.header_font_size:
f = header.font()
if settings.header_font:
f.setFamily(settings.header_font)
if settings.header_font_size:
f.setPointSize(settings.header_font_size)
header.setFont(f)
self.setStyleSheet(f'QTreeView::item {{ padding: {settings.search_view_padding}px }}')
self.model = SearchModel(q)
self.tree.setModel(self.model)
Expand Down
24 changes: 24 additions & 0 deletions dodo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,30 @@
Solarized and Gruvbox color palettes.
"""

tab_font = ''
"""The font used for tab titles

If empty, the system default is used.
"""

tab_font_size = 0
"""The font size used for tab titles

If 0, the system default is used.
"""

header_font = ''
"""The font used for column headers in the search panel (date, from, subject, tags)

If empty, the system default is used.
"""

header_font_size = 0
"""The font size used for column headers in the search panel

If 0, the system default is used.
"""

search_font = 'DejaVu Sans Mono'
"""The font used for search output and various other list-boxes"""

Expand Down