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