menu to buttons

This commit is contained in:
ingvar1995 2016-11-05 13:03:47 +03:00
parent 5477a7d548
commit e854516183
3 changed files with 124 additions and 78 deletions

View File

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from menu import *
from profile import *
from list_items import *
@ -22,44 +20,50 @@ class MainWindow(QtGui.QMainWindow, Singleton):
if settings.Settings.get_instance()['show_welcome_screen']:
self.ws = WelcomeScreen()
def setup_menu(self, MainWindow):
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setObjectName("menubar")
self.menubar.setNativeMenuBar(False)
self.menubar.setMinimumSize(self.width(), 25)
self.menubar.setMaximumSize(self.width(), 25)
self.menubar.setBaseSize(self.width(), 25)
def setup_menu(self, Form):
box = QtGui.QHBoxLayout()
box.setContentsMargins(0, 0, 0, 0)
box.setAlignment(QtCore.Qt.AlignLeft)
self.profile_button = MainMenuButton(Form)
box.addWidget(self.profile_button)
self.settings_button = MainMenuButton(Form)
box.addWidget(self.settings_button)
self.plugins_button = MainMenuButton(Form)
box.addWidget(self.plugins_button)
self.about_button = MainMenuButton(Form)
box.addWidget(self.about_button)
box.setSpacing(0)
self.menuProfile = QtGui.QMenu(self.menubar)
self.menuProfile = QtGui.QMenu()
self.menuProfile.setObjectName("menuProfile")
self.menuSettings = QtGui.QMenu(self.menubar)
self.menuSettings = QtGui.QMenu()
self.menuSettings.setObjectName("menuSettings")
self.menuPlugins = QtGui.QMenu(self.menubar)
self.menuPlugins = QtGui.QMenu()
self.menuPlugins.setObjectName("menuPlugins")
self.menuAbout = QtGui.QMenu(self.menubar)
self.menuAbout = QtGui.QMenu()
self.menuAbout.setObjectName("menuAbout")
self.actionAdd_friend = QtGui.QAction(MainWindow)
self.actionAdd_friend = QtGui.QAction(Form)
self.actionAdd_friend.setObjectName("actionAdd_friend")
self.actionprofilesettings = QtGui.QAction(MainWindow)
self.actionprofilesettings = QtGui.QAction(Form)
self.actionprofilesettings.setObjectName("actionprofilesettings")
self.actionPrivacy_settings = QtGui.QAction(MainWindow)
self.actionPrivacy_settings = QtGui.QAction(Form)
self.actionPrivacy_settings.setObjectName("actionPrivacy_settings")
self.actionInterface_settings = QtGui.QAction(MainWindow)
self.actionInterface_settings = QtGui.QAction(Form)
self.actionInterface_settings.setObjectName("actionInterface_settings")
self.actionNotifications = QtGui.QAction(MainWindow)
self.actionNotifications = QtGui.QAction(Form)
self.actionNotifications.setObjectName("actionNotifications")
self.actionNetwork = QtGui.QAction(MainWindow)
self.actionNetwork = QtGui.QAction(Form)
self.actionNetwork.setObjectName("actionNetwork")
self.actionAbout_program = QtGui.QAction(MainWindow)
self.actionAbout_program = QtGui.QAction(Form)
self.actionAbout_program.setObjectName("actionAbout_program")
self.updateSettings = QtGui.QAction(MainWindow)
self.actionSettings = QtGui.QAction(MainWindow)
self.updateSettings = QtGui.QAction(Form)
self.actionSettings = QtGui.QAction(Form)
self.actionSettings.setObjectName("actionSettings")
self.audioSettings = QtGui.QAction(MainWindow)
self.pluginData = QtGui.QAction(MainWindow)
self.importPlugin = QtGui.QAction(MainWindow)
self.lockApp = QtGui.QAction(MainWindow)
self.audioSettings = QtGui.QAction(Form)
self.pluginData = QtGui.QAction(Form)
self.importPlugin = QtGui.QAction(Form)
self.lockApp = QtGui.QAction(Form)
self.menuProfile.addAction(self.actionAdd_friend)
self.menuProfile.addAction(self.actionSettings)
self.menuProfile.addAction(self.lockApp)
@ -72,10 +76,11 @@ class MainWindow(QtGui.QMainWindow, Singleton):
self.menuPlugins.addAction(self.pluginData)
self.menuPlugins.addAction(self.importPlugin)
self.menuAbout.addAction(self.actionAbout_program)
self.menubar.addAction(self.menuProfile.menuAction())
self.menubar.addAction(self.menuSettings.menuAction())
self.menubar.addAction(self.menuPlugins.menuAction())
self.menubar.addAction(self.menuAbout.menuAction())
self.profile_button.setMenu(self.menuProfile)
self.settings_button.setMenu(self.menuSettings)
self.plugins_button.setMenu(self.menuPlugins)
self.about_button.setMenu(self.menuAbout)
self.actionAbout_program.triggered.connect(self.about_program)
self.actionNetwork.triggered.connect(self.network_settings)
@ -89,7 +94,9 @@ class MainWindow(QtGui.QMainWindow, Singleton):
self.pluginData.triggered.connect(self.plugins_menu)
self.lockApp.triggered.connect(self.lock_app)
self.importPlugin.triggered.connect(self.import_plugin)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
Form.setLayout(box)
QtCore.QMetaObject.connectSlotsByName(Form)
def languageChange(self, *args, **kwargs):
self.retranslateUi()
@ -102,11 +109,11 @@ class MainWindow(QtGui.QMainWindow, Singleton):
def retranslateUi(self):
self.lockApp.setText(QtGui.QApplication.translate("MainWindow", "Lock", None, QtGui.QApplication.UnicodeUTF8))
self.menuPlugins.setTitle(QtGui.QApplication.translate("MainWindow", "Plugins", None, QtGui.QApplication.UnicodeUTF8))
self.plugins_button.setText(QtGui.QApplication.translate("MainWindow", "Plugins", None, QtGui.QApplication.UnicodeUTF8))
self.pluginData.setText(QtGui.QApplication.translate("MainWindow", "List of plugins", None, QtGui.QApplication.UnicodeUTF8))
self.menuProfile.setTitle(QtGui.QApplication.translate("MainWindow", "Profile", None, QtGui.QApplication.UnicodeUTF8))
self.menuSettings.setTitle(QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8))
self.menuAbout.setTitle(QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8))
self.profile_button.setText(QtGui.QApplication.translate("MainWindow", "Profile", None, QtGui.QApplication.UnicodeUTF8))
self.settings_button.setText(QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8))
self.about_button.setText(QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8))
self.actionAdd_friend.setText(QtGui.QApplication.translate("MainWindow", "Add contact", None, QtGui.QApplication.UnicodeUTF8))
self.actionprofilesettings.setText(QtGui.QApplication.translate("MainWindow", "Profile", None, QtGui.QApplication.UnicodeUTF8))
self.actionPrivacy_settings.setText(QtGui.QApplication.translate("MainWindow", "Privacy", None, QtGui.QApplication.UnicodeUTF8))
@ -186,15 +193,15 @@ class MainWindow(QtGui.QMainWindow, Singleton):
def setup_left_top(self, Form):
Form.setCursor(QtCore.Qt.PointingHandCursor)
Form.setMinimumSize(QtCore.QSize(270, 100))
Form.setMaximumSize(QtCore.QSize(270, 100))
Form.setBaseSize(QtCore.QSize(270, 100))
Form.setMinimumSize(QtCore.QSize(270, 75))
Form.setMaximumSize(QtCore.QSize(270, 75))
Form.setBaseSize(QtCore.QSize(270, 75))
self.avatar_label = Form.avatar_label = QtGui.QLabel(Form)
self.avatar_label.setGeometry(QtCore.QRect(5, 30, 64, 64))
self.avatar_label.setGeometry(QtCore.QRect(5, 5, 64, 64))
self.avatar_label.setScaledContents(False)
self.avatar_label.setAlignment(QtCore.Qt.AlignCenter)
self.name = Form.name = DataLabel(Form)
Form.name.setGeometry(QtCore.QRect(75, 40, 150, 25))
Form.name.setGeometry(QtCore.QRect(75, 15, 150, 25))
font = QtGui.QFont()
font.setFamily(settings.Settings.get_instance()['font'])
font.setPointSize(14)
@ -202,13 +209,13 @@ class MainWindow(QtGui.QMainWindow, Singleton):
Form.name.setFont(font)
Form.name.setObjectName("name")
self.status_message = Form.status_message = DataLabel(Form)
Form.status_message.setGeometry(QtCore.QRect(75, 60, 170, 25))
Form.status_message.setGeometry(QtCore.QRect(75, 35, 170, 25))
font.setPointSize(12)
font.setBold(False)
Form.status_message.setFont(font)
Form.status_message.setObjectName("status_message")
self.connection_status = Form.connection_status = StatusCircle(Form)
Form.connection_status.setGeometry(QtCore.QRect(230, 35, 32, 32))
Form.connection_status.setGeometry(QtCore.QRect(230, 10, 32, 32))
self.avatar_label.mouseReleaseEvent = self.profile_settings
self.status_message.mouseReleaseEvent = self.profile_settings
self.name.mouseReleaseEvent = self.profile_settings
@ -216,12 +223,12 @@ class MainWindow(QtGui.QMainWindow, Singleton):
Form.connection_status.setObjectName("connection_status")
def setup_right_top(self, Form):
Form.resize(650, 100)
Form.resize(650, 75)
self.account_avatar = QtGui.QLabel(Form)
self.account_avatar.setGeometry(QtCore.QRect(10, 30, 64, 64))
self.account_avatar.setGeometry(QtCore.QRect(10, 5, 64, 64))
self.account_avatar.setScaledContents(False)
self.account_name = DataLabel(Form)
self.account_name.setGeometry(QtCore.QRect(100, 25, 400, 25))
self.account_name.setGeometry(QtCore.QRect(100, 0, 400, 25))
self.account_name.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse)
font = QtGui.QFont()
font.setFamily(settings.Settings.get_instance()['font'])
@ -230,23 +237,23 @@ class MainWindow(QtGui.QMainWindow, Singleton):
self.account_name.setFont(font)
self.account_name.setObjectName("account_name")
self.account_status = DataLabel(Form)
self.account_status.setGeometry(QtCore.QRect(100, 45, 400, 25))
self.account_status.setGeometry(QtCore.QRect(100, 20, 400, 25))
self.account_status.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse)
font.setPointSize(12)
font.setBold(False)
self.account_status.setFont(font)
self.account_status.setObjectName("account_status")
self.callButton = QtGui.QPushButton(Form)
self.callButton.setGeometry(QtCore.QRect(550, 30, 50, 50))
self.callButton.setGeometry(QtCore.QRect(550, 5, 50, 50))
self.callButton.setObjectName("callButton")
self.callButton.clicked.connect(lambda: self.profile.call_click(True))
self.videocallButton = QtGui.QPushButton(Form)
self.videocallButton.setGeometry(QtCore.QRect(550, 30, 50, 50))
self.videocallButton.setGeometry(QtCore.QRect(550, 5, 50, 50))
self.videocallButton.setObjectName("videocallButton")
self.videocallButton.clicked.connect(lambda: self.profile.call_click(True, True))
self.update_call_state('call')
self.typing = QtGui.QLabel(Form)
self.typing.setGeometry(QtCore.QRect(500, 50, 50, 30))
self.typing.setGeometry(QtCore.QRect(500, 25, 50, 30))
pixmap = QtGui.QPixmap(QtCore.QSize(50, 30))
pixmap.load(curr_directory() + '/images/typing.png')
self.typing.setScaledContents(False)
@ -289,6 +296,7 @@ class MainWindow(QtGui.QMainWindow, Singleton):
self.setGeometry(s['x'], s['y'], s['width'], s['height'])
self.setWindowTitle('Toxygen')
os.chdir(curr_directory() + '/images/')
menu = QtGui.QWidget()
main = QtGui.QWidget()
grid = QtGui.QGridLayout()
search = QtGui.QWidget()
@ -303,35 +311,38 @@ class MainWindow(QtGui.QMainWindow, Singleton):
self.setup_right_top(info)
self.setup_right_bottom(message_buttons)
self.setup_left_center(main_list)
self.setup_menu(menu)
if not Settings.get_instance()['mirror_mode']:
grid.addWidget(search, 1, 0)
grid.addWidget(name, 0, 0)
grid.addWidget(messages, 1, 1, 2, 1)
grid.addWidget(info, 0, 1)
grid.addWidget(message_buttons, 3, 1)
grid.addWidget(main_list, 2, 0, 2, 1)
grid.addWidget(search, 2, 0)
grid.addWidget(name, 1, 0)
grid.addWidget(messages, 2, 1, 2, 1)
grid.addWidget(info, 1, 1)
grid.addWidget(message_buttons, 4, 1)
grid.addWidget(main_list, 3, 0, 2, 1)
grid.setColumnMinimumWidth(1, 500)
grid.setColumnMinimumWidth(0, 270)
else:
grid.addWidget(search, 1, 1)
grid.addWidget(name, 0, 1)
grid.addWidget(messages, 1, 0, 2, 1)
grid.addWidget(info, 0, 0)
grid.addWidget(message_buttons, 3, 0)
grid.addWidget(main_list, 2, 1, 2, 1)
grid.addWidget(search, 2, 1)
grid.addWidget(name, 1, 1)
grid.addWidget(messages, 2, 0, 2, 1)
grid.addWidget(info, 1, 0)
grid.addWidget(message_buttons, 4, 0)
grid.addWidget(main_list, 3, 1, 2, 1)
grid.setColumnMinimumWidth(0, 500)
grid.setColumnMinimumWidth(1, 270)
grid.addWidget(menu, 0, 0, 1, 2)
grid.setSpacing(0)
grid.setContentsMargins(0, 0, 0, 0)
grid.setRowMinimumHeight(0, 100)
grid.setRowMinimumHeight(1, 25)
grid.setRowMinimumHeight(2, 320)
grid.setRowMinimumHeight(3, 55)
grid.setRowMinimumHeight(0, 25)
grid.setRowMinimumHeight(1, 75)
grid.setRowMinimumHeight(2, 25)
grid.setRowMinimumHeight(3, 320)
grid.setRowMinimumHeight(4, 55)
grid.setColumnStretch(1, 1)
grid.setRowStretch(2, 1)
grid.setRowStretch(3, 1)
main.setLayout(grid)
self.setCentralWidget(main)
self.setup_menu(self)
self.messageEdit.setFocus()
self.user_info = name
self.friend_info = info
@ -364,16 +375,16 @@ class MainWindow(QtGui.QMainWindow, Singleton):
self.messages.setGeometry(0, 0, self.width() - 270, self.height() - 155)
self.friends_list.setGeometry(0, 0, 270, self.height() - 125)
self.videocallButton.setGeometry(QtCore.QRect(self.width() - 330, 40, 50, 50))
self.callButton.setGeometry(QtCore.QRect(self.width() - 390, 40, 50, 50))
self.typing.setGeometry(QtCore.QRect(self.width() - 450, 50, 50, 30))
self.videocallButton.setGeometry(QtCore.QRect(self.width() - 330, 10, 50, 50))
self.callButton.setGeometry(QtCore.QRect(self.width() - 390, 10, 50, 50))
self.typing.setGeometry(QtCore.QRect(self.width() - 450, 20, 50, 30))
self.messageEdit.setGeometry(QtCore.QRect(55, 0, self.width() - 395, 55))
self.menuButton.setGeometry(QtCore.QRect(0, 0, 55, 55))
self.sendMessageButton.setGeometry(QtCore.QRect(self.width() - 340, 0, 70, 55))
self.account_name.setGeometry(QtCore.QRect(100, 40, self.width() - 560, 25))
self.account_status.setGeometry(QtCore.QRect(100, 60, self.width() - 560, 25))
self.account_name.setGeometry(QtCore.QRect(100, 15, self.width() - 560, 25))
self.account_status.setGeometry(QtCore.QRect(100, 35, self.width() - 560, 25))
self.messageEdit.setFocus()
self.profile.update()

View File

@ -392,3 +392,15 @@ class WelcomeScreen(CenteredWidget):
s = settings.Settings.get_instance()
s['show_welcome_screen'] = False
s.save()
class MainMenuButton(QtGui.QPushButton):
def __init__(self, *args):
super().__init__(*args)
self.setObjectName("mainmenubutton")
def setText(self, text):
metrics = QtGui.QFontMetrics(self.font())
self.setFixedWidth(metrics.size(QtCore.Qt.TextSingleLine, text).width() + 20)
super().setText(text)

View File

@ -1070,12 +1070,6 @@ QToolButton::menu-arrow:open {
border: 1px solid #3A3939;
}
QPushButton::menu-indicator {
subcontrol-origin: padding;
subcontrol-position: bottom right;
left: 8px;
}
QTableView
{
border: 1px solid #444;
@ -1286,4 +1280,33 @@ QListWidget > QLabel
#contact_name
{
padding-left: 22px;
}
#mainmenubutton
{
border: 1px solid #3A3939;
color: silver;
margin: 0px;
text-align: center;
}
#mainmenubutton:hover
{
background: transparent;
border: 1px solid #A9A9A9;
background-color: #302F2F;
}
#mainmenubutton:pressed
{
background: transparent;
border: 1px solid #A9A9A9;
background-color: #302F2F;
}
#mainmenubutton::menu-indicator
{
image: none;
width: 0px;
height: 0px;
}