From b24366c6d8326a768919dde48bb36c0cab131702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sat, 17 Oct 2009 23:27:02 +0000 Subject: [PATCH] Implemented focusing the Name property on pressing Command-E. (Ticket #2742) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33631 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/icon-o-matic/MainWindow.cpp | 18 +++++++++------- .../generic/property/view/PropertyListView.h | 8 ++++--- .../icon-o-matic/gui/IconObjectListView.cpp | 21 +++++++++++++++++++ .../icon-o-matic/gui/IconObjectListView.h | 2 ++ 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/apps/icon-o-matic/MainWindow.cpp b/src/apps/icon-o-matic/MainWindow.cpp index 6316783d08..6cf0413686 100644 --- a/src/apps/icon-o-matic/MainWindow.cpp +++ b/src/apps/icon-o-matic/MainWindow.cpp @@ -1,9 +1,6 @@ /* - * Copyright 2006-2008, Haiku. - * Distributed under the terms of the MIT License. - * - * Authors: - * Stephan Aßmus + * Copyright 2006-2009, Stephan Aßmus . + * All rights reserved. Distributed under the terms of the MIT License. */ #include "MainWindow.h" @@ -80,6 +77,8 @@ enum { MSG_STYLE_RESET_TRANSFORMATION = 'rtst', MSG_MOUSE_FILTER_MODE = 'mfmd', + + MSG_RENAME_OBJECT = 'rnam', }; // constructor @@ -358,6 +357,10 @@ case MSG_SHAPE_SELECTED: { } break; } + case MSG_RENAME_OBJECT: + fPropertyListView->FocusNameProperty(); + break; + default: BWindow::MessageReceived(message); } @@ -576,6 +579,7 @@ MainWindow::_Init() AddShortcut('Y', 0, new BMessage(MSG_UNDO)); AddShortcut('Y', B_SHIFT_KEY, new BMessage(MSG_REDO)); + AddShortcut('E', 0, new BMessage(MSG_RENAME_OBJECT)); } // _CreateGUI @@ -1027,9 +1031,9 @@ MainWindow::_CreateMenuBar(BRect frame) new BMessage(MSG_SAVE_AS), 'S', B_SHIFT_KEY)); fileMenu->AddSeparatorItem(); fileMenu->AddItem(new BMenuItem("Export", - new BMessage(MSG_EXPORT), 'E')); + new BMessage(MSG_EXPORT), 'P')); fileMenu->AddItem(new BMenuItem("Export As"B_UTF8_ELLIPSIS, - new BMessage(MSG_EXPORT_AS), 'E', B_SHIFT_KEY)); + new BMessage(MSG_EXPORT_AS), 'P', B_SHIFT_KEY)); fileMenu->AddSeparatorItem(); fileMenu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); diff --git a/src/apps/icon-o-matic/generic/property/view/PropertyListView.h b/src/apps/icon-o-matic/generic/property/view/PropertyListView.h index 4af428db0d..8775717315 100644 --- a/src/apps/icon-o-matic/generic/property/view/PropertyListView.h +++ b/src/apps/icon-o-matic/generic/property/view/PropertyListView.h @@ -80,13 +80,15 @@ class PropertyListView : public BView, void Clicked(PropertyItemView* item); void DoubleClicked(PropertyItemView* item); - private: +protected: + PropertyItemView* _ItemAt(int32 index) const; + int32 _CountItems() const; + +private: void _UpdateSavedProperties(); bool _AddItem(PropertyItemView* item); PropertyItemView* _RemoveItem(int32 index); - PropertyItemView* _ItemAt(int32 index) const; - int32 _CountItems() const; void _MakeEmpty(); diff --git a/src/apps/icon-o-matic/gui/IconObjectListView.cpp b/src/apps/icon-o-matic/gui/IconObjectListView.cpp index f60ea2e41f..00879b124e 100644 --- a/src/apps/icon-o-matic/gui/IconObjectListView.cpp +++ b/src/apps/icon-o-matic/gui/IconObjectListView.cpp @@ -13,8 +13,10 @@ #include #include "CommandStack.h" +#include "CommonPropertyIDs.h" #include "IconObject.h" #include "Property.h" +#include "PropertyItemView.h" #include "PropertyObject.h" #include "Selection.h" #include "SetPropertiesCommand.h" @@ -161,6 +163,25 @@ IconObjectListView::SetCommandStack(CommandStack* stack) fCommandStack = stack; } +// FocusNameProperty +void +IconObjectListView::FocusNameProperty() +{ + if (fObject == NULL) + return; + + int32 count = _CountItems(); + for (int32 i = 0; i < count; i++) { + PropertyItemView* item = _ItemAt(i); + Property* property = item->GetProperty(); + if (property != NULL && property->Identifier() == PROPERTY_NAME) { + item->MakeFocus(true); + break; + } + } +} + + // #pragma mark - // _SetObject diff --git a/src/apps/icon-o-matic/gui/IconObjectListView.h b/src/apps/icon-o-matic/gui/IconObjectListView.h index 0618f04bb0..d821c8c0df 100644 --- a/src/apps/icon-o-matic/gui/IconObjectListView.h +++ b/src/apps/icon-o-matic/gui/IconObjectListView.h @@ -38,6 +38,8 @@ class IconObjectListView : public PropertyListView, void SetSelection(Selection* selection); void SetCommandStack(CommandStack* stack); + void FocusNameProperty(); + private: void _SetObject(IconObject* object);