HTML can now be manually called. "Enabled" now refers to "Enable Automatic". Also, fixed nagging typo. ("HTMl" lol)

This commit is contained in:
blitzmann
2014-03-27 22:15:34 -04:00
parent 890ff55690
commit 4faa2abe96
5 changed files with 36 additions and 15 deletions

View File

@@ -13,10 +13,12 @@ import gui.globalEvents as GE
class PFHTMLExportPref ( PreferenceView):
title = "HTML Export"
desc = "Turning this feature on will create a HTML file at the specified location "+ \
"with all your fits in it. If you browse to this HTML file from the "+\
"in-game browser you can easily view and import your fits by clicking on them. "+\
"The file will be updated every time a fit changes or gets added."
desc = "HTML Export (File > Export HTML) allows you to export your entire fitting "+\
"database into an HTML file at the specified location. This file can be "+\
"used in the in-game browser to easily open and import your fits, or used "+\
"in a regular web browser to open them at NULL-SEC.com."
desc2 = "Enabling automatic exporting will update the HTML file after any change "+\
"to a fit is made. Under certain circumstance, this may cause performance issues."
def populatePanel( self, panel ):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
@@ -37,11 +39,6 @@ class PFHTMLExportPref ( PreferenceView):
self.stDesc.Wrap(dlgWidth - 50)
mainSizer.Add( self.stDesc, 0, wx.ALL, 5 )
self.exportEnabled = wx.CheckBox( panel, wx.ID_ANY, u"Enable HTML export", wx.DefaultPosition, wx.DefaultSize, 0 )
self.exportEnabled.SetValue(self.HTMLExportSettings.getEnabled())
self.exportEnabled.Bind(wx.EVT_CHECKBOX, self.OnExportEnabledChange)
mainSizer.Add( self.exportEnabled, 0, wx.ALL|wx.EXPAND, 5 )
self.PathLinkCtrl = wx.HyperlinkCtrl( panel, wx.ID_ANY, self.HTMLExportSettings.getPath(), u'file:///{}'.format(self.HTMLExportSettings.getPath()), wx.DefaultPosition, wx.DefaultSize, wx.HL_ALIGN_LEFT|wx.NO_BORDER|wx.HL_CONTEXTMENU )
mainSizer.Add( self.PathLinkCtrl, 0, wx.ALL|wx.EXPAND, 5)
@@ -53,6 +50,15 @@ class PFHTMLExportPref ( PreferenceView):
self.fileSelectButton.Bind(wx.EVT_BUTTON, self.selectHTMLExportFilePath)
mainSizer.Add( self.fileSelectButton, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
self.stDesc2 = wx.StaticText( panel, wx.ID_ANY, self.desc2, wx.DefaultPosition, wx.DefaultSize, 0 )
self.stDesc2.Wrap(dlgWidth - 50)
mainSizer.Add( self.stDesc2, 0, wx.ALL, 5 )
self.exportEnabled = wx.CheckBox( panel, wx.ID_ANY, u"Enable automatic HTML export", wx.DefaultPosition, wx.DefaultSize, 0 )
self.exportEnabled.SetValue(self.HTMLExportSettings.getEnabled())
self.exportEnabled.Bind(wx.EVT_CHECKBOX, self.OnExportEnabledChange)
mainSizer.Add( self.exportEnabled, 0, wx.ALL|wx.EXPAND, 5 )
panel.SetSizer( mainSizer )
panel.Layout()

View File

@@ -392,7 +392,7 @@ class FittingView(d.Display):
self.populate(self.mods)
self.refresh(self.mods)
exportHtml.getInstance().refreshFittingHTMl()
exportHtml.getInstance().refreshFittingHtml()
self.Show(self.activeFitID is not None and self.activeFitID == event.fitID)
except wx._core.PyDeadObjectError:

View File

@@ -361,6 +361,8 @@ class MainFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.exportSkillsNeeded, id=menuBar.exportSkillsNeededId)
# Import character
self.Bind(wx.EVT_MENU, self.importCharacter, id=menuBar.importCharacterId)
# Export HTML
self.Bind(wx.EVT_MENU, self.exportHtml, id=menuBar.exportHtmlId)
# Preference dialog
self.Bind(wx.EVT_MENU, self.showPreferenceDialog, id = menuBar.preferencesId)
# User guide
@@ -546,6 +548,12 @@ class MainFrame(wx.Frame):
dlg.Destroy()
self.waitDialog.ShowModal()
def exportHtml(self, event):
from gui.utils.exportHtml import exportHtml
self.waitDialog = animUtils.WaitDialog(self)
exportHtml.getInstance().refreshFittingHtml(True, self.closeWaitDialog)
self.waitDialog.ShowModal()
def importCharacterCallback(self):
self.waitDialog.Destroy()
wx.PostEvent(self, GE.CharListUpdated())

View File

@@ -32,6 +32,7 @@ class MainMenuBar(wx.MenuBar):
self.backupFitsId = wx.NewId()
self.exportSkillsNeededId = wx.NewId()
self.importCharacterId = wx.NewId()
self.exportHtmlId = wx.NewId()
self.preferencesId = wx.NewId()
self.wikiId = wx.NewId()
self.forumId = wx.NewId()
@@ -51,10 +52,11 @@ class MainMenuBar(wx.MenuBar):
fileMenu.Append(self.backupFitsId, "&Backup All Fittings", "Backup all fittings to a XML file")
fileMenu.Append(wx.ID_OPEN, "&Import Fittings\tCTRL+O", "Import fittings into pyfa")
fileMenu.Append(wx.ID_SAVEAS, "&Export Fitting\tCTRL+S", "Export fitting to another format")
fileMenu.AppendSeparator()
fileMenu.Append(self.exportHtmlId, "Export HTML", "Export fits to HTML file (set in Preferences)")
fileMenu.Append(self.exportSkillsNeededId, "Export &Skills Needed", "Export skills needed for this fitting")
fileMenu.Append(self.importCharacterId, "Import C&haracters", "Import characters into pyfa")
fileMenu.AppendSeparator()
fileMenu.Append(wx.ID_EXIT)

View File

@@ -1,6 +1,7 @@
import threading
import time
import service
import wx
class exportHtml():
_instance = None
@@ -14,18 +15,19 @@ class exportHtml():
def __init__(self):
self.thread = exportHtmlThread()
def refreshFittingHTMl(self):
def refreshFittingHtml(self, force = False, callback = False):
settings = service.settings.HTMLExportSettings.getInstance()
if (settings.getEnabled()):
if (force or settings.getEnabled()):
self.thread.stop()
self.thread = exportHtmlThread()
self.thread = exportHtmlThread(callback)
self.thread.start()
class exportHtmlThread(threading.Thread):
def __init__(self):
def __init__(self, callback = False):
threading.Thread.__init__(self)
self.callback = callback
self.stopRunning = False
def stop(self):
@@ -169,3 +171,6 @@ class exportHtmlThread(threading.Thread):
print "Failed to write to " + settings.getPath()
pass
if self.callback:
wx.CallAfter(self.callback)