diff --git a/gui/copySelectDialog.py b/gui/copySelectDialog.py new file mode 100644 index 000000000..45fb91d10 --- /dev/null +++ b/gui/copySelectDialog.py @@ -0,0 +1,61 @@ +#=============================================================================== +# 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 = (-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", + 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,0,wx.EXPAND | wx.ALL, 5) + + buttonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL) + if (buttonSizer): + mainSizer.Add(buttonSizer,0, wx.EXPAND | wx.ALL, 5) + + self.SetSizer(mainSizer) + self.Fit() + self.Center() + + + def Selected(self, event): + self.copyFormat = event.GetSelection() + + def GetSelected(self): + return self.copyFormat + + diff --git a/gui/fittingView.py b/gui/fittingView.py index 9edec4d86..e93c78da8 100644 --- a/gui/fittingView.py +++ b/gui/fittingView.py @@ -248,3 +248,5 @@ class FittingView(d.Display): wx.PostEvent(self.mainFrame, FitChanged(fitID=self.mainFrame.getActiveFit())) else: event.Skip() + + \ No newline at end of file diff --git a/gui/mainFrame.py b/gui/mainFrame.py index bcf336ad5..38ac58ac5 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 @@ -242,19 +243,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())) @@ -266,6 +265,19 @@ 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: + CopySelectDict[selected]() + except: + pass + dlg.Destroy() def toClipboard(self, text): clip = wx.TheClipboard diff --git a/gui/mainMenuBar.py b/gui/mainMenuBar.py index fe56fcfac..5bcd5e8a5 100644 --- a/gui/mainMenuBar.py +++ b/gui/mainMenuBar.py @@ -51,18 +51,12 @@ class MainMenuBar(wx.MenuBar): #editMenu.Append(wx.ID_UNDO) #editMenu.Append(wx.ID_REDO) - 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 = "Export &To Clipboard" + ("\tCTRL+C" if 'wxMSW' in wx.PlatformInfo else "") - pasteText = "Import &From Clipboard" + ("\tCTRL+V" if 'wxMSW' in wx.PlatformInfo else "") - editMenu.AppendMenu(wx.ID_COPY, copyText, clipboardMenu, "Export a 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 "") + editMenu.Append(wx.ID_COPY, copyText, "Export a fit to the clipboard") editMenu.Append(wx.ID_PASTE, pasteText, "Import a fit from the clipboard") - # Character menu windowMenu = wx.Menu() self.Append(windowMenu, "&Window")