Skip to content

Commit

Permalink
add an about dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
knipknap committed Aug 27, 2023
1 parent 7b4d09e commit 8d79b21
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 0 deletions.
37 changes: 37 additions & 0 deletions btl/resources/icons/info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions btl/ui/about.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
from PySide import QtGui, QtCore
from btl import __version__
from .util import load_ui

__dir__ = os.path.dirname(__file__)
ui_path = os.path.join(__dir__, "about.ui")

class AboutDialog(QtGui.QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.form = load_ui(ui_path)
self.form.buttonBox.clicked.connect(self.form.reject)
self.form.labelVersion.setText(__version__)

def exec(self):
return self.form.exec()
109 changes: 109 additions & 0 deletions btl/ui/about.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>200</height>
</rect>
</property>
<property name="windowTitle">
<string>About</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>12</number>
</property>
<item>
<widget class="QLabel" name="aboutLabel">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Better Tool Library</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
<item row="1" column="1">
<widget class="QLabel" name="labelVersion">
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="text">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Homepage:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Version:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_3">
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="text">
<string notr="true">&lt;a href=&quot;https://github.com/knipknap/better-tool-library&quot;&gt;https://github.com/knipknap/better-tool-library&lt;/a&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
6 changes: 6 additions & 0 deletions btl/ui/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ..fcutil import add_tool_to_job, get_jobs, get_active_job
from .util import load_ui
from .preferences import PreferencesDialog
from .about import AboutDialog
from .tablecell import TwoLineTableCell
from .shapeselector import ShapeSelector
from .tooleditor import ToolEditor
Expand Down Expand Up @@ -65,6 +66,7 @@ def __init__(self, db, serializer, standalone=False, parent=None):
self.form.actionDelete.triggered.connect(self.on_delete_tool_clicked)
self.form.actionDuplicate.triggered.connect(self._duplicate_tool)
self.form.actionPreferences.triggered.connect(self.on_preferences_clicked)
self.form.actionAbout.triggered.connect(self.on_action_about_clicked)

if standalone:
self.form.pushButtonAddToJob.hide()
Expand Down Expand Up @@ -450,3 +452,7 @@ def on_preferences_clicked(self):
if not dialog.exec():
return
self.load()

def on_action_about_clicked(self):
dialog = AboutDialog()
dialog.exec()
31 changes: 31 additions & 0 deletions btl/ui/library.ui
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@
<addaction name="separator"/>
<addaction name="actionPreferences"/>
</widget>
<widget class="QMenu" name="menuAbout">
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="actionAbout"/>
</widget>
<addaction name="menuEdit"/>
<addaction name="menuAbout"/>
</widget>
</item>
<item>
Expand Down Expand Up @@ -301,6 +308,30 @@
<string notr="true">Ctrl+D</string>
</property>
</action>
<action name="actionCreate_Library">
<property name="text">
<string>Add a Library</string>
</property>
</action>
<action name="actionDelete_Library">
<property name="text">
<string>Delete Library</string>
</property>
</action>
<action name="actionCreate_Tool">
<property name="text">
<string>Create Tool</string>
</property>
</action>
<action name="actionAbout">
<property name="icon">
<iconset>
<normaloff>../resources/icons/info.svg</normaloff>../resources/icons/info.svg</iconset>
</property>
<property name="text">
<string>About</string>
</property>
</action>
</widget>
<resources/>
<connections/>
Expand Down

0 comments on commit 8d79b21

Please sign in to comment.