30
30
#include <qevent.h>
31
31
#include <qlineedit.h>
32
32
#include <qlayout.h>
34
StyleManager::StyleManager(QWidget *parent, const char *name) : SMBase(parent, name), item_(0), widget_(0)
33
#include <qbuttongroup.h>
34
#include <qradiobutton.h>
35
#include <qpushbutton.h>
36
#include <qsplitter.h>
42
#include <qmessagebox.h>
44
const QString StyleManager::SEPARATOR = "$$$$"; // dumb but it works
46
StyleManager::StyleManager(QWidget *parent, const char *name) : SMBase(parent, name), item_(0), widget_(0), shortcutWidget_(0), currentType_(QString::null), isEditMode_(true), doc_(0)
36
typeView->header()->hide();
48
splitter->setMinimumWidth(0);
49
splitter->setResizeMode(leftFrame, QSplitter::KeepSize);
50
splitter->setResizeMode(rightFrame, QSplitter::Stretch);
53
svLayout = new QHBoxLayout(styleViewFrame);
54
styleView = new StyleView(styleViewFrame);
55
svLayout->addWidget(styleView);
56
styleView->addColumn( tr("Name"));
57
styleView->addColumn( tr("Shortcut"));
58
styleView->setColumnWidthMode(NAME_COL, QListView::Maximum);
59
styleView->setColumnWidthMode(SHORTCUT_COL, QListView::Maximum);
60
styleView->setColumnWidth(NAME_COL, 0);
61
styleView->setColumnWidth(SHORTCUT_COL, 0);
37
62
styleView->header()->hide();
63
applyButton->setEnabled(false);
64
resetButton->setEnabled(false);
38
65
layout_ = new QGridLayout(mainFrame);
41
void StyleManager::currentDoc(ScribusDoc *doc)
43
for (uint i = 0; i < items_.count(); ++i)
66
newPopup_ = new QPopupMenu(newButton, "newPopup_");
67
rightClickPopup_ = new QPopupMenu(styleView, "rightClickPopup_");
68
newButton->setPopup(newPopup_);
71
pname = "styleManager";
72
prefs_ = PrefsManager::instance()->prefsFile->getContext(pname);
74
isStoryEditMode_ = false;
75
editPosition_.setX(prefs_->getInt("eX", x()));
76
editPosition_.setY(prefs_->getInt("eY", y()));
78
width_ = prefs_->getInt("Width", 212);
79
widthEm_ = prefs_->getInt("WidthEM", 500);
80
height_ = prefs_->getInt("Height", 450);
81
widthLeft_ = prefs_->getInt("WidthLeft", 192);
82
widthRight_ = prefs_->getInt("WidthRight", 474);
84
newButton->setEnabled(false);
85
cloneButton->setEnabled(false);
86
importButton->setEnabled(false);
87
deleteButton->setEnabled(false);
88
rightClickPopup_->setEnabled(false);
89
newPopup_->setEnabled(false);
91
connect(newPopup_, SIGNAL(activated(int)), this, SLOT(slotNewPopup(int)));
92
connect(okButton, SIGNAL(clicked()), this, SLOT(slotOk()));
93
connect(importButton, SIGNAL(clicked()), this, SLOT(slotImport()));
94
connect(resetButton, SIGNAL(clicked()), this, SLOT(slotClean()));
95
connect(applyButton, SIGNAL(clicked()), this, SLOT(slotApply()));
96
connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDelete()));
97
connect(cloneButton, SIGNAL(clicked()), this, SLOT(slotClone()));
98
connect(newButton, SIGNAL(clicked()), this, SLOT(slotNew()));
99
connect(styleView, SIGNAL(rightButtonClicked(QListViewItem*, const QPoint&, int)),
100
this, SLOT(slotRightClick(QListViewItem*, const QPoint&, int)));
101
connect(styleView, SIGNAL(doubleClicked(QListViewItem*, const QPoint&, int)),
102
this, SLOT(slotDoubleClick(QListViewItem*, const QPoint&, int)));
108
void StyleManager::languageChange()
110
/***********************************/
112
/***********************************/
113
// These are for general Style Manager widgets (not for c/pstyles except the name field
115
// for the "<< Done" button when in edit mode
116
exitEditModeOk_ = tr("Apply all changes and exit edit mode");
117
// for the "Edit >>" button when not in edit mode
118
enterEditModeOk_= tr("Edit styles");
120
QToolTip::add(nameEdit, tr("Name of the selected style"));
121
QToolTip::add(resetButton, tr("Reset all changes"));
122
QToolTip::add(applyButton, tr("Apply all changes"));
123
QToolTip::add(newButton, tr("Create a new style"));
124
QToolTip::add(importButton, tr("Import styles from another document"));
125
QToolTip::add(cloneButton, tr("Clone selected style"));
126
QToolTip::add(deleteButton, tr("Delete selected styles"));
128
/***********************************/
130
/***********************************/
132
nameLabel->setText( tr("Name:"));
133
resetButton->setText( tr("&Reset"));
134
applyButton->setText( tr("&Apply"));
135
doneText= tr("&Done");
136
editText= tr("&Edit");
138
newButton->setText( tr("&New"));
139
importButton->setText( tr("&Import"));
140
cloneButton->setText( tr("&Clone"));
141
deleteButton->setText( tr("&Delete"));
144
QToolTip::add(okButton, exitEditModeOk_);
146
QToolTip::add(okButton, enterEditModeOk_);
149
shortcutWidget_->languageChange();
152
QStringList popupStrings;
153
for (uint i = 0; i < items_.count(); ++i)
155
popupStrings << items_.at(i)->typeNameSingular();
156
items_.at(i)->languageChange();
157
styleClassesPS_[items_.at(i)->typeNamePlural()] = items_.at(i)->typeNameSingular();
158
styleClassesSP_[items_.at(i)->typeNameSingular()] = items_.at(i)->typeNamePlural();
161
for (uint i = 0; i < popupStrings.count(); ++i)
162
newPopup_->insertItem(popupStrings[i]);
165
for (uint i = 0; i < items_.count(); ++i)
166
addNewType(items_.at(i));
168
rightClickPopup_->clear();
169
rcpNewId_ = rightClickPopup_->insertItem( tr("New"), newPopup_);
170
rightClickPopup_->insertItem( tr("Import"), this, SLOT(slotImport()));
171
rightClickPopup_->insertSeparator();
172
rcpEditId_ = rightClickPopup_->insertItem( tr("Edit"), this, SLOT(slotEdit()));
173
rcpCloneId_ = rightClickPopup_->insertItem( tr("Clone"), this, SLOT(slotClone()));
174
rcpToScrapId_ = rightClickPopup_->insertItem( tr("Send to Scrapbook"), this, SLOT(slotScrap()));
175
rightClickPopup_->insertSeparator();
176
rcpDeleteId_ = rightClickPopup_->insertItem( tr("Delete"), this, SLOT(slotDelete()));
179
void StyleManager::unitChange()
183
for (uint i = 0; i < items_.count(); ++i)
184
items_.at(i)->unitChange();
190
void StyleManager::setOkButtonText()
192
if (!isStoryEditMode_)
193
okButton->setText(isEditMode_ ? "<< " + doneText : editText + " >>");
195
okButton->setText(CommonStrings::tr_OK);
198
void StyleManager::setDoc(ScribusDoc *doc)
203
newButton->setEnabled(true);
204
cloneButton->setEnabled(true);
205
importButton->setEnabled(true);
206
deleteButton->setEnabled(true);
207
rightClickPopup_->setEnabled(true);
208
newPopup_->setEnabled(true);
209
connect(doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(slotDocSelectionChanged()));
214
newButton->setEnabled(false);
215
cloneButton->setEnabled(false);
216
importButton->setEnabled(false);
217
deleteButton->setEnabled(false);
218
rightClickPopup_->setEnabled(false);
219
newPopup_->setEnabled(false);
222
// clear the style list and reload from new doc
224
styleActions_.clear();
225
for (uint i = 0; i < items_.count(); ++i)
44
227
items_.at(i)->currentDoc(doc);
45
slotTypeChanged(typeView->currentItem()); // refresh the style view
228
addNewType(items_.at(i)); // forces a reload
230
items_.at(i)->unitChange();
48
void StyleManager::languageChange()
234
void StyleManager::updateColorList()
236
for (uint i = 0; i < items_.count(); ++i)
238
items_.at(i)->currentDoc(doc_);
239
items_.at(i)->reload();
53
243
void StyleManager::addStyle(StyleItem *item)
55
245
items_.append(item);
56
new QListViewItem(typeView, item->typeName());
247
connect(item, SIGNAL(selectionDirty()), this, SLOT(slotDirty()));
59
250
void StyleManager::slotApply()
252
if (applyButton->isEnabled())
254
for (uint i = 0; i < items_.count(); ++i)
255
items_.at(i)->apply();
65
261
void StyleManager::slotDelete()
264
slotOk(); // switch to edit mode before deleting
266
QStringList selected;
268
if (!rcStyle_.isNull())
269
selected << rcStyle_;
272
QListViewItemIterator it(styleView, QListViewItemIterator::Selected);
273
while (it.current()) {
274
selected << it.current()->text(0);
278
if (selected.isEmpty())
279
return; // nothing to delete
282
QValueList<StyleName> styles = item_->styles(false); // get list from cache
283
for (uint i = 0; i < styles.count(); ++i)
284
tmp << styles[i].first;
285
SMReplaceDia *dia = new SMReplaceDia(selected, tmp, this);
286
if (dia->exec() && item_)
288
item_->deleteStyles(dia->items());
289
applyButton->setEnabled(true);
290
resetButton->setEnabled(true);
291
reloadStyleView(false);
71
298
void StyleManager::slotImport()
303
PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
304
QString wdir = dirs->get("editformats", ".");
305
CustomFDialog dia(this, wdir, tr("Open"), tr("documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)"));
306
if (dia.exec() == QDialog::Accepted)
308
QString selectedFile = dia.selectedFile();
309
dirs->set("editformats", selectedFile.left(selectedFile.findRev("/")));
311
StyleSet<ParagraphStyle> tmpParaStyles;
312
StyleSet<CharStyle> tmpCharStyles;
313
QMap<QString, multiLine> tmpLineStyles;
315
doc_->loadStylesFromFile(selectedFile, &tmpParaStyles, &tmpCharStyles, &tmpLineStyles);
317
// FIXME Once all styles are derived from Style remove this and make a proper
321
SMParagraphStyle *pstyle = 0;
322
SMCharacterStyle *cstyle = 0;
323
SMLineStyle *lstyle = 0;
324
for (uint i = 0; i < items_.count(); ++i)
326
pstyle = dynamic_cast<SMParagraphStyle*>(items_.at(i));
330
for (uint i = 0; i < items_.count(); ++i)
332
cstyle = dynamic_cast<SMCharacterStyle*>(items_.at(i));
336
for (uint i = 0; i < items_.count(); ++i)
338
lstyle = dynamic_cast<SMLineStyle*>(items_.at(i));
343
Q_ASSERT(pstyle && cstyle && lstyle);
345
ImportDialog *dia2 = new ImportDialog(this, &tmpParaStyles, &tmpCharStyles, &tmpLineStyles);
348
QValueList<QPair<QString, QString> > selected;
353
QStringList neededColors;
354
neededColors.clear();
355
QMap<QCheckListItem*, QString>::Iterator it;
356
for (it = dia2->storedStyles.begin(); it != dia2->storedStyles.end(); ++it)
358
ParagraphStyle& sty(tmpParaStyles[tmpParaStyles.find(it.data())]);
359
if (it.key()->isOn())
361
if (dia2->clashRename())
363
sty.setName(pstyle->getUniqueName(sty.name()));
364
pstyle->tmpStyles()->create(sty);
368
if (pstyle->tmpStyles()->find(sty.name()) >= 0)
369
(*(pstyle->tmpStyles()))[pstyle->tmpStyles()->find(it.data())] = sty;
371
pstyle->tmpStyles()->create(sty);
373
selected << QPair<QString, QString>(pstyle->typeName(), sty.name());
374
if ((!doc_->PageColors.contains(sty.charStyle().strokeColor())) && (!neededColors.contains(sty.charStyle().strokeColor())))
375
neededColors.append(sty.charStyle().strokeColor());
376
if ((!doc_->PageColors.contains(sty.charStyle().fillColor())) && (!neededColors.contains(sty.charStyle().fillColor())))
377
neededColors.append(sty.charStyle().fillColor());
381
for (it = dia2->storedCharStyles.begin(); it != dia2->storedCharStyles.end(); ++it)
383
CharStyle& sty(tmpCharStyles[tmpCharStyles.find(it.data())]);
384
if (it.key()->isOn())
386
if (dia2->clashRename())
388
sty.setName(cstyle->getUniqueName(sty.name()));
389
cstyle->tmpStyles()->create(sty);
393
if (cstyle->tmpStyles()->find(sty.name()) >= 0)
394
(*(cstyle->tmpStyles()))[cstyle->tmpStyles()->find(it.data())] = sty;
396
cstyle->tmpStyles()->create(sty);
398
selected << QPair<QString, QString>(cstyle->typeName(), sty.name());
399
if ((!doc_->PageColors.contains(sty.strokeColor())) && (!neededColors.contains(sty.strokeColor())))
400
neededColors.append(sty.strokeColor());
401
if ((!doc_->PageColors.contains(sty.fillColor())) && (!neededColors.contains(sty.fillColor())))
402
neededColors.append(sty.fillColor());
406
for (it = dia2->storedLineStyles.begin(); it != dia2->storedLineStyles.end(); ++it)
408
multiLine &sty = tmpLineStyles[it.data()];
409
QString styName = it.data();
411
if (it.key()->isOn())
413
if (dia2->clashRename())
414
styName = lstyle->getUniqueName(styName);
416
lstyle->tmpLines[styName] = sty;
417
selected << QPair<QString, QString>(lstyle->typeName(), styName);
419
for (uint i = 0; i < sty.count(); ++i)
421
if ((!doc_->PageColors.contains(sty[i].Color)) && (!neededColors.contains(sty[i].Color)))
422
neededColors.append(sty[i].Color);
427
if (!neededColors.isEmpty())
429
FileLoader fl(selectedFile);
430
if (fl.TestFile() == -1)
431
{ //TODO put in nice user warning
436
if (fl.ReadColors(selectedFile, LColors))
438
ColorList::Iterator itc;
439
for (itc = LColors.begin(); itc != LColors.end(); ++itc)
441
if (neededColors.contains(itc.key()))
442
doc_->PageColors.insert(itc.key(), itc.data());
449
pstyle->currentDoc(doc_);
450
cstyle->currentDoc(doc_);
452
reloadStyleView(false);
453
setSelection(selected);
461
void StyleManager::setSelection(const QValueList<QPair<QString, QString> > &selected)
463
styleView->clearSelection();
465
QListViewItemIterator it(styleView, QListViewItemIterator::Selectable);
470
item = dynamic_cast<StyleViewItem*>(it.current());
473
for (uint i = 0; i < selected.count(); ++i)
475
if (item->rootName() == selected[i].first && item->text(NAME_COL) == selected[i].second)
477
styleView->setCurrentItem(item);
478
item->setSelected(true);
486
styleView->triggerUpdate();
489
void StyleManager::slotEdit()
492
slotOk(); // switch to edit mode for cloning
494
if (!rcStyle_.isNull())
496
QListViewItemIterator it(styleView);
499
StyleViewItem *item = dynamic_cast<StyleViewItem*>(it.current());
500
if (item && !item->isRoot())
502
if (item->rootName() == styleClassesSP_[rcType_] &&
503
item->text(0) == rcStyle_)
505
styleView->setCurrentItem(item);
506
item->setSelected(true);
513
rcStyle_ = QString::null;
514
rcType_ = QString::null;
77
519
void StyleManager::slotClone()
522
slotOk(); // switch to edit mode for cloning
524
if (!rcStyle_.isNull())
526
QListViewItemIterator it(styleView);
529
StyleViewItem *item = dynamic_cast<StyleViewItem*>(it.current());
530
if (item && !item->isRoot())
532
if (item->rootName() == styleClassesSP_[rcType_] &&
533
item->text(0) == rcStyle_)
535
styleView->setCurrentItem(item);
536
item->setSelected(true);
543
rcStyle_ = QString::null;
544
rcType_ = QString::null;
547
QListViewItemIterator it(styleView, QListViewItemIterator::Selected);
548
QValueList<QPair<QString, QString> > names;
551
{ // can't create styles here cause createNewStyle() alters the selection
552
StyleViewItem *item = dynamic_cast<StyleViewItem*>(it.current());
554
names << QPair<QString, QString>(item->rootName(), item->text(NAME_COL));
558
for (uint i = 0; i < names.count(); ++i)
559
createNewStyle(names[i].first, names[i].second);
562
void StyleManager::slotScrap()
83
568
void StyleManager::slotNew()
88
void StyleManager::slotStyleChanged()
91
QListViewItemIterator it(styleView, QListViewItemIterator::Selected);
92
while (it.current()) {
93
selected << it.current()->text(0);
570
//#5334: Dont open into edit mdoe until user has selected a style type
572
// slotOk(); // switch to edit mode for a new style
574
// TODO maybe there's something more clever for this
575
newPopup_->exec(newButton->mapToGlobal(QPoint(0, newButton->height() + 2)));
578
void StyleManager::slotNewPopup(int i)
581
slotOk(); // switch to edit mode for a new style
583
QString typeName = rcType_;
584
if (typeName.isNull())
585
typeName = newPopup_->text(i);
586
else if (typeName.isNull() && i < 0)
587
return; // nothing to create
589
rcType_ = QString::null;
590
rcStyle_ = QString::null;
592
createNewStyle(typeName);
595
void StyleManager::slotRightClick(QListViewItem *item, const QPoint &point, int col)
597
rcStyle_ = QString::null;
598
rcType_ = QString::null;
600
if (isEditMode_ && item) // make item the only selection if in edit mode
601
{ // default behaviour for right clicking is not to select the item
602
styleView->clearSelection();
603
styleView->setCurrentItem(item);
604
item->setSelected(true);
608
StyleViewItem *sitem = dynamic_cast<StyleViewItem*>(item);
609
if (sitem && !sitem->isRoot())
611
rightClickPopup_->removeItem(rcpNewId_);
612
rcpNewId_ = rightClickPopup_->insertItem( tr("New %1").arg(styleClassesPS_[sitem->rootName()]),
613
this, SLOT(slotNewPopup(int)), 0, -1, 0);
614
rightClickPopup_->setItemEnabled(rcpDeleteId_, true);
615
rightClickPopup_->setItemEnabled(rcpEditId_, true);
616
rightClickPopup_->setItemEnabled(rcpCloneId_, true);
617
rightClickPopup_->setItemEnabled(rcpToScrapId_, true);
618
rcStyle_ = sitem->text(0);
619
rcType_ = styleClassesPS_[sitem->rootName()];
620
loadType(styleClassesPS_[sitem->rootName()]);
622
else if (sitem && sitem->isRoot())
624
rightClickPopup_->removeItem(rcpNewId_);
625
rcpNewId_ = rightClickPopup_->insertItem( tr("New %1").arg(styleClassesPS_[sitem->text(0)]),
626
this, SLOT(slotNewPopup(int)), 0, -1, 0);
627
rightClickPopup_->setItemEnabled(rcpDeleteId_, false);
628
rightClickPopup_->setItemEnabled(rcpEditId_, false);
629
rightClickPopup_->setItemEnabled(rcpCloneId_, false);
630
rightClickPopup_->setItemEnabled(rcpToScrapId_, false);
631
rcType_ = styleClassesPS_[sitem->text(0)];
636
rightClickPopup_->removeItem(rcpNewId_);
637
rcpNewId_ = rightClickPopup_->insertItem( tr("New"), newPopup_, -1, 0);
638
rightClickPopup_->setItemEnabled(rcpDeleteId_, false);
639
rightClickPopup_->setItemEnabled(rcpEditId_, false);
640
rightClickPopup_->setItemEnabled(rcpCloneId_, false);
641
rightClickPopup_->setItemEnabled(rcpToScrapId_, false);
644
rightClickPopup_->exec(point);
647
void StyleManager::slotDoubleClick(QListViewItem *item, const QPoint &point, int col)
649
rcStyle_ = QString::null;
650
rcType_ = QString::null;
652
if (isEditMode_ && item) // make item the only selection if in edit mode
654
styleView->clearSelection();
655
styleView->setCurrentItem(item);
656
item->setSelected(true);
658
return; // work done, already in edit mode
661
StyleViewItem *sitem = dynamic_cast<StyleViewItem*>(item);
662
if (sitem && !sitem->isRoot())
664
rcType_ = sitem->rootName();
665
rcStyle_ = sitem->text(0);
666
slotOk(); // switch to edit mode
668
else if (sitem && sitem->isRoot())
670
rcType_ = sitem->text(0);
673
rcStyle_ = QString::null;
674
rcType_ = QString::null;
677
void StyleManager::createNewStyle(const QString &typeName, const QString &fromParent)
682
loadType(typeName); // get the right style class
685
QString newName = fromParent.isNull() ?
686
item_->newStyle() : item_->newStyle(fromParent);
688
if (newName.isNull())
691
QListViewItem *root = 0;
692
QListViewItemIterator it(styleView, QListViewItemIterator::NotSelectable);
695
StyleViewItem *item = dynamic_cast<StyleViewItem*>(it.current());
698
if (item->text(NAME_COL) == item_->typeName())
97
uint count = selected.count();
98
disconnect(nameEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotNameChanged(const QString&)));
100
cloneButton->setEnabled(true);
101
deleteButton->setEnabled(true);
102
nameEdit->setText( tr("More than one item selected"));
103
nameEdit->setEnabled(false);
104
widget_->setEnabled(true);
105
} else if (count == 1) {
106
cloneButton->setEnabled(true);
107
deleteButton->setEnabled(true);
108
nameEdit->setEnabled(true);
109
nameEdit->setText(selected[0]);
110
widget_->setEnabled(true);
112
cloneButton->setEnabled(false);
113
deleteButton->setEnabled(false);
114
nameEdit->setText("");
115
nameEdit->setEnabled(false);
116
widget_->setEnabled(false);
118
connect(nameEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotNameChanged(const QString&)));
120
item_->selected(selected);
124
// f.e. Line Styles --> Paragraph Styles
125
void StyleManager::slotTypeChanged(QListViewItem *item)
707
styleView->clearSelection();
708
StyleViewItem *newItem = new StyleViewItem(root, newName, item_->typeName());
709
Q_CHECK_PTR(newItem);
710
newItem->setDirty(true);
711
styleView->setCurrentItem(newItem);
712
newItem->setSelected(true);
715
nameEdit->setFocus();
716
nameEdit->selectAll();
717
applyButton->setEnabled(true);
718
resetButton->setEnabled(true);
721
void StyleManager::show()
727
// open or close edit mode
728
void StyleManager::slotOk()
730
static bool isFirst = true;
733
disconnect(styleView, SIGNAL(selectionChanged()), this, SLOT(slotSetupWidget()));
735
prefs_->set("WidthEM", widthEm_);
737
prefs_->set("Height", height_);
738
QValueList<int> l = splitter->sizes();
741
prefs_->set("WidthLeft", widthLeft_);
742
prefs_->set("WidthRight", widthRight_);
744
styleView->setSelectionMode(QListView::Multi);
745
okButton->setText(QString("%1 >>").arg( tr("&Edit")));
749
// editButtonsFrame->hide();
752
for (uint i = 0; i < items_.count(); ++i)
754
items_.at(i)->apply();
755
items_.at(i)->editMode(false);
757
QToolTip::add(okButton, enterEditModeOk_);
759
slotDocSelectionChanged();
761
resize(width_, height_);
764
prefs_->set("isEditMode", isEditMode_);
765
connect(styleView, SIGNAL(selectionChanged(QListViewItem*)),
766
this, SLOT(slotApplyStyle(QListViewItem*)));
767
connect(styleView, SIGNAL(clicked(QListViewItem*)),
768
this, SLOT(slotApplyStyle(QListViewItem*)));
769
if (isStoryEditMode_)
771
isStoryEditMode_=false;
777
disconnect(styleView, SIGNAL(selectionChanged(QListViewItem*)),
778
this, SLOT(slotApplyStyle(QListViewItem*)));
779
disconnect(styleView, SIGNAL(clicked(QListViewItem*)),
780
this, SLOT(slotApplyStyle(QListViewItem*)));
784
prefs_->set("Width", width_);
787
prefs_->set("Height", height_);
789
styleView->setSelectionMode(QListView::Extended);
790
editPosition_.setX(x());
791
editPosition_.setY(y());
792
prefs_->set("eX", x());
793
prefs_->set("eY", y());
794
// okButton->setText(QString("<< %1").arg( tr("&Done")));
798
// editButtonsFrame->show();
801
for (uint i = 0; i < items_.count(); ++i)
802
items_.at(i)->editMode(true);
803
QToolTip::add(okButton, exitEditModeOk_);
807
l << widthLeft_ << widthRight_;
808
splitter->setSizes(l);
809
resize(widthEm_, height_);
810
prefs_->set("isEditMode", isEditMode_);
811
connect(styleView, SIGNAL(selectionChanged()), this, SLOT(slotSetupWidget()));
817
void StyleManager::addNewType(StyleItem *item, bool loadFromDoc)
822
QValueList<StyleName> styles = item_->styles(loadFromDoc);
823
StyleViewItem *rootItem = new StyleViewItem(styleView, item_->typeName());
824
rootItem->setOpen(true);
825
QMap<QString, StyleViewItem*> sitems;
827
for (uint i = 0; i < styles.count(); ++i) // set the list of styles of this type
829
StyleViewItem *sitem;
830
if (styles[i].second.isNull())
832
sitem = new StyleViewItem(rootItem, styles[i].first, item_->typeName());
834
else if (sitems.contains(styles[i].second))
836
StyleViewItem *parent = sitems[styles[i].second];
837
sitem = new StyleViewItem(parent, styles[i].first, item_->typeName());
838
parent->setOpen(true);
842
bool postpone = false;
843
// search if parent is in remaing styles
844
for (uint j = i+1; j < styles.count(); ++j)
846
if (styles[j].first == styles[i].second)
848
styles.append(styles[i]); // postpone
856
qDebug(QString("stylemanager: unknown parent '%1' of %2 style '%3'").arg(styles[i].second).arg(item_->typeName()).arg(styles[i].first));
857
sitem = new StyleViewItem(rootItem, styles[i].first, item_->typeName());
861
sitems[styles[i].first] = sitem;
862
sitem->setText(SHORTCUT_COL, item_->shortcut(sitem->text(NAME_COL)));
864
QString key = sitem->rootName() + SEPARATOR + sitem->text(NAME_COL);
865
if (styleActions_.contains(key))
869
new ScrAction(ScrAction::DataQString, QIconSet(), "",
870
sitem->text(SHORTCUT_COL), doc_->view(), key, 0, 0.0, key);
871
connect(styleActions_[key], SIGNAL(activatedData(QString)),
872
this, SLOT(slotApplyStyle(QString)));
877
void StyleManager::slotDirty()
879
QListViewItemIterator it(styleView, QListViewItemIterator::Selected);
881
while (it.current()) {
882
StyleViewItem *item = dynamic_cast<StyleViewItem*>(it.current());
885
item->setDirty(true);
887
applyButton->setEnabled(true);
888
resetButton->setEnabled(true);
892
applyButton->setEnabled(true);
893
resetButton->setEnabled(true);
896
void StyleManager::slotClean()
898
QListViewItemIterator it(styleView);
900
while (it.current()) {
901
StyleViewItem *item = dynamic_cast<StyleViewItem*>(it.current());
904
item->setDirty(false);
912
StyleItem *tmp = item_;
129
914
for (uint i = 0; i < items_.count(); ++i)
130
{ // search the selected StyleItem based on selection
131
if (items_.at(i)->typeName() == item->text(0))
916
item_ = items_.at(i);
922
applyButton->setEnabled(false);
923
resetButton->setEnabled(false);
927
void StyleManager::reloadStyleView(bool loadFromDoc)
929
QListViewItemIterator it(styleView, QListViewItemIterator::Selected);
930
QValueList<QPair<QString, QString> > selected;
934
StyleViewItem *item = dynamic_cast<StyleViewItem*>(it.current());
936
selected << QPair<QString, QString>(item->rootName(), item->text(NAME_COL));
941
if (item_ && loadFromDoc)
944
for (uint i = 0; i < items_.count(); ++i)
945
addNewType(items_.at(i), false);
947
QListViewItemIterator it2(styleView, QListViewItemIterator::Selectable);
949
while (it2.current())
951
StyleViewItem *item = dynamic_cast<StyleViewItem*>(it2.current());
954
for (uint i = 0; i < selected.count(); ++i)
133
item_ = items_.at(i);
956
if (selected[i].first == item->rootName() &&
957
selected[i].second == item->text(NAME_COL))
959
item->setDirty(false);
960
styleView->setCurrentItem(item);
961
item->setSelected(true);
969
styleView->repaint();
972
void StyleManager::insertShortcutPage(QTabWidget *twidget)
976
if (!shortcutWidget_)
140
QStringList styles = item_->styles();
141
for (uint i = 0; i < styles.count(); ++i) // set the list of styles of this type
142
new QListViewItem(styleView, styles[i]);
145
{ // remove the old style type's widget
147
layout_->remove(widget_);
148
widget_->reparent(0,0, QPoint(0,0), false);
150
// show the widget for the new style type
151
widget_ = item_->widget(); // show the widget for the style type
152
widget_->reparent(mainFrame, 0, QPoint(0,0), true);
153
layout_->addWidget(widget_, 0, 0);
978
shortcutWidget_ = new ShortcutWidget(0, "shortcutWidget_");
979
connect(shortcutWidget_, SIGNAL(newKey(const QString&)),
980
this, SLOT(slotShortcutChanged(const QString&)));
982
twidget->addTab(shortcutWidget_, tr("Shortcut"));
158
void StyleManager::slotPageChanged(QWidget *widget)
163
986
void StyleManager::slotNameChanged(const QString& name)
165
styleView->currentItem()->setText(0, name);
988
if (!nameIsUnique(name))
991
okButton->setEnabled(false);
992
applyButton->setEnabled(false);
995
else if (uniqueLabel->isVisible())
998
okButton->setEnabled(true);
999
applyButton->setEnabled(true);
167
1005
item_->nameChanged(name);
1006
updateActionName(styleView->currentItem()->text(NAME_COL), name);
1007
styleView->currentItem()->setText(NAME_COL, name);
1008
applyButton->setEnabled(true);
1009
resetButton->setEnabled(true);
1014
void StyleManager::updateActionName(const QString &oldName, const QString &newName)
1018
QString oldKey = item_->typeName() + SEPARATOR + oldName;
1019
QString newKey = item_->typeName() + SEPARATOR + newName;
1021
if (styleActions_.contains(oldKey))
1023
ScrAction *a = styleActions_[oldKey];
1024
disconnect(a, SIGNAL(activatedData(QString)), this, SLOT(slotApplyStyle(QString)));
1025
ScrAction *b = new ScrAction(ScrAction::DataQString, QIconSet(), "",
1026
a->accel(), doc_->view(), newKey, 0, 0.0, newKey);
1027
styleActions_.remove(oldKey);
1029
styleActions_[newKey] = b;
1030
connect(b, SIGNAL(activatedData(QString)), this, SLOT(slotApplyStyle(QString)));
1034
void StyleManager::slotShortcutChanged(const QString& shortcut)
1039
StyleViewItem *sitem = dynamic_cast<StyleViewItem*>(styleView->currentItem());
1043
if (!shortcut.isNull() && shortcutExists(shortcut))
1045
QMessageBox::information(this, CommonStrings::trWarning,
1046
tr("This key sequence is already in use"),
1047
CommonStrings::tr_OK);
1048
shortcutWidget_->setShortcut(item_->shortcut(sitem->text(NAME_COL)));
1052
sitem->setText(SHORTCUT_COL, shortcut.isNull() ? "" : shortcut);
1053
QString key = sitem->rootName() + SEPARATOR + sitem->text(NAME_COL);
1054
if (styleActions_.contains(key))
1055
styleActions_[key]->setAccel(shortcut);
1058
styleActions_[key] =
1059
new ScrAction(ScrAction::DataQString, QIconSet(), "",
1060
shortcut, doc_->view(), key, 0, 0.0, key);
1061
connect(styleActions_[key], SIGNAL(activatedData(QString)),
1062
this, SLOT(slotApplyStyle(QString)));
1066
item_->setShortcut(shortcut);
1069
bool StyleManager::shortcutExists(const QString &keys)
1071
QKeySequence key(keys);
1073
QMap<QString, QGuardedPtr<ScrAction> >::iterator it;
1074
for (it = styleActions_.begin(); it != styleActions_.end(); ++it)
1076
if ((*it)->accel() == key)
1080
ApplicationPrefs *prefsData=&(PrefsManager::instance()->appPrefs);
1081
for (QMap<QString,Keys>::Iterator it=prefsData->KeyActions.begin();
1082
it!=prefsData->KeyActions.end(); ++it)
1084
if (key.matches(it.data().keySequence) != Qt::NoMatch)
1091
void StyleManager::slotApplyStyle(QString keyString)
1096
QStringList slist = QStringList::split(SEPARATOR, keyString);
1097
Q_ASSERT(slist.count() == 2);
1100
item_->toSelection(slist[1]);
1101
slotDocSelectionChanged();
1104
bool StyleManager::nameIsUnique(const QString &name)
1106
QValueList<StyleName> names = item_->styles(false);
1107
for (uint i = 0; i < names.count(); ++i)
1109
if (names[i].first == name)
1115
// setups the selected type and edit widgets related to it
1116
void StyleManager::slotSetupWidget()
1118
QPair<QString, QStringList> selection = namesFromSelection();
1119
QString typeName = selection.first;
1121
if (typeName.isNull() && widget_)
1122
widget_->setEnabled(false); // nothing selected or two or more different types
1123
else if (!item_ || item_->typeName() != typeName || widget_ != item_->widget())
1124
loadType(typeName); // new type selected
1125
else if (widget_ && !widget_->isEnabled())
1126
widget_->setEnabled(true);
1128
disconnect(nameEdit, SIGNAL(textChanged(const QString&)),
1129
this, SLOT(slotNameChanged(const QString&)));
1130
if (!typeName.isNull())
1132
item_->selected(selection.second);
1133
if (selection.second.count() > 1)
1135
nameEdit->setText( tr("More than one style selected"));
1136
nameEdit->setEnabled(false);
1137
shortcutWidget_->setEnabled(false);
1138
shortcutWidget_->setShortcut(QString::null);
1142
nameEdit->setText(selection.second[0]);
1143
nameEdit->setEnabled(true);
1144
shortcutWidget_->setEnabled(true);
1145
shortcutWidget_->setShortcut(item_->shortcut(selection.second[0]));
1150
nameEdit->setText("");
1151
nameEdit->setEnabled(false);
1154
connect(nameEdit, SIGNAL(textChanged(const QString&)),
1155
this, SLOT(slotNameChanged(const QString&)));
1159
void StyleManager::slotApplyStyle(QListViewItem *item)
1161
StyleViewItem *sitem = dynamic_cast<StyleViewItem*>(item);
1163
if (isEditMode_ || !sitem || sitem->isRoot())
1164
return; // don't apply a style in edit mode or if there was no item/type selected
1166
styleView->clearSelection();
1168
if (!item_ || item_->typeName() != sitem->rootName())
1169
loadType(sitem->rootName()); // load the type where we want to apply this style
1173
item_->toSelection(sitem->text(NAME_COL)); // apply selected style to the selection
1175
slotDocSelectionChanged();
1178
void StyleManager::slotDocSelectionChanged()
1181
return; // don't track changes when in edit mode
1183
disconnect(styleView, SIGNAL(currentChanged(QListViewItem*)),
1184
this, SLOT(slotApplyStyle(QListViewItem*)));
1186
styleView->clearSelection();
1188
QValueList<QPair<QString, QString> > selected;
1190
for (uint i = 0; i < items_.count(); ++i)
1191
selected << QPair<QString, QString>(items_.at(i)->typeName(), items_.at(i)->fromSelection());
1193
QListViewItemIterator it(styleView, QListViewItemIterator::Selectable);
1194
StyleViewItem *item;
1196
while (it.current())
1198
item = dynamic_cast<StyleViewItem*>(it.current());
1201
for (uint i = 0; i < selected.count(); ++i)
1203
if (item->rootName() == selected[i].first && item->text(NAME_COL) == selected[i].second)
1205
styleView->setCurrentItem(item);
1206
item->setSelected(true);
1214
styleView->triggerUpdate();
1216
connect(styleView, SIGNAL(currentChanged(QListViewItem*)),
1217
this, SLOT(slotApplyStyle(QListViewItem*)));
1220
void StyleManager::slotDocStylesChanged()
1222
qDebug("slotDocStylesChanged()");
1225
// QPair.first == QString::null if nothing is selected or if
1226
// there are items from more than one type in the selection
1227
// if selection is valid (only from single type) QPair.first will
1228
// include the type name and QPair.second will have all the selected
1230
QPair<QString, QStringList> StyleManager::namesFromSelection()
1232
QString typeName(QString::null);
1233
QStringList styleNames;
1235
if (rcStyle_.isNull())
1237
QListViewItemIterator it(styleView, QListViewItemIterator::Selected);
1238
while (it.current())
1240
StyleViewItem *item = dynamic_cast<StyleViewItem*>(it.current());
1246
else if (typeName.isNull())
1247
typeName = item->rootName();
1248
else if (!typeName.isNull() && typeName != item->rootName())
1250
typeName = QString::null;
1251
break; // two different types selected returning null
1254
if (!item->isRoot())
1255
styleNames << item->text(NAME_COL);
1260
else // right click selection which doesn't show in the gui
1263
styleNames << rcStyle_;
1265
return QPair<QString, QStringList>(typeName, styleNames);
1268
// sets the current type to name including item_ and the main widget
1269
// for editing styles
1270
void StyleManager::loadType(const QString &name)
1273
for (uint i = 0; i < items_.count(); ++i)
1275
if (items_.at(i)->typeNameSingular() == name || items_.at(i)->typeName() == name)
1277
item_ = items_.at(i);
1285
{ // remove the old style type's widget
1287
layout_->remove(widget_);
1288
widget_->reparent(0,0, QPoint(0,0), false);
1290
// show the widget for the new style type
1291
if (shortcutWidget_)
1292
widget_->removePage(shortcutWidget_);
1293
widget_ = item_->widget(); // show the widget for the style type
1294
insertShortcutPage(widget_);
1295
widget_->reparent(mainFrame, 0, QPoint(0,0), true);
1296
layout_->addWidget(widget_, 0, 0);
170
1299
void StyleManager::hideEvent(QHideEvent *e)
1303
QValueList<int> l = splitter->sizes();
1312
prefs_->set("eX", x());
1313
prefs_->set("eY", y());
1314
prefs_->set("isEditMode", isEditMode_);
1315
prefs_->set("Width", width_);
1316
prefs_->set("WidthEM", widthEm_);
1317
prefs_->set("WidthLeft", widthLeft_);
1318
prefs_->set("WidthRight", widthRight_);
1319
prefs_->set("Height", height_);
1320
prefs_->set("InitX", x());
1321
prefs_->set("InitY", y());
1322
storeVisibility(false);
172
1324
SMBase::hideEvent(e);
1328
void StyleManager::closeEvent(QCloseEvent *e)
1332
QValueList<int> l = splitter->sizes();
1341
prefs_->set("eX", x());
1342
prefs_->set("eY", y());
1343
prefs_->set("isEditMode", isEditMode_);
1344
prefs_->set("Width", width_);
1345
prefs_->set("WidthEM", widthEm_);
1346
prefs_->set("WidthLeft", widthLeft_);
1347
prefs_->set("WidthRight", widthRight_);
1348
prefs_->set("Height", height_);
1349
prefs_->set("InitX", x());
1350
prefs_->set("InitY", y());
1351
storeVisibility(false);
1353
SMBase::closeEvent(e);
1357
void StyleManager::showEvent(QShowEvent *e)
1359
static bool isFirst = true;
1362
isStoryEditMode_=true;
1363
applyButton->setEnabled(false);
1367
SMBase::showEvent(e);
1370
QPoint p(prefs_->getInt("InitX", x()), prefs_->getInt("InitY", y()));
176
1376
StyleManager::~StyleManager()
1380
QValueList<int> l = splitter->sizes();
1389
prefs_->set("eX", x());
1390
prefs_->set("eY", y());
1391
prefs_->set("isEditMode", isEditMode_);
1392
prefs_->set("Width", width_);
1393
prefs_->set("WidthEM", widthEm_);
1394
prefs_->set("WidthLeft", widthLeft_);
1395
prefs_->set("WidthRight", widthRight_);
1396
prefs_->set("InitX", x());
1397
prefs_->set("InitY", y());
1398
prefs_->set("Height", height_);
1399
storeVisibility(this->isVisible());
1405
/*** StyleViewItem *******************************************************************/
1407
StyleView::StyleView(QWidget *parent) : QListView(parent, "StyleView")
1412
StyleView::~StyleView()
1417
void StyleView::contentsMousePressEvent(QMouseEvent *e)
1419
if (e->button() == Qt::RightButton)
1420
emit rightButtonClicked(itemAt(e->pos()), e->globalPos(), 0);
1422
QListView::contentsMousePressEvent(e);
1425
void StyleView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1427
if (e->button() == Qt::LeftButton)
1428
emit doubleClicked(itemAt(e->pos()), e->globalPos(), 0);
1430
QListView::contentsMouseDoubleClickEvent(e);
1433
/*** StyleViewItem *******************************************************************/
1435
StyleViewItem::StyleViewItem(QListView *view, const QString &text) : QListViewItem(view, text),
1436
isRoot_(true), isDirty_(false), parentName_(QString::null), rootName_(QString::null)
1438
setSelectable(false);
1441
StyleViewItem::StyleViewItem(QListViewItem *parent, const QString &text, const QString &rootName)
1442
: QListViewItem(parent, text),
1443
isRoot_(false), isDirty_(false), parentName_(parent->text(0)), rootName_(rootName)
1448
void StyleViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align)
1453
f.setBold(isDirty_);
1457
QListViewItem::paintCell(p, cg, column, width, align);
1460
void StyleViewItem::setDirty(bool isDirty)
1465
bool StyleViewItem::isDirty()
1470
bool StyleViewItem::isRoot()
1475
QString StyleViewItem::parentName()
1480
QString StyleViewItem::rootName()
1485
StyleViewItem::~StyleViewItem()
1490
/*** ShortcutWidget ******************************************************************/
1492
ShortcutWidget::ShortcutWidget(QWidget *parent, const char *name) : QWidget(parent, name)
1499
keyManagerLayout = new QVBoxLayout( this, 0, 6);
1500
keyManagerLayout->setAlignment( Qt::AlignHCenter );
1502
keyGroup = new QButtonGroup( this, "keyGroup" );
1503
keyGroup->setFrameStyle(0);
1504
keyGroup->setColumnLayout(0, Qt::Vertical );
1505
keyGroup->layout()->setSpacing( 0 );
1506
keyGroup->layout()->setMargin( 0 );
1507
keyGroupLayout = new QGridLayout( keyGroup->layout() );
1508
keyGroupLayout->setAlignment( Qt::AlignTop );
1509
keyGroupLayout->setSpacing( 6 );
1510
keyGroupLayout->setMargin( 11 );
1512
noKey = new QRadioButton( tr( "&No Key" ), keyGroup, "noKey" );
1513
keyGroupLayout->addMultiCellWidget( noKey, 0, 1, 0, 1 );
1514
userDef = new QRadioButton( tr( "&User Defined Key" ), keyGroup, "userDef" );
1515
keyGroupLayout->addWidget( userDef, 2, 0 );
1517
keyDisplay = new QLabel( tr( "ALT+SHIFT+T" ), keyGroup, "keyDisplay" );
1518
keyDisplay->setFrameShape( QLabel::Panel );
1519
keyDisplay->setFrameShadow( QLabel::Sunken );
1520
keyDisplay->setAlignment( static_cast<int>( QLabel::AlignCenter ) );
1521
keyDisplay->setMinimumHeight(40);
1523
keyGroupLayout->addMultiCellWidget( keyDisplay, 3, 4, 0, 2 );
1525
setKeyButton = new QPushButton( tr( "Set &Key" ), keyGroup, "setKeyButton" );
1526
setKeyButton->setToggleButton(true);
1530
keyGroupLayout->addMultiCellWidget( setKeyButton, 0, 2, 1, 1, Qt::AlignCenter );
1531
keyManagerLayout->addWidget( keyGroup );
1533
connect(noKey, SIGNAL(clicked()), this, SLOT(setNoKey()));
1534
connect(setKeyButton, SIGNAL(clicked()), this, SLOT(setKeyText()));
1537
void ShortcutWidget::languageChange()
1539
/***********************************/
1540
/* Begin Tooltips */
1541
/***********************************/
1543
QToolTip::add(noKey, tr("No shortcut for the style")); // set no shortcut for this style
1544
QToolTip::add(userDef, tr("Style has user defined shortcut")); // not sure what this thing does
1545
QToolTip::add(setKeyButton, tr("Assign a shortcut for the style")); // activate shorcut assigning
1547
/***********************************/
1549
/***********************************/
1551
noKey->setText( tr("&No Key"));
1552
userDef->setText( tr("&User Defined Key"));
1553
setKeyButton->setText( tr("Set &Key"));
1556
bool ShortcutWidget::event( QEvent* ev )
1558
bool ret = QWidget::event( ev );
1559
if ( ev->type() == QEvent::KeyPress )
1560
keyPressEvent((QKeyEvent*)ev);
1561
if ( ev->type() == QEvent::KeyRelease )
1562
keyReleaseEvent((QKeyEvent*)ev);
1566
void ShortcutWidget::keyPressEvent(QKeyEvent *k)
1568
if (setKeyButton->isOn())
1571
if (!keyDisplay->text().isEmpty())
1573
tl = tl.split("+", keyDisplay->text());
1574
Part4 = tl[tl.count()-1];
1575
if (Part4 == tr("Alt") || Part4 == tr("Ctrl") || Part4 == tr("Shift") || Part4 == tr("Meta"))
1583
Part0 = tr("Meta+");
1587
Part3 = tr("Shift+");
1595
Part1 = tr("Ctrl+");
1599
keyCode |= k->key();
1600
keyDisplay->setText(getKeyText(keyCode));
1601
// if (checkKey(keyCode))
1603
// QMessageBox::information(this,
1604
// CommonStrings::trWarning,
1605
// tr("This key sequence is already in use"),
1606
// CommonStrings::tr_OK);
1607
// keyTable->setText(currRow, 1, "");
1608
// keyDisplay->setText("");
1609
// if (currentKeyMapRow!=NULL)
1610
// currentKeyMapRow.data().keySequence=QKeySequence();
1611
// noKey->setChecked(true);
1615
// QKeySequence newKeySequence(keyCode);
1616
// keyTable->setText(currRow, 1, QString(newKeySequence));
1617
// if (currentKeyMapRow!=NULL)
1618
// currentKeyMapRow.data().keySequence=newKeySequence;
1619
// userDef->setChecked(true);
1621
setKeyButton->setOn(false);
1622
userDef->setChecked(true);
1624
emit newKey(keyDisplay->text());
1627
if (setKeyButton->isOn())
1629
keyDisplay->setText(Part0+Part1+Part2+Part3+Part4);
1633
void ShortcutWidget::keyReleaseEvent(QKeyEvent *k)
1635
if (setKeyButton->isOn())
1637
if (!keyDisplay->text().isEmpty())
1640
tl = tl.split("+", keyDisplay->text());
1641
Part4 = tl[tl.count()-1];
1642
if (Part4 == tr("Alt") || Part4 == tr("Ctrl") || Part4 == tr("Shift") || Part4 == tr("Meta"))
1647
if (k->key() == Key_Meta)
1652
if (k->key() == Key_Shift)
1657
if (k->key() == Key_Alt)
1662
if (k->key() == Key_Control)
1667
keyDisplay->setText(Part0+Part1+Part2+Part3+Part4);
1671
QString ShortcutWidget::getKeyText(int KeyC)
1673
if ((KeyC & ~(Qt::META | Qt::CTRL | Qt::ALT | Qt::SHIFT)) == 0)
1675
// on OSX Qt translates modifiers to forsaken symbols, arrows and the like
1676
// we prefer plain English
1678
if ((KeyC & Qt::META) != 0)
1680
if ((KeyC & Qt::CTRL) != 0)
1682
if ((KeyC & Qt::ALT) != 0)
1684
if ((KeyC & Qt::SHIFT) != 0)
1686
return res + QString(QKeySequence(KeyC & ~(Qt::META | Qt::CTRL | Qt::ALT | Qt::SHIFT)));
1689
void ShortcutWidget::setKeyText()
1691
if (setKeyButton->isOn())
1705
void ShortcutWidget::setShortcut(const QString &shortcut)
1707
disconnect(noKey, SIGNAL(clicked()), this, SLOT(setNoKey()));
1708
disconnect(setKeyButton, SIGNAL(clicked()), this, SLOT(setKeyText()));
1710
setKeyButton->setOn(false);
1711
if (shortcut.length() > 0)
1713
userDef->setChecked(true);
1714
keyDisplay->setText(shortcut);
1718
noKey->setChecked(true);
1719
keyDisplay->setText("");
1722
connect(noKey, SIGNAL(clicked()), this, SLOT(setNoKey()));
1723
connect(setKeyButton, SIGNAL(clicked()), this, SLOT(setKeyText()));
1726
void ShortcutWidget::setNoKey()
1728
if (noKey->isChecked())
1730
keyDisplay->setText("");
1731
emit newKey(QString::null);
1735
ShortcutWidget::~ShortcutWidget()