add a help dialog

This commit is contained in:
Andreas Zweili 2019-02-18 16:26:38 +01:00
parent e834f350b7
commit 5fb21b0f76
6 changed files with 2254 additions and 0 deletions

View File

@ -122,6 +122,10 @@ class Config(QDialog):
def schedule_predefined_name(self):
return self._return_single_option('schedule_predefined_name')
@property
def hide_help(self):
return util.strtobool(self._return_single_option('hide_help'))
def _return_single_option(self, option):
"""Gets the provided option from the configparser object."""
if option in self.config['borgqt']:

19
borg_qt/help.py Normal file
View File

@ -0,0 +1,19 @@
import os
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDialog
from PyQt5 import uic
from PyQt5.QtGui import QIcon, QPixmap
class Help(QDialog):
"""A class to display the help dialog."""
def __init__(self):
super(QDialog, self).__init__()
# Load the UI file to get the dialogs layout.
dir_path = os.path.dirname(os.path.realpath(__file__))
ui_path = os.path.join(dir_path + '/static/UI/Help.ui')
uic.loadUi(ui_path, self)
self.button_box.accepted.connect(self.accept)

View File

@ -9,6 +9,7 @@ from PyQt5.QtWidgets import (QMainWindow, QFileSystemModel, QFileDialog,
from config import Config
from helper import (BorgException, show_error, convert_size, open_path,
create_path, remove_path, check_path)
from help import Help
import borg_interface as borg
from progress import ProgressDialog
@ -56,6 +57,7 @@ class MainWindow(QMainWindow):
self.action_restore.triggered.connect(self.restore_backup)
self.action_delete.triggered.connect(self.delete_backup)
self.action_mount.triggered.connect(self.mount_backup)
self.action_help.triggered.connect(self.show_help)
def start(self):
"""This method is intendet to be used only once at the application
@ -63,6 +65,11 @@ class MainWindow(QMainWindow):
environment variables."""
try:
self.config.read()
# show the help window if needed and save it's answer
if not self.config.hide_help:
self.config.config['borgqt']['hide_help'] = (
str(self.show_help()))
self.config.write()
self.config._set_environment_variables()
self._update_archives()
self._update_repository_stats()
@ -136,6 +143,13 @@ class MainWindow(QMainWindow):
self, "Select Directory", os.getenv('HOME')))
return folder_name
def show_help(self):
"""Diplays the help dialog with some informations about the
application."""
help_window = Help()
help_window.exec_()
return help_window.check_hide_enabled.isChecked()
@property
def selected_archive(self):
return self.list_archive.currentItem().text()

454
borg_qt/static/UI/Help.ui Normal file
View File

@ -0,0 +1,454 @@
<?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>1088</width>
<height>809</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="button_box">
<property name="geometry">
<rect>
<x>350</x>
<y>770</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="check_hide_enabled">
<property name="geometry">
<rect>
<x>20</x>
<y>770</y>
<width>211</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Don't show this window again.</string>
</property>
</widget>
<widget class="QLabel" name="label_image">
<property name="geometry">
<rect>
<x>273</x>
<y>10</y>
<width>802</width>
<height>738</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>main_window.png</pixmap>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>251</width>
<height>741</height>
</rect>
</property>
<layout class="QVBoxLayout" name="layout_description">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item>
<widget class="QLabel" name="label_file_tree">
<property name="maximumSize">
<size>
<width>230</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>1. Filetree</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_file_tree_text">
<property name="maximumSize">
<size>
<width>230</width>
<height>650</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>The file tree displays your current files on your computer. It doesn't show the content of the selected archive.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_backup_button">
<property name="maximumSize">
<size>
<width>230</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>2. Backup Button</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_backup_button_text">
<property name="maximumSize">
<size>
<width>230</width>
<height>650</height>
</size>
</property>
<property name="text">
<string>After you selected a file or folder in the file tree you can create a backup from it by clicking on the &quot;Backup&quot; button.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_archive_list">
<property name="maximumSize">
<size>
<width>230</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>3. Archive List</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_archive_list_text">
<property name="maximumSize">
<size>
<width>230</width>
<height>65</height>
</size>
</property>
<property name="text">
<string>Once an action like &quot;Backup&quot; or &quot;Delete&quot; completes the archive list gets updated.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_repository_details">
<property name="maximumSize">
<size>
<width>230</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>4. Repository Details</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_repository_details_text">
<property name="maximumSize">
<size>
<width>230</width>
<height>65</height>
</size>
</property>
<property name="text">
<string>In addition the repository details will update and display the current statistic about the repository's size.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_restore_button">
<property name="maximumSize">
<size>
<width>230</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>5. Restore/Delete Button</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_restore_button_text">
<property name="maximumSize">
<size>
<width>230</width>
<height>65</height>
</size>
</property>
<property name="text">
<string>Select an archive from the list (3) and click on &quot;Restore&quot; to restore it to a location of your choice or click on &quot;Delete&quot; to remove it.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_mount_button">
<property name="maximumSize">
<size>
<width>230</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>6. Mount Button</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_mount_button_text">
<property name="maximumSize">
<size>
<width>230</width>
<height>65</height>
</size>
</property>
<property name="text">
<string>The &quot;Mount&quot; button let's you mount the selected archive as read only directory. This is a great way to restore a few files by hand.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_settings_button">
<property name="maximumSize">
<size>
<width>230</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>7. Settings Button</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_settings_button_text">
<property name="maximumSize">
<size>
<width>230</width>
<height>65</height>
</size>
</property>
<property name="text">
<string>Let's you customise the settings of Borg-Qt like which files to backup or exclude or a schedule for automatic backups.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_help_button">
<property name="maximumSize">
<size>
<width>230</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>8. Help Button</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_help_button_text">
<property name="maximumSize">
<size>
<width>230</width>
<height>65</height>
</size>
</property>
<property name="text">
<string>Diplays this window again.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QFrame" name="frame_text">
<property name="geometry">
<rect>
<x>5</x>
<y>10</y>
<width>260</width>
<height>738</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>260</width>
<height>738</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
<widget class="QFrame" name="frame_image">
<property name="geometry">
<rect>
<x>273</x>
<y>10</y>
<width>802</width>
<height>738</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>802</width>
<height>738</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>802</width>
<height>738</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
<zorder>frame_text</zorder>
<zorder>button_box</zorder>
<zorder>check_hide_enabled</zorder>
<zorder>label_image</zorder>
<zorder>verticalLayoutWidget</zorder>
<zorder>frame_image</zorder>
</widget>
<resources/>
<connections>
<connection>
<sender>button_box</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_box</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

1763
docs/help_main_window.svg Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 123 KiB