-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easter-eggs #8
Open
Guts
wants to merge
19
commits into
main
Choose a base branch
from
eastereggs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Easter-eggs #8
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4f821df
Add easteregg structure
Guts 74e115b
Add menu
Guts 3a1a370
Merge branch 'main' into eastereggs
Guts 3ef2735
Merge branch 'main' into eastereggs
Guts cf64cbd
Merge branch 'main' into eastereggs
Guts 064db29
Merge branch 'main' into eastereggs
Guts 684cff9
Merge branch 'main' into eastereggs
Guts dad565e
Merge branch 'main' into eastereggs
Guts 4ea77a8
Add option
Guts 60c3adc
Handle empty project
Guts fbb5731
Use only one QLineEdit
Guts 7ec9f20
Add troll error box
Guts 6c033d4
Merge branch 'main' into eastereggs
Guts 510472f
Merge branch 'main' into eastereggs
Guts ff9b7cc
Add type hint to about
Guts f1cd06d
Refactoring easter eggs
Guts e3fac93
Merge branch 'main' into eastereggs
Guts 1bdc88e
Merge branch 'main' into eastereggs
Guts c942cec
Rename help menu
Guts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#! python3 # noqa: E265 | ||
from .custom_datatypes import RssItem # noqa: F401 | ||
from .eastereggs_manager import PlgEasterEggs # noqa: F401 | ||
from .rss_reader import RssMiniReader # noqa: F401 | ||
from .splash_changer import SplashChanger # noqa: F401 | ||
from .web_viewer import WebViewer # noqa: F401 |
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,2 @@ | ||
#! python3 # noqa: E265 | ||
from .egg_tribu import EggGeotribu # noqa: F401 |
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,101 @@ | ||
#! python3 # noqa: E265 | ||
|
||
""" | ||
Easter egg on widget Coordinates. | ||
""" | ||
|
||
# ############################################################################ | ||
# ########## Imports ############### | ||
# ################################## | ||
|
||
# Standard library | ||
import logging | ||
|
||
# PyQGIS | ||
from qgis.core import QgsProject, QgsProjectMetadata | ||
from qgis.PyQt.QtCore import QCoreApplication | ||
from qgis.PyQt.QtGui import QIcon | ||
from qgis.utils import iface | ||
|
||
# project | ||
from qtribu.__about__ import __icon_path__ | ||
from qtribu.toolbelt import PlgLogger | ||
|
||
# ############################################################################ | ||
# ########## Globals ############### | ||
# ################################## | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
# ############################################################################ | ||
# ########## Classes ############### | ||
# ################################## | ||
|
||
|
||
class EggGeotribu(object): | ||
|
||
APPLIED: bool = False | ||
KEYWORDS: tuple = ("geotribu",) | ||
NAME: str = "Geotribu" | ||
PRIORITY: int = 1 | ||
|
||
def __init__(self): | ||
"""Instancitation logic.""" | ||
self.log = PlgLogger().log | ||
|
||
def apply(self) -> bool: | ||
self.log( | ||
message=self.tr(f"Easter egg found: {self.NAME}"), | ||
log_level=4, | ||
) | ||
|
||
# QGIS main window | ||
self.bkp_title = iface.mainWindow().windowTitle() | ||
# new_title = self.bkp_title.replace("QGIS", "GIStribu") | ||
iface.mainWindow().setWindowTitle("GISTribu") | ||
iface.mainWindow().setWindowIcon(QIcon(str(__icon_path__.resolve()))) | ||
iface.pluginToolBar().setVisible(False) | ||
|
||
# modify menus | ||
iface.editMenu().setTitle("Créer") | ||
iface.helpMenu().setTitle("Débrouille toi !") | ||
iface.helpMenu().setEnabled(False) | ||
|
||
# Project | ||
current_project = QgsProject.instance() | ||
self.bkp_project = {"title": current_project.title()} | ||
current_project.setTitle(f"Easter Egg {self.NAME}") | ||
try: | ||
self.bkp_project["metadata"] = current_project.Metadata() | ||
except AttributeError as err: | ||
self.log( | ||
message="Project doesn't exist yet. Trace: {}".format(err), | ||
log_level=4, | ||
) | ||
self.bkp_project["metadata"] = None | ||
gt_md = QgsProjectMetadata() | ||
gt_md.setAuthor("Geotribu") | ||
gt_md.setLanguage("FRE") | ||
current_project.setMetadata(gt_md) | ||
|
||
self.APPLIED = True | ||
return True | ||
|
||
def revert(self) -> bool: | ||
iface.mainWindow().setWindowTitle(self.bkp_title) | ||
iface.pluginToolBar().setVisible(True) | ||
|
||
self.APPLIED = False | ||
return False | ||
|
||
def tr(self, message: str) -> str: | ||
"""Translation method. | ||
|
||
:param message: text to be translated | ||
:type message: str | ||
|
||
:return: translated text | ||
:rtype: str | ||
""" | ||
return QCoreApplication.translate(self.__class__.__name__, message) |
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,127 @@ | ||
#! python3 # noqa: E265 | ||
|
||
""" | ||
Easter egg on widget Coordinates. | ||
""" | ||
|
||
# ############################################################################ | ||
# ########## Imports ############### | ||
# ################################## | ||
|
||
# Standard library | ||
import logging | ||
|
||
# PyQGIS | ||
from qgis.core import QgsApplication, QgsProject, QgsProjectMetadata | ||
from qgis.PyQt.QtCore import QCoreApplication | ||
from qgis.PyQt.QtGui import QIcon | ||
from qgis.PyQt.QtWidgets import QApplication, QLineEdit, QMessageBox | ||
from qgis.utils import iface | ||
|
||
# project | ||
from qtribu.logic.eastereggs.egg_tribu import EggGeotribu | ||
from qtribu.toolbelt import PlgLogger | ||
from qtribu.toolbelt.preferences import PlgOptionsManager | ||
|
||
# ############################################################################ | ||
# ########## Globals ############### | ||
# ################################## | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
# ############################################################################ | ||
# ########## Classes ############### | ||
# ################################## | ||
|
||
|
||
class PlgEasterEggs: | ||
|
||
CONNECTION_ENABLED: bool = False | ||
EGG_TROLL_APPLIED: bool = False | ||
|
||
def __init__(self, parent): | ||
"""Instancitation logic.""" | ||
self.log = PlgLogger().log | ||
self.parent = parent | ||
|
||
# -- Easter eggs --------------------------------------------------------------- | ||
self.eggs: tuple = (EggGeotribu(),) | ||
|
||
# on attrape la barre de statut de QGIS | ||
qgis_st = iface.mainWindow().statusBar() | ||
|
||
# on filtre la barre de statut pour ne garder le widget des coordonnées | ||
for wdgt in qgis_st.children()[1].children(): | ||
if wdgt.objectName() == "mCoordsEdit": | ||
break | ||
|
||
# dans le widget, on ne garde que la ligne de saisie | ||
self.le_coords = wdgt.findChild(QLineEdit) | ||
|
||
def switch(self): | ||
if self.CONNECTION_ENABLED: | ||
self.parent.action_eastereggs.setIcon( | ||
QIcon(QgsApplication.iconPath("repositoryConnected.svg")), | ||
) | ||
self.le_coords.editingFinished.disconnect(self.on_coords_changed) | ||
self.CONNECTION_ENABLED = False | ||
PlgOptionsManager.set_value_from_key(key="easter_eggs_enabled", value=False) | ||
self.log(message="Easter eggs connection has been disabled.") | ||
else: | ||
self.parent.action_eastereggs.setIcon( | ||
QIcon(QgsApplication.iconPath("repositoryUnavailable.svg")), | ||
) | ||
self.le_coords.editingFinished.connect(self.on_coords_changed) | ||
self.CONNECTION_ENABLED = True | ||
PlgOptionsManager.set_value_from_key(key="easter_eggs_enabled", value=True) | ||
self.log(message="Easter eggs connection has been enabled.") | ||
|
||
for egg in self.eggs: | ||
if egg.APPLIED: | ||
egg.revert() | ||
|
||
def on_coords_changed(self): | ||
for egg in self.eggs: | ||
if not egg.APPLIED and self.le_coords.text() in egg.KEYWORDS: | ||
self.le_coords.setEchoMode(QLineEdit.EchoMode.PasswordEchoOnEdit) | ||
egg.apply() | ||
break | ||
|
||
# -- Easter eggs ------------------------------------------------------------------- | ||
def egg_coords_arcgis(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C'est prévu d'en faire une classe spécifique comme |
||
"""Easter egg to mimic the behavior of ArcGIS Pro license subscription.""" | ||
if not self.EGG_TROLL_APPLIED: | ||
app = QApplication.instance() | ||
app.setStyleSheet(".QWidget {color: green; background-color: blue;}") | ||
self.log( | ||
message="Easter egg found! Let's ask end-user for his QGIS license subscription." | ||
) | ||
|
||
# message box | ||
msg = QMessageBox() | ||
msg.setIcon(QMessageBox.Critical) | ||
msg.setWindowTitle("QGIS Pro") | ||
msg.setInformativeText( | ||
"Your account is not licensed for QGIS Pro. " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😱 😱 |
||
"Please ask your organization administrator to assign you a user type " | ||
"that is compatible with QGIS Pro (e.g. Creator) along with an add-on " | ||
"QGIS Pro license, or a user type that includes QGIS Pro " | ||
"(e.g. GIS Professional)." | ||
) | ||
msg.exec_() | ||
|
||
self.EGG_TROLL_APPLIED = True | ||
else: | ||
self.EGG_TROLL_APPLIED = False | ||
|
||
def tr(self, message: str) -> str: | ||
"""Translation method. | ||
|
||
:param message: text to be translated | ||
:type message: str | ||
|
||
:return: translated text | ||
:rtype: str | ||
""" | ||
return QCoreApplication.translate(self.__class__.__name__, message) |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je me dis que ça pourrait être sympa de revenir à l'état initial: remettre les titres des menu
Edit
etHelp
, réactiver le menu Help ..