mirror of
https://github.com/ankitects/anki.git
synced 2025-12-16 16:20:58 -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.setupHooks()
|
||||
self.loadPlugins()
|
||||
self.mainWin = ankiqt.forms.main.Ui_MainWindow()
|
||||
self.mainWin.setupUi(self)
|
||||
self.setupMainWindow()
|
||||
self.rebuildPluginsMenu()
|
||||
self.alterShortcuts()
|
||||
self.help = ui.help.HelpArea(self.mainWin.helpFrame, self.config, self)
|
||||
self.trayIcon = ui.tray.AnkiTrayIcon( self )
|
||||
self.setupTray()
|
||||
self.connectMenuActions()
|
||||
if self.config['mainWindowGeom']:
|
||||
self.restoreGeometry(self.config['mainWindowGeom'])
|
||||
self.bodyView = ui.view.View(self, self.mainWin.mainText,
|
||||
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.setupViews()
|
||||
self.setupEditor()
|
||||
self.setupButtons()
|
||||
self.setupAnchors()
|
||||
|
|
@ -79,6 +70,31 @@ class AnkiQt(QMainWindow):
|
|||
# check for updates
|
||||
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
|
||||
##########################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ from anki.utils import stripHTML
|
|||
import types, time, re, os, urllib, sys
|
||||
from ankiqt import ui
|
||||
from ankiqt.ui.utils import mungeQA
|
||||
from PyQt4.QtWebKit import QWebPage, QWebView
|
||||
|
||||
# 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.main.deck.deckFinishedMsg() +
|
||||
"</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>
|
||||
</property>
|
||||
<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" >
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<horstretch>1</horstretch>
|
||||
|
|
@ -153,27 +161,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -366,7 +353,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>454</width>
|
||||
<height>25</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuHelp" >
|
||||
|
|
@ -498,11 +485,28 @@
|
|||
<addaction name="menuAdvanced" />
|
||||
<addaction name="menuHelp" />
|
||||
</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" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>23</y>
|
||||
<width>454</width>
|
||||
<height>46</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
|
@ -1014,13 +1018,6 @@
|
|||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QWebView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>QtWebKit/QWebView</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../icons.qrc" />
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Reference in a new issue