feat: set start tab

This commit is contained in:
aclist committed 2026-05-05 18:31:50 +09:00
1 parent ce44d67bf6
commit 73d131a64b
9 files changed
+75 -31

No files matched your search

+6 -5
View File
@@ -34,7 +34,7 @@ def rc2json(file: Path) -> str:
lex = shlex.shlex(f.read())
lex.whitespace += "="
d = {}
keys = {}
ips: list[str] = []
toggles = ["auto_install", "fullscreen"]
@@ -69,8 +69,9 @@ def rc2json(file: Path) -> str:
if not tok:
break
d[tok] = ntok
keys[tok] = ntok
d["ip_list"] = ips
d["use_miles"] = False
return json.dumps(d, indent=2)
keys["ip_list"] = ips
keys["use_miles"] = False
keys["start_tab"] = 0
return json.dumps(keys, indent=2)
+7 -4
View File
@@ -10,10 +10,10 @@ class Port(Enum):
class ServerTab(Enum):
BROWSER = 1
SAVED = 2
RECENT = 3
LAN = 4
BROWSER = 0
SAVED = 1
RECENT = 2
LAN = 3
class Popup(Enum):
@@ -97,6 +97,9 @@ class Preferences(EnumWithAttrs):
BRANCH = {
"key": "branch",
}
START_TAB = {
"key": "start_tab",
}
class NotebookPage(EnumWithAttrs):
+4
View File
@@ -464,3 +464,7 @@ class Controller(GObject.GObject):
# TODO: populate assistant
# TODO: embed dialogs
# 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)
+11 -3
View File
@@ -1,6 +1,7 @@
## Added
- Add pyproject.toml file
- Changelog text wrapping and formatting
- Changelog ships with source
- Documentation ships with source
- Decouple UI components into modules
- Choose from kilometer or miles distance display
- More granular haversine calculation
@@ -8,12 +9,12 @@
- Dedicated mods page
- Dedicated thanks page
- Rearrange menus/breadcrumbs
- Documentation ships with source
- Open filepicker when generating system log
- Developers page (and -d flag)
- Redact API key in log table
- Integrate add/connect widgets into main menu
- Favorite/connect/LAN panels integrated with server views
- Abort on first LAN server found
- Colorized IP/ID validation fields
- Copy favorite server IP to clipboard
- Set favorite server from tables
@@ -30,6 +31,7 @@
- Lazy load ping cell data func
- Refresh servers button
- Early load alerts button
- Preconnect dialog
## Changed
- 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
- Load new model into view without flushing
- Cull servers with abnormal queue values (integer overflow: 2147483647)
- Packaging structure
## Dropped
- Debug mode
- Branch switching
## Fixed
- 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
- Local documentation
## Devs
## Developer-facing
- Add pyproject.toml file
- Show deprecation warnings
- Options -> Dev page
- Raw debug command
+3
View File
@@ -95,6 +95,9 @@ class ConfigManager:
)
return
def get_start_tab(self) -> int:
return self.lookup(Preferences.START_TAB)
def get_favorites(self) -> list[str]:
return list(self.lookup(Preferences.IP_LIST))
+1 -4
View File
@@ -88,10 +88,7 @@ class OuterWindow(Gtk.Window):
css.load_css()
MainController.open_page(NotebookPage.SERVERS)
# TODO:
# 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)
MainController.set_start_tab()
self.grid.hide_widgets_on_init()
# TODO: POC, trigger page change here
+41 -14
View File
@@ -4,17 +4,6 @@ from typing import TYPE_CHECKING
from dzgui.api import pefile as PeFile
from dzgui.api.steam import find_user_id
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 (
APPID_DAYZ,
APPID_DAYZ_EXP,
@@ -29,6 +18,16 @@ from dzgui.const.constants import (
VIEW_CONCEAL,
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
@@ -96,17 +95,36 @@ class Options(Gtk.Box):
self.client_combo.append_text("Flatpak (container)")
self.client_combo.set_active(0)
self.client_combo.connect("changed", self._on_client_changed)
hbox = Gtk.Box(spacing=5, halign=Gtk.Align.START)
hbox.pack_start(self.client_combo, NO_EXPAND, NO_FILL, NO_PADDING)
client_hbox = Gtk.Box(spacing=5, halign=Gtk.Align.START)
client_hbox.pack_start(self.client_combo, NO_EXPAND, NO_FILL, NO_PADDING)
self.distance_toggle = self.make_binary_radio(
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 = [
[LeftLabel(strings.options.client), hbox],
[LeftLabel(strings.options.client), client_hbox],
[LeftLabel(strings.options.window_size), self.fullscreen_toggle],
[LeftLabel(strings.options.distance), self.distance_toggle],
[LeftLabel("Start tab"), start_tab_hbox],
[LeftLabel(strings.options.name), self.player_box],
]
@@ -295,6 +313,12 @@ class Options(Gtk.Box):
# TODO: 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:
# TODO: use two columns or constants here, not strings
client = combo.get_active_text()
@@ -457,6 +481,9 @@ class Options(Gtk.Box):
self.client_combo.set_active(active_combo)
# 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:
for toggle in [
self.mod_install_toggle,
+1 -1
View File
@@ -2,7 +2,7 @@ import logging
import threading
from queue import Queue
from typing import Any, Optional, Self, Union
from typing import Any, Self, Union
from warnings import deprecated
from dzgui.api.servers import ping, Record
+1
View File
@@ -29,6 +29,7 @@ def keys():
"client",
"ip_list",
"use_miles",
"start_tab"
]