Glad your finding the plugin of some use. I'm going to be very busy for the next week or two, but after that I can port it to Anki 2 for you. (I would have already done it but I prefer Anki 1.2.8).
It would probably take <10 minutes to port for someone who is already familiar with Anki 2 plugin creation. Here is the existing Copy2Clipboard code if anybody wants to port it sooner:
Code:
# -*- coding: utf-8 -*-
# Copyright (C) 2012 Christopher Brochtrup
#
# This file is part of Copy2Clipboard
#
# Copy2Clipboard 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.
#
# Copy2Clipboard 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 Copy2Clipboard. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
# Description:
#
# Copy2Clipboard will automatically copy a single card field to the clipboard
# when either the card's question side is shown or when the card's answer side
# is shown (or both, if desired).
#
# Default behavior:
#
# * When the card's question is shown:
# Nothing will be copied to the clipboard.
#
# * When the card's answer is shown:
# The card's "Expression" field will be copied to the clipboard (if one exists).
#
# To change the default behavior simply edit the questionField or answerField
# variables in the User Options section of this file.
#
###############################################################################
# Version: 1.0
# Contact: cb4960@gmail.com
###############################################################################
#### Includes ####
import os, codecs
import ankiqt
from anki.hooks import wrap
from PyQt4 import QtGui
#### User Options ####
# The name of the field to copy to the clipboard when the question side of the
# card is shown. Case sensitive. If you don't want to copy, set to a blank string.
questionField = ""
# The name of the field to copy to the clipboard when the answer side of the
# card is shown. Case sensitive. If you don't want to copy, set to a blank string.
answerField = "Expression"
#### Debugging ####
DEBUG = False
LOG_FILE = os.path.join(ankiqt.mw.config.configPath, "plugins", "Copy2Clipboard.log")
CLEAR_LOG_AT_STARTUP = True
#### Functions ####
def clearLog():
if DEBUG:
file = codecs.open(LOG_FILE, "w", "utf-8-sig")
file.write("")
file.close()
def writeLog(text):
if DEBUG:
file = codecs.open(LOG_FILE, "a", "utf-8-sig")
file.write(text + "\n")
file.close()
def copyTextToClipboard(text):
clipboard = QtGui.QApplication.clipboard()
clipboard.setText(text)
def copyField(state):
if state == "showQuestion":
writeLog("copyField: showQuestion")
if questionField != "":
for field in ankiqt.mw.currentCard.fact.fields:
if field.getName() == questionField:
writeLog(field.getName() + ": " + field.value)
copyTextToClipboard(field.value)
break;
elif state == "showAnswer":
writeLog("copyField: showAnswer")
if answerField != "":
for field in ankiqt.mw.currentCard.fact.fields:
if field.getName() == answerField:
writeLog(field.getName() + ": " + field.value)
copyTextToClipboard(field.value)
break;
#### Main ####
if CLEAR_LOG_AT_STARTUP:
clearLog()
writeLog("-----------------------------------------------------------")
writeLog("Main.START")
ankiqt.mw.moveToState = wrap(ankiqt.mw.moveToState, copyField)