示例#1
0
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();
}
示例#2
0
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();

   }
ShortcutCatcher::ShortcutCatcher(QWidget *parent)
  : QWidget(parent) {
  // Setup layout of the control
  m_layout = new QHBoxLayout(this);
  m_layout->setMargin(0);
  m_layout->setSpacing(1);

  // Create reset button.
  m_btnReset = new PlainToolButton(this);
  m_btnReset->setIcon(IconFactory::instance()->fromTheme("edit-revert"));
  m_btnReset->setFocusPolicy(Qt::NoFocus);
  m_btnReset->setToolTip(tr("Reset to original shortcut."));

  // Create clear button.
  m_btnClear = new PlainToolButton(this);
  m_btnClear->setIcon(IconFactory::instance()->fromTheme("item-remove"));
  m_btnClear->setFocusPolicy(Qt::NoFocus);
  m_btnClear->setToolTip(tr("Clear current shortcut."));

  // Clear main shortcut catching button.
  m_btnChange = new ShortcutButton(this);
  m_btnChange->setFocusPolicy(Qt::StrongFocus);
  m_btnChange->setToolTip(tr("Click and hit new shortcut."));

  // Add both buttons to the layout.
  m_layout->addWidget(m_btnChange);
  m_layout->addWidget(m_btnReset);
  m_layout->addWidget(m_btnClear);

  // Establish needed connections.
  connect(m_btnReset, SIGNAL(clicked()), this, SLOT(resetShortcut()));
  connect(m_btnClear, SIGNAL(clicked()), this, SLOT(clearShortcut()));
  connect(m_btnChange, SIGNAL(clicked()), this, SLOT(startRecording()));

  // Prepare initial state of the control.
  updateDisplayShortcut();
}