source: smplayer/vendor/0.6.9/src/actionseditor.cpp@ 154

Last change on this file since 154 was 90, checked in by Silvan Scherrer, 16 years ago

smplayer: import 0.6.9

File size: 17.0 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2010 Ricardo Villalba <[email protected]>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19/* This is based on qq14-actioneditor-code.zip from Qt */
20
21
22#include "actionseditor.h"
23
24#include <QTableWidget>
25#include <QHeaderView>
26
27#include <QLayout>
28#include <QObject>
29#include <QPushButton>
30#include <QString>
31#include <QSettings>
32#include <QFile>
33#include <QTextStream>
34#include <QMessageBox>
35#include <QFileInfo>
36#include <QRegExp>
37#include <QApplication>
38#include <QAction>
39
40#include "images.h"
41#include "filedialog.h"
42#include "paths.h"
43
44#include "shortcutgetter.h"
45
46
47/*
48#include <QLineEdit>
49#include <QItemDelegate>
50
51class MyDelegate : public QItemDelegate
52{
53public:
54 MyDelegate(QObject *parent = 0);
55
56 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
57 const QModelIndex &index) const;
58 virtual void setModelData(QWidget * editor, QAbstractItemModel * model,
59 const QModelIndex & index ) const;
60};
61
62MyDelegate::MyDelegate(QObject *parent) : QItemDelegate(parent)
63{
64}
65
66static QString old_accel_text;
67
68QWidget * MyDelegate::createEditor(QWidget *parent,
69 const QStyleOptionViewItem & option,
70 const QModelIndex & index) const
71{
72 qDebug("MyDelegate::createEditor");
73
74 old_accel_text = index.model()->data(index, Qt::DisplayRole).toString();
75 //qDebug( "text: %s", old_accel_text.toUtf8().data());
76
77 return QItemDelegate::createEditor(parent, option, index);
78}
79
80void MyDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
81 const QModelIndex &index) const
82{
83 QLineEdit *line_edit = static_cast<QLineEdit*>(editor);
84
85 QString accelText = QKeySequence(line_edit->text()).toString();
86 if (accelText.isEmpty() && !line_edit->text().isEmpty()) {
87 model->setData(index, old_accel_text);
88 }
89 else {
90 model->setData(index, accelText);
91 }
92}
93*/
94
95
96#if USE_MULTIPLE_SHORTCUTS
97QString ActionsEditor::shortcutsToString(QList <QKeySequence> shortcuts_list) {
98 QString accelText = "";
99
100 for (int n=0; n < shortcuts_list.count(); n++) {
101 accelText += shortcuts_list[n].toString(QKeySequence::PortableText);
102 if (n < (shortcuts_list.count()-1)) accelText += ", ";
103 }
104
105 return accelText;
106}
107
108QList <QKeySequence> ActionsEditor::stringToShortcuts(QString shortcuts) {
109 QList <QKeySequence> shortcuts_list;