Project

General

Profile

Actions

Bug #1630

open

Qt: Add menu items to change sound volume

Added by Dean Brown 3 months ago. Updated 4 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Qt-client
Target version:
-
Start date:
07/28/2025
Due date:
% Done:

0%

Estimated time:

Description

Affects gtk3.22, gtk4 and gtk5 clients, Qt client does not have any keys affecting sound volume.

In this code -

  if (state & GDK_SHIFT_MASK) {
    bool volchange = FALSE;

    switch (keyval) {
    case GDK_KEY_plus:
    case GDK_KEY_KP_Add:
      gui_options.sound_effects_volume += 10;
      volchange = TRUE;
      break;

    case GDK_KEY_minus:
    case GDK_KEY_KP_Subtract:
      gui_options.sound_effects_volume -= 10;
      volchange = TRUE;
      break;

    default:
      break;
    }

    if (volchange) {
      struct option *poption = optset_option_by_name(client_optset,
                                                     "sound_effects_volume");

      gui_options.sound_effects_volume = CLIP(0,
                                              gui_options.sound_effects_volume,
                                              100);
      option_changed(poption);

      return TRUE;
    }
  } else if (!(state & GDK_CONTROL_MASK)) {
    switch (keyval) {
    case GDK_KEY_plus:
    case GDK_KEY_KP_Add:
      zoom_step_up();
      return TRUE;

You can't ever get past the volchange part because the "+" key has the GDK_SHIFT_MASK on by definition - it's (GDK_KEY_equals with GDK_SHIFT_MASK). Since this also eats the key press, it won't get to the Menu entries for zoom that #943 wants to add.

We could drop having "+" and "-" affect sound volume, leaving only the keypad GDK_KEY_KP_Add and GDK_KEY_KP_Subtract to do that. (GDK_KEY_plus with Ctrl/Meta mask) is View menu item Show Stack Size.


Files

1630_qt.patch (2.78 KB) 1630_qt.patch Dean Brown, 09/15/2025 12:03 AM
Actions #1

Updated by Marko Lindqvist 3 months ago

Dean Brown wrote:

the "+" key has the GDK_SHIFT_MASK on by definition

Is that an American keyboard layout, or what? Likely I have implemented that code without realizing that such a details can differ between layouts (in Finnish keyboard '+' and '-' do not use any modifiers)

Actions #2

Updated by Dean Brown 3 months ago

Oy - the plot thickens. Yes American keyboard layout, "+" and "=" are the same key. I also didn't know that keyboards could be that different.

Actions #3

Updated by Dean Brown 3 months ago

An idea - use "<" and ">" to change sound volume. They are not used for anything in the gtk clients and in the Qt client, so could be added to Qt client as well.

Actions #4

Updated by Marko Lindqvist 3 months ago

Dean Brown wrote in #note-3:

An idea - use "<" and ">" to change sound volume. They are not used for anything in the gtk clients and in the Qt client, so could be added to Qt client as well.

Should be fine for sdl clients too.

Actions #5

Updated by Dean Brown 3 months ago

For Qt and gtk clients, no reason not to make them menu items, in the game menu. The sdl client is a problem on my Mac, I get no menus - might be better to let someone else handle that. Maybe I should create separate issues for the different clients?

Adding menu items means a little more translation work.

Also affects #1293 - if the new menu items get done first I can make an updated patch for #1293, if #1293 gets done first than adding the new menu items should also update the helpdata.txt

Actions #6

Updated by Dean Brown about 2 months ago

  • File 1630_gtk3.22.patch added
  • File 1630_gtk4.patch added
  • File 1630_gtk5.patch added
  • File 1630_qt.patch 1630_qt.patch added
  • Subject changed from gtk clients have a problem with GDK_KEY_plus key and sound volume to Add menu items to change sound volume
  • Category changed from gtk4-client to client-common

The qt, gtk3.22 & gtk4 patches work for all branches. gtk5 patch works for S3_3 and Main.

I did not remove the gtk(*) functionality of GDK_SHIFT_MASK with "+"/"-" changing volume. Thinking that should be a separate task for after this one is done. Created #1684 for that.

Also re-titled this issue

Actions #7

Updated by Marko Lindqvist 5 days ago

Dean Brown wrote in #note-5:

The sdl client is a problem on my Mac, I get no menus

There's no menus in sdl-clients.

For unit actions, icons often work much the same way as menus in other clients, but that's not relevant here.

Actions #8

Updated by Marko Lindqvist 5 days ago

As usual, there should be only one patch for a given branch in a ticket. Likely you need to split this to per-client tickets.

Actions #9

Updated by Dean Brown 4 days ago

  • Subject changed from Add menu items to change sound volume to Qt: Add menu items to change sound volume
  • Category changed from client-common to Qt-client

Split off new issues for gtk clients - #1717, #1718, #1719
Retitled this one.

Actions #10

Updated by Dean Brown 4 days ago

  • File deleted (1630_gtk3.22.patch)
Actions #11

Updated by Dean Brown 4 days ago

  • File deleted (1630_gtk4.patch)
Actions #12

Updated by Dean Brown 4 days ago

  • File deleted (1630_gtk5.patch)
Actions

Also available in: Atom PDF