Skip to content
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

Make texts selectable in the application #127

Merged
merged 2 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion openandroidinstaller/openandroidinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@
Icon,
Image,
Page,
Text,
TextButton,
UserControl,
colors,
icons,
)
from loguru import logger

from styles import (
Text,
)
from app_state import AppState
from views import (
SelectFilesView,
Expand Down
30 changes: 30 additions & 0 deletions openandroidinstaller/styles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""This module contains different pre-configured style elements for building the application."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller 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.

# OpenAndroidInstaller 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 OpenAndroidInstaller.
# If not, see <https://www.gnu.org/licenses/>."""
# Author: Tobias Sterbak

import flet as ft


class Text(ft.Text):
"""Text element to replace the default text element from flet but is selectable."""

def __init__(self, *args, **kwargs):
super().__init__(selectable=True, *args, **kwargs)


class Markdown(ft.Markdown):
"""Markdown element to replace the markdown element from flet but is selectable."""

def __init__(self, *args, **kwargs):
super().__init__(selectable=True, *args, **kwargs)
6 changes: 4 additions & 2 deletions openandroidinstaller/views/addon_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
ElevatedButton,
OutlinedButton,
FilledButton,
Markdown,
Row,
Text,
colors,
icons,
TextButton,
Expand All @@ -35,6 +33,10 @@
)
from flet.buttons import CountinuosRectangleBorder

from styles import (
Text,
Markdown,
)
from views import BaseView
from app_state import AppState
from widgets import get_title, confirm_button
Expand Down
5 changes: 4 additions & 1 deletion openandroidinstaller/views/install_addons_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
Column,
ElevatedButton,
Row,
Text,
icons,
Switch,
colors,
)

from styles import (
Text,
Markdown,
)

Expand Down
5 changes: 4 additions & 1 deletion openandroidinstaller/views/install_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
Column,
ElevatedButton,
Row,
Text,
icons,
Switch,
colors,
)

from styles import (
Text,
Markdown,
)

Expand Down
6 changes: 4 additions & 2 deletions openandroidinstaller/views/requirements_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@
Container,
Divider,
ElevatedButton,
Markdown,
Row,
colors,
OutlinedButton,
Text,
icons,
TextButton,
AlertDialog,
)
from flet.buttons import CountinuosRectangleBorder

from styles import (
Text,
Markdown,
)
from views import BaseView
from app_state import AppState
from widgets import get_title
Expand Down
6 changes: 4 additions & 2 deletions openandroidinstaller/views/select_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
ElevatedButton,
OutlinedButton,
FilledButton,
Markdown,
Row,
Text,
colors,
icons,
TextButton,
Expand All @@ -35,6 +33,10 @@
)
from flet.buttons import CountinuosRectangleBorder

from styles import (
Text,
Markdown,
)
from views import BaseView
from app_state import AppState
from widgets import get_title, confirm_button
Expand Down
8 changes: 6 additions & 2 deletions openandroidinstaller/views/start_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@
ElevatedButton,
OutlinedButton,
FilledButton,
Markdown,
Row,
Text,
TextButton,
colors,
icons,
)
from flet.buttons import CountinuosRectangleBorder

from styles import (
Text,
Markdown,
)
from views import BaseView
from app_state import AppState
from widgets import get_title
Expand Down Expand Up @@ -257,6 +259,8 @@ def search_devices(self, e):
f"{device_name} (code: {self.state.config.device_code})"
)
self.device_name.color = colors.GREEN
# if there are no steps for bootloader unlocking, assume there is nothing to do and toggle the switch
self.bootloader_switch.value = True
else:
# failed to load config
logger.error(f"Failed to load config for {device_code}.")
Expand Down
6 changes: 5 additions & 1 deletion openandroidinstaller/views/step_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
Column,
ElevatedButton,
Row,
Text,
icons,
TextField,
Switch,
colors,
)


from styles import (
Text,
)

from views import BaseView
from installer_config import Step
from app_state import AppState
Expand Down
4 changes: 3 additions & 1 deletion openandroidinstaller/views/success_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
from flet import (
ElevatedButton,
Row,
)

from styles import (
Text,
Markdown,
)

from views import BaseView
from app_state import AppState
from widgets import get_title
Expand Down
7 changes: 5 additions & 2 deletions openandroidinstaller/views/welcome_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
from flet import (
Divider,
ElevatedButton,
Markdown,
Row,
Text,
icons,
)

from styles import (
Text,
Markdown,
)

from views import BaseView
from app_state import AppState
from widgets import get_title
Expand Down
7 changes: 5 additions & 2 deletions openandroidinstaller/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@
ProgressRing,
ProgressBar,
Row,
Text,
alignment,
icons,
IconButton,
Image,
Column,
)

from styles import (
Text,
)


class TerminalBox(UserControl):
def __init__(self, expand: bool = True, visible: bool = False):
Expand All @@ -43,7 +46,7 @@ def __init__(self, expand: bool = True, visible: bool = False):
def build(self):
self._box = Container(
content=Column(
controls=[Text("", selectable=True)],
controls=[Text("")],
scroll="auto",
expand=True,
auto_scroll=True,
Expand Down