summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/preferences_dialog.py51
-rw-r--r--src/preferences_dialog.ui128
2 files changed, 137 insertions, 42 deletions
diff --git a/src/preferences_dialog.py b/src/preferences_dialog.py
index 7f39fb7..e6d4187 100644
--- a/src/preferences_dialog.py
+++ b/src/preferences_dialog.py
@@ -1,5 +1,7 @@
+import os
import sys
-from PyQt5.QtWidgets import QApplication, QDialog, QFileDialog, QFormLayout, QHBoxLayout, QLineEdit, QPushButton, QTabWidget, QVBoxLayout, QWidget
+from PyQt5 import uic
+from PyQt5.QtWidgets import QApplication, QDialog, QFileDialog
from src.config import Config
class PreferencesDialog(QDialog):
@@ -8,6 +10,7 @@ class PreferencesDialog(QDialog):
"""
def __init__(self):
super().__init__()
+ uic.loadUi(os.path.join("src", "preferences_dialog.ui"), self)
# class globals
self.config = Config()
@@ -15,58 +18,22 @@ class PreferencesDialog(QDialog):
self.initializeUI()
def initializeUI(self):
- self.resize(500, 320)
- self.setWindowTitle("Preferences")
self.displayWidgets()
self.exec()
def displayWidgets(self):
# TODO make this a scrollable window
# FIXME could use some work on sizing
- main_layout = QVBoxLayout()
- tab_bar = QTabWidget(self)
- paths_tab = self.pathsTabLayout()
+ self.pathsTabLayout()
- tab_bar.addTab(paths_tab, "Paths")
- main_layout.addWidget(tab_bar)
- main_layout.addStretch()
-
- buttons_hbox = QHBoxLayout()
- buttons_hbox.addStretch()
-
- close_button = QPushButton("Close", self)
- close_button.clicked.connect(self.close)
- buttons_hbox.addWidget(close_button)
-
- apply_button = QPushButton("Apply", self)
- apply_button.clicked.connect(self.apply)
- buttons_hbox.addWidget(apply_button)
-
- reload_button = QPushButton("Reload", self)
- reload_button.clicked.connect(self.reload)
- buttons_hbox.addWidget(reload_button)
-
- main_layout.addLayout(buttons_hbox)
- self.setLayout(main_layout)
+ self.close_button.clicked.connect(self.close)
+ self.apply_button.clicked.connect(self.apply)
+ self.reload_button.clicked.connect(self.reload)
def pathsTabLayout(self):
- output = QWidget()
- output_layout = QFormLayout()
-
- # Dialog for setting the database file path
- db_path_hbox = QHBoxLayout()
- self.db_path_edit = QLineEdit()
if "paths" in self.config.config:
self.db_path_edit.setText(self.config.config["paths"]["db_path"])
- db_path_hbox.addWidget(self.db_path_edit)
- db_path_button = QPushButton("...")
- db_path_button.setMaximumWidth(25)
- db_path_button.clicked.connect(self.dbPathDialog)
- db_path_hbox.addWidget(db_path_button)
- output_layout.addRow("Database File:", db_path_hbox)
-
- output.setLayout(output_layout)
- return output
+ self.db_path_button.clicked.connect(self.dbPathDialog)
def dbPathDialog(self):
file_dialog = QFileDialog(self)
diff --git a/src/preferences_dialog.ui b/src/preferences_dialog.ui
new file mode 100644
index 0000000..244eb26
--- /dev/null
+++ b/src/preferences_dialog.ui
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>500</width>
+ <height>320</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Preferences</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="main_layout">
+ <item>
+ <widget class="QTabWidget" name="tab_bar">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Paths</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QWidget" name="widget" native="true">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <layout class="QFormLayout" name="paths_tab_layout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="databaseFileLabel">
+ <property name="text">
+ <string>Database File:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QWidget" name="db_path_hbox" native="true">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLineEdit" name="db_path_edit"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="db_path_button">
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="buttons_hbox">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="close_button">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="apply_button">
+ <property name="text">
+ <string>Apply</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="reload_button">
+ <property name="text">
+ <string>Reload</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>