Skip to content

Commit

Permalink
Merge progress bars into single source file
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo committed Jun 16, 2024
1 parent 45ad0f8 commit 43cdc84
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""
novelWriter – Custom Widget: Progress Circle
============================================
novelWriter – Custom Widget: Progress Bars
==========================================
File History:
Created: 2023-06-07 [2.1b1]
Created: 2023-06-07 [2.1b1] NProgressCircle
Created: 2023-06-09 [2.1b1] NProgressSimple
This file is a part of novelWriter
Copyright 2018–2024, Veronica Berglyd Olsen
Expand Down Expand Up @@ -101,3 +102,25 @@ def paintEvent(self, event: QPaintEvent) -> None:
painter.setPen(self._tColor)
painter.drawText(self._cRect, QtAlignCenter, self._text or f"{progress:.1f} %")
return


class NProgressSimple(QProgressBar):
"""Extension: Simple Progress Widget
A custom widget that paints a plain bar with no other styling.
"""

def __init__(self, parent: QWidget) -> None:
super().__init__(parent=parent)
return

def paintEvent(self, event: QPaintEvent) -> None:
"""Custom painter for the progress bar."""
if (value := self.value()) > 0:
progress = ceil(self.width()*float(value)/self.maximum())
painter = QPainter(self)
painter.setRenderHint(QtPaintAnitAlias, True)
painter.setPen(self.palette().highlight().color())
painter.setBrush(self.palette().highlight())
painter.drawRect(0, 0, progress, self.height())
return
53 changes: 0 additions & 53 deletions novelwriter/extensions/simpleprogress.py

This file was deleted.

2 changes: 1 addition & 1 deletion novelwriter/tools/manusbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from novelwriter.core.item import NWItem
from novelwriter.enum import nwBuildFmt
from novelwriter.extensions.modified import NDialog, NIconToolButton
from novelwriter.extensions.simpleprogress import NProgressSimple
from novelwriter.extensions.progressbars import NProgressSimple
from novelwriter.types import QtAlignCenter, QtDialogClose, QtRoleAction, QtRoleReject, QtUserRole

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion novelwriter/tools/manuscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
from novelwriter.core.docbuild import NWBuildDocument
from novelwriter.core.tokenizer import HeadingFormatter
from novelwriter.core.toqdoc import TextDocumentTheme, ToQTextDocument
from novelwriter.extensions.circularprogress import NProgressCircle
from novelwriter.extensions.modified import NIconToggleButton, NIconToolButton, NToolDialog
from novelwriter.extensions.progressbars import NProgressCircle
from novelwriter.gui.theme import STYLES_FLAT_TABS, STYLES_MIN_TOOLBUTTON
from novelwriter.tools.manusbuild import GuiManuscriptBuild
from novelwriter.tools.manussettings import GuiBuildSettings
Expand Down

0 comments on commit 43cdc84

Please sign in to comment.