mirror of
https://github.com/ankitects/anki.git
synced 2025-12-18 09:10:57 -05:00
tidy init routine, add ctrl+c
This commit is contained in:
parent
360cf3c373
commit
2a66095eed
3 changed files with 67 additions and 42 deletions
|
|
@ -41,23 +41,14 @@ class AnkiQt(QMainWindow):
|
||||||
self.setupBackupDir()
|
self.setupBackupDir()
|
||||||
self.setupHooks()
|
self.setupHooks()
|
||||||
self.loadPlugins()
|
self.loadPlugins()
|
||||||
self.mainWin = ankiqt.forms.main.Ui_MainWindow()
|
self.setupMainWindow()
|
||||||
self.mainWin.setupUi(self)
|
|
||||||
self.rebuildPluginsMenu()
|
self.rebuildPluginsMenu()
|
||||||
self.alterShortcuts()
|
self.alterShortcuts()
|
||||||
self.help = ui.help.HelpArea(self.mainWin.helpFrame, self.config, self)
|
self.setupTray()
|
||||||
self.trayIcon = ui.tray.AnkiTrayIcon( self )
|
|
||||||
self.connectMenuActions()
|
self.connectMenuActions()
|
||||||
if self.config['mainWindowGeom']:
|
if self.config['mainWindowGeom']:
|
||||||
self.restoreGeometry(self.config['mainWindowGeom'])
|
self.restoreGeometry(self.config['mainWindowGeom'])
|
||||||
self.bodyView = ui.view.View(self, self.mainWin.mainText,
|
self.setupViews()
|
||||||
self.mainWin.mainTextFrame)
|
|
||||||
self.mainWin.mainText.pageAction(QWebPage.Reload).setVisible(False)
|
|
||||||
self.addView(self.bodyView)
|
|
||||||
self.statusView = ui.status.StatusView(self)
|
|
||||||
self.addView(self.statusView)
|
|
||||||
self.mainWin.welcomeText.hide()
|
|
||||||
self.mainWin.mainText.hide()
|
|
||||||
self.setupEditor()
|
self.setupEditor()
|
||||||
self.setupButtons()
|
self.setupButtons()
|
||||||
self.setupAnchors()
|
self.setupAnchors()
|
||||||
|
|
@ -79,6 +70,31 @@ class AnkiQt(QMainWindow):
|
||||||
# check for updates
|
# check for updates
|
||||||
self.setupAutoUpdate()
|
self.setupAutoUpdate()
|
||||||
|
|
||||||
|
def setupMainWindow(self):
|
||||||
|
self.mainWin = ankiqt.forms.main.Ui_MainWindow()
|
||||||
|
self.mainWin.setupUi(self)
|
||||||
|
self.mainWin.mainText = ui.view.AnkiWebView(self.mainWin.mainTextFrame)
|
||||||
|
self.mainWin.mainText.setObjectName("mainText")
|
||||||
|
self.mainWin.vboxlayout.addWidget(self.mainWin.mainText)
|
||||||
|
self.mainWin.buttonWidget = QWidget(self.mainWin.mainTextFrame)
|
||||||
|
self.mainWin.buttonWidget.setObjectName("buttonWidget")
|
||||||
|
self.mainWin.vboxlayout.addWidget(self.mainWin.buttonWidget)
|
||||||
|
self.help = ui.help.HelpArea(self.mainWin.helpFrame, self.config, self)
|
||||||
|
self.mainWin.mainText.pageAction(QWebPage.Reload).setVisible(False)
|
||||||
|
self.mainWin.welcomeText.hide()
|
||||||
|
self.mainWin.mainText.hide()
|
||||||
|
|
||||||
|
def setupViews(self):
|
||||||
|
self.bodyView = ui.view.View(self, self.mainWin.mainText,
|
||||||
|
self.mainWin.mainTextFrame)
|
||||||
|
self.addView(self.bodyView)
|
||||||
|
self.statusView = ui.status.StatusView(self)
|
||||||
|
self.addView(self.statusView)
|
||||||
|
|
||||||
|
def setupTray(self):
|
||||||
|
self.trayIcon = ui.tray.AnkiTrayIcon(self)
|
||||||
|
|
||||||
|
|
||||||
# State machine
|
# State machine
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ from anki.utils import stripHTML
|
||||||
import types, time, re, os, urllib, sys
|
import types, time, re, os, urllib, sys
|
||||||
from ankiqt import ui
|
from ankiqt import ui
|
||||||
from ankiqt.ui.utils import mungeQA
|
from ankiqt.ui.utils import mungeQA
|
||||||
|
from PyQt4.QtWebKit import QWebPage, QWebView
|
||||||
|
|
||||||
# Views - define the way a user is prompted for questions, etc
|
# Views - define the way a user is prompted for questions, etc
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
@ -224,3 +225,14 @@ Start adding your own material.</td>
|
||||||
self.write("<br><center><table width=250><tr><td align='left'>" +
|
self.write("<br><center><table width=250><tr><td align='left'>" +
|
||||||
self.main.deck.deckFinishedMsg() +
|
self.main.deck.deckFinishedMsg() +
|
||||||
"</td></tr></table></center>")
|
"</td></tr></table></center>")
|
||||||
|
|
||||||
|
class AnkiWebView(QWebView):
|
||||||
|
|
||||||
|
def keyPressEvent(self, evt):
|
||||||
|
if evt.matches(QKeySequence.Copy):
|
||||||
|
self.triggerPageAction(QWebPage.Copy)
|
||||||
|
evt.accept()
|
||||||
|
evt.ignore()
|
||||||
|
|
||||||
|
def contextMenuEvent(self, evt):
|
||||||
|
QWebView.contextMenuEvent(self, evt)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,14 @@
|
||||||
<normaloff>:/icons/anki.png</normaloff>:/icons/anki.png</iconset>
|
<normaloff>:/icons/anki.png</normaloff>:/icons/anki.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget" >
|
<widget class="QWidget" name="centralwidget" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>69</y>
|
||||||
|
<width>454</width>
|
||||||
|
<height>415</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
<property name="sizePolicy" >
|
<property name="sizePolicy" >
|
||||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||||
<horstretch>1</horstretch>
|
<horstretch>1</horstretch>
|
||||||
|
|
@ -153,27 +161,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QWebView" name="mainText" >
|
|
||||||
<property name="sizePolicy" >
|
|
||||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy" >
|
|
||||||
<enum>Qt::WheelFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="url" >
|
|
||||||
<url>
|
|
||||||
<string>about:blank</string>
|
|
||||||
</url>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" native="1" name="buttonWidget" />
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
@ -366,7 +353,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>454</width>
|
<width>454</width>
|
||||||
<height>25</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuHelp" >
|
<widget class="QMenu" name="menuHelp" >
|
||||||
|
|
@ -498,11 +485,28 @@
|
||||||
<addaction name="menuAdvanced" />
|
<addaction name="menuAdvanced" />
|
||||||
<addaction name="menuHelp" />
|
<addaction name="menuHelp" />
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar" />
|
<widget class="QStatusBar" name="statusbar" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>484</y>
|
||||||
|
<width>454</width>
|
||||||
|
<height>20</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<widget class="QToolBar" name="toolBar" >
|
<widget class="QToolBar" name="toolBar" >
|
||||||
<property name="enabled" >
|
<property name="enabled" >
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>23</y>
|
||||||
|
<width>454</width>
|
||||||
|
<height>46</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -1014,13 +1018,6 @@
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>QWebView</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>QtWebKit/QWebView</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../icons.qrc" />
|
<include location="../icons.qrc" />
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue