10 #include <QFocusEvent>
11 #include <QMouseEvent>
35 popup(NULL), helptext(QString::null), AcceptOnSelect(
false),
36 useVirtualKeyboard(
true), allowVirtualKeyboard(rw),
64 if (hasFocus() && changed)
82 bool handled =
false, updated =
false;
89 for (
int i = 0; i < actions.size() && !handled; i++)
91 QString
action = actions[i];
96 focusNextPrevChild(
false);
98 else if (action ==
"DOWN")
100 focusNextPrevChild(
true);
102 else if (action ==
"LEFT")
104 if (currentIndex() == 0)
105 setCurrentIndex(count()-1);
106 else if (count() > 0)
107 setCurrentIndex((currentIndex() - 1) % count());
110 else if (action ==
"RIGHT")
113 setCurrentIndex((currentIndex() + 1) % count());
116 else if (action ==
"PAGEDOWN")
118 if (currentIndex() == 0)
119 setCurrentIndex(count() - (
step % count()));
120 else if (count() > 0)
122 (currentIndex() + count() - (
step % count())) % count());
125 else if (action ==
"PAGEUP")
129 (currentIndex() + (
step % count())) % count());
134 else if (action ==
"SELECT" &&
135 (e->text().isEmpty() ||
136 (e->key() == Qt::Key_Enter) ||
137 (e->key() == Qt::Key_Return) ||
138 (e->key() == Qt::Key_Space)))
153 emit activated(currentIndex());
154 emit activated(itemText(currentIndex()));
170 QColor highlight = palette().color(QPalette::Highlight);
173 palette.setColor(backgroundRole(), highlight);
177 lineEdit()->setPalette(palette);
184 setPalette(QPalette());
188 lineEdit()->setPalette(QPalette());
191 QString curText = currentText();
193 bool foundItem =
false;
195 for(i = 0; i < count(); i++)
196 if (curText == itemText(i))
202 setCurrentIndex(count()-1);
211 bool handled =
false;
216 for (
int i = 0; i < actions.size() && !handled; i++)
218 QString
action = actions[i];
222 focusNextPrevChild(
false);
223 else if (action ==
"DOWN")
224 focusNextPrevChild(
true);
225 else if (action ==
"LEFT" || action ==
"RIGHT" || action ==
"SELECT")
239 if (hasFocus() && changed)
247 QColor highlight = palette().color(QPalette::Highlight);
249 palette.setColor(backgroundRole(), highlight);
257 setPalette(QPalette());
263 bool handled =
false;
267 for (
int i = 0; i < actions.size() && !handled; i++)
269 QString
action = actions[i];
273 focusNextPrevChild(
false);
274 else if (action ==
"DOWN")
275 focusNextPrevChild(
true);
276 else if (action ==
"LEFT" || action ==
"RIGHT")
290 if (hasFocus() && changed)
298 QColor highlight = palette().color(QPalette::Highlight);
301 palette.setColor(backgroundRole(), highlight);
309 setPalette(QPalette());
318 if (hasFocus() && changed)
324 bool handled =
false;
328 for (
int i = 0; i < actions.size() && !handled; i++)
330 QString
action = actions[i];
334 focusNextPrevChild(
false);
335 else if (action ==
"DOWN")
336 focusNextPrevChild(
true);
337 else if (action ==
"LEFT")
339 else if (action ==
"RIGHT")
341 else if (action ==
"PAGEDOWN")
343 else if (action ==
"PAGEUP")
345 else if (action ==
"SELECT")
359 QColor highlight = palette().color(QPalette::Highlight);
362 palette.setColor(backgroundRole(), highlight);
370 setPalette(QPalette());
376 bool handled =
false;
380 for (
int i = 0; i < actions.size() && !handled; i++)
382 QString
action = actions[i];
386 focusNextPrevChild(
false);
387 else if (action ==
"DOWN")
388 focusNextPrevChild(
true);
389 else if (action ==
"LEFT")
390 setValue(value() - singleStep());
391 else if (action ==
"RIGHT")
392 setValue(value() + singleStep());
393 else if (action ==
"SELECT")
407 if (hasFocus() && changed)
415 QColor highlight = palette().color(QPalette::Highlight);
418 palette.setColor(backgroundRole(), highlight);
426 setPalette(QPalette());
432 popup(NULL), helptext(QString::null), rw(
true),
433 useVirtualKeyboard(
true),
434 allowVirtualKeyboard(
true),
442 const QString &contents, QWidget *parent,
const char *
name) :
443 QLineEdit(contents, parent),
444 popup(NULL), helptext(QString::null), rw(
true),
445 useVirtualKeyboard(
true),
446 allowVirtualKeyboard(
true),
482 bool handled =
false;
486 if ((!
popup ||
popup->isHidden()) && !handled)
488 for (
int i = 0; i < actions.size() && !handled; i++)
490 QString
action = actions[i];
494 focusNextPrevChild(
false);
495 else if (action ==
"DOWN")
496 focusNextPrevChild(
true);
497 else if (action ==
"SELECT" &&
498 (e->text().isEmpty() ||
499 (e->key() == Qt::Key_Enter) ||
500 (e->key() == Qt::Key_Return)))
507 else if (action ==
"SELECT" && e->text().isEmpty() )
515 if (
rw || e->key() == Qt::Key_Escape || e->key() == Qt::Key_Left
516 || e->key() == Qt::Key_Return || e->key() == Qt::Key_Right)
517 QLineEdit::keyPressEvent(e);
526 int pos = cursorPosition();
528 setCursorPosition(pos);
540 if (hasFocus() && changed)
548 QColor highlight = palette().color(QPalette::Highlight);
551 palette.setColor(backgroundRole(), highlight);
559 setPalette(QPalette());
587 QWidget * parent,
const char *
name) :
632 QColor(100, 100, 100), QColor(0, 255, 255), QColor(255, 0, 0));
635 setWordWrapMode(QTextOption::NoWrap);
640 QFontMetrics fontsize(font());
642 setMinimumHeight(fontsize.height() * 5 / 4);
643 setMaximumHeight(fontsize.height() *
m_lines * 5 / 4);
654 QColor unselected, QColor selected, QColor special)
679 LOG(VB_GENERAL, LOG_ALERT,
680 "startCycle() called, but edit is already in a cycle.");
688 QTextCursor pre_cycle_cursor = textCursor();
690 QTextCursor upto_cursor_sel = pre_cycle_cursor;
691 upto_cursor_sel.movePosition(
692 QTextCursor::NoMove, QTextCursor::MoveAnchor);
693 upto_cursor_sel.movePosition(
694 QTextCursor::Start, QTextCursor::KeepAnchor);
697 QTextCursor from_cursor_sel = pre_cycle_cursor;
698 from_cursor_sel.movePosition(
699 QTextCursor::NoMove, QTextCursor::MoveAnchor);
700 from_cursor_sel.movePosition(
701 QTextCursor::End, QTextCursor::KeepAnchor);
712 QString aString, bString;
723 current_choice = current_choice.toUpper();
727 if (current_choice ==
"_" || current_choice ==
"X")
729 bString +=
"<FONT COLOR=\"#";
733 bString +=
"</FONT>";
737 bString +=
"<FONT COLOR=\"#";
741 bString +=
"</FONT>";
745 index =
set.indexOf(current_choice);
746 int length =
set.length();
749 LOG(VB_GENERAL, LOG_ALERT,
750 QString(
"MythRemoteLineEdit passed a choice of \"%1"
751 "\" which is not in set \"%2\"")
752 .arg(current_choice).arg(
set));
758 set.replace(index, current_choice.length(), bString);
764 esc_upto.replace(
"<",
"<").replace(
">",
">").replace(
"\n",
"<br>");
765 esc_from.replace(
"<",
"<").replace(
">",
">").replace(
"\n",
"<br>");
768 aString +=
"<FONT COLOR=\"#";
772 aString +=
"]</FONT>";
776 QTextCursor
tmp = textCursor();
777 tmp.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
778 tmp.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor,
786 QTextCursor tmp = textCursor();
787 tmp.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
788 tmp.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor,
790 tmp.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
796 QTextCursor tmp = textCursor();
797 tmp.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
798 tmp.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor,
809 QString tmpString =
"";
839 setPlainText(tmpString);
841 QTextCursor tmpCursor = textCursor();
842 tmpCursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
843 tmpCursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, pos);
844 setTextCursor(tmpCursor);
859 QTextEdit::insertPlainText(text);
864 return QTextEdit::toPlainText();
869 bool handled =
false;
873 if ((!
popup ||
popup->isHidden()) && !handled)
875 for (
int i = 0; i < actions.size() && !handled; i++)
877 QString
action = actions[i];
887 QWidget::focusNextPrevChild(
false);
890 else if (action ==
"DOWN")
893 QWidget::focusNextPrevChild(
true);
896 else if ((action ==
"SELECT") &&
898 ((e->text().isEmpty()) ||
899 (e->key() == Qt::Key_Enter) ||
900 (e->key() == Qt::Key_Return)))
1009 if (desired_interval < 0.5 || desired_interval > 10.0)
1011 LOG(VB_GENERAL, LOG_ALERT,
1012 QString(
"cycle interval of %1 milliseconds ")
1013 .arg((
int) (desired_interval * 1000)) +
1014 "\n\t\t\tis outside of the allowed range of "
1015 "500 to 10,000 milliseconds");
1034 if (index + 1 >= length)
1089 if (hasFocus() && changed)
1098 QColor highlight = palette().color(QPalette::Highlight);
1101 palette.setColor(backgroundRole(), highlight);
1102 setPalette(palette);
1109 setPalette(QPalette());
1154 QTextEdit::insertPlainText(text);
1160 textCursor().deleteChar();
1166 textCursor().deletePreviousChar();
1171 QWidget *parent,
bool isOn)
1172 : QPushButton(ontext, parent)
1191 if (hasFocus() && changed)
1197 bool handled =
false;
1198 QStringList actions;
1203 if (!handled && !actions.isEmpty())
1207 for (
int i = 0; i < actions.size() && !handled; i++)
1209 QString
action = actions[i];
1210 if (action ==
"SELECT")
1227 bool handled =
false;
1229 for (
int i = 0; i < actions.size() && !handled; i++)
1231 QString
action = actions[i];
1232 if (action ==
"SELECT")
1234 QKeyEvent tempe(QEvent::KeyRelease, Qt::Key_Space,
1235 Qt::NoModifier,
" ");
1260 QColor highlight = palette().color(QPalette::Highlight);
1262 palette.setColor(backgroundRole(), highlight);
1263 setPalette(palette);
1270 setPalette(QPalette());
1277 setObjectName(name);
1278 connect(
this, SIGNAL(itemSelectionChanged()),
1286 QPalette pal = palette();
1287 QPalette::ColorRole nR = QPalette::Highlight;
1288 QPalette::ColorGroup oA = QPalette::Active;
1289 QPalette::ColorRole oR = QPalette::Button;
1290 pal.setColor(QPalette::Active, nR, pal.color(oA,oR));
1291 pal.setColor(QPalette::Inactive, nR, pal.color(oA,oR));
1292 pal.setColor(QPalette::Disabled, nR, pal.color(oA,oR));
1300 for (
unsigned i = 0 ; i < (unsigned)count() ; ++i)
1306 if (
text(i).startsWith(matchText))
1314 if (
text(i).toLower().startsWith(matchText.toLower()))
1325 if (
text(i) == matchText)
1333 if (
text(i).toLower() == matchText.toLower())
1345 QList<QListWidgetItem*>
items = QListWidget::selectedItems();
1353 bool handled =
false;
1354 QStringList actions;
1357 for (
int i = 0; i < actions.size() && !handled; i++)
1359 QString
action = actions[i];
1360 if (action ==
"UP" || action ==
"DOWN" || action ==
"PAGEUP" ||
1361 action ==
"PAGEDOWN" || action ==
"LEFT" || action ==
"RIGHT")
1367 if (currentItem() == 0)
1369 focusNextPrevChild(
false);
1376 else if (action ==
"DOWN")
1379 if (currentRow() == (
int) count() - 1)
1381 focusNextPrevChild(
true);
1388 else if (action ==
"LEFT")
1390 focusNextPrevChild(
false);
1394 else if (action ==
"RIGHT")
1396 focusNextPrevChild(
true);
1400 else if (action ==
"PAGEUP")
1401 key = Qt::Key_PageUp;
1402 else if (action ==
"PAGEDOWN")
1403 key = Qt::Key_PageDown;
1405 key = Qt::Key_unknown;
1407 QKeyEvent ev(QEvent::KeyPress, key, Qt::NoModifier);
1411 else if (action ==
"0" || action ==
"1" || action ==
"2" ||
1412 action ==
"3" || action ==
"4" || action ==
"5" ||
1413 action ==
"6" || action ==
"7" || action ==
"8" ||
1416 int percent = action.toInt() * 10;
1417 int nextItem = percent * count() / 100;
1423 else if (action ==
"PREVVIEW")
1425 int nextItem = currentRow();
1428 while (nextItem > 0 &&
text(nextItem)[0] ==
' ')
1435 else if (action ==
"NEXTVIEW")
1437 int nextItem = currentRow();
1438 if (nextItem < (
int)count() - 1)
1440 while (nextItem < (
int)count() - 1 &&
text(nextItem)[0] ==
' ')
1447 else if (action ==
"MENU")
1449 else if (action ==
"EDIT")
1451 else if (action ==
"DELETE")
1453 else if (action ==
"SELECT")
1465 if (hasFocus() && changed)
1471 QPalette pal = palette();
1472 QPalette::ColorRole nR = QPalette::Highlight;
1473 QPalette::ColorGroup oA = QPalette::Active;
1474 QPalette::ColorRole oR = QPalette::Button;
1475 pal.setColor(QPalette::Active, nR, pal.color(oA,oR));
1476 pal.setColor(QPalette::Inactive, nR, pal.color(oA,oR));
1477 pal.setColor(QPalette::Disabled, nR, pal.color(oA,oR));
1484 setPalette(QPalette());
1493 QListWidgetItem *widget = item(row);
1495 scrollToItem(widget, QAbstractItemView::PositionAtTop);
1505 addItems(label_list);
1510 QListWidgetItem *widget = takeItem(row);
1517 QListWidgetItem *widget = item(row);
1519 widget->setText(new_text);
1524 return (list.empty()) ? -1 : row(list[0]);
1529 QListWidgetItem *widget = item(row);
1530 return (widget) ? widget->text() : QString::null;
1535 QListWidgetItem *widget = item(row);
1536 return (widget) ? !isItemHidden(widget) :
false;