-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved UI, Typecast checkbox constants to integer for 2.1.24
- Loading branch information
Showing
12 changed files
with
198 additions
and
74 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2020 Lovac42 | ||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html | ||
|
||
|
||
__author__ = "lovac42" | ||
|
||
__version__ = "0.0.2" | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2020 Lovac42 | ||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html | ||
|
||
|
||
from aqt.qt import * | ||
from anki.lang import _ | ||
|
||
|
||
class TristateCheckbox(QCheckBox): | ||
_descriptions = { | ||
Qt.Unchecked: "Disabled", | ||
Qt.PartiallyChecked: "Partial", | ||
Qt.Checked: "Full" | ||
} | ||
|
||
def __init__(self, parent): | ||
super(TristateCheckbox, self).__init__(parent) | ||
self.setTristate(True) | ||
self.stateChanged.connect(self.onStateChanged) | ||
|
||
def onStateChanged(self, state): | ||
assert Qt.Unchecked <= state <= Qt.Checked | ||
desc = self._descriptions[state] | ||
self.setText(_(desc)) | ||
|
||
def getDescriptions(self): | ||
return self._descriptions | ||
|
||
def setDescriptions(self, desc): | ||
assert len(desc) == 3 | ||
self._descriptions = desc | ||
|
||
def setCheckState(self, state): | ||
assert Qt.Unchecked <= state <= Qt.Checked | ||
super(TristateCheckbox, self).setCheckState(state) | ||
if not state: | ||
self.onStateChanged(Qt.Unchecked) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2019-2020 Lovac42 | ||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html | ||
|
||
|
||
from aqt.qt import * | ||
|
||
|
||
def getMuffinsTab(ui_pref): | ||
try: | ||
return ui_pref.lrnStageGLayout | ||
except AttributeError: | ||
ui_pref.lrnStage = QWidget() | ||
ui_pref.tabWidget.addTab(ui_pref.lrnStage, "Muffins") | ||
ui_pref.lrnStageGLayout = QGridLayout() | ||
ui_pref.lrnStageVLayout = QVBoxLayout(ui_pref.lrnStage) | ||
ui_pref.lrnStageVLayout.addLayout(ui_pref.lrnStageGLayout) | ||
spacerItem = QSpacerItem( | ||
1, 1, | ||
QSizePolicy.Expanding, | ||
QSizePolicy.Expanding | ||
) | ||
ui_pref.lrnStageVLayout.addItem(spacerItem) | ||
return ui_pref.lrnStageGLayout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2020 Lovac42 | ||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html | ||
|
||
|
||
from aqt import QMenu | ||
|
||
def getMenu(parent, menuName): | ||
menubar = parent.form.menubar | ||
for a in menubar.actions(): | ||
if menuName == a.text(): | ||
return a.menu() | ||
else: | ||
return menubar.addMenu(menuName) | ||
|
||
|
||
def getSubMenu(menu, subMenuName): | ||
for a in menu.actions(): | ||
if subMenuName == a.text(): | ||
return a.menu() | ||
else: | ||
subMenu = QMenu(subMenuName, menu) | ||
menu.addMenu(subMenu) | ||
return subMenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2020 Lovac42 | ||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html | ||
|
||
|
||
from anki import version | ||
|
||
ANKI20 = version.startswith("2.0.") | ||
|
||
CCBC = version.endswith("ccbc") | ||
|
||
ANKI21 = not CCBC and version.startswith("2.1.") | ||
|
||
VERSION = version.split('_')[0] #rm ccbc | ||
m,n,p = VERSION.split('.') | ||
|
||
MAJOR_VERSION = int(m) | ||
MINOR_VERSION = int(n) | ||
PATCH_VERSION = int(p) | ||
POINT_VERSION = 0 if ANKI20 else PATCH_VERSION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters