ShortcutConfig::ShortcutConfig(QWidget* parent) : QDialog(parent) { setupUi(this); connect(cgListView, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(categorySelChanged(QTreeWidgetItem*, int))); connect(cgListView, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(categorySelChanged(QTreeWidgetItem*, int))); connect(scListView, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(shortcutSelChanged(QTreeWidgetItem*, int))); connect(defineButton, SIGNAL(pressed()), this, SLOT(assignShortcut())); connect(clearButton, SIGNAL(pressed()), this, SLOT(clearShortcut())); connect(applyButton, SIGNAL(pressed()), this, SLOT(assignAll())); current_category = ALL_SHRT; cgListView->sortItems(SHRT_CATEGORY_COL, Qt::AscendingOrder); _config_changed = false; //Fill up category listview: SCListViewItem* newItem; SCListViewItem* selItem = 0; for (int i = 0; i < SHRT_NUM_OF_CATEGORIES; i++) { newItem = new SCListViewItem(cgListView, i); newItem->setText(SHRT_CATEGORY_COL, shortcut_category[i].name); if (shortcut_category[i].id_flag == current_category) selItem = newItem; } if (selItem) cgListView->setCurrentItem(selItem); // Tim updateSCListView(); }
void ShortcutConfig::updateSCListView(int category) { scListView->clear(); SCListViewItem* newItem; //QString catpre; for (int i=0; i < SHRT_NUM_OF_ELEMENTS; i++) { if (shortcuts[i].type & category) { newItem = new SCListViewItem(scListView, i); newItem->setText(SHRT_DESCR_COL, qApp->translate("shortcuts", shortcuts[i].descr)); //if(category == ALL_SHRT) // catpre = QString(shortcut_category[shortcuts[i].type].name) + QString(": "); //else // catpre.clear(); //newItem->setText(SHRT_DESCR_COL, catpre + tr(qApp->translate("shortcuts", shortcuts[i].descr)); // Tim QKeySequence key = QKeySequence(shortcuts[i].key); newItem->setText(SHRT_SHRTCUT_COL, key.toString()); } } }
void ShortcutConfig::clearShortcut() { SCListViewItem* active = (SCListViewItem*) scListView->selectedItems()[0]; int shortcutindex = active->getIndex(); shortcuts[shortcutindex].key = 0; //Cleared active->setText(SHRT_SHRTCUT_COL,""); clearButton->setDown(false); clearButton->setEnabled(false); _config_changed = true; }
void ShortcutConfig::assignShortcut() { SCListViewItem* active = (SCListViewItem*) scListView->selectedItems()[0]; int shortcutindex = active->getIndex(); ShortcutCaptureDialog* sc = new ShortcutCaptureDialog(this, shortcutindex); int key = sc->exec(); delete(sc); if (key != Rejected) { shortcuts[shortcutindex].key = key; QKeySequence keySequence = QKeySequence(key); active->setText(SHRT_SHRTCUT_COL, keySequence.toString()); _config_changed = true; clearButton->setEnabled(true); } defineButton->setDown(false); }
ShortcutConfig::ShortcutConfig(QWidget* parent) : QDialog(parent) { setupUi(this); QSettings settings("MusE", "MusE-qt"); restoreGeometry(settings.value("ShortcutConfig/geometry").toByteArray()); connect(cgListView, SIGNAL(itemActivated(QTreeWidgetItem*, int )), this, SLOT(categorySelChanged(QTreeWidgetItem*, int))); connect(scListView, SIGNAL(itemActivated(QTreeWidgetItem*, int )), this, SLOT(shortcutSelChanged(QTreeWidgetItem*, int))); okButton->setDefault(true); connect(defineButton, SIGNAL(pressed()), this, SLOT(assignShortcut())); connect(clearButton, SIGNAL(pressed()), this, SLOT(clearShortcut())); connect(textFileButton, SIGNAL(pressed()), this, SLOT(textFileClicked())); connect(applyButton, SIGNAL(pressed()), this, SLOT(applyAll())); connect(okButton, SIGNAL(pressed()), this, SLOT(okClicked())); current_category = ALL_SHRT; cgListView->sortItems(SHRT_CATEGORY_COL, Qt::AscendingOrder); _config_changed = false; //Fill up category listview: SCListViewItem* newItem; SCListViewItem* selItem = 0; for (int i=0; i < SHRT_NUM_OF_CATEGORIES; i++) { newItem = new SCListViewItem(cgListView, i); newItem->setText(SHRT_CATEGORY_COL, shortcut_category[i].name); if(shortcut_category[i].id_flag == current_category) selItem = newItem; } if(selItem) cgListView->setCurrentItem(selItem); // Tim updateSCListView(); }