Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
e8145a51
Commit
e8145a51
authored
Apr 09, 2014
by
Saul Ibarra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix color in account selection combobox
parent
f0f4b3c8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
17 deletions
+21
-17
accounts.py
blink/accounts.py
+21
-17
No files found.
blink/accounts.py
View file @
e8145a51
...
@@ -169,13 +169,26 @@ class ActiveAccountModel(QSortFilterProxyModel):
...
@@ -169,13 +169,26 @@ class ActiveAccountModel(QSortFilterProxyModel):
return
account_info
.
account
.
enabled
return
account_info
.
account
.
enabled
class
AccountStatePalettes
(
dict
):
def
__init__
(
self
,
palette
):
super
(
AccountStatePalettes
,
self
)
.
__init__
(
succeeded
=
palette
)
self
.
alternate_palette
=
QPalette
(
palette
)
self
.
alternate_palette
.
setColor
(
QPalette
.
Text
,
self
.
alternate_palette
.
color
(
QPalette
.
Mid
))
self
.
alternate_palette
.
setColor
(
QPalette
.
ButtonText
,
self
.
alternate_palette
.
color
(
QPalette
.
Mid
))
self
.
alternate_palette
.
setColor
(
QPalette
.
WindowText
,
self
.
alternate_palette
.
color
(
QPalette
.
Mid
))
def
__missing__
(
self
,
key
):
return
self
.
setdefault
(
key
,
self
.
alternate_palette
)
class
AccountDelegate
(
QStyledItemDelegate
):
class
AccountDelegate
(
QStyledItemDelegate
):
def
__init__
(
self
,
parent
):
super
(
AccountDelegate
,
self
)
.
__init__
(
parent
)
self
.
state_palette_map
=
AccountStatePalettes
(
parent
.
palette
())
def
paint
(
self
,
painter
,
option
,
index
):
def
paint
(
self
,
painter
,
option
,
index
):
account_info
=
index
.
data
(
Qt
.
UserRole
)
account_info
=
index
.
data
(
Qt
.
UserRole
)
if
account_info
.
registration_state
==
'succeeded'
:
option
.
palette
=
self
.
state_palette_map
[
account_info
.
registration_state
]
option
.
palette
.
setColor
(
QPalette
.
Text
,
Qt
.
black
)
else
:
option
.
palette
.
setColor
(
QPalette
.
Text
,
Qt
.
gray
)
super
(
AccountDelegate
,
self
)
.
paint
(
painter
,
option
,
index
)
super
(
AccountDelegate
,
self
)
.
paint
(
painter
,
option
,
index
)
...
@@ -184,9 +197,10 @@ class AccountSelector(QComboBox):
...
@@ -184,9 +197,10 @@ class AccountSelector(QComboBox):
def
__init__
(
self
,
parent
=
None
):
def
__init__
(
self
,
parent
=
None
):
super
(
AccountSelector
,
self
)
.
__init__
(
parent
)
super
(
AccountSelector
,
self
)
.
__init__
(
parent
)
self
.
state_palette_map
=
AccountStatePalettes
(
self
.
palette
())
self
.
setItemDelegate
(
AccountDelegate
(
self
.
view
()))
self
.
currentIndexChanged
[
int
]
.
connect
(
self
.
_SH_SelectionChanged
)
self
.
currentIndexChanged
[
int
]
.
connect
(
self
.
_SH_SelectionChanged
)
self
.
model
()
.
dataChanged
.
connect
(
self
.
_SH_DataChanged
)
self
.
model
()
.
dataChanged
.
connect
(
self
.
_SH_DataChanged
)
self
.
view
()
.
setItemDelegate
(
AccountDelegate
(
self
.
view
()))
notification_center
=
NotificationCenter
()
notification_center
=
NotificationCenter
()
notification_center
.
add_observer
(
self
,
name
=
"SIPAccountManagerDidChangeDefaultAccount"
)
notification_center
.
add_observer
(
self
,
name
=
"SIPAccountManagerDidChangeDefaultAccount"
)
...
@@ -201,23 +215,13 @@ class AccountSelector(QComboBox):
...
@@ -201,23 +215,13 @@ class AccountSelector(QComboBox):
index
=
self
.
currentIndex
()
index
=
self
.
currentIndex
()
if
topLeft
.
row
()
<=
index
<=
bottomRight
.
row
():
if
topLeft
.
row
()
<=
index
<=
bottomRight
.
row
():
account_info
=
self
.
itemData
(
index
)
account_info
=
self
.
itemData
(
index
)
palette
=
self
.
palette
()
self
.
setPalette
(
self
.
state_palette_map
[
account_info
.
registration_state
])
if
account_info
.
registration_state
==
'succeeded'
:
palette
.
setColor
(
QPalette
.
Text
,
Qt
.
black
)
else
:
palette
.
setColor
(
QPalette
.
Text
,
Qt
.
gray
)
self
.
setPalette
(
palette
)
def
_SH_SelectionChanged
(
self
,
index
):
def
_SH_SelectionChanged
(
self
,
index
):
if
index
==
-
1
:
if
index
==
-
1
:
return
return
account_info
=
self
.
itemData
(
index
)
account_info
=
self
.
itemData
(
index
)
palette
=
self
.
palette
()
self
.
setPalette
(
self
.
state_palette_map
[
account_info
.
registration_state
])
if
account_info
.
registration_state
==
'succeeded'
:
palette
.
setColor
(
QPalette
.
Text
,
Qt
.
black
)
else
:
palette
.
setColor
(
QPalette
.
Text
,
Qt
.
gray
)
self
.
setPalette
(
palette
)
@
run_in_gui_thread
@
run_in_gui_thread
def
handle_notification
(
self
,
notification
):
def
handle_notification
(
self
,
notification
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment