Добавлена поддержка DPI

develop 3.6.1.3
parent 615843b371
commit 21e104b364

@ -36,10 +36,6 @@ def main():
app = qt.QApplication(sys.argv)
app.setQuitOnLastWindowClosed(True)
font = app.font()
font.setPixelSize(13)
app.setFont(font)
ex = SelectedMethodWgt(app, args)
if args.method == 'update':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@ -80,10 +76,6 @@ def main():
app = qt.QApplication(sys.argv)
app.setApplicationName(_("Calculate Console"))
font = app.font()
font.setPixelSize(13)
app.setFont(font)
second = False
for run_commands in filter(lambda x:'cl-console-gui' in x[0],getRunProc()):
if 'python' in run_commands[0]:

@ -25,7 +25,8 @@ import ConfigParser
from TrayIcon import TrayIcon
from more import get_sid, get_view_params, _print, get_icon, get_system_rgb
from more import get_sid, get_view_params, _print, get_icon, get_system_rgb, \
dpivalue
from MainClass import ApiClient
from calculate.consolegui.datavars import DataVarsGui
@ -316,7 +317,7 @@ class ToolTabWidget(qt.QTabWidget):
if d_size.height() < 768:
self.resize(900,560)
else:
self.resize(900, 700)
self.resize(dpivalue(900), dpivalue(700))
self.setMinimumHeight(100)
self.setMinimumWidth(500)

@ -15,7 +15,7 @@
# limitations under the License.
from calculate.consolegui import qt
from more import LabelWordWrap, _print, get_system_rgb, ParameterWindow
from more import LabelWordWrap, _print, get_system_rgb, ParameterWindow, dpivalue
DEBUG_LEVEL = 0
@ -130,7 +130,7 @@ class ControlButtonWgt(qt.QWidget):
self.main_layout.addLayout(self.hlayout)
# self.setLayout(self.hlayout)
self.setFixedHeight(90)
self.setFixedHeight(dpivalue(90))
self.hide()
self.confirmWgt = None
self.break_button = None
@ -204,7 +204,7 @@ class ControlButtonWgt(qt.QWidget):
button.clicked.connect(self.button_disabled)
button.clicked.connect(callback)
button.setMinimumWidth(62)
button.setFixedHeight(32)
button.setFixedHeight(dpivalue(32))
if field.guitype == "readonly":
button.setDisabled(True)
end_layout.addWidget(button)
@ -252,7 +252,7 @@ class ControlButtonWgt(qt.QWidget):
lambda:main_frame.clear_cache_info(method_name))
self.cancel_button.setMinimumWidth(62)
self.cancel_button.setFixedHeight(32)
self.cancel_button.setFixedHeight(dpivalue(32))
if self.button_widget:
end_layout.addWidget(self.cancel_button)
@ -281,7 +281,7 @@ class ControlButtonWgt(qt.QWidget):
self.prev_button.clicked.connect(main_frame.button_call_view(-1))
# self.prev_button.clicked.connect(self.button_enabled)
self.prev_button.setMinimumWidth(62)
self.prev_button.setFixedHeight(32)
self.prev_button.setFixedHeight(dpivalue(32))
if self.button_widget:
end_layout.addWidget(self.prev_button)
@ -321,7 +321,7 @@ class ControlButtonWgt(qt.QWidget):
end_layout.addWidget(self.next_button)
self.next_button.setMinimumWidth(64)
self.next_button.setFixedHeight(32)
self.next_button.setFixedHeight(dpivalue(32))
self.next_button.setShortcut(qt.QKeySequence(qt.Qt.Key_Return))
self.next_button.setShortcut(qt.QKeySequence(qt.Qt.Key_Enter))
self.default_button = self.next_button
@ -370,7 +370,7 @@ class ControlButtonWgt(qt.QWidget):
else:
self.clear_proc_cache_button.clicked.connect(self._parent.back)
self.clear_proc_cache_button.setMinimumWidth(64)
self.clear_proc_cache_button.setFixedHeight(32)
self.clear_proc_cache_button.setFixedHeight(dpivalue(32))
end_layout.addWidget(self.clear_proc_cache_button)
self.hlayout.addWidget(self.button_widget)

@ -18,7 +18,7 @@ from calculate.consolegui import qt
from more import ButtonMenu, FlowLayout, get_sid, ClientServiceThread, \
get_view_params, show_msg, client_list_methods, get_system_rgb, \
get_icon
get_icon, dpivalue
class DisplayMethod(qt.QWidget):
def __init__(self, parent, ClientObj):
@ -43,7 +43,8 @@ class DisplayMethod(qt.QWidget):
self.ClientObj._parent.setWindowTitle(self.ClientObj.Name)
groupbox_style = "QGroupBox { padding-top: 24px; padding-left: 10px;}"
groupbox_style = \
"QGroupBox { padding-top: %dpx; padding-left: 10px;}" % dpivalue(24)
# transform a list into the dictionary {'group': [methods], ...}
guiMethods = {}

@ -17,7 +17,7 @@
from calculate.consolegui import qt
from more import ButtonMenu, icon_visible, LabelWordWrap, get_sid, show_msg, \
ClientServiceThread, show_question, get_view_params, _print, \
get_system_rgb
get_system_rgb, dpivalue
class StepLabel(qt.QLabel):
@ -35,7 +35,7 @@ class StepLabel(qt.QLabel):
"background-color: %s;}"%bg)
self.setContentsMargins(26,0,26,0)
self.adjustSize()
self.setFixedHeight(self.height() + 13)
self.setFixedHeight(dpivalue(self.height() + 18))
def mousePressEvent(self, event):
self.clicked.emit()

@ -33,7 +33,7 @@ from calculate.lib.utils.tools import imap_regexp
from more import WorkPalette, ParameterWindow, get_system_rgb
from more import get_sid, ClientServiceThread, show_msg, TaskWidget, ErrorWgt,\
ResultLayout, get_view_params, get_icon
ResultLayout, get_view_params, get_icon, dpivalue
from more import LabelWordWrap as Label
from SelectTable import SelectedTableWidget
@ -1118,7 +1118,7 @@ class ButtonDialog(qt.QWidget):
minimum = qt.QSizePolicy.Fixed
self.setSizePolicy(minimum, minimum)
self.setFixedHeight(32)
self.setFixedHeight(dpivalue(32))
self.init(item)
def init(self, item):
@ -1139,7 +1139,7 @@ class ButtonDialog(qt.QWidget):
button.setShortcut(qt.QKeySequence(shortcut))
button.clicked.connect(self.send(answer, label))
button.setFixedWidth(self.button_size)
button.setFixedHeight(32)
button.setFixedHeight(dpivalue(32))
self.layout.addWidget(button)
def send(self, answer, human_answer=None):

@ -25,7 +25,7 @@ from session_function import client_post_cert
from calculate.core.client.cert_verify import VerifyError
from client_class import Client_suds, HTTPSClientCertTransport
from more import post_connect_action, show_msg, uniq, LabelWordWrap, get_icon
from more import post_connect_action, show_msg, uniq, LabelWordWrap, get_icon, dpivalue
class LocalhostPasswd(qt.QDialog):
def __init__(self, parent):
@ -78,7 +78,7 @@ class FrameConnection(qt.QWidget):
def initUI(self, parent, window):
grid = qt.QGridLayout(self)
grid.setContentsMargins(10, 10, 10, 10)
grid.setSpacing(4)
grid.setSpacing(2)
self.lbl_host = LabelWordWrap(_("Host"), self)
self.lbl_port = LabelWordWrap(_("Port"), self)
@ -151,7 +151,7 @@ class FrameConnection(qt.QWidget):
self.setLayout(grid)
self.setFixedSize(300, 135)
self.setFixedSize(dpivalue(300), dpivalue(160))
self.move(window.geometry().x() + window.geometry().width() / 2 \
- self.sizeHint().width() / 2, \
window.geometry().y() + window.geometry().height() / 2 \

@ -123,7 +123,6 @@ class MainMenu(qt.QWidget):
self.hlayout.setContentsMargins(2,2,2,2)
self.hlayout.setSpacing(0)
# self.setFixedHeight(48)
self.setFixedHeight(self.hlayout.sizeHint().height())
self.setAttribute(qt.Qt.WA_DeleteOnClose)

@ -36,8 +36,9 @@ def get_system_rgb(obj, pallete_type):
def dpivalue(size):
try:
return size * qt.QApplication.screen()[0].logicalDotsPerInch() / 96.0;
except BaseExeception as e:
return size * qt.QApplication.screens()[0].logicalDotsPerInch() / 96.0;
except BaseException as e:
print str(e)
if isinstance(e, KeyboardInterrupt):
raise
return size
@ -87,9 +88,9 @@ _('The user must not be root')
class TopMenu(qt.QPushButton):
def __init__(self, label, images, parent = None):
qt.QPushButton.__init__(self, parent)
self.setStyleSheet("QPushButton{border: none; margin: 1px;}"
self.setStyleSheet("QPushButton{border: none; margin: 0px;}"
"QPushButton:hover{border: 1px solid #73D1FF;"
"border-radius: 3px; margin: 1px;}")
"border-radius: 3px; margin: 0px;}")
# self.setStyleSheet("QPushButton{border: none; margin: 0px 0px 0px 0px;}"
# ":hover {border: 1px solid #73D1FF;"
# "border-radius: 3px; margin: 0px 0px 0px 0px;}"
@ -112,6 +113,7 @@ class TopMenu(qt.QPushButton):
self.image_lbl.setPixmap(pm2)
# self.image_lbl.adjustSize()
#self.image_lbl.setFixedHeight(dpivalue(24))
self.image_lbl.setAlignment(qt.Qt.AlignCenter)
# add transparency
@ -129,11 +131,11 @@ class TopMenu(qt.QPushButton):
self.lbl.setAttribute(qt.Qt.WA_NoSystemBackground)
self.layout.addWidget(self.lbl)
self.layout.setContentsMargins(2,4,2,2)
self.layout.setContentsMargins(2,4,2,4)
self.layout.setSpacing(0)
# self.setFixedSize(48,40)
self.setFixedHeight(48)
self.setFixedHeight(52)
if self.lbl.sizeHint().width() > 32:
self.setFixedWidth(self.lbl.sizeHint().width()+16)
else:
@ -144,12 +146,12 @@ class TopMenu(qt.QPushButton):
self.setAttribute(qt.Qt.WA_DeleteOnClose)
def mousePressEvent(self, event):
self.layout.setContentsMargins(2,5,2,2)
self.layout.setContentsMargins(2,5,2,4)
event.accept()
qt.QPushButton.mousePressEvent(self, event)
def mouseReleaseEvent(self, event):
self.layout.setContentsMargins(2,4,2,2)
self.layout.setContentsMargins(2,4,2,4)
event.accept()
qt.QPushButton.mouseReleaseEvent(self, event)
@ -158,8 +160,8 @@ class TopMenu(qt.QPushButton):
def setText(self, text):
self.lbl.setText(text)
self.setFixedHeight(48)
if self.lbl.sizeHint().width() > 32:
self.setFixedHeight(52)
if self.lbl.sizeHint().width() > 48:
self.setFixedWidth(self.lbl.sizeHint().width()+16)
else:
self.setFixedWidth(48)
@ -2222,7 +2224,7 @@ class ResultLayout(qt.QVBoxLayout):
self.addLayout(self.content)
self.kill_process_button = self._create_button(_('Break the process'))
self.kill_process_button.setFixedHeight(32)
self.kill_process_button.setFixedHeight(dpivalue(32))
parent._parent.control_button.set_break_button(self.kill_process_button)
def _addWidget(self, widget):
@ -2230,12 +2232,13 @@ class ResultLayout(qt.QVBoxLayout):
def _create_button(self, label, width=144):
button = qt.QPushButton(label)
button.setFixedWidth(width)
button.setFixedWidth(dpivalue(width))
button.setContentsMargins(0, 10, 0, 0)
button.setMinimumHeight(
button.minimumSizeHint().height())
button.setMaximumHeight(
button.minimumSizeHint().height())
button.setFixedHeight(dpivalue(32))
#button.setMinimumHeight(
# button.minimumSizeHint().height())
#button.setMaximumHeight(
# button.minimumSizeHint().height())
return button
def hide_kill_button(self):

@ -18,7 +18,7 @@ from calculate.consolegui import qt
import urllib2
from calculate.lib.utils.tools import Locker
from more import show_msg, LabelWordWrap, get_ip_mac, get_sid, get_icon
from more import show_msg, LabelWordWrap, get_ip_mac, get_sid, get_icon, dpivalue
def client_sid(sid, client, cert_id, lang):
""" get number session from server and write this in file """
@ -130,7 +130,7 @@ class ViewSessionInfo (qt.QWidget):
self.layout.addWidget(Quit_button, 9, 1)
Quit_button.clicked.connect(self.close)
self.setFixedSize(260,200)
self.setFixedSize(dpivalue(260),100 + dpivalue(100))
self.setLayout(self.layout)
self.setWindowIcon(get_icon("document-edit-verify"))

@ -19,7 +19,7 @@ import os
from calculate.consolegui import qt
from more import LabelWordWrap, FileOpenWgt, show_msg, show_question, \
client_list_methods, get_icon
client_list_methods, get_icon, dpivalue
class ToolsWidget (qt.QWidget):
def __init__(self, parent, ClientObj, window):
@ -31,7 +31,7 @@ class ToolsWidget (qt.QWidget):
# self.move(100+parent.frameGeometry().x(), \
# 100+parent.frameGeometry().y())
self.setFixedSize(450, 220)
self.setFixedSize(dpivalue(450), 100 + dpivalue(120))
self.setWindowTitle(_('Preferences'))
self.setWindowIcon(get_icon("preferences-other"))
@ -74,19 +74,16 @@ class ToolsWidget (qt.QWidget):
self.botton_layout.setAlignment(qt.Qt.AlignRight)
toolOk = qt.QPushButton(_('Ok'), self)
toolOk.setFixedWidth(50)
toolOk.setShortcut(qt.QKeySequence(qt.Qt.Key_Return))
toolOk.clicked.connect(self.save_changes(ClientObj, tab))
toolOk.clicked.connect(self.close)
self.botton_layout.addWidget(toolOk)
toolApply = qt.QPushButton(_('Apply'), self)
toolApply.setFixedWidth(100)
toolApply.clicked.connect(self.save_changes(ClientObj, tab))
self.botton_layout.addWidget(toolApply)
toolQuit = qt.QPushButton(_('Cancel'), self)
toolQuit.setFixedWidth(100)
toolQuit.clicked.connect(self.close)
toolQuit.setShortcut(qt.QKeySequence(qt.Qt.Key_Escape))
self.botton_layout.addWidget(toolQuit)
@ -98,7 +95,7 @@ class ToolsWidget (qt.QWidget):
self.vlayout.addWidget(botton_wgt)
# clear_button.setMaximumWidth(self.sizeHint().width() / 2)
clear_button.setMaximumWidth(220)
clear_button.setMaximumWidth(dpivalue(220))
def save_changes(self, ClientObj, tab):
def wrapper():

Loading…
Cancel
Save