mirror of
https://github.com/aclist/dztui.git
synced 2026-08-29 19:27:13 +02:00
feat: set start tab
This commit is contained in:
parent
ce44d67bf6
commit
73d131a64b
@ -34,7 +34,7 @@ def rc2json(file: Path) -> str:
|
|||||||
lex = shlex.shlex(f.read())
|
lex = shlex.shlex(f.read())
|
||||||
lex.whitespace += "="
|
lex.whitespace += "="
|
||||||
|
|
||||||
d = {}
|
keys = {}
|
||||||
ips: list[str] = []
|
ips: list[str] = []
|
||||||
|
|
||||||
toggles = ["auto_install", "fullscreen"]
|
toggles = ["auto_install", "fullscreen"]
|
||||||
@ -69,8 +69,9 @@ def rc2json(file: Path) -> str:
|
|||||||
if not tok:
|
if not tok:
|
||||||
break
|
break
|
||||||
|
|
||||||
d[tok] = ntok
|
keys[tok] = ntok
|
||||||
|
|
||||||
d["ip_list"] = ips
|
keys["ip_list"] = ips
|
||||||
d["use_miles"] = False
|
keys["use_miles"] = False
|
||||||
return json.dumps(d, indent=2)
|
keys["start_tab"] = 0
|
||||||
|
return json.dumps(keys, indent=2)
|
||||||
|
|||||||
@ -10,10 +10,10 @@ class Port(Enum):
|
|||||||
|
|
||||||
|
|
||||||
class ServerTab(Enum):
|
class ServerTab(Enum):
|
||||||
BROWSER = 1
|
BROWSER = 0
|
||||||
SAVED = 2
|
SAVED = 1
|
||||||
RECENT = 3
|
RECENT = 2
|
||||||
LAN = 4
|
LAN = 3
|
||||||
|
|
||||||
|
|
||||||
class Popup(Enum):
|
class Popup(Enum):
|
||||||
@ -97,6 +97,9 @@ class Preferences(EnumWithAttrs):
|
|||||||
BRANCH = {
|
BRANCH = {
|
||||||
"key": "branch",
|
"key": "branch",
|
||||||
}
|
}
|
||||||
|
START_TAB = {
|
||||||
|
"key": "start_tab",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class NotebookPage(EnumWithAttrs):
|
class NotebookPage(EnumWithAttrs):
|
||||||
|
|||||||
@ -464,3 +464,7 @@ class Controller(GObject.GObject):
|
|||||||
# TODO: populate assistant
|
# TODO: populate assistant
|
||||||
# TODO: embed dialogs
|
# TODO: embed dialogs
|
||||||
# dialog = ServerModDialog(self, mods)
|
# dialog = ServerModDialog(self, mods)
|
||||||
|
|
||||||
|
def set_start_tab(self) -> int:
|
||||||
|
ind = self.config_man.get_start_tab()
|
||||||
|
self.get_servers().notebook.set_current_page(ind)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
## Added
|
## Added
|
||||||
- Add pyproject.toml file
|
|
||||||
- Changelog text wrapping and formatting
|
- Changelog text wrapping and formatting
|
||||||
|
- Changelog ships with source
|
||||||
|
- Documentation ships with source
|
||||||
- Decouple UI components into modules
|
- Decouple UI components into modules
|
||||||
- Choose from kilometer or miles distance display
|
- Choose from kilometer or miles distance display
|
||||||
- More granular haversine calculation
|
- More granular haversine calculation
|
||||||
@ -8,12 +9,12 @@
|
|||||||
- Dedicated mods page
|
- Dedicated mods page
|
||||||
- Dedicated thanks page
|
- Dedicated thanks page
|
||||||
- Rearrange menus/breadcrumbs
|
- Rearrange menus/breadcrumbs
|
||||||
- Documentation ships with source
|
|
||||||
- Open filepicker when generating system log
|
- Open filepicker when generating system log
|
||||||
- Developers page (and -d flag)
|
- Developers page (and -d flag)
|
||||||
- Redact API key in log table
|
- Redact API key in log table
|
||||||
- Integrate add/connect widgets into main menu
|
- Integrate add/connect widgets into main menu
|
||||||
- Favorite/connect/LAN panels integrated with server views
|
- Favorite/connect/LAN panels integrated with server views
|
||||||
|
- Abort on first LAN server found
|
||||||
- Colorized IP/ID validation fields
|
- Colorized IP/ID validation fields
|
||||||
- Copy favorite server IP to clipboard
|
- Copy favorite server IP to clipboard
|
||||||
- Set favorite server from tables
|
- Set favorite server from tables
|
||||||
@ -30,6 +31,7 @@
|
|||||||
- Lazy load ping cell data func
|
- Lazy load ping cell data func
|
||||||
- Refresh servers button
|
- Refresh servers button
|
||||||
- Early load alerts button
|
- Early load alerts button
|
||||||
|
- Preconnect dialog
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
- Reduce padding on keys button
|
- Reduce padding on keys button
|
||||||
@ -39,6 +41,11 @@
|
|||||||
- Copy IP copies IP:queryport only instead of IP:gameport:queryport, mimics syntax needed by add by ip method
|
- Copy IP copies IP:queryport only instead of IP:gameport:queryport, mimics syntax needed by add by ip method
|
||||||
- Load new model into view without flushing
|
- Load new model into view without flushing
|
||||||
- Cull servers with abnormal queue values (integer overflow: 2147483647)
|
- Cull servers with abnormal queue values (integer overflow: 2147483647)
|
||||||
|
- Packaging structure
|
||||||
|
|
||||||
|
## Dropped
|
||||||
|
- Debug mode
|
||||||
|
- Branch switching
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
- Longstanding issue with left clicks not registering as tree selection changes after spamming keyboard input
|
- Longstanding issue with left clicks not registering as tree selection changes after spamming keyboard input
|
||||||
@ -53,7 +60,8 @@
|
|||||||
- Move debug mode to developers only
|
- Move debug mode to developers only
|
||||||
- Local documentation
|
- Local documentation
|
||||||
|
|
||||||
## Devs
|
## Developer-facing
|
||||||
|
- Add pyproject.toml file
|
||||||
- Show deprecation warnings
|
- Show deprecation warnings
|
||||||
- Options -> Dev page
|
- Options -> Dev page
|
||||||
- Raw debug command
|
- Raw debug command
|
||||||
|
|||||||
@ -95,6 +95,9 @@ class ConfigManager:
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def get_start_tab(self) -> int:
|
||||||
|
return self.lookup(Preferences.START_TAB)
|
||||||
|
|
||||||
def get_favorites(self) -> list[str]:
|
def get_favorites(self) -> list[str]:
|
||||||
return list(self.lookup(Preferences.IP_LIST))
|
return list(self.lookup(Preferences.IP_LIST))
|
||||||
|
|
||||||
|
|||||||
@ -88,10 +88,7 @@ class OuterWindow(Gtk.Window):
|
|||||||
css.load_css()
|
css.load_css()
|
||||||
|
|
||||||
MainController.open_page(NotebookPage.SERVERS)
|
MainController.open_page(NotebookPage.SERVERS)
|
||||||
# TODO:
|
MainController.set_start_tab()
|
||||||
# combo box in options could link to same index as pages
|
|
||||||
# or use enum in case page order is changed in future
|
|
||||||
# MainController.get_servers().notebook.set_current_page(3)
|
|
||||||
self.grid.hide_widgets_on_init()
|
self.grid.hide_widgets_on_init()
|
||||||
|
|
||||||
# TODO: POC, trigger page change here
|
# TODO: POC, trigger page change here
|
||||||
|
|||||||
@ -4,17 +4,6 @@ from typing import TYPE_CHECKING
|
|||||||
from dzgui.api import pefile as PeFile
|
from dzgui.api import pefile as PeFile
|
||||||
from dzgui.api.steam import find_user_id
|
from dzgui.api.steam import find_user_id
|
||||||
from dzgui.config import query
|
from dzgui.config import query
|
||||||
from dzgui.util import strings, css, open_links
|
|
||||||
|
|
||||||
from dzgui.views.components.labels import LeftLabel
|
|
||||||
from dzgui.views.components.eventbox import InfoEventBox
|
|
||||||
from dzgui.views.components.buttons import WebButton
|
|
||||||
from dzgui.views.components.frame import HeadingFrame
|
|
||||||
from dzgui.views.dialogs.generic import ExceptionDialog
|
|
||||||
from dzgui.views.dialogs.link_dialog import WorkshopLinkDialog
|
|
||||||
|
|
||||||
from dzgui.const.enum import Preferences
|
|
||||||
from dzgui.const.endpoints import STEAM_API_SETUP, BM_API_SETUP
|
|
||||||
from dzgui.const.constants import (
|
from dzgui.const.constants import (
|
||||||
APPID_DAYZ,
|
APPID_DAYZ,
|
||||||
APPID_DAYZ_EXP,
|
APPID_DAYZ_EXP,
|
||||||
@ -29,6 +18,16 @@ from dzgui.const.constants import (
|
|||||||
VIEW_CONCEAL,
|
VIEW_CONCEAL,
|
||||||
VIEW_REVEAL,
|
VIEW_REVEAL,
|
||||||
)
|
)
|
||||||
|
from dzgui.const.endpoints import STEAM_API_SETUP, BM_API_SETUP
|
||||||
|
from dzgui.const.enum import Preferences, ServerTab
|
||||||
|
from dzgui.util import strings, css, open_links
|
||||||
|
from dzgui.views.components.labels import LeftLabel
|
||||||
|
from dzgui.views.components.eventbox import InfoEventBox
|
||||||
|
from dzgui.views.components.buttons import WebButton
|
||||||
|
from dzgui.views.components.frame import HeadingFrame
|
||||||
|
from dzgui.views.dialogs.generic import ExceptionDialog
|
||||||
|
from dzgui.views.dialogs.link_dialog import WorkshopLinkDialog
|
||||||
|
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
@ -96,17 +95,36 @@ class Options(Gtk.Box):
|
|||||||
self.client_combo.append_text("Flatpak (container)")
|
self.client_combo.append_text("Flatpak (container)")
|
||||||
self.client_combo.set_active(0)
|
self.client_combo.set_active(0)
|
||||||
self.client_combo.connect("changed", self._on_client_changed)
|
self.client_combo.connect("changed", self._on_client_changed)
|
||||||
hbox = Gtk.Box(spacing=5, halign=Gtk.Align.START)
|
client_hbox = Gtk.Box(spacing=5, halign=Gtk.Align.START)
|
||||||
hbox.pack_start(self.client_combo, NO_EXPAND, NO_FILL, NO_PADDING)
|
client_hbox.pack_start(self.client_combo, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||||
|
|
||||||
self.distance_toggle = self.make_binary_radio(
|
self.distance_toggle = self.make_binary_radio(
|
||||||
strings.options.km, strings.options.mi, Preferences.DIST
|
strings.options.km, strings.options.mi, Preferences.DIST
|
||||||
)
|
)
|
||||||
|
|
||||||
|
combo_store = Gtk.ListStore(str, object)
|
||||||
|
tabs = (
|
||||||
|
("Server browser", ServerTab.BROWSER),
|
||||||
|
("Saved servers", ServerTab.SAVED),
|
||||||
|
("Recent", ServerTab.RECENT),
|
||||||
|
("LAN", ServerTab.LAN),
|
||||||
|
)
|
||||||
|
for tab in tabs:
|
||||||
|
combo_store.append(tab)
|
||||||
|
self.start_tab_combo = Gtk.ComboBox.new_with_model(combo_store)
|
||||||
|
renderer_text = Gtk.CellRendererText()
|
||||||
|
self.start_tab_combo.pack_start(renderer_text, True)
|
||||||
|
self.start_tab_combo.add_attribute(renderer_text, "text", 0)
|
||||||
|
self.start_tab_combo.set_active(0)
|
||||||
|
start_tab_hbox = Gtk.Box(spacing=5, halign=Gtk.Align.START)
|
||||||
|
start_tab_hbox.pack_start(self.start_tab_combo, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||||
|
self.start_tab_combo.connect("changed", self._on_start_tab_changed)
|
||||||
|
|
||||||
pref_rows = [
|
pref_rows = [
|
||||||
[LeftLabel(strings.options.client), hbox],
|
[LeftLabel(strings.options.client), client_hbox],
|
||||||
[LeftLabel(strings.options.window_size), self.fullscreen_toggle],
|
[LeftLabel(strings.options.window_size), self.fullscreen_toggle],
|
||||||
[LeftLabel(strings.options.distance), self.distance_toggle],
|
[LeftLabel(strings.options.distance), self.distance_toggle],
|
||||||
|
[LeftLabel("Start tab"), start_tab_hbox],
|
||||||
[LeftLabel(strings.options.name), self.player_box],
|
[LeftLabel(strings.options.name), self.player_box],
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -295,6 +313,12 @@ class Options(Gtk.Box):
|
|||||||
# TODO: unimplemented
|
# TODO: unimplemented
|
||||||
print("UNIMPLEMENTED")
|
print("UNIMPLEMENTED")
|
||||||
|
|
||||||
|
def _on_start_tab_changed(self, combo: Gtk.ComboBoxText) -> None:
|
||||||
|
_iter = combo.get_active_iter()
|
||||||
|
enum = combo.get_model()[_iter][1]
|
||||||
|
index = enum.value
|
||||||
|
self.controller.update_config(Preferences.START_TAB, index)
|
||||||
|
|
||||||
def _on_client_changed(self, combo: Gtk.ComboBoxText) -> None:
|
def _on_client_changed(self, combo: Gtk.ComboBoxText) -> None:
|
||||||
# TODO: use two columns or constants here, not strings
|
# TODO: use two columns or constants here, not strings
|
||||||
client = combo.get_active_text()
|
client = combo.get_active_text()
|
||||||
@ -457,6 +481,9 @@ class Options(Gtk.Box):
|
|||||||
self.client_combo.set_active(active_combo)
|
self.client_combo.set_active(active_combo)
|
||||||
# active_combo = 0
|
# active_combo = 0
|
||||||
|
|
||||||
|
start_tab = self.controller.query_config(Preferences.START_TAB)
|
||||||
|
self.start_tab_combo.set_active(start_tab)
|
||||||
|
|
||||||
def _suppress_toggles(self, state: bool) -> None:
|
def _suppress_toggles(self, state: bool) -> None:
|
||||||
for toggle in [
|
for toggle in [
|
||||||
self.mod_install_toggle,
|
self.mod_install_toggle,
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import logging
|
|||||||
import threading
|
import threading
|
||||||
|
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from typing import Any, Optional, Self, Union
|
from typing import Any, Self, Union
|
||||||
from warnings import deprecated
|
from warnings import deprecated
|
||||||
|
|
||||||
from dzgui.api.servers import ping, Record
|
from dzgui.api.servers import ping, Record
|
||||||
|
|||||||
@ -29,6 +29,7 @@ def keys():
|
|||||||
"client",
|
"client",
|
||||||
"ip_list",
|
"ip_list",
|
||||||
"use_miles",
|
"use_miles",
|
||||||
|
"start_tab"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user