mirror of
https://review.haiku-os.org/haiku
synced 2025-02-01 03:06:08 +01:00
Keymap: Add Defaults button to revert keymap
Fixes #9980 Since hrev44455 we save your modifier keys settings when you switch keymaps so you could get your modifiers keys messed up and unable to get back to normal. This Defaults button allows you to override all that and go back to the default US-International keymap with default modifiers so you can start with a fresh slate and set things up the way you want. Also moved Revert button to the left side next to the Defaults button. We do this on other preflets, the right side is reserved for an Apply or OK button, and, if the preflet doesn't have one, is left empty.
This commit is contained in:
parent
5243ff9403
commit
7889cac6cf
@ -17,6 +17,8 @@
|
||||
|
||||
#include <ByteOrder.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Path.h>
|
||||
|
||||
#include <input_globals.h>
|
||||
|
||||
@ -336,6 +338,23 @@ Keymap::SetDeadKeyTrigger(dead_key_index deadKeyIndex, const BString& trigger)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Keymap::RestoreSystemDefault()
|
||||
{
|
||||
BPath path;
|
||||
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
path.Append("Key_map");
|
||||
|
||||
BEntry entry(path.Path());
|
||||
entry.Remove();
|
||||
|
||||
return Use();
|
||||
}
|
||||
|
||||
|
||||
//! We make our input server use the map in /boot/home/config/settings/Keymap
|
||||
status_t
|
||||
Keymap::Use()
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
void SetDeadKeyTrigger(dead_key_index deadKeyIndex,
|
||||
const BString& trigger);
|
||||
|
||||
status_t RestoreSystemDefault();
|
||||
status_t Use();
|
||||
|
||||
void SetKey(uint32 keyCode, uint32 modifiers,
|
||||
|
@ -55,6 +55,7 @@ static const uint32 kMsgMenuFontChanged = 'mMFC';
|
||||
static const uint32 kMsgSystemMapSelected = 'SmST';
|
||||
static const uint32 kMsgUserMapSelected = 'UmST';
|
||||
|
||||
static const uint32 kMsgDefaultKeymap = 'Dflt';
|
||||
static const uint32 kMsgRevertKeymap = 'Rvrt';
|
||||
static const uint32 kMsgKeymapUpdated = 'kMup';
|
||||
|
||||
@ -67,6 +68,7 @@ static const uint32 kMsgDeadKeyTildeChanged = 'dkTc';
|
||||
static const char* kDeadKeyTriggerNone = "<none>";
|
||||
|
||||
static const char* kCurrentKeymapName = "(Current)";
|
||||
static const char* kDefaultKeymapName = "US-International";
|
||||
|
||||
|
||||
KeymapWindow::KeymapWindow()
|
||||
@ -85,9 +87,6 @@ KeymapWindow::KeymapWindow()
|
||||
fSwitchShortcutsButton = new BButton("switch", "",
|
||||
new BMessage(kMsgSwitchShortcuts));
|
||||
|
||||
fRevertButton = new BButton("revertButton", B_TRANSLATE("Revert"),
|
||||
new BMessage(kMsgRevertKeymap));
|
||||
|
||||
// controls pane
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
||||
.Add(_CreateMenu())
|
||||
@ -103,8 +102,12 @@ KeymapWindow::KeymapWindow()
|
||||
.Add(fTextControl)
|
||||
.AddGlue(0.0)
|
||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
|
||||
.AddGlue(0.0)
|
||||
.Add(fRevertButton)))
|
||||
.Add(fDefaultsButton = new BButton("defaultsButton",
|
||||
B_TRANSLATE("Defaults"),
|
||||
new BMessage(kMsgDefaultKeymap)))
|
||||
.Add(fRevertButton = new BButton("revertButton",
|
||||
B_TRANSLATE("Revert"), new BMessage(kMsgRevertKeymap)))
|
||||
.AddGlue()))
|
||||
.SetInsets(10, 10, 10, 10)));
|
||||
|
||||
fKeyboardLayoutView->SetTarget(fTextControl->TextView());
|
||||
@ -292,6 +295,11 @@ KeymapWindow::MessageReceived(BMessage* message)
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgDefaultKeymap:
|
||||
_DefaultKeymap();
|
||||
_UpdateButtons();
|
||||
break;
|
||||
|
||||
case kMsgRevertKeymap:
|
||||
_RevertKeymap();
|
||||
_UpdateButtons();
|
||||
@ -735,6 +743,8 @@ KeymapWindow::_UpdateButtons()
|
||||
_UseKeymap();
|
||||
}
|
||||
|
||||
fDefaultsButton->SetEnabled(
|
||||
fCurrentMapName.ICompare(kDefaultKeymapName) != 0);
|
||||
fRevertButton->SetEnabled(fCurrentMap != fPreviousMap);
|
||||
|
||||
_UpdateDeadKeyMenu();
|
||||
@ -763,6 +773,20 @@ KeymapWindow::_SwitchShortcutKeys()
|
||||
}
|
||||
|
||||
|
||||
//! Restores the default keymap.
|
||||
void
|
||||
KeymapWindow::_DefaultKeymap()
|
||||
{
|
||||
fCurrentMap.RestoreSystemDefault();
|
||||
fAppliedMap = fCurrentMap;
|
||||
|
||||
fKeyboardLayoutView->SetKeymap(&fCurrentMap);
|
||||
|
||||
fCurrentMapName = _GetActiveKeymapName();
|
||||
_SelectCurrentMap();
|
||||
}
|
||||
|
||||
|
||||
//! Saves previous map to the "Key_map" file.
|
||||
void
|
||||
KeymapWindow::_RevertKeymap()
|
||||
|
@ -51,6 +51,7 @@ protected:
|
||||
void _SwitchShortcutKeys();
|
||||
|
||||
void _UseKeymap();
|
||||
void _DefaultKeymap();
|
||||
void _RevertKeymap();
|
||||
|
||||
BMenuField* _CreateDeadKeyMenuField();
|
||||
@ -74,6 +75,7 @@ protected:
|
||||
private:
|
||||
BListView* fSystemListView;
|
||||
BListView* fUserListView;
|
||||
BButton* fDefaultsButton;
|
||||
BButton* fRevertButton;
|
||||
BMenu* fLayoutMenu;
|
||||
BMenu* fFontMenu;
|
||||
|
Loading…
x
Reference in New Issue
Block a user