Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
athre0z committed Jun 22, 2018
2 parents 5acae46 + de8eb90 commit 634f2ae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
24 changes: 16 additions & 8 deletions plugins/idaskins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

import idaapi
from idaskins import IDA_DIR
from idaskins import IDA_DIR, THEMES_DIR
from idaskins.idafontconfig import IdaFontConfig
from idaskins.objectinspector import ObjectInspector
from idaskins.settings import Settings
Expand Down Expand Up @@ -71,6 +71,13 @@ def __init__(self, *args, **kwargs):
self.open_theme_selector()

self._settings.first_start = False
else:
# v2.0.0 used absolute pathes due to a bug.
# Fix settings from this particular version here.
theme_dir = self._settings.selected_theme_dir
if theme_dir and os.path.isabs(theme_dir):
print('[IDASkins] Updating buggy v2.0.0 theme path')
self._settings.selected_theme_dir = os.path.split(theme_dir)[-1]

self._theme_selector = None
self.apply_stylesheet_from_settings()
Expand All @@ -79,9 +86,9 @@ def __init__(self, *args, **kwargs):
self._ui_hooks = UiHooks()
self._ui_hooks.hook()

def preprocess_stylesheet(self, qss, theme_dir):
def preprocess_stylesheet(self, qss, abs_theme_dir):
qss = qss.replace('<IDADIR>', QDir.fromNativeSeparators(IDA_DIR))
qss = qss.replace('<SKINDIR>', QDir.fromNativeSeparators(theme_dir))
qss = qss.replace('<SKINDIR>', QDir.fromNativeSeparators(abs_theme_dir))

def replace_keyword(x, keyword, kind):
cfg = IdaFontConfig(kind)
Expand All @@ -102,31 +109,32 @@ def replace_keyword(x, keyword, kind):

return qss

def apply_stylesheet(self, theme_dir, manifest):
def apply_stylesheet(self, abs_theme_dir, manifest):
try:
with open(os.path.join(theme_dir, manifest.qss_file)) as f:
with open(os.path.join(abs_theme_dir, manifest.qss_file)) as f:
qss = f.read()
except IOError as exc:
print('[IDASkins] Unable to load stylesheet.')
return

qss = self.preprocess_stylesheet(qss, theme_dir)
qss = self.preprocess_stylesheet(qss, abs_theme_dir)
qApp.setStyleSheet(qss)
#idaapi.request_refresh(idaapi.IWID_ALL)
print('[IDASkins] Skin file successfully applied!')

def apply_stylesheet_from_settings(self):
theme_dir = self._settings.selected_theme_dir
abs_theme_dir = os.path.join(THEMES_DIR, theme_dir)
if theme_dir:
try:
manifest = ThemeManifest(open(os.path.join(
theme_dir, 'manifest.json'
abs_theme_dir, 'manifest.json'
)))
except ManifestError as exc:
print('[IDASkins]', str(exc))
return

self.apply_stylesheet(theme_dir, manifest)
self.apply_stylesheet(abs_theme_dir, manifest)

def open_theme_selector(self):
self._theme_selector = ThemeSelector(qApp.activeWindow())
Expand Down
7 changes: 4 additions & 3 deletions plugins/idaskins/themeselector.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def refresh(self):
try:
self._theme_list = [
(
os.path.join(THEMES_DIR, x),
x,
ThemeManifest(open(
os.path.join(THEMES_DIR, x, 'manifest.json')
),
Expand All @@ -69,18 +69,19 @@ def refresh(self):

def theme_selected(self):
theme_dir, manifest = self._get_selected()
abs_theme_dir = os.path.join(THEMES_DIR, theme_dir)

self._ui.lblAuthorVal.setText(manifest.author)
self._ui.lblVersionVal.setText(manifest.version)
self._ui.lblNotesVal.setText(manifest.notes)
self._ui.leClrPathVal.setText(
os.path.join(theme_dir, manifest.clr_file)
os.path.join(abs_theme_dir, manifest.clr_file)
if manifest.clr_file else
None
)

if manifest.preview_image:
abs_path = os.path.join(theme_dir, manifest.preview_image)
abs_path = os.path.join(abs_theme_dir, manifest.preview_image)
self._preview_pixmap = QPixmap(abs_path)
self.update_preview()
else:
Expand Down

0 comments on commit 634f2ae

Please sign in to comment.