From 8b34a9c666ab93ea6b940876f446de44650e5d8b Mon Sep 17 00:00:00 2001 From: Lucas Thode Date: Thu, 28 Oct 2010 08:42:26 -0500 Subject: [PATCH 1/7] Removed submenu for copy, will replace with dialog --- gui/mainFrame.py | 13 +++++++------ gui/mainMenuBar.py | 8 +------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index c85514d32..4bdd9c956 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -230,19 +230,17 @@ class MainFrame(wx.Frame): self.Bind(wx.EVT_MENU, self.showPreferenceDialog, id=wx.ID_PREFERENCES) #Clipboard exports - self.Bind(wx.EVT_MENU, self.clipboardEft, id=menuBar.idExportEft) - self.Bind(wx.EVT_MENU, self.clipboardDna, id=menuBar.idExportDna) - self.Bind(wx.EVT_MENU, self.clipboardXml, id=menuBar.idExportXml) + self.Bind(wx.EVT_MENU, self.exportToClipboard, id=wx.ID_COPY) - def clipboardEft(self, event): + def clipboardEft(self): sFit = service.Fit.getInstance() self.toClipboard(sFit.exportFit(self.getActiveFit())) - def clipboardDna(self, event): + def clipboardDna(self): sFit = service.Fit.getInstance() self.toClipboard(sFit.exportDna(self.getActiveFit())) - def clipboardXml(self, event): + def clipboardXml(self): sFit = service.Fit.getInstance() self.toClipboard(sFit.exportXml(self.getActiveFit())) @@ -254,6 +252,9 @@ class MainFrame(wx.Frame): self._openAfterImport(len(fits), IDs) except: pass + + def exportToClipboard(self, event): + sFit = service.Fit.getInstance() def toClipboard(self, text): clip = wx.TheClipboard diff --git a/gui/mainMenuBar.py b/gui/mainMenuBar.py index d983bfd25..73fdb7ead 100644 --- a/gui/mainMenuBar.py +++ b/gui/mainMenuBar.py @@ -54,15 +54,9 @@ class MainMenuBar(wx.MenuBar): fitMenu.Append(wx.ID_OPEN, "&Import", "Import a fit into pyfa.") fitMenu.Append(wx.ID_SAVEAS, "&Export\tCTRL+S", "Export the fit to another format.") - clipboardMenu = wx.Menu() - self.idExportDna, self.idExportEft, self.idExportXml = wx.NewId(), wx.NewId(), wx.NewId() - clipboardMenu.Append(self.idExportEft, "&EFT", "Copy the EFT export of this fit to the clipboard") - clipboardMenu.Append(self.idExportXml, "&XML", "Copy the XML export of this fit to the clipboard") - clipboardMenu.Append(self.idExportDna, "&DNA", "Copy the DNA export of this fit to the clipboard") - copyText = "&To Clipboard" + ("\tCTRL+C" if 'wxMSW' in wx.PlatformInfo else "") pasteText = "&From Clipboard" + ("\tCTRL+V" if 'wxMSW' in wx.PlatformInfo else "") - fitMenu.AppendMenu(wx.ID_COPY, copyText, clipboardMenu, "Export a fit to the clipboard") + fitMenu.Append(wx.ID_COPY, copyText, "Export a fit to the clipboard") fitMenu.Append(wx.ID_PASTE, pasteText, "Import a fit from the clipboard") From 92457a8006a7c773ab478632ab1002c6f0977377 Mon Sep 17 00:00:00 2001 From: Lucas Thode Date: Thu, 28 Oct 2010 09:40:56 -0500 Subject: [PATCH 2/7] Added copy-format selection dialog. --- gui/copySelectDialog.py | 59 +++++++++++++++++++++++++++++++++++++++++ gui/mainFrame.py | 6 +++++ 2 files changed, 65 insertions(+) create mode 100644 gui/copySelectDialog.py diff --git a/gui/copySelectDialog.py b/gui/copySelectDialog.py new file mode 100644 index 000000000..4903bc791 --- /dev/null +++ b/gui/copySelectDialog.py @@ -0,0 +1,59 @@ +#=============================================================================== +# Copyright (C) 2010 Lucas Thode +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyfa. If not, see . +#=============================================================================== + + +import wx + +class CopySelectDialog(wx.Dialog): + copyFormatEft = 0 + copyFormatXml = 1 + copyFormatDna = 2 + + def __init__(self, parent): + wx.Dialog.__init__(self, parent, id = wx.ID_ANY, title = u"Select a format", size = wx.Size(200, 125), style = wx.DEFAULT_DIALOG_STYLE) + mainSizer = wx.BoxSizer(wx.VERTICAL) + + copyFormats = [u"EFT", u"XML", u"DNA"] + copyFormatTooltips = {CopySelectDialog.copyFormatEft: u"Eve Fitting Tool text format", + CopySelectDialog.copyFormatXml: u"EvE native XML format", + CopySelectDialog.copyFormatDna: u"A one-line text format"} + selector = wx.RadioBox(self, wx.ID_ANY, label = u"Copy to the clipboard using:", choices = copyFormats, style = wx.RA_SPECIFY_ROWS) + selector.Bind(wx.EVT_RADIOBOX, self.Selected) + for format, tooltip in copyFormatTooltips.iteritems(): + selector.SetItemToolTip(format, tooltip) + + self.copyFormat = CopySelectDialog.copyFormatEft + selector.SetSelection(self.copyFormat) + + mainSizer.Add(selector) + + buttonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL) + if (buttonSizer): + mainSizer.Add(buttonSizer) + + self.SetSizer(mainSizer) + + + def Selected(self, event): + self.copyFormat = event.GetSelection() + + def GetSelected(self): + return self.copyFormat + + diff --git a/gui/mainFrame.py b/gui/mainFrame.py index 4bdd9c956..35cdd6b2a 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -31,6 +31,7 @@ from gui.characterEditor import CharacterEditor from gui.characterSelection import CharacterSelection from gui.patternEditor import DmgPatternEditorDlg from gui.preferenceDialog import PreferenceDialog +from gui.copySelectDialog import CopySelectDialog import aboutData import gui.fittingView as fv from wx._core import PyDeadObjectError @@ -255,6 +256,11 @@ class MainFrame(wx.Frame): def exportToClipboard(self, event): sFit = service.Fit.getInstance() + dlg = CopySelectDialog(self) + dlg.ShowModal() + selected = dlg.GetSelected() + print selected + dlg.Destroy() def toClipboard(self, text): clip = wx.TheClipboard From 683a9111494b0c4780ada4edd98989e39dcb782c Mon Sep 17 00:00:00 2001 From: Lucas Thode Date: Thu, 28 Oct 2010 09:45:13 -0500 Subject: [PATCH 3/7] Finished export-to-clipboard dialog support. (Well, almost: it defaults to EFT at the moment, which is not quite right. I strongly suspect that the default should be configurable, although further discussion is needed on this matter. --- gui/mainFrame.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index 35cdd6b2a..5818de7fd 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -255,11 +255,17 @@ class MainFrame(wx.Frame): pass def exportToClipboard(self, event): - sFit = service.Fit.getInstance() dlg = CopySelectDialog(self) dlg.ShowModal() selected = dlg.GetSelected() - print selected + if selected == CopySelectDialog.copyFormatEft: + self.clipboardEft() + elif selected == CopySelectDialog.copyFormatXml: + self.clipboardXml() + elif selected == CopySelectDialog.copyFormatDna: + self.clipboardDna() + else: + print "Invalid clipboard export format, we should never get here!" dlg.Destroy() def toClipboard(self, text): From 0280d278539d4da65ab8f0cdd928715a230eea44 Mon Sep 17 00:00:00 2001 From: Lucas Thode Date: Thu, 28 Oct 2010 09:56:49 -0500 Subject: [PATCH 4/7] Swallowed traceback on copying with no active fit. --- gui/mainFrame.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index 5818de7fd..bbd093e5f 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -258,14 +258,17 @@ class MainFrame(wx.Frame): dlg = CopySelectDialog(self) dlg.ShowModal() selected = dlg.GetSelected() - if selected == CopySelectDialog.copyFormatEft: - self.clipboardEft() - elif selected == CopySelectDialog.copyFormatXml: - self.clipboardXml() - elif selected == CopySelectDialog.copyFormatDna: - self.clipboardDna() - else: - print "Invalid clipboard export format, we should never get here!" + try: + if selected == CopySelectDialog.copyFormatEft: + self.clipboardEft() + elif selected == CopySelectDialog.copyFormatXml: + self.clipboardXml() + elif selected == CopySelectDialog.copyFormatDna: + self.clipboardDna() + else: + print "oops, invalid clipboard export format: %d" % selected + except: + pass dlg.Destroy() def toClipboard(self, text): From 1750624f0feacd519778cbf175b064b631d667ad Mon Sep 17 00:00:00 2001 From: Lucas Thode Date: Thu, 28 Oct 2010 15:40:19 -0500 Subject: [PATCH 5/7] made the export-to-clipboard code use a lookup tbl --- gui/mainFrame.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index bbd093e5f..d6aa815f6 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -253,20 +253,16 @@ class MainFrame(wx.Frame): self._openAfterImport(len(fits), IDs) except: pass - + def exportToClipboard(self, event): + CopySelectDict = {CopySelectDialog.copyFormatEft: self.clipboardEft, + CopySelectDialog.copyFormatXml: self.clipboardXml, + CopySelectDialog.copyFormatDna: self.clipboardDna} dlg = CopySelectDialog(self) dlg.ShowModal() selected = dlg.GetSelected() try: - if selected == CopySelectDialog.copyFormatEft: - self.clipboardEft() - elif selected == CopySelectDialog.copyFormatXml: - self.clipboardXml() - elif selected == CopySelectDialog.copyFormatDna: - self.clipboardDna() - else: - print "oops, invalid clipboard export format: %d" % selected + CopySelectDict[selected]() except: pass dlg.Destroy() From 90aaf81826cc753ee421222832fc727348807eaf Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 29 Oct 2010 00:12:13 +0300 Subject: [PATCH 6/7] Fixed dialog childs layout --- gui/copySelectDialog.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/gui/copySelectDialog.py b/gui/copySelectDialog.py index 4903bc791..310c6fb64 100644 --- a/gui/copySelectDialog.py +++ b/gui/copySelectDialog.py @@ -24,11 +24,11 @@ class CopySelectDialog(wx.Dialog): copyFormatEft = 0 copyFormatXml = 1 copyFormatDna = 2 - + def __init__(self, parent): - wx.Dialog.__init__(self, parent, id = wx.ID_ANY, title = u"Select a format", size = wx.Size(200, 125), style = wx.DEFAULT_DIALOG_STYLE) + wx.Dialog.__init__(self, parent, id = wx.ID_ANY, title = u"Select a format", size = (-1,-1), style = wx.DEFAULT_DIALOG_STYLE) mainSizer = wx.BoxSizer(wx.VERTICAL) - + copyFormats = [u"EFT", u"XML", u"DNA"] copyFormatTooltips = {CopySelectDialog.copyFormatEft: u"Eve Fitting Tool text format", CopySelectDialog.copyFormatXml: u"EvE native XML format", @@ -37,23 +37,24 @@ class CopySelectDialog(wx.Dialog): selector.Bind(wx.EVT_RADIOBOX, self.Selected) for format, tooltip in copyFormatTooltips.iteritems(): selector.SetItemToolTip(format, tooltip) - + self.copyFormat = CopySelectDialog.copyFormatEft selector.SetSelection(self.copyFormat) - - mainSizer.Add(selector) + + mainSizer.Add(selector,0,wx.EXPAND | wx.ALL, 5) buttonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL) if (buttonSizer): - mainSizer.Add(buttonSizer) - + mainSizer.Add(buttonSizer,0, wx.EXPAND | wx.ALL, 5) + self.SetSizer(mainSizer) - - + self.Fit() + + def Selected(self, event): self.copyFormat = event.GetSelection() - + def GetSelected(self): return self.copyFormat - - + + From d03aa092378a40c62ab10c85811722d47b269801 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Fri, 29 Oct 2010 00:14:07 +0300 Subject: [PATCH 7/7] Have copyto dialog centered to main window --- gui/copySelectDialog.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gui/copySelectDialog.py b/gui/copySelectDialog.py index 310c6fb64..45fb91d10 100644 --- a/gui/copySelectDialog.py +++ b/gui/copySelectDialog.py @@ -49,6 +49,7 @@ class CopySelectDialog(wx.Dialog): self.SetSizer(mainSizer) self.Fit() + self.Center() def Selected(self, event):