|
|
|
@ -31,10 +31,10 @@ class ToolsWidget (QtGui.QWidget):
|
|
|
|
|
|
|
|
|
|
# self.move(100+parent.frameGeometry().x(), \
|
|
|
|
|
# 100+parent.frameGeometry().y())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.setFixedSize(450, 300)
|
|
|
|
|
self.setWindowTitle(_('Tools'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.setWindowIcon(QtGui.QIcon.fromTheme("preferences-other"))
|
|
|
|
|
# for clear memory after closed this window
|
|
|
|
|
self.setAttribute(QtCore.Qt.WA_ShowModal)
|
|
|
|
@ -46,26 +46,24 @@ class ToolsWidget (QtGui.QWidget):
|
|
|
|
|
- self.size().width() / 2, \
|
|
|
|
|
window.geometry().y() + window.geometry().height() / 2 \
|
|
|
|
|
- self.size().height() / 2)
|
|
|
|
|
|
|
|
|
|
gui_signal = QtCore.Signal()
|
|
|
|
|
other_signal = QtCore.Signal()
|
|
|
|
|
|
|
|
|
|
def create(self, parent, ClientObj):
|
|
|
|
|
|
|
|
|
|
if self.layout():
|
|
|
|
|
for i in range(self.layout().count()):
|
|
|
|
|
child = self.layout().takeAt(0)
|
|
|
|
|
child.widget().hide()
|
|
|
|
|
child.widget().destroy()
|
|
|
|
|
del (child)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Add clear config button
|
|
|
|
|
clear_icon = QtGui.QIcon.fromTheme("edit-delete-page")
|
|
|
|
|
clear_button = QtGui.QPushButton (clear_icon, _('Clear config'),self)
|
|
|
|
|
clear_button.clicked.connect(self.clear_config(parent, ClientObj))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.vlayout.addWidget(clear_button)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tab = ToolTabWidget(self, ClientObj)
|
|
|
|
|
tab.resize(tab.sizeHint())
|
|
|
|
|
self.vlayout.addWidget(tab)
|
|
|
|
@ -75,7 +73,7 @@ class ToolsWidget (QtGui.QWidget):
|
|
|
|
|
self.botton_layout = QtGui.QHBoxLayout(botton_wgt)
|
|
|
|
|
self.botton_layout.setContentsMargins(0,0,0,0)
|
|
|
|
|
self.botton_layout.setAlignment(QtCore.Qt.AlignRight)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toolOk = QtGui.QPushButton(_('Ok'), self)
|
|
|
|
|
toolOk.setFixedWidth(50)
|
|
|
|
|
toolOk.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Return))
|
|
|
|
@ -87,7 +85,7 @@ class ToolsWidget (QtGui.QWidget):
|
|
|
|
|
toolApply.setFixedWidth(100)
|
|
|
|
|
toolApply.clicked.connect(self.save_changes(ClientObj, tab))
|
|
|
|
|
self.botton_layout.addWidget(toolApply)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toolQuit = QtGui.QPushButton(_('Cancel'), self)
|
|
|
|
|
toolQuit.setFixedWidth(100)
|
|
|
|
|
toolQuit.clicked.connect(self.close)
|
|
|
|
@ -128,17 +126,17 @@ class ToolTabWidget(QtGui.QTabWidget):
|
|
|
|
|
def __init__(self, parent, ClientObj):
|
|
|
|
|
QtGui.QTabWidget.__init__(self, parent)
|
|
|
|
|
self.ClientObj = ClientObj
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.GuiWidget = ToolGui(self, ClientObj)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.OtherWidget = ToolOther(self, ClientObj)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.gui_icon = QtGui.QIcon.fromTheme("video-display")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.other_icon = QtGui.QIcon.fromTheme("preferences-other")
|
|
|
|
|
if self.other_icon.isNull():
|
|
|
|
|
self.other_icon = QtGui.QIcon.fromTheme("preferences-desctop")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.addTab(self.GuiWidget, self.gui_icon ,_('Gui Tools'))
|
|
|
|
|
self.addTab(self.OtherWidget, self.other_icon, _('Other Tools'))
|
|
|
|
|
|
|
|
|
@ -146,7 +144,7 @@ class ToolTabWidget(QtGui.QTabWidget):
|
|
|
|
|
self.cur_tab_num = 0
|
|
|
|
|
self.changed_flag = False
|
|
|
|
|
self.currentChanged.connect(self.save_mess)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
|
|
|
|
|
|
|
|
|
gui_signal = QtCore.Signal()
|
|
|
|
@ -155,14 +153,14 @@ class ToolTabWidget(QtGui.QTabWidget):
|
|
|
|
|
def save_mess(self, tab_num):
|
|
|
|
|
# change tab with unsaved changes
|
|
|
|
|
tab_list = [_('Gui Tools'),_('Other Tools')]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.changed_flag:
|
|
|
|
|
text = _('In the %s tab has unsaved changes') \
|
|
|
|
|
%tab_list[self.cur_tab_num]
|
|
|
|
|
informative_text = _('<center>Apply them?</center>')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reply = show_question(self.parent(), text, informative_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if reply == QtGui.QMessageBox.Yes:
|
|
|
|
|
if self.cur_tab_num == 0:
|
|
|
|
|
self.gui_signal.connect \
|
|
|
|
@ -172,10 +170,10 @@ class ToolTabWidget(QtGui.QTabWidget):
|
|
|
|
|
self.other_signal.connect \
|
|
|
|
|
(self.OtherWidget.save_changes(self.ClientObj))
|
|
|
|
|
self.other_signal.emit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.changed_flag = False
|
|
|
|
|
self.removeTab(self.cur_tab_num)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.cur_tab_num == 0:
|
|
|
|
|
self.GuiWidget = ToolGui(self, self.ClientObj)
|
|
|
|
|
self.insertTab(self.cur_tab_num, self.GuiWidget, \
|
|
|
|
@ -184,7 +182,7 @@ class ToolTabWidget(QtGui.QTabWidget):
|
|
|
|
|
self.OtherWidget = ToolOther(self, self.ClientObj)
|
|
|
|
|
self.insertTab(self.cur_tab_num, self.OtherWidget, \
|
|
|
|
|
self.other_icon, _('Other Tools'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.cur_tab_num = tab_num
|
|
|
|
|
self.changed_flag = False
|
|
|
|
|
|
|
|
|
@ -194,15 +192,15 @@ class ToolGui(QtGui.QWidget):
|
|
|
|
|
QtGui.QWidget.__init__(self, parent)
|
|
|
|
|
self.user_config = ClientObj.user_config
|
|
|
|
|
self._parent = parent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.grid = QtGui.QGridLayout(self)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.grid.setContentsMargins(2,2,2,2)
|
|
|
|
|
self.grid.setSpacing(2)
|
|
|
|
|
self.grid.setColumnStretch(0,3)
|
|
|
|
|
self.grid.setColumnStretch(1,5)
|
|
|
|
|
# self.grid.setAlignment(QtCore.Qt.AlignLeft)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# background color settings
|
|
|
|
|
self.bg_color = ClientObj.method_background_color
|
|
|
|
|
self.color_lbl = LabelWordWrap(_('Select Color'), self)
|
|
|
|
@ -212,7 +210,7 @@ class ToolGui(QtGui.QWidget):
|
|
|
|
|
self.color_button = QtGui.QPushButton(color_icon, \
|
|
|
|
|
ClientObj.method_background_color,self)
|
|
|
|
|
self.color_button.setToolTip(_('Format RGB (Red Green Blue)'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def color_dialog():
|
|
|
|
|
def color_select(color):
|
|
|
|
|
red = str(color.red())
|
|
|
|
@ -221,95 +219,54 @@ class ToolGui(QtGui.QWidget):
|
|
|
|
|
|
|
|
|
|
self.bg_color = red + ' ' + green + ' ' + blue
|
|
|
|
|
self.color_button.setText(self.bg_color)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.colordialog = QColorDialog(self)
|
|
|
|
|
self.colordialog.setWindowModality \
|
|
|
|
|
(QtCore.Qt.WindowModality.WindowModal)
|
|
|
|
|
self.colordialog.colorSelected.connect(color_select)
|
|
|
|
|
|
|
|
|
|
self.colordialog.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.color_button.clicked.connect(color_dialog)
|
|
|
|
|
|
|
|
|
|
#add background color settings in grid
|
|
|
|
|
self.grid.addWidget(self.color_lbl,0,0)
|
|
|
|
|
self.grid.addWidget(self.color_button,0,1)
|
|
|
|
|
|
|
|
|
|
# # add open background image in grid
|
|
|
|
|
# self.cert_bg_image_lbl = LabelWordWrap(_('Path to bg Image'), self)
|
|
|
|
|
# self.cert_bg_image_lbl.setMaximumWidth \
|
|
|
|
|
# (self.cert_bg_image_lbl.sizeHint().width())
|
|
|
|
|
#
|
|
|
|
|
# self.fd_bg_image = FileOpenWgt \
|
|
|
|
|
# (self, 'file', _('Select Background Image'), '~/')
|
|
|
|
|
#
|
|
|
|
|
# self.fd_bg_image.setText(ClientObj.background_image)
|
|
|
|
|
#
|
|
|
|
|
# self.fd_bg_image.setToolTip(_('Enter "No" to remove Background'))
|
|
|
|
|
#
|
|
|
|
|
# self.grid.addWidget(self.cert_bg_image_lbl, 1, 0)
|
|
|
|
|
# self.grid.addWidget(self.fd_bg_image, 1, 1)
|
|
|
|
|
#
|
|
|
|
|
# # repeat background settings
|
|
|
|
|
# self.repeat_lbl = LabelWordWrap(_('Select repeat background'), self)
|
|
|
|
|
# self.repeat_lbl.setMaximumWidth(self.repeat_lbl.sizeHint().width())
|
|
|
|
|
#
|
|
|
|
|
# self.repeat_ComboBox = QComboBox(self)
|
|
|
|
|
# repeat_dict = {'no-repeat':_('no repeat'), \
|
|
|
|
|
# 'repeat-xy':_('repeat for x and y'), \
|
|
|
|
|
# 'repeat-x': _('repeat for x'), \
|
|
|
|
|
# 'repeat-y': _('repeat for y')}
|
|
|
|
|
#
|
|
|
|
|
# for repeat in repeat_dict:
|
|
|
|
|
# self.repeat_ComboBox.addItem(repeat_dict[repeat])
|
|
|
|
|
# self.repeat_ComboBox.setItemData(self.repeat_ComboBox.count()-1, \
|
|
|
|
|
# repeat)
|
|
|
|
|
# if ClientObj.background_repeat == repeat:
|
|
|
|
|
# self.repeat_ComboBox.setCurrentIndex \
|
|
|
|
|
# (self.repeat_ComboBox.count()-1)
|
|
|
|
|
#
|
|
|
|
|
## self.repeat_ComboBox.currentIndexChanged.connect(self.repeat_checked)
|
|
|
|
|
#
|
|
|
|
|
# #add repeat settings in grid
|
|
|
|
|
# self.grid.addWidget(self.repeat_lbl,2,0)
|
|
|
|
|
# self.grid.addWidget(self.repeat_ComboBox,2,1)
|
|
|
|
|
#
|
|
|
|
|
# # opacity setting
|
|
|
|
|
# self.opacity_lbl_text = _('Set opacity ')
|
|
|
|
|
# self.opacity_lbl = LabelWordWrap(self.opacity_lbl_text, self)
|
|
|
|
|
#
|
|
|
|
|
# self.opacity = QtGui.QSlider(QtCore.Qt.Orientation.Horizontal)
|
|
|
|
|
#
|
|
|
|
|
# self.opacity.setFocusPolicy(QtCore.Qt.StrongFocus)
|
|
|
|
|
#
|
|
|
|
|
# self.opacity.setTickPosition(QtGui.QSlider.TicksBothSides)
|
|
|
|
|
# self.opacity.setTickInterval(20)
|
|
|
|
|
# self.opacity.setSingleStep(1)
|
|
|
|
|
#
|
|
|
|
|
# self.opacity.setMaximum(255)
|
|
|
|
|
# self.opacity.setMinimum(0)
|
|
|
|
|
#
|
|
|
|
|
# self.opacity.setValue(int(ClientObj.bg_opacity))
|
|
|
|
|
#
|
|
|
|
|
# self.opacity.valueChanged.connect(self.set_opacity_lbl)
|
|
|
|
|
# self.set_opacity_lbl(ClientObj.bg_opacity)
|
|
|
|
|
#
|
|
|
|
|
# #add opacity settings in grid
|
|
|
|
|
# self.grid.addWidget(self.opacity_lbl,3,0)
|
|
|
|
|
# self.grid.addWidget(self.opacity,3,1)
|
|
|
|
|
|
|
|
|
|
# add height image in grid
|
|
|
|
|
self.h_image_lbl = LabelWordWrap(_('Height image'), self)
|
|
|
|
|
self.h_image_lbl.setMaximumWidth(self.h_image_lbl.sizeHint().width())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.h_image_lineedit = QtGui.QLineEdit(self)
|
|
|
|
|
self.h_image_lineedit.setToolTip(_('Set fixed height image for '
|
|
|
|
|
'actions')+_('0 - hide images'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.h_image_lineedit.setText(str(ClientObj.height_image))
|
|
|
|
|
|
|
|
|
|
self.grid.addWidget(self.h_image_lbl, 4, 0)
|
|
|
|
|
self.grid.addWidget(self.h_image_lineedit, 4, 1)
|
|
|
|
|
|
|
|
|
|
self.grid.addWidget(self.h_image_lbl, 1, 0)
|
|
|
|
|
self.grid.addWidget(self.h_image_lineedit, 1, 1)
|
|
|
|
|
|
|
|
|
|
# add expers view result in grid
|
|
|
|
|
self.expert_lbl = LabelWordWrap(_('Expert view'), self)
|
|
|
|
|
self.expert_checkbox = QtGui.QCheckBox(self)
|
|
|
|
|
self.expert_checkbox.setChecked(ClientObj.expert)
|
|
|
|
|
self.expert_lbl.setToolTip(_('Expert mode view results'))
|
|
|
|
|
self.expert_checkbox.setToolTip(_('Expert mode view results'))
|
|
|
|
|
|
|
|
|
|
self.grid.addWidget(self.expert_lbl, 2, 0)
|
|
|
|
|
self.grid.addWidget(self.expert_checkbox, 2, 1, 1, 2)
|
|
|
|
|
|
|
|
|
|
# add count item in result table in grid
|
|
|
|
|
self.count_row_lbl = LabelWordWrap(_('Count Row in result Table'),self)
|
|
|
|
|
self.count_row_lbl.setMaximumWidth \
|
|
|
|
|
(self.count_row_lbl.sizeHint().width())
|
|
|
|
|
|
|
|
|
|
self.count_row_lineedit = QtGui.QLineEdit(self)
|
|
|
|
|
|
|
|
|
|
self.count_row_lineedit.setText(str(ClientObj.count_row_res_table))
|
|
|
|
|
|
|
|
|
|
self.grid.addWidget(self.count_row_lbl, 3, 0)
|
|
|
|
|
self.grid.addWidget(self.count_row_lineedit, 3, 1)
|
|
|
|
|
|
|
|
|
|
# add spacer
|
|
|
|
|
self.grid.addItem(QtGui.QSpacerItem(0,0, QtGui.QSizePolicy.Expanding, \
|
|
|
|
@ -317,19 +274,16 @@ class ToolGui(QtGui.QWidget):
|
|
|
|
|
|
|
|
|
|
# connect all with change value slot
|
|
|
|
|
self.color_button.clicked.connect(self.changed_val)
|
|
|
|
|
# self.fd_bg_image.textChanged.connect(self.changed_val)
|
|
|
|
|
# self.repeat_ComboBox.currentIndexChanged.connect(self.changed_val)
|
|
|
|
|
# self.opacity.valueChanged.connect(self.changed_val)
|
|
|
|
|
self.h_image_lineedit.textChanged.connect(self.changed_val)
|
|
|
|
|
|
|
|
|
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
|
|
|
|
self.expert_checkbox.clicked.connect(self.changed_val)
|
|
|
|
|
self.count_row_lineedit.textChanged.connect(self.changed_val)
|
|
|
|
|
|
|
|
|
|
def changed_val(self):
|
|
|
|
|
self._parent.changed_flag = True
|
|
|
|
|
|
|
|
|
|
def set_opacity_lbl(self, val):
|
|
|
|
|
self.opacity_lbl.setText(self.opacity_lbl_text + str(val))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_cfg (self, flag, config, part, param, value):
|
|
|
|
|
# if param not exists in config
|
|
|
|
|
if not flag:
|
|
|
|
@ -341,7 +295,7 @@ class ToolGui(QtGui.QWidget):
|
|
|
|
|
if line.startswith(part):
|
|
|
|
|
temp_cfg.append('%s = %s\n' %(param, value))
|
|
|
|
|
part_flag = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config = temp_cfg
|
|
|
|
|
# if part not exists
|
|
|
|
|
if not part_flag:
|
|
|
|
@ -349,45 +303,28 @@ class ToolGui(QtGui.QWidget):
|
|
|
|
|
config.append('%s\n' %part)
|
|
|
|
|
config.append('%s = %s\n' %(param, value))
|
|
|
|
|
return config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def save_changes(self, ClientObj):
|
|
|
|
|
def wrapper():
|
|
|
|
|
if not os.path.isfile (self.user_config):
|
|
|
|
|
f = open (self.user_config, 'w')
|
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fc = open (self.user_config, 'r')
|
|
|
|
|
config = fc.readlines()
|
|
|
|
|
fc.close()
|
|
|
|
|
new_config = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bg_color_flag = False
|
|
|
|
|
bg_image_flag = False
|
|
|
|
|
bg_opacity_flag = False
|
|
|
|
|
repeat_bg_flag = False
|
|
|
|
|
count_row_flag = False
|
|
|
|
|
expert_flag = False
|
|
|
|
|
count_row_flag = False
|
|
|
|
|
h_image_flag = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for line in config:
|
|
|
|
|
if line.startswith('bg_color '):
|
|
|
|
|
bg_color_flag = True
|
|
|
|
|
new_config.append('bg_color = %s\n' %self.bg_color)
|
|
|
|
|
# elif line.startswith('bg_image '):
|
|
|
|
|
# bg_image_flag = True
|
|
|
|
|
# if self.fd_bg_image.text().lower() == 'no' \
|
|
|
|
|
# or os.path.isfile(self.fd_bg_image.text()):
|
|
|
|
|
# new_config.append('bg_image = %s\n' \
|
|
|
|
|
# %self.fd_bg_image.text())
|
|
|
|
|
# else:
|
|
|
|
|
# new_config.append(line)
|
|
|
|
|
# elif line.startswith('bg_repeat '):
|
|
|
|
|
# repeat_bg_flag = True
|
|
|
|
|
# new_config.append('bg_repeat = %s\n' \
|
|
|
|
|
# %self.repeat_ComboBox.itemData \
|
|
|
|
|
# (self.repeat_ComboBox.currentIndex()))
|
|
|
|
|
# elif line.startswith('bg_opacity '):
|
|
|
|
|
# bg_opacity_flag = True
|
|
|
|
|
# new_config.append('bg_opacity = %s\n' \
|
|
|
|
|
# %str(self.opacity.value()))
|
|
|
|
|
elif line.startswith('height_image '):
|
|
|
|
|
h_image_flag = True
|
|
|
|
|
try:
|
|
|
|
@ -397,23 +334,43 @@ class ToolGui(QtGui.QWidget):
|
|
|
|
|
if height_image < 0 or height_image > 512:
|
|
|
|
|
height_image = ClientObj.height_image
|
|
|
|
|
new_config.append('height_image = %d\n' %height_image)
|
|
|
|
|
elif line.startswith('expert '):
|
|
|
|
|
expert_flag = True
|
|
|
|
|
if self.expert_checkbox.isChecked():
|
|
|
|
|
expert = 1
|
|
|
|
|
else:
|
|
|
|
|
expert = 0
|
|
|
|
|
new_config.append('expert = %d\n' %expert)
|
|
|
|
|
elif line.startswith('count_row '):
|
|
|
|
|
count_row_flag = True
|
|
|
|
|
try:
|
|
|
|
|
count_row = int(self.count_row_lineedit.text())
|
|
|
|
|
if count_row < 2:
|
|
|
|
|
count_row = 2
|
|
|
|
|
except ValueError:
|
|
|
|
|
count_row = ClientObj.count_row_res_table
|
|
|
|
|
new_config.append('count_row = %d\n' %count_row)
|
|
|
|
|
else:
|
|
|
|
|
new_config.append(line)
|
|
|
|
|
|
|
|
|
|
new_config = self.check_cfg (bg_color_flag, new_config, \
|
|
|
|
|
'[gui]', 'bg_color', self.bg_color)
|
|
|
|
|
|
|
|
|
|
# if self.fd_bg_image.text().lower() == 'no' \
|
|
|
|
|
# or os.path.isfile(self.fd_bg_image.text()):
|
|
|
|
|
# new_config = self.check_cfg (bg_image_flag, new_config, \
|
|
|
|
|
# '[gui]', 'bg_image', self.fd_bg_image.text())
|
|
|
|
|
#
|
|
|
|
|
# new_config = self.check_cfg (repeat_bg_flag, new_config, \
|
|
|
|
|
# '[gui]', 'bg_repeat', self.repeat_ComboBox.itemData \
|
|
|
|
|
# (self.repeat_ComboBox.currentIndex()))
|
|
|
|
|
#
|
|
|
|
|
# new_config = self.check_cfg (bg_opacity_flag, new_config, \
|
|
|
|
|
# '[gui]', 'bg_opacity', str(self.opacity.value()))
|
|
|
|
|
|
|
|
|
|
if self.expert_checkbox.isChecked():
|
|
|
|
|
expert = 1
|
|
|
|
|
else:
|
|
|
|
|
expert = 0
|
|
|
|
|
new_config = self.check_cfg (expert_flag, new_config, \
|
|
|
|
|
'[other]', 'expert', expert)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
count_row = int(self.count_row_lineedit.text())
|
|
|
|
|
if count_row < 2:
|
|
|
|
|
count_row = 2
|
|
|
|
|
except ValueError:
|
|
|
|
|
count_row = ClientObj.count_row_res_table
|
|
|
|
|
new_config = self.check_cfg (count_row_flag, new_config, \
|
|
|
|
|
'[other]', 'count_row', count_row)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
height_image = int(self.h_image_lineedit.text())
|
|
|
|
@ -429,14 +386,6 @@ class ToolGui(QtGui.QWidget):
|
|
|
|
|
fnc.write(line)
|
|
|
|
|
fnc.close()
|
|
|
|
|
|
|
|
|
|
# # save all without closing application
|
|
|
|
|
# ClientObj.method_background_color = self.bg_color
|
|
|
|
|
# ClientObj.bg_opacity = self.opacity.value()
|
|
|
|
|
#
|
|
|
|
|
# if self.fd_bg_image.text().lower() == 'not' \
|
|
|
|
|
# or os.path.isfile(self.fd_bg_image.text()):
|
|
|
|
|
# ClientObj.background_image = self.fd_bg_image.text()
|
|
|
|
|
|
|
|
|
|
# read config for changed parameters
|
|
|
|
|
ClientObj.create_user_config()
|
|
|
|
|
ClientObj.read_user_config(ClientObj.user_config)
|
|
|
|
@ -445,86 +394,63 @@ class ToolGui(QtGui.QWidget):
|
|
|
|
|
self._parent.changed_flag = False
|
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Other tools in ToolTabWidget
|
|
|
|
|
class ToolOther(QtGui.QWidget):
|
|
|
|
|
def __init__(self, parent, ClientObj):
|
|
|
|
|
QtGui.QWidget.__init__(self, parent)
|
|
|
|
|
self.user_config = ClientObj.user_config
|
|
|
|
|
self._parent = parent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.grid = QtGui.QGridLayout(self)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.grid.setContentsMargins(2,2,2,2)
|
|
|
|
|
self.grid.setSpacing(2)
|
|
|
|
|
self.grid.setColumnStretch(0,3)
|
|
|
|
|
self.grid.setColumnStretch(1,5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# lang settings
|
|
|
|
|
self.lang_lbl = LabelWordWrap(_('Select Language'), self)
|
|
|
|
|
self.lang_lbl.setMaximumWidth(self.lang_lbl.sizeHint().width())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.lang_ComboBox = QComboBox(self)
|
|
|
|
|
lang_dict = {'en': _('English'),'ru': _('Russian')}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for lang in lang_dict:
|
|
|
|
|
self.lang_ComboBox.addItem(lang_dict[lang])
|
|
|
|
|
self.lang_ComboBox.setItemData(self.lang_ComboBox.count()-1,lang)
|
|
|
|
|
if ClientObj.lang == lang:
|
|
|
|
|
self.lang_ComboBox.setCurrentIndex \
|
|
|
|
|
(self.lang_ComboBox.count()-1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#add lang settings in grid
|
|
|
|
|
self.grid.addWidget(self.lang_lbl,0,0)
|
|
|
|
|
self.grid.addWidget(self.lang_ComboBox,0,1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# add open file in grid
|
|
|
|
|
self.cert_path_lbl = LabelWordWrap(_('Path to Certificates'), self)
|
|
|
|
|
self.cert_path_lbl.setMaximumWidth \
|
|
|
|
|
(self.cert_path_lbl.sizeHint().width())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.fd_cert = FileOpenWgt(self, 'dir', _('Certificate Directory'), \
|
|
|
|
|
'~/.calculate')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.fd_cert.setToolTip(_('Empty to default path'))
|
|
|
|
|
self.fd_cert.setText(ClientObj.path_to_cert)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.grid.addWidget(self.cert_path_lbl, 1, 0)
|
|
|
|
|
self.grid.addWidget(self.fd_cert, 1, 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# add timeout in grid
|
|
|
|
|
self.timeout_lbl = LabelWordWrap(_('Timeout'), self)
|
|
|
|
|
self.timeout_lbl.setMaximumWidth(self.timeout_lbl.sizeHint().width())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.timeout_lineedit = QtGui.QLineEdit(self)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.timeout_lineedit.setText(str(ClientObj.timeout))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.grid.addWidget(self.timeout_lbl, 2, 0)
|
|
|
|
|
self.grid.addWidget(self.timeout_lineedit, 2, 1)
|
|
|
|
|
|
|
|
|
|
# add expers view result in grid
|
|
|
|
|
self.expert_lbl = LabelWordWrap(_('Expert view'), self)
|
|
|
|
|
self.expert_checkbox = QtGui.QCheckBox(self)
|
|
|
|
|
self.expert_checkbox.setChecked(ClientObj.expert)
|
|
|
|
|
self.expert_lbl.setToolTip(_('Expert mode view results'))
|
|
|
|
|
self.expert_checkbox.setToolTip(_('Expert mode view results'))
|
|
|
|
|
|
|
|
|
|
self.grid.addWidget(self.expert_lbl, 3, 0)
|
|
|
|
|
self.grid.addWidget(self.expert_checkbox, 3, 1, 1, 2)
|
|
|
|
|
|
|
|
|
|
# add count item in result table in grid
|
|
|
|
|
self.count_row_lbl = LabelWordWrap(_('Count Row in result Table'),self)
|
|
|
|
|
self.count_row_lbl.setMaximumWidth \
|
|
|
|
|
(self.count_row_lbl.sizeHint().width())
|
|
|
|
|
|
|
|
|
|
self.count_row_lineedit = QtGui.QLineEdit(self)
|
|
|
|
|
|
|
|
|
|
self.count_row_lineedit.setText(str(ClientObj.count_row_res_table))
|
|
|
|
|
|
|
|
|
|
self.grid.addWidget(self.count_row_lbl, 4, 0)
|
|
|
|
|
self.grid.addWidget(self.count_row_lineedit, 4, 1)
|
|
|
|
|
|
|
|
|
|
# add spacer
|
|
|
|
|
self.grid.addItem(QtGui.QSpacerItem(0,0, QtGui.QSizePolicy.Expanding, \
|
|
|
|
|
QtGui.QSizePolicy.Expanding ), 5, 0, 1, 2)
|
|
|
|
@ -533,8 +459,6 @@ class ToolOther(QtGui.QWidget):
|
|
|
|
|
self.lang_ComboBox.currentIndexChanged.connect(self.changed_val)
|
|
|
|
|
self.fd_cert.textChanged.connect(self.changed_val)
|
|
|
|
|
self.timeout_lineedit.textChanged.connect(self.changed_val)
|
|
|
|
|
self.expert_checkbox.clicked.connect(self.changed_val)
|
|
|
|
|
self.count_row_lineedit.textChanged.connect(self.changed_val)
|
|
|
|
|
|
|
|
|
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
|
|
|
|
|
|
|
|
@ -575,8 +499,6 @@ class ToolOther(QtGui.QWidget):
|
|
|
|
|
lang_flag = False
|
|
|
|
|
cert_flag = False
|
|
|
|
|
timeout_flag = False
|
|
|
|
|
expert_flag = False
|
|
|
|
|
count_row_flag = False
|
|
|
|
|
for line in config:
|
|
|
|
|
if line.startswith('lang '):
|
|
|
|
|
lang_flag = True
|
|
|
|
@ -599,34 +521,20 @@ class ToolOther(QtGui.QWidget):
|
|
|
|
|
except ValueError:
|
|
|
|
|
timeout = ClientObj.timeout
|
|
|
|
|
new_config.append('timeout = %d\n' %timeout)
|
|
|
|
|
elif line.startswith('expert '):
|
|
|
|
|
expert_flag = True
|
|
|
|
|
if self.expert_checkbox.isChecked():
|
|
|
|
|
expert = 1
|
|
|
|
|
else:
|
|
|
|
|
expert = 0
|
|
|
|
|
new_config.append('expert = %d\n' %expert)
|
|
|
|
|
elif line.startswith('count_row '):
|
|
|
|
|
count_row_flag = True
|
|
|
|
|
try:
|
|
|
|
|
count_row = int(self.count_row_lineedit.text())
|
|
|
|
|
except ValueError:
|
|
|
|
|
count_row = ClientObj.count_row_res_table
|
|
|
|
|
new_config.append('count_row = %d\n' %count_row)
|
|
|
|
|
else:
|
|
|
|
|
new_config.append(line)
|
|
|
|
|
|
|
|
|
|
new_config = self.check_cfg (lang_flag, new_config, \
|
|
|
|
|
'[other]', 'lang', self.lang_ComboBox.itemData \
|
|
|
|
|
(self.lang_ComboBox.currentIndex()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not self.fd_cert.text().lower():
|
|
|
|
|
new_config = self.check_cfg (cert_flag, new_config, \
|
|
|
|
|
'[other]', 'path_to_cert', 'no')
|
|
|
|
|
elif os.path.isdir(self.fd_cert.text()):
|
|
|
|
|
new_config = self.check_cfg (cert_flag, new_config, \
|
|
|
|
|
'[other]', 'path_to_cert', self.fd_cert.text())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
timeout = int(self.timeout_lineedit.text())
|
|
|
|
|
except ValueError:
|
|
|
|
@ -634,20 +542,6 @@ class ToolOther(QtGui.QWidget):
|
|
|
|
|
new_config = self.check_cfg (timeout_flag, new_config, \
|
|
|
|
|
'[other]', 'timeout', timeout)
|
|
|
|
|
|
|
|
|
|
if self.expert_checkbox.isChecked():
|
|
|
|
|
expert = 1
|
|
|
|
|
else:
|
|
|
|
|
expert = 0
|
|
|
|
|
new_config = self.check_cfg (expert_flag, new_config, \
|
|
|
|
|
'[other]', 'expert', expert)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
count_row = int(self.count_row_lineedit.text())
|
|
|
|
|
except ValueError:
|
|
|
|
|
count_row = ClientObj.count_row_res_table
|
|
|
|
|
new_config = self.check_cfg (count_row_flag, new_config, \
|
|
|
|
|
'[other]', 'count_row', count_row)
|
|
|
|
|
|
|
|
|
|
fnc = open(self.user_config, 'w')
|
|
|
|
|
for line in new_config:
|
|
|
|
|
fnc.write(line)
|
|
|
|
|