Changeset 176 for smplayer/trunk/src/actionseditor.cpp
- Timestamp:
- May 3, 2016, 5:25:45 PM (9 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 175
- Property svn:mergeinfo changed
-
smplayer/trunk/src/actionseditor.cpp
r165 r176 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 4Ricardo Villalba <rvm@users.sourceforge.net>2 Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 37 37 #include <QApplication> 38 38 #include <QAction> 39 #include <QDebug> 39 40 40 41 #include "images.h" … … 103 104 } 104 105 106 //qDebug("ActionsEditor::shortcutsToString: accelText: '%s'", accelText.toUtf8().constData()); 107 105 108 return accelText; 106 109 } … … 109 112 QList <QKeySequence> shortcuts_list; 110 113 111 QStringList l = shortcuts.split( ',');114 QStringList l = shortcuts.split(", "); 112 115 113 116 for (int n=0; n < l.count(); n++) { … … 121 124 QString s = QKeySequence( l[n].simplified() ); 122 125 #endif 123 126 124 127 //Work-around for Simplified-Chinese 125 128 s.replace( QString::fromUtf8("å·Š"), "Left"); … … 147 150 latest_dir = Paths::shortcutsPath(); 148 151 149 152 actionsTable = new QTableWidget(0, COL_NAME +1, this); 150 153 actionsTable->setSelectionMode( QAbstractItemView::SingleSelection ); 151 154 actionsTable->verticalHeader()->hide(); … … 154 157 actionsTable->horizontalHeader()->setSectionResizeMode(COL_DESC, QHeaderView::Stretch); 155 158 actionsTable->horizontalHeader()->setSectionResizeMode(COL_NAME, QHeaderView::Stretch); 159 actionsTable->horizontalHeader()->setSectionResizeMode(COL_CONFLICTS, QHeaderView::ResizeToContents); 156 160 #else 157 161 actionsTable->horizontalHeader()->setResizeMode(COL_DESC, QHeaderView::Stretch); 158 162 actionsTable->horizontalHeader()->setResizeMode(COL_NAME, QHeaderView::Stretch); 163 actionsTable->horizontalHeader()->setResizeMode(COL_CONFLICTS, QHeaderView::ResizeToContents); 159 164 #endif 160 165 … … 254 259 actionsTable->setRowCount( actionsList.count() ); 255 260 256 261 QAction *action; 257 262 QString accelText; 258 263 … … 283 288 // Shortcut column 284 289 QTableWidgetItem * i_shortcut = new QTableWidgetItem(accelText); 290 int column_height = i_shortcut->sizeHint().height(); 291 i_shortcut->setSizeHint(QSize(150, column_height)); 285 292 286 293 // Set flags … … 372 379 373 380 if (!result.isNull()) { 374 QString accelText = QKeySequence(result).toString(QKeySequence::PortableText); 381 //qDebug("ActionsEditor::editShortcut: result: '%s'", result.toUtf8().constData()); 382 QString accelText = QKeySequence(result).toString(QKeySequence::PortableText); 375 383 i->setText(accelText); 376 384 if (hasConflicts()) qApp->beep(); … … 387 395 } 388 396 397 bool ActionsEditor::containsShortcut(const QString & accel, const QString & shortcut) { 398 QStringList shortcut_list = accel.split(", "); 399 QString s; 400 foreach(s, shortcut_list) { 401 s = s.trimmed(); 402 //qDebug("ActionsEditor::containsShortcut: comparing '%s' with '%s'", s.toUtf8().constData(), shortcut.toUtf8().constData()); 403 if (s == shortcut) return true; 404 } 405 return false; 406 } 407 389 408 int ActionsEditor::findActionAccel(const QString & accel, int ignoreRow) { 390 for (int row=0; row < actionsTable->rowCount(); row++) { 409 QStringList shortcuts = accel.split(", "); 410 QString shortcut; 411 412 for (int row = 0; row < actionsTable->rowCount(); row++) { 391 413 QTableWidgetItem * i = actionsTable->item(row, COL_SHORTCUT); 392 if ( (i) && (i->text() == accel) ) { 393 if (ignoreRow == -1) return row; 394 else 395 if (ignoreRow != row) return row; 414 if (i && row != ignoreRow) { 415 if (!i->text().isEmpty()) { 416 foreach(shortcut, shortcuts) { 417 if (containsShortcut(i->text(), shortcut.trimmed())) { 418 return row; 419 } 420 } 421 } 396 422 } 397 423 } … … 406 432 QTableWidgetItem *i; 407 433 408 for (int n =0; n < actionsTable->rowCount(); n++) {434 for (int n = 0; n < actionsTable->rowCount(); n++) { 409 435 //actionsTable->setText( n, COL_CONFLICTS, " "); 410 436 i = actionsTable->item( n, COL_CONFLICTS ); … … 416 442 if (!accelText.isEmpty()) { 417 443 found = findActionAccel( accelText, n ); 418 if ( (found != -1) && (found != n)) {444 if ( (found != -1) /*&& (found != n)*/ ) { 419 445 conflict = true; 420 446 //actionsTable->setText( n, COL_CONFLICTS, "!"); … … 497 523 498 524 bool ActionsEditor::loadActionsTable(const QString & filename) { 499 qDebug("ActionsEditor::loadActions: '%s'", filename.toUtf8().data()); 500 501 QRegExp rx("^(.*)\\t(.*)"); 525 qDebug() << "ActionsEditor::loadActions:" << filename; 526 502 527 int row; 503 528 504 505 529 QFile f( filename ); 530 if ( f.open( QIODevice::ReadOnly ) ) { 506 531 507 532 #if !USE_SHORTCUTGETTER … … 509 534 #endif 510 535 511 536 QTextStream stream( &f ); 512 537 stream.setCodec("UTF-8"); 513 538 514 QString line; 515 while ( !stream.atEnd() ) { 516 line = stream.readLine(); 517 qDebug("line: '%s'", line.toUtf8().data()); 518 if (rx.indexIn(line) > -1) { 519 QString name = rx.cap(1); 520 QString accelText = rx.cap(2); 521 qDebug(" name: '%s' accel: '%s'", name.toUtf8().data(), accelText.toUtf8().data()); 539 QString line; 540 while ( !stream.atEnd() ) { 541 line = stream.readLine().trimmed(); 542 qDebug() << "ActionsEditor::loadActions: line:" << line; 543 QString name; 544 QString accelText; 545 int pos = line.indexOf(QRegExp("\\t|\\s")); 546 //qDebug() << "ActionsEditor::loadActions: pos:" << pos; 547 if (pos == -1) { 548 name = line; 549 } else { 550 name = line.left(pos); 551 accelText = line.mid(pos+1).trimmed(); 552 } 553 qDebug() << "ActionsEditor::loadActions: name:" << name << "accel:" << accelText; 554 if (!name.isEmpty()) { 522 555 row = findActionName(name); 523 556 if (row > -1) { 524 qDebug( "Action found!");557 qDebug() << "ActionsEditor::loadActions: action found!"; 525 558 actionsTable->item(row, COL_SHORTCUT)->setText(accelText); 526 } 559 } 527 560 } else { 528 qDebug( " wrong line");561 qDebug() << "ActionsEditor::loadActions: error in line"; 529 562 } 530 563 }
Note:
See TracChangeset
for help on using the changeset viewer.