1 /* 2 * Copyright 1999-2009 Jeremy Friesner 3 * Copyright 2009-2010 Haiku, Inc. All rights reserved. 4 * Distributed under the terms of the MIT License. 5 * 6 * Authors: 7 * Jeremy Friesner 8 */ 9 #ifndef SHORTCUTS_WINDOW_H 10 #define SHORTCUTS_WINDOW_H 11 12 13 #include <ColumnListView.h> 14 #include <Entry.h> 15 #include <Window.h> 16 17 18 class BButton; 19 class BColumnListView; 20 class BFilePanel; 21 class BMessage; 22 class ShortcutsSpec; 23 24 // This class defines our preferences/configuration window. 25 class ShortcutsWindow : public BWindow { 26 public: 27 ShortcutsWindow(); 28 ~ShortcutsWindow(); 29 30 virtual void DispatchMessage(BMessage* message, 31 BHandler* handler); 32 virtual void Quit(); 33 virtual void MessageReceived(BMessage* message); 34 virtual bool QuitRequested(); 35 36 // BMessage 'what' codes, representing commands understood by this Window. 37 enum { 38 ADD_HOTKEY_ITEM = 'SpKy', // Add a new hotkey entry to the GUI list. 39 REMOVE_HOTKEY_ITEM, // Remove a hotkey entry from the GUI list. 40 HOTKEY_ITEM_SELECTED, // Give the "focus bar" to the specified 41 // entry. 42 HOTKEY_ITEM_MODIFIED, // Update the state of an entry to reflect 43 // user's changes. 44 OPEN_KEYSET, // Bring up a File requester to load new 45 // settings. 46 APPEND_KEYSET, // Bring up a File requester to append 47 // settings. 48 REVERT_KEYSET, // Dump the current state and re-read 49 // settings from disk. 50 SAVE_KEYSET, // Save the current settings to disk 51 SAVE_KEYSET_AS, // Bring up a File requester to save 52 // current settings. 53 SELECT_APPLICATION, // Set the current entry to point to the 54 // given file. 55 }; 56 57 private: 58 BMenuItem* _CreateActuatorPresetMenuItem(const char* label) 59 const; 60 void _AddNewSpec(const char* defaultCommand, uint32 keyCode = 0); 61 void _MarkKeySetModified(); 62 bool _LoadKeySet(const BMessage& loadMessage); 63 bool _SaveKeySet(BEntry& saveEntry); 64 bool _GetSettingsFile(entry_ref* ref); 65 void _LoadWindowSettings( 66 const BMessage& loadMessage); 67 void _SaveWindowSettings(BEntry& saveEntry); 68 bool _GetWindowSettingsFile(entry_ref* ref); 69 70 BButton* fAddButton; 71 BButton* fRemoveButton; 72 BButton* fSaveButton; 73 BColumnListView* fColumnListView; 74 BFilePanel* fSavePanel; 75 // for saving settings 76 BFilePanel* fOpenPanel; 77 // for loading settings 78 BFilePanel* fSelectPanel; 79 // for selecting apps to launch 80 81 // Points to the settings file to save to 82 BEntry fLastSaved; 83 84 // true iff changes were made since last load or save 85 bool fKeySetModified; 86 87 // true iff the file-requester's ref should be appended to current 88 bool fLastOpenWasAppend; 89 90 BRow* fSelectedRow; 91 }; 92 93 94 #endif // SHORTCUTS_WINDOW_H 95