fixed keyboard shortcut implementation
This commit is contained in:
@@ -51,6 +51,7 @@ void Config::SetDefaults()
|
||||
config_map_.clear();
|
||||
config_map_["TimecodeDisplay"] = olive::kTimecodeFrames;
|
||||
config_map_["DefaultStillLength"] = QVariant::fromValue(rational(2));
|
||||
config_map_["HoverFocus"] = false;
|
||||
}
|
||||
|
||||
void Config::Load()
|
||||
|
||||
@@ -32,7 +32,7 @@ void KeySequenceEditor::set_action_shortcut() {
|
||||
}
|
||||
|
||||
void KeySequenceEditor::reset_to_default() {
|
||||
setKeySequence(action->property("default").toString());
|
||||
setKeySequence(action->property("keydefault").toString());
|
||||
}
|
||||
|
||||
QString KeySequenceEditor::action_name() {
|
||||
@@ -41,7 +41,7 @@ QString KeySequenceEditor::action_name() {
|
||||
|
||||
QString KeySequenceEditor::export_shortcut() {
|
||||
QString ks = keySequence().toString();
|
||||
if (ks != action->property("default")) {
|
||||
if (ks != action->property("keydefault")) {
|
||||
return action->property("id").toString() + "\t" + ks;
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -281,10 +281,7 @@ void PreferencesDialog::accept()
|
||||
delete_previews(delete_type);
|
||||
}
|
||||
|
||||
// Save keyboard shortcuts
|
||||
for (int i=0;i<key_shortcut_fields.size();i++) {
|
||||
key_shortcut_fields.at(i)->set_action_shortcut();
|
||||
}
|
||||
|
||||
|
||||
QDialog::accept();
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
|
||||
PreferencesGeneralTab::PreferencesGeneralTab()
|
||||
{
|
||||
QGridLayout* general_layout = new QGridLayout(this);
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
QGridLayout* general_layout = new QGridLayout();
|
||||
layout->addLayout(general_layout);
|
||||
|
||||
int row = 0;
|
||||
|
||||
@@ -76,17 +79,6 @@ PreferencesGeneralTab::PreferencesGeneralTab()
|
||||
|
||||
QHBoxLayout* misc_general = new QHBoxLayout();
|
||||
|
||||
// General -> Use Software Fallbacks When Possible
|
||||
QCheckBox* use_software_fallbacks_checkbox = new QCheckBox(tr("Use Software Fallbacks When Possible"));
|
||||
//AddBoolPair(use_software_fallbacks_checkbox, &olive::config.use_software_fallback, true);
|
||||
misc_general->addWidget(use_software_fallbacks_checkbox);
|
||||
|
||||
// General -> Don't Use Proxies When Exporting
|
||||
QCheckBox* dont_use_proxies_when_exporting = new QCheckBox(tr("Don't Use Proxies When Exporting"));
|
||||
dont_use_proxies_when_exporting->setToolTip(tr("Use originals instead of proxies when exporting"));
|
||||
//AddBoolPair(dont_use_proxies_when_exporting, &olive::config.dont_use_proxies_on_export);
|
||||
misc_general->addWidget(dont_use_proxies_when_exporting);
|
||||
|
||||
// General -> Default Sequence Settings
|
||||
QPushButton* default_sequence_settings = new QPushButton(tr("Default Sequence Settings"));
|
||||
connect(default_sequence_settings, SIGNAL(clicked(bool)), this, SLOT(edit_default_sequence_settings()));
|
||||
@@ -94,7 +86,7 @@ PreferencesGeneralTab::PreferencesGeneralTab()
|
||||
|
||||
general_layout->addLayout(misc_general, row, 0, 1, 5);
|
||||
|
||||
row++;
|
||||
layout->addStretch();
|
||||
}
|
||||
|
||||
void PreferencesGeneralTab::Accept()
|
||||
|
||||
@@ -17,11 +17,11 @@ PreferencesKeyboardTab::PreferencesKeyboardTab(QMenuBar *menubar)
|
||||
|
||||
shortcut_layout->addWidget(key_search_line);
|
||||
|
||||
keyboard_tree = new QTreeWidget();
|
||||
QTreeWidgetItem* tree_header = keyboard_tree->headerItem();
|
||||
keyboard_tree_ = new QTreeWidget();
|
||||
QTreeWidgetItem* tree_header = keyboard_tree_->headerItem();
|
||||
tree_header->setText(0, tr("Action"));
|
||||
tree_header->setText(1, tr("Shortcut"));
|
||||
shortcut_layout->addWidget(keyboard_tree);
|
||||
shortcut_layout->addWidget(keyboard_tree_);
|
||||
|
||||
QHBoxLayout* reset_shortcut_layout = new QHBoxLayout();
|
||||
|
||||
@@ -50,7 +50,10 @@ PreferencesKeyboardTab::PreferencesKeyboardTab(QMenuBar *menubar)
|
||||
|
||||
void PreferencesKeyboardTab::Accept()
|
||||
{
|
||||
|
||||
// Save keyboard shortcuts
|
||||
for (int i=0;i<key_shortcut_fields_.size();i++) {
|
||||
key_shortcut_fields_.at(i)->set_action_shortcut();
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesKeyboardTab::setup_kbd_shortcuts(QMenuBar* menubar) {
|
||||
@@ -59,19 +62,19 @@ void PreferencesKeyboardTab::setup_kbd_shortcuts(QMenuBar* menubar) {
|
||||
for (int i=0;i<menus.size();i++) {
|
||||
QMenu* menu = menus.at(i)->menu();
|
||||
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem(keyboard_tree);
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem(keyboard_tree_);
|
||||
item->setText(0, menu->title().replace("&", ""));
|
||||
|
||||
keyboard_tree->addTopLevelItem(item);
|
||||
keyboard_tree_->addTopLevelItem(item);
|
||||
|
||||
setup_kbd_shortcut_worker(menu, item);
|
||||
}
|
||||
|
||||
for (int i=0;i<key_shortcut_items.size();i++) {
|
||||
if (!key_shortcut_actions.at(i)->property("id").isNull()) {
|
||||
KeySequenceEditor* editor = new KeySequenceEditor(keyboard_tree, key_shortcut_actions.at(i));
|
||||
keyboard_tree->setItemWidget(key_shortcut_items.at(i), 1, editor);
|
||||
key_shortcut_fields.append(editor);
|
||||
for (int i=0;i<key_shortcut_items_.size();i++) {
|
||||
if (!key_shortcut_actions_.at(i)->property("id").isNull()) {
|
||||
KeySequenceEditor* editor = new KeySequenceEditor(keyboard_tree_, key_shortcut_actions_.at(i));
|
||||
keyboard_tree_->setItemWidget(key_shortcut_items_.at(i), 1, editor);
|
||||
key_shortcut_fields_.append(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,18 +94,18 @@ void PreferencesKeyboardTab::setup_kbd_shortcut_worker(QMenu* menu, QTreeWidgetI
|
||||
item->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
|
||||
setup_kbd_shortcut_worker(a->menu(), item);
|
||||
} else {
|
||||
key_shortcut_items.append(item);
|
||||
key_shortcut_actions.append(a);
|
||||
key_shortcut_items_.append(item);
|
||||
key_shortcut_actions_.append(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesKeyboardTab::reset_default_shortcut() {
|
||||
QList<QTreeWidgetItem*> items = keyboard_tree->selectedItems();
|
||||
QList<QTreeWidgetItem*> items = keyboard_tree_->selectedItems();
|
||||
for (int i=0;i<items.size();i++) {
|
||||
QTreeWidgetItem* item = keyboard_tree->selectedItems().at(i);
|
||||
static_cast<KeySequenceEditor*>(keyboard_tree->itemWidget(item, 1))->reset_to_default();
|
||||
QTreeWidgetItem* item = keyboard_tree_->selectedItems().at(i);
|
||||
static_cast<KeySequenceEditor*>(keyboard_tree_->itemWidget(item, 1))->reset_to_default();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,16 +115,16 @@ void PreferencesKeyboardTab::reset_all_shortcuts() {
|
||||
tr("Confirm Reset All Shortcuts"),
|
||||
tr("Are you sure you wish to reset all keyboard shortcuts to their defaults?"),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
for (int i=0;i<key_shortcut_fields.size();i++) {
|
||||
key_shortcut_fields.at(i)->reset_to_default();
|
||||
for (int i=0;i<key_shortcut_fields_.size();i++) {
|
||||
key_shortcut_fields_.at(i)->reset_to_default();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PreferencesKeyboardTab::refine_shortcut_list(const QString &s, QTreeWidgetItem* parent) {
|
||||
if (parent == nullptr) {
|
||||
for (int i=0;i<keyboard_tree->topLevelItemCount();i++) {
|
||||
refine_shortcut_list(s, keyboard_tree->topLevelItem(i));
|
||||
for (int i=0;i<keyboard_tree_->topLevelItemCount();i++) {
|
||||
refine_shortcut_list(s, keyboard_tree_->topLevelItem(i));
|
||||
}
|
||||
} else {
|
||||
parent->setExpanded(!s.isEmpty());
|
||||
@@ -138,8 +141,8 @@ bool PreferencesKeyboardTab::refine_shortcut_list(const QString &s, QTreeWidgetI
|
||||
all_children_are_hidden = false;
|
||||
} else {
|
||||
QString shortcut;
|
||||
if (keyboard_tree->itemWidget(item, 1) != nullptr) {
|
||||
shortcut = static_cast<QKeySequenceEdit*>(keyboard_tree->itemWidget(item, 1))->keySequence().toString();
|
||||
if (keyboard_tree_->itemWidget(item, 1) != nullptr) {
|
||||
shortcut = static_cast<QKeySequenceEdit*>(keyboard_tree_->itemWidget(item, 1))->keySequence().toString();
|
||||
}
|
||||
if (item->text(0).contains(s, Qt::CaseInsensitive) || shortcut.contains(s, Qt::CaseInsensitive)) {
|
||||
all_children_are_hidden = false;
|
||||
@@ -166,8 +169,8 @@ void PreferencesKeyboardTab::load_shortcut_file() {
|
||||
if (f.exists() && f.open(QFile::ReadOnly)) {
|
||||
QByteArray ba = f.readAll();
|
||||
f.close();
|
||||
for (int i=0;i<key_shortcut_fields.size();i++) {
|
||||
int index = ba.indexOf(key_shortcut_fields.at(i)->action_name());
|
||||
for (int i=0;i<key_shortcut_fields_.size();i++) {
|
||||
int index = ba.indexOf(key_shortcut_fields_.at(i)->action_name());
|
||||
if (index == 0 || (index > 0 && ba.at(index-1) == '\n')) {
|
||||
while (index < ba.size() && ba.at(index) != '\t') index++;
|
||||
QString ks;
|
||||
@@ -176,9 +179,9 @@ void PreferencesKeyboardTab::load_shortcut_file() {
|
||||
ks.append(ba.at(index));
|
||||
index++;
|
||||
}
|
||||
key_shortcut_fields.at(i)->setKeySequence(ks);
|
||||
key_shortcut_fields_.at(i)->setKeySequence(ks);
|
||||
} else {
|
||||
key_shortcut_fields.at(i)->reset_to_default();
|
||||
key_shortcut_fields_.at(i)->reset_to_default();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -197,8 +200,8 @@ void PreferencesKeyboardTab::save_shortcut_file() {
|
||||
QFile f(fn);
|
||||
if (f.open(QFile::WriteOnly)) {
|
||||
bool start = true;
|
||||
for (int i=0;i<key_shortcut_fields.size();i++) {
|
||||
QString s = key_shortcut_fields.at(i)->export_shortcut();
|
||||
for (int i=0;i<key_shortcut_fields_.size();i++) {
|
||||
QString s = key_shortcut_fields_.at(i)->export_shortcut();
|
||||
if (!s.isEmpty()) {
|
||||
if (!start) f.write("\n");
|
||||
f.write(s.toUtf8());
|
||||
|
||||
@@ -91,25 +91,25 @@ private:
|
||||
/**
|
||||
* @brief UI widget for editing keyboard shortcuts
|
||||
*/
|
||||
QTreeWidget* keyboard_tree;
|
||||
QTreeWidget* keyboard_tree_;
|
||||
|
||||
/**
|
||||
* @brief List of keyboard shortcut actions that can be triggered (links with key_shortcut_items and
|
||||
* key_shortcut_fields)
|
||||
*/
|
||||
QVector<QAction*> key_shortcut_actions;
|
||||
QVector<QAction*> key_shortcut_actions_;
|
||||
|
||||
/**
|
||||
* @brief List of keyboard shortcut items in keyboard_tree corresponding to existing actions (links with
|
||||
* key_shortcut_actions and key_shortcut_fields)
|
||||
*/
|
||||
QVector<QTreeWidgetItem*> key_shortcut_items;
|
||||
QVector<QTreeWidgetItem*> key_shortcut_items_;
|
||||
|
||||
/**
|
||||
* @brief List of keyboard shortcut editing fields in keyboard_tree corresponding to existing actions (links with
|
||||
* key_shortcut_actions and key_shortcut_fields)
|
||||
*/
|
||||
QVector<KeySequenceEditor*> key_shortcut_fields;
|
||||
QVector<KeySequenceEditor*> key_shortcut_fields_;
|
||||
};
|
||||
|
||||
#endif // PREFERENCESKEYBOARDTAB_H
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "panelmanager.h"
|
||||
|
||||
#include "config/config.h"
|
||||
|
||||
PanelManager* olive::panel_manager = nullptr;
|
||||
|
||||
PanelManager::PanelManager(QObject *parent) :
|
||||
@@ -43,6 +45,16 @@ const QList<PanelWidget *> &PanelManager::panels()
|
||||
|
||||
PanelWidget *PanelManager::CurrentlyFocused() const
|
||||
{
|
||||
// If hover focus is enabled, find the currently hovered panel and return it (if no panel is hovered, resort to
|
||||
// default behavior)
|
||||
if (Config::Current()["HoverFocus"].toBool()) {
|
||||
PanelWidget* hovered = CurrentlyHovered();
|
||||
|
||||
if (hovered != nullptr) {
|
||||
return hovered;
|
||||
}
|
||||
}
|
||||
|
||||
if (focus_history_.isEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user