~ubuntu-branches/ubuntu/wily/scribus/wily-proposed

« back to all changes in this revision

Viewing changes to scribus/charselect.cpp

  • Committer: Package Import Robot
  • Author(s): Oleksandr Moskalenko
  • Date: 2012-02-09 21:50:56 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120209215056-2wrx1ara0jbm7fi5
Tags: 1.4.0.dfsg+r17287-1
* New upstream stable release upload into Debian (Closes: #654703).
* Applied the Ubuntu armel patch.
* Removed non-free color swatches from resources.
* debian/control:
  - Moved icc-profiles from Recommends to Suggests (Closes: #655885).
  - Updated Standards-Version to 3.9.2.
  - Updated extended description per lintian warning.
* debian/rules:
  - Update mailcap (Closes: #630751). A request for mime.types update has
    been sent to the mime-support maintainer.
  - Added build-arch and build-indep targets per lintian warning.
* debian/patches:
  - top_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't install the non-free "doc" dir.
  - profiles_cmakelists.patch - don't install non-free sRGB profile.
* debian/copyright: 
  - Converted to the DEP5 machine readable foramt.
  - Added licenses for free color swatches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
        m_userTable->setAcceptDrops(true);
46
46
 
47
47
        // signals and slots connections
48
 
        connect(m_userTable, SIGNAL(selectChar(uint)),
49
 
                this, SLOT(userNewChar(uint)));
 
48
        connect(m_userTable, SIGNAL(selectChar(uint, QString)),
 
49
                this, SLOT(userNewChar(uint, QString)));
50
50
        connect(m_userTableModel, SIGNAL(selectionChanged(QItemSelectionModel*)),
51
51
                m_userTable, SLOT(modelSelectionChanged(QItemSelectionModel*)));
52
52
        connect(m_userTableModel, SIGNAL(rowAppended()),
55
55
                m_userTableModel, SLOT(appendUnicode(const QString &)));
56
56
        connect(hideButton, SIGNAL(toggled(bool)),
57
57
                this, SLOT(hideButton_toggled(bool)));
58
 
        connect(this, SIGNAL(insertUserSpecialChar(QChar)),
59
 
                this, SLOT(slot_insertUserSpecialChar(QChar)));
 
58
        connect(this, SIGNAL(insertUserSpecialChar(QChar, QString)),
 
59
                this, SLOT(slot_insertUserSpecialChar(QChar, QString)));
60
60
        connect(uniLoadButton, SIGNAL(clicked()),
61
61
                this, SLOT(uniLoadButton_clicked()));
62
62
        connect(uniSaveButton, SIGNAL(clicked()),
93
93
        return chToIns;
94
94
}
95
95
 
96
 
void CharSelect::userNewChar(uint i)
 
96
void CharSelect::userNewChar(uint i, QString font)
97
97
{
98
 
        emit insertUserSpecialChar(QChar(i));
 
98
        emit insertUserSpecialChar(QChar(i), font);
99
99
}
100
100
 
101
101
void CharSelect::slot_insertSpecialChars(const QString & chars)
120
120
        //CB: Avox please make text->insertchar(char) so none of this happens in gui code, and item can tell doc its changed so the view and mainwindow slotdocch are not necessary
121
121
        QChar ch;
122
122
        QString txtIns;
123
 
        m_Item->oldCPos = m_Item->CPos;
 
123
        QString fontName = m_doc->currentStyle.charStyle().font().scName();
 
124
        if (m_enhanced)
 
125
                fontName = m_enhanced->getUsedFont();
 
126
        m_Item->oldCPos = m_Item->itemText.cursorPosition();
124
127
        for (int a=0; a<chToIns.length(); ++a)
125
128
        {
126
129
                ch = chToIns.at(a);
128
131
                        ch = QChar(13);
129
132
                if (ch == QChar(9))
130
133
                        ch = QChar(32);
131
 
                m_Item->itemText.insertChars(m_Item->CPos, ch, true);
132
 
                m_Item->CPos += 1;
 
134
                int pot = m_Item->itemText.cursorPosition();
 
135
                m_Item->itemText.insertChars(ch, true);
 
136
                CharStyle nstyle = m_Item->itemText.charStyle(pot);
 
137
                nstyle.setFont((*m_doc->AllFonts)[fontName]);
 
138
                m_Item->itemText.applyCharStyle(pot, 1, nstyle);
133
139
                txtIns.append(ch);
134
140
        }
135
141
        if (m_Item->itemTextSaxed.isEmpty())
142
148
//      delEdit();
143
149
}
144
150
 
145
 
void CharSelect::slot_insertUserSpecialChar(QChar ch)
 
151
void CharSelect::slot_insertUserSpecialChar(QChar ch, QString font)
146
152
{
147
153
        if (!m_Item)
148
154
                return;
159
165
                ch = QChar(13);
160
166
        if (ch == QChar(9))
161
167
                ch = QChar(32);
162
 
        m_Item->oldCPos = m_Item->CPos;
163
 
        m_Item->itemText.insertChars(m_Item->CPos, ch, true);
 
168
        m_Item->oldCPos = m_Item->itemText.cursorPosition();
 
169
        int pot = m_Item->itemText.cursorPosition();
 
170
        m_Item->itemText.insertChars(ch, true);
 
171
        CharStyle nstyle = m_Item->itemText.charStyle(pot);
 
172
        nstyle.setFont((*m_doc->AllFonts)[font]);
 
173
        m_Item->itemText.applyCharStyle(pot, 1, nstyle);
164
174
        if (m_Item->itemTextSaxed.isEmpty())
165
175
                m_Item->asTextFrame()->updateUndo(PageItem::INS, QString(ch));
166
176
        else
167
177
                m_Item->asTextFrame()->updateUndo(PageItem::REPSAX, m_Item->getTextSaxed(QString(ch)));
168
178
        m_doc->updateFrameItems();
169
 
        m_Item->CPos += 1;
170
179
        m_doc->view()->DrawNew();
171
180
        m_doc->changed();
172
181
}
178
187
 
179
188
        QApplication::changeOverrideCursor(QCursor(Qt::WaitCursor));
180
189
        m_enhanced = new CharSelectEnhanced(this);
181
 
        connect(m_enhanced, SIGNAL(insertSpecialChars(const QString &)),
182
 
                this, SLOT(slot_insertSpecialChars(const QString &)));
 
190
        connect(m_enhanced, SIGNAL(insertSpecialChars(const QString &)), this, SLOT(slot_insertSpecialChars(const QString &)));
 
191
//      connect(m_enhanced, SIGNAL(paletteShown(bool)), hideButton, SLOT(setChecked(bool)));
183
192
        m_enhanced->setDoc(m_doc);
184
193
        m_enhanced->setEnabled(this->isEnabled());
185
194
        m_enhanced->show();
193
202
 
194
203
        hideButton->blockSignals(true);
195
204
        hideButton->setChecked(false);
196
 
        hideButton->blockSignals(false);
197
205
 
198
 
        disconnect(m_enhanced, SIGNAL(insertSpecialChars(const QString &)),
199
 
                   this, SLOT(slot_insertSpecialChars(const QString &)));
 
206
        disconnect(m_enhanced, SIGNAL(insertSpecialChars(const QString &)), this, SLOT(slot_insertSpecialChars(const QString &)));
 
207
//      disconnect(m_enhanced, SIGNAL(paletteShown(bool)), hideButton, SLOT(setChecked(bool)));
200
208
        m_enhanced->close();
201
209
        delete m_enhanced;
202
210
        m_enhanced = 0;
 
211
        hideButton->blockSignals(false);
203
212
}
204
213
 
205
214
void CharSelect::hideButton_toggled(bool state)
259
268
        if (file.open(QIODevice::ReadOnly))
260
269
        {
261
270
                QTextStream stream(&file);
262
 
                QString line;
 
271
                QString line = stream.readLine();
 
272
                if (line != "# Character palette file for Scribus")
 
273
                {
 
274
                        file.close();
 
275
                        return;
 
276
                }
 
277
                m_userTableModel->setCharacters(CharClassDef());
263
278
                while (!stream.atEnd())
264
279
                {
265
280
                        bool ok = false;
266
281
                        line = stream.readLine();
267
282
                        if (line.left(1) == "#")
268
283
                                continue; // don't mess with a comment
269
 
                        int val = line.toInt(&ok, 10);
 
284
                        int a = line.indexOf(" ");
 
285
                        QString si = line.left(a);
 
286
                        si.toInt(&ok, 10);
270
287
                        if (ok)
271
 
                                newChars.append(val);
 
288
                                m_userTableModel->addCharacter(line);
272
289
                        else
273
290
                        {
274
291
                                QMessageBox::warning(this, tr("Error"),
278
295
                        }
279
296
                }
280
297
                file.close();
281
 
                m_userTableModel->setCharacters(newChars);
282
298
        }
283
299
//     tDebug("loadUserContent end");
284
300
}
308
324
        {
309
325
                QTextStream stream(&file);
310
326
                CharClassDef chars = m_userTableModel->characters();
311
 
                stream << "# This is a character palette file for Scribus\n";
312
 
                for (CharClassDef::Iterator it = chars.begin(); it != chars.end(); ++it)
313
 
                        stream << (*it) << "\n";
 
327
                QStringList fonts = m_userTableModel->fonts();
 
328
                stream << "# Character palette file for Scribus\n";
 
329
                for (int a = 0; a < chars.count(); a++)
 
330
                {
 
331
                        stream << chars[a] << " " << fonts[a] << "\n";
 
332
                }
314
333
                file.close();
315
334
        }
316
335
        else