Shortcuts: save columns information
- Clean up useless code - Remove horizontal scrollbar - Fixes #14278 Change-Id: I7edcb998bfca4b90d02f949b6e7979bcdbcc3cbb
This commit is contained in:
@@ -133,13 +133,8 @@ ShortcutsWindow::ShortcutsWindow()
|
|||||||
new BMessage(B_QUIT_REQUESTED), 'Q'));
|
new BMessage(B_QUIT_REQUESTED), 'Q'));
|
||||||
menuBar->AddItem(fileMenu);
|
menuBar->AddItem(fileMenu);
|
||||||
|
|
||||||
BRect tableBounds = Bounds();
|
|
||||||
tableBounds.top = menuBar->Bounds().bottom + 1;
|
|
||||||
tableBounds.right -= B_V_SCROLL_BAR_WIDTH;
|
|
||||||
tableBounds.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
|
||||||
|
|
||||||
fColumnListView = new BColumnListView(NULL,
|
fColumnListView = new BColumnListView(NULL,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
|
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER, false);
|
||||||
|
|
||||||
float cellWidth = be_plain_font->StringWidth("Either") + 20;
|
float cellWidth = be_plain_font->StringWidth("Either") + 20;
|
||||||
// ShortcutsSpec does not seem to translate the string "Either".
|
// ShortcutsSpec does not seem to translate the string "Either".
|
||||||
@@ -187,19 +182,21 @@ ShortcutsWindow::ShortcutsWindow()
|
|||||||
fColumnListView->SetTarget(this);
|
fColumnListView->SetTarget(this);
|
||||||
|
|
||||||
fAddButton = new BButton("add", B_TRANSLATE("Add new shortcut"),
|
fAddButton = new BButton("add", B_TRANSLATE("Add new shortcut"),
|
||||||
new BMessage(ADD_HOTKEY_ITEM), B_FOLLOW_BOTTOM);
|
new BMessage(ADD_HOTKEY_ITEM));
|
||||||
|
|
||||||
fRemoveButton = new BButton("remove",
|
fRemoveButton = new BButton("remove",
|
||||||
B_TRANSLATE("Remove selected shortcut"),
|
B_TRANSLATE("Remove selected shortcut"),
|
||||||
new BMessage(REMOVE_HOTKEY_ITEM), B_FOLLOW_BOTTOM);
|
new BMessage(REMOVE_HOTKEY_ITEM));
|
||||||
fRemoveButton->SetEnabled(false);
|
fRemoveButton->SetEnabled(false);
|
||||||
|
|
||||||
fSaveButton = new BButton("save", B_TRANSLATE("Save & apply"),
|
fSaveButton = new BButton("save", B_TRANSLATE("Save & apply"),
|
||||||
new BMessage(SAVE_KEYSET), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT);
|
new BMessage(SAVE_KEYSET));
|
||||||
fSaveButton->SetEnabled(false);
|
fSaveButton->SetEnabled(false);
|
||||||
|
|
||||||
CenterOnScreen();
|
CenterOnScreen();
|
||||||
|
|
||||||
|
fColumnListView->ResizeAllColumnsToPreferred();
|
||||||
|
|
||||||
entry_ref windowSettingsRef;
|
entry_ref windowSettingsRef;
|
||||||
if (_GetWindowSettingsFile(&windowSettingsRef)) {
|
if (_GetWindowSettingsFile(&windowSettingsRef)) {
|
||||||
// The window settings file is not accepted via B_REFS_RECEIVED; this
|
// The window settings file is not accepted via B_REFS_RECEIVED; this
|
||||||
@@ -220,8 +217,6 @@ ShortcutsWindow::ShortcutsWindow()
|
|||||||
// tell ourselves to load this file if it exists
|
// tell ourselves to load this file if it exists
|
||||||
}
|
}
|
||||||
|
|
||||||
fColumnListView->ResizeAllColumnsToPreferred();
|
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
||||||
.Add(menuBar)
|
.Add(menuBar)
|
||||||
.AddGroup(B_VERTICAL)
|
.AddGroup(B_VERTICAL)
|
||||||
@@ -403,10 +398,9 @@ ShortcutsWindow::_SaveWindowSettings(BEntry& saveEntry)
|
|||||||
BMessage saveMsg;
|
BMessage saveMsg;
|
||||||
saveMsg.AddRect("window frame", Frame());
|
saveMsg.AddRect("window frame", Frame());
|
||||||
|
|
||||||
for (int i = 0; i < fColumnListView->CountColumns(); i++) {
|
BMessage columnsState;
|
||||||
BColumn* column = fColumnListView->ColumnAt(i);
|
fColumnListView->SaveState(&columnsState);
|
||||||
saveMsg.AddFloat("column width", column->Width());
|
saveMsg.AddMessage ("columns state", &columnsState);
|
||||||
}
|
|
||||||
|
|
||||||
saveMsg.Flatten(&saveTo);
|
saveMsg.Flatten(&saveTo);
|
||||||
}
|
}
|
||||||
@@ -432,12 +426,9 @@ ShortcutsWindow::_LoadWindowSettings(const BMessage& loadMessage)
|
|||||||
MoveTo(left, top);
|
MoveTo(left, top);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < fColumnListView->CountColumns(); i++) {
|
BMessage columnsStateMessage;
|
||||||
BColumn* column = fColumnListView->ColumnAt(i);
|
if (loadMessage.FindMessage ("columns state", &columnsStateMessage) == B_OK)
|
||||||
float columnWidth;
|
fColumnListView->LoadState(&columnsStateMessage);
|
||||||
if (loadMessage.FindFloat("column width", i, &columnWidth) == B_OK)
|
|
||||||
column->SetWidth(max_c(column->Width(), columnWidth));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user