~ubuntu-branches/ubuntu/precise/ipe/precise

« back to all changes in this revision

Viewing changes to src/ipe/initui.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2007-01-09 23:14:51 UTC
  • mfrom: (3.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20070109231451-3nd095g7ishc108l
Tags: 6.0pre27-3
* debian/gsfonts-fontmap.xml: New.  Fontmap for fonts from gsfonts package.
* debian/rules: Use gsfonts-fontmap.xml instead of tetex-fontmap.xml.
* debian/control: Add texlive-latex-base dependency as alternative to
  tetex-bin (for pdflatex) and replace tetex-extra by gsfonts (for font
  files).  Patch courtesy of Norbert Preining.  Closes: #378537.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
/*
5
5
 
6
6
    This file is part of the extensible drawing editor Ipe.
7
 
    Copyright (C) 1993-2004  Otfried Cheong
 
7
    Copyright (C) 1993-2005  Otfried Cheong
8
8
 
9
9
    Ipe is free software; you can redistribute it and/or modify it
10
10
    under the terms of the GNU General Public License as published by
32
32
#include "ipeq.h"
33
33
 
34
34
#include "appui.h"
35
 
 
36
 
#include <qaction.h>
37
 
#include <qapplication.h>
38
 
#include <qbuttongroup.h>
39
 
#include <qclipboard.h>
40
 
#include <qcolordialog.h>
41
 
#include <qcombobox.h>
42
 
#include <qdatetime.h>
43
 
#include <qdragobject.h>
44
 
#include <qvalidator.h>
45
 
#include <qfiledialog.h>
46
 
#include <qfocusdata.h>
47
 
#include <qheader.h>
48
 
#include <qinputdialog.h>
49
 
#include <qlabel.h>
50
 
#include <qlineedit.h>
51
 
#include <qlistbox.h>
52
 
#include <qmainwindow.h>
53
 
#include <qmenubar.h>
54
 
#include <qmessagebox.h>
55
 
#include <qpushbutton.h>
56
 
#include <qstatusbar.h>
57
 
#include <qtextbrowser.h>
58
 
#include <qtextstream.h>
59
 
#include <qtoolbar.h>
60
 
#include <qtoolbutton.h>
61
 
#include <qtooltip.h>
62
 
#include <qwhatsthis.h>
63
 
#include <qwidgetstack.h>
64
 
 
65
 
QPixmap ipeIcon(const char* name);
66
 
QPixmap penguinIcon(int width);
67
 
 
68
 
// --------------------------------------------------------------------
69
 
 
70
 
IpeSpinBox::IpeSpinBox(QWidget *parent, const char *name,
71
 
                       int minValue, int maxValue, int step)
72
 
  : QSpinBox(minValue, maxValue, step, parent, name)
73
 
{
74
 
  // nothing
75
 
}
76
 
 
77
 
//! This does not emit any valueChanged() signal.
78
 
void IpeSpinBox::Set(int val, int maxVal)
79
 
{
80
 
  // set value to 1 first, in case maxVal is less than current value
81
 
  directSetValue(1);
82
 
  setMaxValue(maxVal);
83
 
  directSetValue(val);
84
 
  updateDisplay();
85
 
}
86
 
 
87
 
//! This does not emit any valueChanged() signal.
88
 
void IpeSpinBox::Set(int val)
89
 
{
90
 
  directSetValue(val);
91
 
  updateDisplay();
92
 
}
93
 
 
94
 
// --------------------------------------------------------------------
95
 
 
96
 
DecimalSpinBox::DecimalSpinBox(int minValue, int maxValue, int step,
97
 
                               int decimals, QWidget *parent)
98
 
  : QSpinBox(minValue, maxValue, step, parent)
99
 
{
100
 
  iDecimals = decimals;
101
 
  setValidator(new QDoubleValidator(minValue / 1000.0, maxValue / 1000.0,
102
 
                                    iDecimals, this));
103
 
}
104
 
 
105
 
QString DecimalSpinBox::mapValueToText(int value)
106
 
{
107
 
  QString s1, s2;
108
 
  s1.sprintf("%d.", value / 1000);
109
 
  s2.sprintf("%03d", value % 1000);
110
 
  return s1 + s2.left(iDecimals);
111
 
}
112
 
 
113
 
int DecimalSpinBox::mapTextToValue(bool *ok)
114
 
{
115
 
  *ok = false;
116
 
  QString str = cleanText();
117
 
  IpeLex lex(IpeQ(str));
118
 
  IpeFixed d = lex.GetFixed();
119
 
  lex.SkipWhitespace();
120
 
  if (lex.Eos()) {
121
 
    *ok = true;
122
 
    return d.Internal();
123
 
  }
124
 
  return 0;
125
 
}
126
 
 
127
 
void DecimalSpinBox::setValueFromAttribute(int value)
128
 
{
129
 
  directSetValue(value);
130
 
  updateDisplay();
131
 
}
132
 
 
133
 
// --------------------------------------------------------------------
134
 
 
135
 
class ZoomSpinBox : public QSpinBox {
136
 
public:
137
 
  ZoomSpinBox(QWidget *parent = 0);
138
 
public slots:
139
 
  virtual void stepUp();
140
 
  virtual void stepDown();
141
 
protected:
142
 
  virtual QString mapValueToText(int value);
143
 
  virtual int mapTextToValue(bool *ok);
144
 
};
145
 
 
146
 
ZoomSpinBox::ZoomSpinBox(QWidget *parent)
147
 
  : QSpinBox(10000, 1000000, 1000, parent)
148
 
{
149
 
  // nothing
150
 
}
151
 
 
152
 
void ZoomSpinBox::stepUp()
153
 
{
154
 
  int res = value();
155
 
  res = int(res * 1.3 + 0.5);
156
 
  if (res > maxValue())
157
 
    res = maxValue();
158
 
  setValue(res);
159
 
}
160
 
 
161
 
void ZoomSpinBox::stepDown()
162
 
{
163
 
  int res = value();
164
 
  res = int(res / 1.3 + 0.5);
165
 
  if (res < minValue())
166
 
    res = minValue();
167
 
  setValue(res);
168
 
}
169
 
 
170
 
QString ZoomSpinBox::mapValueToText(int value)
171
 
{
172
 
  QString s;
173
 
  s.sprintf("%d", int(value * 0.001 + 0.5));
174
 
  return s;
175
 
}
176
 
 
177
 
int ZoomSpinBox::mapTextToValue(bool *ok)
178
 
{
179
 
  return 1000 * QSpinBox::mapTextToValue(ok);
180
 
}
181
 
 
182
 
// --------------------------------------------------------------------
183
 
 
184
 
class LayerBox : public QListBox {
185
 
public:
186
 
  LayerBox(QWidget *parent, const char *name) :
187
 
    QListBox(parent, name) { /* nothing else */ }
188
 
  virtual void mousePressEvent(QMouseEvent *e);
189
 
};
190
 
 
191
 
void LayerBox::mousePressEvent(QMouseEvent *e)
192
 
{
193
 
  QListBoxItem *i = itemAt(e->pos());
194
 
  // ignore mouse outside items
195
 
  if (!i)
196
 
    return;
197
 
  if (e->button() == LeftButton) {
198
 
    QListBox::mousePressEvent(e);
199
 
  } else
200
 
    emit rightButtonPressed(i, e->globalPos());
201
 
}
 
35
#include "widgets.h"
 
36
 
 
37
extern QPixmap ipeIcon(const char* name);
202
38
 
203
39
// --------------------------------------------------------------------
204
40
 
205
41
const char * fileNewText = QT_TR_NOOP(
206
 
"<qt><img source=\"new\"> "
207
 
"This button creates a new document. "
 
42
"<qt>This button creates a new document. "
208
43
"You can also select the <b>New</b> command from the File menu.</qt>");
209
44
const char * fileOpenText = QT_TR_NOOP(
210
 
"<qt><img source=\"open\"> "
211
 
"This button opens a document from a file. "
 
45
"<qt>This button opens a document from a file. "
212
46
"You can also select the <b>Open</b> command from the File menu.</qt>");
213
47
const char * fileSaveText = QT_TR_NOOP(
214
 
"<qt><img source=\"save\"> "
215
 
"This button saves the current document. If it is a new document, "
 
48
"<qt>This button saves the current document. If it is a new document, "
216
49
"you will be prompted for a file name. "
217
50
"You can also select the <b>Save</b> command from the File menu.</qt>");
218
51
const char * cutcopyText = QT_TR_NOOP(
219
 
"<qt>Cut <img source=\"cut\">, copy <img source=\"copy\">, and paste "
220
 
"<img source=\"paste\"> pass Ipe objects to and from the system clipboard. "
 
52
"<qt>Cut, copy , and paste "
 
53
"pass Ipe objects to and from the system clipboard. "
221
54
"When pasting objects, they are inserted into the active layer. "
222
55
"You can examine Ipe objects by copying them to the clipboard, and "
223
56
"pasting into your favorite text editor.</qt>");
335
168
/*! The constructor does not create an Ipe document.
336
169
  Clients need to call either Load or NewDoc after construction,
337
170
  before calling show. */
338
 
AppUi::AppUi(QWidget* parent, const char* name, WFlags f)
339
 
  : QMainWindow(parent,name,f), iKeyTranslator(0)
 
171
 
 
172
AppUi::AppUi(QWidget* parent, Qt::WFlags f)
 
173
  : QMainWindow(parent, f)
340
174
{
341
175
  QPixmap newIcon = ipeIcon("new");
342
176
  QPixmap openIcon = ipeIcon("open");
347
181
  QPixmap copyIcon = ipeIcon("copy");
348
182
  QPixmap pasteIcon = ipeIcon("paste");
349
183
 
350
 
  QMimeSourceFactory::defaultFactory()->setPixmap("new", newIcon);
351
 
  QMimeSourceFactory::defaultFactory()->setPixmap("open", openIcon);
352
 
  QMimeSourceFactory::defaultFactory()->setPixmap("save", saveIcon);
353
 
  QMimeSourceFactory::defaultFactory()->setPixmap("undo", undoIcon);
354
 
  QMimeSourceFactory::defaultFactory()->setPixmap("redo", undoIcon);
355
 
  QMimeSourceFactory::defaultFactory()->setPixmap("cut", cutIcon);
356
 
  QMimeSourceFactory::defaultFactory()->setPixmap("copy", copyIcon);
357
 
  QMimeSourceFactory::defaultFactory()->setPixmap("paste", pasteIcon);
358
 
 
359
184
  IpePreferences *prefs = IpePreferences::Static();
360
185
 
361
186
  // --------------------------------------------------------------------
362
 
  // File tool bar
363
 
  // --------------------------------------------------------------------
364
 
 
365
 
  setUsesBigPixmaps(prefs->iBigToolButtons);
366
 
 
367
 
  iFileTools = new QToolBar( this, "file tools" );
368
 
  iFileTools->setLabel(tr("File tools"));
369
 
 
370
 
  QToolButton *fileNew
371
 
    = new QToolButton(newIcon, tr("New document"), QString::null,
372
 
                      this, SLOT(NewDoc()), iFileTools, "new document" );
373
 
  QWhatsThis::add(fileNew, tr(fileNewText));
374
 
 
375
 
  QToolButton *fileOpen
376
 
    = new QToolButton(openIcon, tr("Open file"), QString::null,
377
 
                      this, SLOT(Load()), iFileTools, "open file" );
378
 
  QWhatsThis::add(fileOpen, tr(fileOpenText));
379
 
 
380
 
  QToolButton *fileSave
381
 
    = new QToolButton(saveIcon, tr("Save file"), QString::null,
382
 
                      this, SLOT(Save()), iFileTools, "save file" );
383
 
  QWhatsThis::add(fileSave, tr(fileSaveText));
384
 
 
385
 
  iFileTools->addSeparator();
386
 
 
387
 
  QToolButton *editCut
388
 
    = new QToolButton(cutIcon, tr("Cut"), QString::null,
389
 
                      this, SLOT(Cut()), iFileTools, "cut" );
390
 
  QWhatsThis::add(editCut, tr(cutcopyText));
391
 
 
392
 
  QToolButton *editCopy
393
 
    = new QToolButton(copyIcon, tr("Copy"), QString::null,
394
 
                      this, SLOT(Copy()), iFileTools, "copy" );
395
 
  QWhatsThis::add(editCopy, tr(cutcopyText));
396
 
 
397
 
  QToolButton *editPaste
398
 
    = new QToolButton(pasteIcon, tr("Paste"), QString::null,
399
 
                      this, SLOT(Paste()), iFileTools, "paste" );
400
 
  QWhatsThis::add(editPaste, tr(cutcopyText));
401
 
 
402
 
  iFileTools->addSeparator();
403
 
 
404
 
  (void) QWhatsThis::whatsThisButton(iFileTools);
 
187
  // Create menus
 
188
  // --------------------------------------------------------------------
 
189
 
 
190
  iFileMenu = menuBar()->addMenu(tr("&File"));
 
191
  iEditMenu = menuBar()->addMenu(tr("&Edit"));
 
192
  iSnapMenu = menuBar()->addMenu(tr("&Snap"));
 
193
  iModeMenu = menuBar()->addMenu(tr("&Mode"));
 
194
  iZoomMenu = menuBar()->addMenu(tr("&Zoom"));
 
195
  iLayerMenu = menuBar()->addMenu(tr("&Layer"));
 
196
  iViewMenu = menuBar()->addMenu(tr("&View"));
 
197
  iPageMenu = menuBar()->addMenu(tr("&Page"));
 
198
  iIpeletMenu = menuBar()->addMenu(tr("&Ipelets"));
 
199
  menuBar()->addSeparator();
 
200
  iHelpMenu = menuBar()->addMenu(tr("&Help"));
 
201
 
 
202
  // --------------------------------------------------------------------
 
203
  // Create toolbars
 
204
  // --------------------------------------------------------------------
 
205
 
 
206
  iFileTools = addToolBar(tr("File"));
 
207
  iResolutionTools = addToolBar(tr("Resolution"));
 
208
  iPageTools = addToolBar(tr("Page"));
 
209
  iSnapTools = addToolBar(tr("Snap"));
 
210
  addToolBarBreak();
 
211
  iObjectTools = addToolBar(tr("Objects"));
 
212
 
 
213
  // --------------------------------------------------------------------
 
214
  // Create docking windows
 
215
  // --------------------------------------------------------------------
 
216
 
 
217
  iPropertiesTools = new QDockWidget(tr("Properties"), this);
 
218
  addDockWidget(Qt::LeftDockWidgetArea, iPropertiesTools);
 
219
  iPropertiesTools->setAllowedAreas(Qt::LeftDockWidgetArea|
 
220
                                    Qt::RightDockWidgetArea);
 
221
 
 
222
  iLayerTools = new QDockWidget(tr("Layers"), this);
 
223
  addDockWidget(Qt::LeftDockWidgetArea, iLayerTools);
 
224
  iLayerTools->setAllowedAreas(Qt::LeftDockWidgetArea|
 
225
                               Qt::RightDockWidgetArea);
 
226
 
 
227
  iBookmarkTools = new QDockWidget(tr("Bookmarks"), this);
 
228
  addDockWidget(Qt::RightDockWidgetArea, iBookmarkTools);
 
229
  iBookmarkTools->setAllowedAreas(Qt::LeftDockWidgetArea|
 
230
                                  Qt::RightDockWidgetArea);
 
231
 
 
232
  // --------------------------------------------------------------------
 
233
  // File toolbar
 
234
  // --------------------------------------------------------------------
 
235
 
 
236
  QAction *newAct = new QAction(newIcon, tr("&New document"), this);
 
237
  newAct->setShortcut(Key("File|New document"));
 
238
  // newAct->setStatusTip(tr("Create a new document"));
 
239
  newAct->setWhatsThis(tr(fileNewText));
 
240
  connect(newAct, SIGNAL(triggered()), this, SLOT(NewDoc()));
 
241
  iFileTools->addAction(newAct);
 
242
 
 
243
  QAction *openAct = new QAction(openIcon, tr("Open file"), this);
 
244
  openAct->setShortcut(Key("File|Open file"));
 
245
  openAct->setWhatsThis(tr(fileOpenText));
 
246
  connect(openAct, SIGNAL(triggered()), this, SLOT(Load()));
 
247
  iFileTools->addAction(openAct);
 
248
 
 
249
  QAction *saveAct = new QAction(saveIcon, tr("Save file"), this);
 
250
  saveAct->setShortcut(Key("File|Save file"));
 
251
  saveAct->setWhatsThis(tr(fileSaveText));
 
252
  connect(saveAct, SIGNAL(triggered()), this, SLOT(Save()));
 
253
  iFileTools->addAction(saveAct);
 
254
 
 
255
  iFileTools->addSeparator();
 
256
 
 
257
  iCutAction = new IpeAction(ECmdCut, cutIcon, tr("Cut"), this);
 
258
  iCutAction->setShortcut(Key("Edit|Cut"));
 
259
  iCutAction->setWhatsThis(tr(cutcopyText));
 
260
  connect(iCutAction, SIGNAL(triggered(int)), this, SLOT(Cmd(int)));
 
261
  iFileTools->addAction(iCutAction);
 
262
 
 
263
  iCopyAction = new IpeAction(ECmdCopy, copyIcon, tr("Copy"), this);
 
264
  iCopyAction->setShortcut(Key("Edit|Copy"));
 
265
  iCopyAction->setWhatsThis(tr(cutcopyText));
 
266
  connect(iCopyAction, SIGNAL(triggered(int)), this, SLOT(Cmd(int)));
 
267
  iFileTools->addAction(iCopyAction);
 
268
 
 
269
  QAction *pasteAct = new IpeAction(ECmdPaste, pasteIcon, tr("Paste"), this);
 
270
  pasteAct->setShortcut(Key("Edit|Paste"));
 
271
  pasteAct->setWhatsThis(tr(cutcopyText));
 
272
  connect(pasteAct, SIGNAL(triggered(int)), this, SLOT(Cmd(int)));
 
273
  iFileTools->addAction(pasteAct);
 
274
 
 
275
  iFileTools->addSeparator();
 
276
 
 
277
  QAction *whatsThisAct = QWhatsThis::createAction();
 
278
  iFileTools->addAction(whatsThisAct);
 
279
 
 
280
  iFileTools->hide();
405
281
 
406
282
  // --------------------------------------------------------------------
407
283
  // Resolution tool bar
408
284
  // --------------------------------------------------------------------
409
285
 
410
 
  iResolutionTools = new QToolBar(this, "resolution tools");
411
 
  iResolutionTools->setLabel(tr("Resolution tool"));
 
286
  QAction *normalSizeAct = new QAction(tr("&Normal size"), this);
 
287
  normalSizeAct->setShortcut(Key("Zoom|Normal size"));
 
288
  connect(normalSizeAct, SIGNAL(triggered()), this, SLOT(NormalSize()));
412
289
 
413
 
  iResolution = new ZoomSpinBox(iResolutionTools);
414
 
  QToolTip::add(iResolution, tr("Screen resolution"));
415
 
  QWhatsThis::add(iResolution, tr(resolutionText));
416
 
  iResolution->setSuffix(tr(" dpi"));
 
290
  iResolution = new ZoomSpinBox();
 
291
  iResolution->setWhatsThis(tr(resolutionText));
 
292
  iResolution->setToolTip(tr("Screen resolution"));
 
293
  iResolution->installEventFilter(this);
417
294
  connect(iResolution, SIGNAL(valueChanged(int)),
418
295
          this, SLOT(ResolutionChanged(int)));
 
296
  iResolutionTools->addWidget(iResolution);
419
297
 
420
298
  // --------------------------------------------------------------------
421
299
  // Page tool bar
422
300
  // --------------------------------------------------------------------
423
301
 
424
 
  iPageTools = new QToolBar(this, "page tools");
425
 
  iPageTools->setLabel(tr("Page tools"));
426
 
 
427
 
  iPageNumber = new IpeSpinBox(iPageTools, "page number");
428
 
  QToolTip::add(iPageNumber, tr("Current page"));
429
 
  QWhatsThis::add(iPageNumber, tr(pageNumberText));
 
302
  iPageNumber = new IpeSpinBox();
 
303
  iPageNumber->setToolTip(tr("Current page"));
 
304
  iPageNumber->setWhatsThis(tr(pageNumberText));
430
305
  iPageNumber->setPrefix(tr("Page "));
431
306
  connect(iPageNumber, SIGNAL(valueChanged(int)),
432
307
          this, SLOT(PageChanged(int)));
433
 
  // iPageNumber->setFocusPolicy(NoFocus);
 
308
  iPageNumber->installEventFilter(this);
434
309
 
435
 
  iViewNumber = new IpeSpinBox(iPageTools, "view number");
436
 
  QToolTip::add(iViewNumber, tr("Current view"));
437
 
  QWhatsThis::add(iViewNumber, tr(viewNumberText));
 
310
  iViewNumber = new IpeSpinBox();
 
311
  iViewNumber->setToolTip(tr("Current view"));
 
312
  iViewNumber->setWhatsThis(tr(viewNumberText));
438
313
  iViewNumber->setPrefix(tr("View "));
439
314
  connect(iViewNumber, SIGNAL(valueChanged(int)),
440
315
          this, SLOT(ViewChanged(int)));
441
 
  // iViewNumber->setFocusPolicy(NoFocus);
442
 
 
443
 
  // --------------------------------------------------------------------
444
 
  // Color tool bar
445
 
  // --------------------------------------------------------------------
446
 
 
447
 
  iColorTools = new QToolBar(this, "color tools");
448
 
  iColorTools->setLabel(tr("Color tools"));
449
 
 
450
 
  iStrokeColorStack = new QWidgetStack(iColorTools);
451
 
  QToolTip::add(iStrokeColorStack, tr("Stroke color"));
452
 
  QWhatsThis::add(iStrokeColorStack, tr(strokeColorText));
453
 
  iStrokeColor = new QComboBox(false);
454
 
  connect(iStrokeColor, SIGNAL(activated(int)),
455
 
          SLOT(SetStrokeColorName(int)));
456
 
  iAbsStrokeColor = new QPushButton(tr("Stroke"), 0);
457
 
  iStrokeColorStack->setMaximumHeight(iStrokeColor->sizeHint().height());
458
 
  connect(iAbsStrokeColor, SIGNAL(clicked()),
459
 
          this, SLOT(SetStrokeColor()));
460
 
  iStrokeColorStack->addWidget(iStrokeColor, 0);
461
 
  iStrokeColorStack->addWidget(iAbsStrokeColor, 1);
462
 
 
463
 
  iFillColorStack = new QWidgetStack(iColorTools);
464
 
  QToolTip::add(iFillColorStack, tr("Fill color"));
465
 
  QWhatsThis::add(iFillColorStack, tr(fillColorText));
466
 
  iFillColor = new QComboBox(false);
467
 
  connect(iFillColor, SIGNAL(activated(int)),
468
 
          SLOT(SetFillColorName(int)));
469
 
  iAbsFillColor = new QPushButton(tr("Fill"), 0);
470
 
  iFillColorStack->setMaximumHeight(iFillColor->sizeHint().height());
471
 
  connect(iAbsFillColor, SIGNAL(clicked()),
472
 
          this, SLOT(SetFillColor()));
473
 
  iFillColorStack->addWidget(iFillColor, 0);
474
 
  iFillColorStack->addWidget(iAbsFillColor, 1);
475
 
 
476
 
  // --------------------------------------------------------------------
477
 
  // Line width/style/arrow tool bar
478
 
  // --------------------------------------------------------------------
479
 
 
480
 
  iLineTools = new QToolBar(this, "line tools");
481
 
  iLineTools->setLabel(tr("Line style settings"));
482
 
 
483
 
  iLineWidthStack = new QWidgetStack(iLineTools);
484
 
  QToolTip::add(iLineWidthStack, tr("Line width"));
485
 
  QWhatsThis::add(iLineWidthStack, tr(lineWidthText));
486
 
  iLineWidth = new QComboBox(false);
487
 
  connect(iLineWidth, SIGNAL(activated(int)),
488
 
          SLOT(LineWidthChanged(int)));
489
 
  iAbsLineWidth = new DecimalSpinBox(0, 10000, 200);
490
 
  connect(iAbsLineWidth, SIGNAL(valueChanged(int)),
491
 
          SLOT(AbsLineWidthChanged(int)));
492
 
  iLineWidthStack->addWidget(iLineWidth, 0);
493
 
  iLineWidthStack->addWidget(iAbsLineWidth, 1);
494
 
 
495
 
  iDashStyle = new QComboBox(false, iLineTools);
496
 
  QToolTip::add(iDashStyle, tr("Line dash pattern"));
497
 
  QWhatsThis::add(iDashStyle, tr(lineDashText));
498
 
  connect(iDashStyle, SIGNAL(activated(int)),
499
 
          SLOT(DashStyleChanged(int)));
500
 
 
501
 
  QPixmap arrowIcon1 = ipeIcon("arrowNone");
502
 
  QPixmap arrowIcon2 = ipeIcon("arrowRight");
503
 
  QPixmap arrowIcon3 = ipeIcon("arrowLeft");
504
 
  QPixmap arrowIcon4 = ipeIcon("arrowBoth");
505
 
  iArrow = new QComboBox(false, iLineTools);
506
 
  QToolTip::add(iArrow, tr("Arrow"));
507
 
  QWhatsThis::add(iArrow, tr(arrowText));
508
 
  iArrow->insertItem(arrowIcon1);
509
 
  iArrow->insertItem(arrowIcon2);
510
 
  iArrow->insertItem(arrowIcon3);
511
 
  iArrow->insertItem(arrowIcon4);
512
 
  connect(iArrow, SIGNAL(activated(int)),
513
 
          SLOT(ArrowChanged(int)));
514
 
  iAttributes.iForwardArrow = false;
515
 
  iAttributes.iBackwardArrow = false;
516
 
 
517
 
  iArrowSizeStack = new QWidgetStack(iLineTools);
518
 
  QToolTip::add(iArrowSizeStack, tr("Arrow size"));
519
 
  QWhatsThis::add(iArrowSizeStack, tr(arrowSizeText));
520
 
  iArrowSize = new QComboBox(false);
521
 
  connect(iArrowSize, SIGNAL(activated(int)),
522
 
          SLOT(ArrowSizeChanged(int)));
523
 
  iAbsArrowSize = new DecimalSpinBox(200, 100000, 1000);
524
 
  connect(iAbsArrowSize, SIGNAL(valueChanged(int)),
525
 
          SLOT(AbsArrowSizeChanged(int)));
526
 
  iArrowSizeStack->addWidget(iArrowSize, 0);
527
 
  iArrowSizeStack->addWidget(iAbsArrowSize, 1);
528
 
 
529
 
 
530
 
  // --------------------------------------------------------------------
531
 
  // Mark and text sizes
532
 
  // --------------------------------------------------------------------
533
 
 
534
 
  iSizeTools = new QToolBar(this, "size tools");
535
 
  iSizeTools->setLabel(tr("Mark and text size settings"));
536
 
 
537
 
  QPixmap markIcon = ipeIcon("marks");
538
 
  iMarkShape = new QComboBox(false, iSizeTools, "mark shape");
539
 
  QToolTip::add(iMarkShape, tr("Mark shape"));
540
 
  QWhatsThis::add(iMarkShape, tr(markShapeText));
541
 
  connect(iMarkShape, SIGNAL(activated(int)),
542
 
          SLOT(MarkShapeChanged(int)));
543
 
  iMarkShape->insertItem(markIcon, tr("Circle"));
544
 
  iMarkShape->insertItem(markIcon, tr("Disc"));
545
 
  iMarkShape->insertItem(markIcon, tr("Box"));
546
 
  iMarkShape->insertItem(markIcon, tr("Square"));
547
 
  iMarkShape->insertItem(markIcon, tr("Cross"));
548
 
  iAttributes.iMarkShape = iMarkShape->currentItem() + 1;
549
 
 
550
 
  iMarkSizeStack = new QWidgetStack(iSizeTools);
551
 
  QToolTip::add(iMarkSizeStack, tr("Mark size"));
552
 
  QWhatsThis::add(iMarkSizeStack, tr(markSizeText));
553
 
  iMarkSize = new QComboBox(false);
554
 
  connect(iMarkSize, SIGNAL(activated(int)),
555
 
          SLOT(MarkSizeChanged(int)));
556
 
  iAbsMarkSize = new DecimalSpinBox(200, 100000, 1000);
557
 
  connect(iAbsMarkSize, SIGNAL(valueChanged(int)),
558
 
          SLOT(AbsMarkSizeChanged(int)));
559
 
  iMarkSizeStack->addWidget(iMarkSize, 0);
560
 
  iMarkSizeStack->addWidget(iAbsMarkSize, 1);
561
 
 
562
 
  iTextSizeStack = new QWidgetStack(iSizeTools);
563
 
  QToolTip::add(iTextSizeStack, tr("Font size"));
564
 
  QWhatsThis::add(iTextSizeStack, tr(textSizeText));
565
 
  iTextSize = new QComboBox(false);
566
 
  connect(iTextSize, SIGNAL(activated(int)),
567
 
          SLOT(TextSizeChanged(int)));
568
 
  iAbsTextSize = new DecimalSpinBox(4000, 50000, 1000);
569
 
  connect(iAbsTextSize, SIGNAL(valueChanged(int)),
570
 
          SLOT(AbsTextSizeChanged(int)));
571
 
  iTextSizeStack->addWidget(iTextSize, 0);
572
 
  iTextSizeStack->addWidget(iAbsTextSize, 1);
 
316
  iViewNumber->installEventFilter(this);
 
317
 
 
318
  iPageTools->addWidget(iPageNumber);
 
319
  iPageTools->addWidget(iViewNumber);
573
320
 
574
321
  // --------------------------------------------------------------------
575
322
  // Snap tool bar
582
329
  QPixmap snapAngleIcon = ipeIcon("snapangle");
583
330
  QPixmap snapAutoIcon = ipeIcon("snapauto");
584
331
 
585
 
  QMimeSourceFactory::defaultFactory()->setPixmap("snapvtx", snapVtxIcon);
586
 
  QMimeSourceFactory::defaultFactory()->setPixmap("snapbd", snapVtxIcon);
587
 
  QMimeSourceFactory::defaultFactory()->setPixmap("snapint", snapVtxIcon);
588
 
  QMimeSourceFactory::defaultFactory()->setPixmap("snapgrid", snapGridIcon);
589
 
  QMimeSourceFactory::defaultFactory()->setPixmap("snapangle", snapAngleIcon);
590
 
  QMimeSourceFactory::defaultFactory()->setPixmap("snapauto", snapAutoIcon);
591
 
 
592
 
  iSnapTools = new QToolBar(this, "snap tools");
593
 
  iSnapTools->setLabel(tr("Snap tools"));
594
 
 
595
 
  iSnapActionGroup = new QActionGroup(this, 0, false);
 
332
  iSnapActionGroup = new QActionGroup(this);
596
333
 
597
334
  iSnapAction[0] = new QAction(iSnapActionGroup);
598
335
  iSnapAction[0]->setText(tr("Snap to vertices"));
599
 
  iSnapAction[0]->setAccel(Key("F4", "Snap|Vertices"));
600
 
  iSnapAction[0]->setIconSet(snapVtxIcon);
601
 
  iSnapAction[0]->addTo(iSnapTools);
 
336
  iSnapAction[0]->setShortcut(Key("Snap|Vertices"));
 
337
  iSnapAction[0]->setIcon(snapVtxIcon);
602
338
 
603
339
  iSnapAction[1] = new QAction(iSnapActionGroup);
604
340
  iSnapAction[1]->setText(tr("Snap to boundary"));
605
 
  iSnapAction[1]->setAccel(Key("F5", "Snap|Boundary"));
606
 
  iSnapAction[1]->setIconSet(snapBdIcon);
607
 
  iSnapAction[1]->addTo(iSnapTools);
 
341
  iSnapAction[1]->setShortcut(Key("Snap|Boundary"));
 
342
  iSnapAction[1]->setIcon(snapBdIcon);
608
343
 
609
344
  iSnapAction[2] = new QAction(iSnapActionGroup);
610
345
  iSnapAction[2]->setText(tr("Snap to intersection"));
611
 
  iSnapAction[2]->setAccel(Key("F6", "Snap|Intersections"));
612
 
  iSnapAction[2]->setIconSet(snapIntIcon);
613
 
  iSnapAction[2]->addTo(iSnapTools);
614
 
 
615
 
  iSnapTools->addSeparator();
 
346
  iSnapAction[2]->setShortcut(Key("Snap|Intersections"));
 
347
  iSnapAction[2]->setIcon(snapIntIcon);
616
348
 
617
349
  iSnapAction[3] = new QAction(iSnapActionGroup);
618
350
  iSnapAction[3]->setText(tr("Snap to grid"));
619
 
  iSnapAction[3]->setAccel(Key("F7", "Snap|Grid"));
620
 
  iSnapAction[3]->setIconSet(snapGridIcon);
621
 
  iSnapAction[3]->addTo(iSnapTools);
622
 
 
623
 
  iGridSizeStack = new QWidgetStack(iSnapTools);
624
 
  QToolTip::add(iGridSizeStack, tr("Grid size"));
625
 
  QWhatsThis::add(iGridSizeStack, tr(gridSizeText));
626
 
  iGridSize = new QComboBox(false);
 
351
  iSnapAction[3]->setShortcut(Key("Snap|Grid"));
 
352
  iSnapAction[3]->setIcon(snapGridIcon);
 
353
 
 
354
  iSnapAction[4] = new QAction(iSnapActionGroup);
 
355
  iSnapAction[4]->setText(tr("Angular snap"));
 
356
  iSnapAction[4]->setShortcut(Key("Snap|Angular"));
 
357
  iSnapAction[4]->setIcon(snapAngleIcon);
 
358
 
 
359
  iSnapAction[5] = new QAction(iSnapActionGroup);
 
360
  iSnapAction[5]->setText(tr("Automatic angular snap"));
 
361
  iSnapAction[5]->setShortcut(Key("Snap|Automatic angular"));
 
362
  iSnapAction[5]->setIcon(snapAutoIcon);
 
363
 
 
364
  iGridSizeStack = new QStackedWidget(iSnapTools);
 
365
  iGridSizeStack->setToolTip(tr("Grid size"));
 
366
  iGridSizeStack->setWhatsThis(tr(gridSizeText));
 
367
  iGridSize = new QComboBox();
627
368
  connect(iGridSize, SIGNAL(activated(int)),
628
369
          SLOT(GridSizeChanged(int)));
629
 
  iAbsGridSize = new IpeSpinBox(0, 0, 4, 100, 2);
 
370
  iAbsGridSize = new IpeSpinBox(0, 4, 100, 2);
630
371
  connect(iAbsGridSize, SIGNAL(valueChanged(int)),
631
372
          SLOT(AbsGridSizeChanged(int)));
632
 
  iGridSizeStack->addWidget(iGridSize, 0);
633
 
  iGridSizeStack->addWidget(iAbsGridSize, 1);
634
 
 
635
 
  iSnapTools->addSeparator();
636
 
 
637
 
  iSnapAction[4] = new QAction(iSnapActionGroup);
638
 
  iSnapAction[4]->setText(tr("Angular snap"));
639
 
  iSnapAction[4]->setAccel(Key("F8", "Snap|Angular"));
640
 
  iSnapAction[4]->setIconSet(snapAngleIcon);
641
 
  iSnapAction[4]->addTo(iSnapTools);
642
 
 
643
 
  iSnapAction[5] = new QAction(iSnapActionGroup);
644
 
  iSnapAction[5]->setText(tr("Automatic angular snap"));
645
 
  iSnapAction[5]->setAccel(Key("F9", "Snap|Automatic angular"));
646
 
  iSnapAction[5]->setIconSet(snapAutoIcon);
647
 
  iSnapAction[5]->addTo(iSnapTools);
648
 
 
649
 
  iAngleSizeStack = new QWidgetStack(iSnapTools);
650
 
  QToolTip::add(iAngleSizeStack, tr("Angular snapping angle"));
651
 
  QWhatsThis::add(iAngleSizeStack, tr(angleSizeText));
652
 
  iAngleSize = new QComboBox(false);
 
373
  iGridSize->installEventFilter(this);
 
374
  iAbsGridSize->installEventFilter(this);
 
375
  iGridSizeStack->addWidget(iGridSize);
 
376
  iGridSizeStack->addWidget(iAbsGridSize);
 
377
 
 
378
  iAngleSizeStack = new QStackedWidget(iSnapTools);
 
379
  iAngleSizeStack->setToolTip(tr("Angular snapping angle"));
 
380
  iAngleSizeStack->setWhatsThis(tr(angleSizeText));
 
381
  iAngleSize = new QComboBox();
653
382
  connect(iAngleSize, SIGNAL(activated(int)),
654
383
          SLOT(AngleSizeChanged(int)));
655
384
  iAbsAngleSize = new DecimalSpinBox(3000, 360000, 2000);
656
385
  connect(iAbsAngleSize, SIGNAL(valueChanged(int)),
657
386
          SLOT(AbsAngleSizeChanged(int)));
658
 
  iAngleSizeStack->addWidget(iAngleSize, 0);
659
 
  iAngleSizeStack->addWidget(iAbsAngleSize, 1);
 
387
  iAngleSize->installEventFilter(this);
 
388
  iAbsAngleSize->installEventFilter(this);
 
389
  iAngleSizeStack->addWidget(iAngleSize);
 
390
  iAngleSizeStack->addWidget(iAbsAngleSize);
 
391
 
 
392
  iSnapTools->addAction(iSnapAction[0]);
 
393
  iSnapTools->addAction(iSnapAction[1]);
 
394
  iSnapTools->addAction(iSnapAction[2]);
 
395
  iSnapTools->addSeparator();
 
396
  iSnapTools->addAction(iSnapAction[3]);
 
397
  iSnapTools->addWidget(iGridSizeStack);
 
398
  iSnapTools->addSeparator();
 
399
  iSnapTools->addAction(iSnapAction[4]);
 
400
  iSnapTools->addAction(iSnapAction[5]);
 
401
  iSnapTools->addWidget(iAngleSizeStack);
 
402
 
 
403
  iSnapActionGroup->setExclusive(false);
660
404
 
661
405
  for (int i = 0; i < 6; ++i) {
662
 
    iSnapAction[i]->setToggleAction(true);
 
406
    iSnapAction[i]->setCheckable(true);
663
407
    iSnapAction[i]->setWhatsThis(tr(snapText));
664
408
    connect(iSnapAction[i], SIGNAL(toggled(bool)),
665
409
            this, SLOT(SnapChanged(bool)));
666
410
  }
667
411
 
668
 
  // ------------------------------------------------------------
669
 
  // Bookmark and layer toolbar
670
 
  // ------------------------------------------------------------
671
 
 
672
 
  iBookmarkTools = new QToolBar(tr("Bookmark tools"), this,
673
 
                                QMainWindow::Right, false, "bookmark tools");
674
 
#if 0
675
 
  iBookmarks = new QListView(iLayerTools, "bookmarks");
676
 
  QToolTip::add(iBookmarks, tr("Bookmarks of this document"));
677
 
  iBookmarks->addColumn("Section");
678
 
  iBookmarks->setSorting(-1); // don't resort
679
 
  iBookmarks->header()->hide();
680
 
  iBookmarks->setRootIsDecorated(true);
681
 
#else
682
 
  iBookmarks = new QListBox(iBookmarkTools, "bookmarks");
683
 
  QToolTip::add(iBookmarks, tr("Bookmarks of this document"));
684
 
  iBookmarks->setFocusPolicy(NoFocus);
685
 
  connect(iBookmarks, SIGNAL(selected(int)),
686
 
          this, SLOT(BookmarkSelected(int)));
687
 
#endif
688
 
 
689
 
  iLayerTools = new QToolBar(tr("Layer tools"), this,
690
 
                             QMainWindow::Left, false, "layer tools");
691
 
  iLayerTools->setVerticalStretchable(true);
692
 
  iLayerList = new LayerBox(iLayerTools, "layer list box");
693
 
  iLayerList->setSelectionMode(QListBox::Multi);
694
 
  iLayerList->setFocusPolicy(NoFocus);
695
 
  QToolTip::add(iLayerList, tr("Layers of this page"));
696
 
  QWhatsThis::add(iLayerList, tr(layerListText));
697
 
 
698
 
  QLabel *penguins = new QLabel(iLayerTools);
699
 
  penguins->setPixmap(penguinIcon(iLayerList->sizeHint().width()));
700
 
  QWhatsThis::add(penguins, tr(penguinText));
701
 
 
702
 
  iLayerTools->setStretchableWidget(iLayerList);
703
 
  iBookmarkTools->setStretchableWidget(iBookmarks);
704
 
  iBookmarks->setMinimumWidth(iLayerList->sizeHint().width());
705
 
 
706
 
  iMouse = new QLabel(statusBar());
707
 
  statusBar()->addWidget(iMouse, 0, true);
708
 
 
709
412
  // --------------------------------------------------------------------
710
413
  // Object creators tool bar
711
414
  // --------------------------------------------------------------------
712
415
 
713
 
  iObjectTools = new QToolBar(this, "mode tools");
714
 
  iObjectTools->setLabel(tr("Mode tools"));
715
 
 
716
416
  iModeActionGroup = new QActionGroup(this);
717
 
  connect(iModeActionGroup, SIGNAL(selected(QAction*)),
 
417
  connect(iModeActionGroup, SIGNAL(triggered(QAction*)),
718
418
          SLOT(SetCreator(QAction*)));
719
419
 
720
420
  for (int i = 0; i < IpeOverlayFactory::Num; ++i) {
721
421
    QPixmap icon = ipeIcon(IpeOverlayFactory::PixmapName(i));
722
422
    iModeAction[i] = new QAction(iModeActionGroup);
723
423
    iModeAction[i]->setText(IpeOverlayFactory::Tooltip(i));
724
 
    iModeAction[i]->setIconSet(icon);
725
 
    iModeAction[i]->setWhatsThis(tr(IpeOverlayFactory::WhatsThis(i)));
726
 
    iModeAction[i]->setAccel(Key(IpeOverlayFactory::Shortcut(i),
727
 
                                 IpeOverlayFactory::Context(i)));
728
 
    iModeAction[i]->setToggleAction(true);
729
 
    iModeAction[i]->addTo(iObjectTools);
 
424
    iModeAction[i]->setIcon(icon);
 
425
    iModeAction[i]->setWhatsThis(IpeOverlayFactory::WhatsThis(i));
 
426
    iModeAction[i]->setShortcut(Key(IpeOverlayFactory::Context(i)));
 
427
    iModeAction[i]->setCheckable(true);
 
428
    iObjectTools->addAction(iModeAction[i]);
730
429
    if (i == 4)
731
430
      iObjectTools->addSeparator();
732
431
  }
733
 
 
734
 
  // ------------------------------------------------------------
735
 
  // Menu
736
 
  // ------------------------------------------------------------
737
 
 
738
 
  QMenuBar* menu = menuBar();
739
 
  int id;
740
 
 
741
 
  iFileMenu = new QPopupMenu;
742
 
  iFileMenu->insertItem(tr("New &Window"), this, SLOT(NewWindow()),
743
 
                        Key("none", "File|New Window"));
744
 
 
745
 
  id = iFileMenu->insertItem(newIcon, tr("&New"), this, SLOT(NewDoc()),
746
 
                             Key("Ctrl+N", "File|New"));
747
 
  iFileMenu->setWhatsThis(id, fileNewText );
748
 
 
749
 
  id = iFileMenu->insertItem(openIcon, tr("&Open"),
750
 
                             this, SLOT(Load()),
751
 
                             Key("Ctrl+O", "File|Open"));
752
 
  iFileMenu->setWhatsThis(id, fileOpenText );
753
 
 
754
 
  id = iFileMenu->insertItem(saveIcon, tr("&Save"), this, SLOT(Save()),
755
 
                             Key("Ctrl+S", "File|Save"));
756
 
  iFileMenu->setWhatsThis(id, fileSaveText );
757
 
 
758
 
  id = iFileMenu->insertItem(tr("Save &as..."), this, SLOT(SaveAs()),
759
 
                             Key("none", "File|Save as"));
760
 
  iFileMenu->setWhatsThis(id, fileSaveText );
761
 
 
762
 
  iFileMenu->insertItem(tr("Save as &bitmap"), this, SLOT(SaveAsBitmap()),
763
 
                        Key("none", "File|Save as bitmap"));
764
 
  iFileMenu->insertSeparator();
765
 
 
766
 
  iFileMenu->insertItem(tr("Run &Latex"), this, SLOT(RunLatex(int)),
767
 
                        Key("Ctrl+L", "File|Run Latex"), 1);
768
 
  iFileMenu->insertSeparator();
769
 
 
770
 
  iFileMenu->insertItem(tr("&Close"), this, SLOT(close()),
771
 
                        Key("Ctrl+Q", "File|Close"));
772
 
  iFileMenu->insertItem(tr("E&xit"), qApp, SLOT(closeAllWindows()),
773
 
                        Key("none", "File|Exit"));
774
 
  menu->insertItem(tr("&File"), iFileMenu);
775
 
 
776
 
  iEditMenu = new QPopupMenu;
777
 
  iEditMenu->insertItem(tr("&Absolute attributes"),
778
 
                        this, SLOT(AbsoluteAttributes()),
779
 
                        Key("Ctrl+T", "Edit|Absolute attributes"),
780
 
                        EAbsoluteAttributesMenuId);
781
 
  iEditMenu->insertSeparator();
782
 
  iEditMenu->insertItem(undoIcon, tr("&Undo"),
783
 
                        this, SLOT(UndoCmd(int)),
784
 
                        Key("Ctrl+Z", "Edit|Undo"), ECmdUndo);
785
 
  iEditMenu->insertItem(redoIcon, tr("&Redo"),
786
 
                        this, SLOT(UndoCmd(int)),
787
 
                        Key("Ctrl+Y", "Edit|Redo"), ECmdRedo);
788
 
  iEditMenu->insertSeparator();
789
 
  iEditMenu->insertItem(cutIcon, tr("Cu&t"),
790
 
                        this, SLOT(Cmd(int)),
791
 
                        Key("Ctrl+X", "Edit|Cut"), ECmdCut);
792
 
  iEditMenu->insertItem(copyIcon, tr("&Copy"),
793
 
                        this, SLOT(Cmd(int)),
794
 
                        Key("Ctrl+C", "Edit|Copy"), ECmdCopy);
795
 
  iEditMenu->insertItem(pasteIcon, tr("&Paste"),
796
 
                        this, SLOT(Cmd(int)),
797
 
                        Key("Ctrl+V", "Edit|Paste"), ECmdPaste);
798
 
  iEditMenu->insertItem(tr("&Delete"),
799
 
                        this, SLOT(Cmd(int)),
800
 
                        Key("Del", "Edit|Delete"), ECmdDelete);
801
 
  iEditMenu->insertSeparator();
802
 
  iEditMenu->insertItem(tr("&Group"), this, SLOT(Cmd(int)),
803
 
                        Key("Ctrl+G", "Edit|Group"), ECmdGroup);
804
 
  iEditMenu->insertItem(tr("&Ungroup"), this, SLOT(Cmd(int)),
805
 
                        Key("Ctrl+U", "Edit|Ungroup"), ECmdUngroup);
806
 
  iEditMenu->insertItem(tr("&Front"), this, SLOT(Cmd(int)),
807
 
                        Key("Ctrl+F", "Edit|Front"), ECmdFront);
808
 
  iEditMenu->insertItem(tr("&Back"), this, SLOT(Cmd(int)),
809
 
                        Key("Ctrl+B", "Edit|Back"), ECmdBack);
810
 
  iEditMenu->insertItem(tr("&Duplicate"),
811
 
                        this, SLOT(Cmd(int)),
812
 
                        Key("d", "Edit|Duplicate"), ECmdDuplicate);
813
 
  iEditMenu->insertItem(tr("Select &all"), this, SLOT(Cmd(int)),
814
 
                        Key("Ctrl+A", "Edit|Select all"), ECmdSelectAll);
815
 
  iEditMenu->insertSeparator();
816
 
  iEditMenu->insertItem(tr("Co&mpose paths"), this, SLOT(Cmd(int)),
817
 
                        Key("none", "Edit|Compose paths"), ECmdComposePaths);
818
 
  iEditMenu->insertItem(tr("&Join paths"), this, SLOT(Cmd(int)),
819
 
                        Key("Ctrl+J", "Edit|Join paths"), ECmdJoinPaths);
820
 
  //iEditMenu->insertItem(tr("Dec&ompose path"), this, SLOT(Cmd(int)),
821
 
  //Key_O, ECmdDecomposePath);
822
 
  iEditMenu->insertSeparator();
823
 
  iEditMenu->insertItem(tr("Insert text box"), this, SLOT(InsertTextBox()),
824
 
                        Key("F10", "Edit|Insert text box"));
825
 
  iEditMenu->insertItem(tr("Insert item box"), this, SLOT(InsertItemBox()),
826
 
                        Key("Shift+F10", "Edit|Insert text box"));
827
 
  iEditMenu->insertItem(tr("Edit object"), this, SLOT(EditObject()),
828
 
                        Key("Ctrl+E", "Edit|Edit"), ECmdEdit);
829
 
  iEditMenu->insertSeparator();
830
 
  iEditMenu->insertItem(tr("D&ocument properties"),
831
 
                        this, SLOT(EditDocProps()),
832
 
                        Key("Ctrl+Shift+P", "Edit|Document properties"));
833
 
  iEditMenu->insertItem(tr("St&yle sheets"), this, SLOT(StyleSheets()),
834
 
                        Key("Ctrl+Shift+S", "Edit|Style sheets"));
835
 
  connect(iEditMenu, SIGNAL(aboutToShow()),
836
 
          this, SLOT(AboutToShowEditMenu()));
837
 
  menu->insertItem(tr("&Edit"), iEditMenu);
838
 
 
839
 
  iModeMenu = new QPopupMenu;
 
432
  iModeActionGroup->setExclusive(true);
 
433
 
 
434
  // --------------------------------------------------------------------
 
435
  // Properties window
 
436
  // --------------------------------------------------------------------
 
437
 
 
438
  QWidget *prop = new QWidget;
 
439
  QGridLayout *layout = new QGridLayout(prop);
 
440
  prop->setLayout(layout);
 
441
 
 
442
  iStrokeColorStack = new QStackedWidget();
 
443
  iStrokeColorStack->setToolTip(tr("Stroke color"));
 
444
  iStrokeColorStack->setWhatsThis(tr(strokeColorText));
 
445
  iStrokeColor = new QComboBox();
 
446
  connect(iStrokeColor, SIGNAL(activated(int)),
 
447
          SLOT(SetStrokeColorName(int)));
 
448
  iAbsStrokeColor = new QPushButton();
 
449
  // iStrokeColorStack->setMaximumHeight(iStrokeColor->sizeHint().height());
 
450
  connect(iAbsStrokeColor, SIGNAL(clicked()),
 
451
          this, SLOT(SetStrokeColor()));
 
452
  iStrokeColor->installEventFilter(this);
 
453
  iAbsStrokeColor->installEventFilter(this);
 
454
  iStrokeColorStack->addWidget(iStrokeColor);
 
455
  iStrokeColorStack->addWidget(iAbsStrokeColor);
 
456
 
 
457
  iFillColorStack = new QStackedWidget();
 
458
  iFillColorStack->setToolTip(tr("Fill color"));
 
459
  iFillColorStack->setWhatsThis(tr(fillColorText));
 
460
  iFillColor = new QComboBox();
 
461
  connect(iFillColor, SIGNAL(activated(int)),
 
462
          SLOT(SetFillColorName(int)));
 
463
  iAbsFillColor = new QPushButton();
 
464
  // iFillColorStack->setMaximumHeight(iFillColor->sizeHint().height());
 
465
  connect(iAbsFillColor, SIGNAL(clicked()),
 
466
          this, SLOT(SetFillColor()));
 
467
  iFillColor->installEventFilter(this);
 
468
  iAbsFillColor->installEventFilter(this);
 
469
  iFillColorStack->addWidget(iFillColor);
 
470
  iFillColorStack->addWidget(iAbsFillColor);
 
471
 
 
472
  layout->addWidget(iStrokeColorStack, 0, 0);
 
473
  layout->addWidget(iFillColorStack, 0, 1);
 
474
  layout->setRowMinimumHeight(0, iStrokeColor->sizeHint().height());
 
475
 
 
476
  // --------------------------------------------------------------------
 
477
 
 
478
  iLineWidthStack = new QStackedWidget();
 
479
  iLineWidthStack->setToolTip(tr("Line width"));
 
480
  iLineWidthStack->setWhatsThis(tr(lineWidthText));
 
481
  iLineWidth = new QComboBox();
 
482
  connect(iLineWidth, SIGNAL(activated(int)),
 
483
          SLOT(LineWidthChanged(int)));
 
484
  iAbsLineWidth = new DecimalSpinBox(0, 10000, 200);
 
485
  connect(iAbsLineWidth, SIGNAL(valueChanged(int)),
 
486
          SLOT(AbsLineWidthChanged(int)));
 
487
  iLineWidth->installEventFilter(this);
 
488
  iAbsLineWidth->installEventFilter(this);
 
489
  iLineWidthStack->addWidget(iLineWidth);
 
490
  iLineWidthStack->addWidget(iAbsLineWidth);
 
491
 
 
492
  iDashStyle = new QComboBox();
 
493
  iDashStyle->setToolTip(tr("Line dash pattern"));
 
494
  iDashStyle->setWhatsThis(tr(lineDashText));
 
495
  connect(iDashStyle, SIGNAL(activated(int)),
 
496
          SLOT(DashStyleChanged(int)));
 
497
  iDashStyle->installEventFilter(this);
 
498
 
 
499
  iArrowSizeStack = new QStackedWidget();
 
500
  iArrowSizeStack->setToolTip(tr("Arrow size"));
 
501
  iArrowSizeStack->setWhatsThis(tr(arrowSizeText));
 
502
  iArrowSize = new QComboBox();
 
503
  connect(iArrowSize, SIGNAL(activated(int)),
 
504
          SLOT(ArrowSizeChanged(int)));
 
505
  iAbsArrowSize = new DecimalSpinBox(200, 100000, 1000);
 
506
  connect(iAbsArrowSize, SIGNAL(valueChanged(int)),
 
507
          SLOT(AbsArrowSizeChanged(int)));
 
508
  iArrowSize->installEventFilter(this);
 
509
  iAbsArrowSize->installEventFilter(this);
 
510
  iArrowSizeStack->addWidget(iArrowSize);
 
511
  iArrowSizeStack->addWidget(iAbsArrowSize);
 
512
 
 
513
  QPixmap arrowIconRight = ipeIcon("arrowRight");
 
514
  QPixmap arrowIconLeft = ipeIcon("arrowLeft");
 
515
  QPixmap arrowIconMid = ipeIcon("arrowMid");
 
516
 
 
517
  iBackwardArrow = new ArrowButton();
 
518
  iBackwardArrow->setArrow(arrowIconLeft);
 
519
  iBackwardArrow->setToolTip(tr("Backward arrow"));
 
520
  iBackwardArrow->setWhatsThis(tr(arrowText));
 
521
  iBackwardArrow->setFocusPolicy(Qt::NoFocus);
 
522
 
 
523
  QLabel *midArrow = new QLabel();
 
524
  midArrow->setPixmap(arrowIconMid);
 
525
  midArrow->setAlignment(Qt::AlignCenter);
 
526
 
 
527
  iForwardArrow = new ArrowButton();
 
528
  iForwardArrow->setArrow(arrowIconRight);
 
529
  iForwardArrow->setToolTip(tr("Forward arrow"));
 
530
  iForwardArrow->setWhatsThis(tr(arrowText));
 
531
  iForwardArrow->setFocusPolicy(Qt::NoFocus);
 
532
 
 
533
  connect(iBackwardArrow, SIGNAL(toggled(bool)),
 
534
          this, SLOT(ArrowChanged(bool)));
 
535
  connect(iForwardArrow, SIGNAL(toggled(bool)),
 
536
          this, SLOT(ArrowChanged(bool)));
 
537
 
 
538
  iAttributes.iForwardArrow = false;
 
539
  iAttributes.iBackwardArrow = false;
 
540
 
 
541
  QHBoxLayout *arrowLayout = new QHBoxLayout();
 
542
  arrowLayout->addStretch(100);
 
543
  arrowLayout->addWidget(iBackwardArrow);
 
544
  arrowLayout->addWidget(midArrow);
 
545
  arrowLayout->addWidget(iForwardArrow);
 
546
  arrowLayout->addStretch(100);
 
547
 
 
548
  layout->addWidget(iLineWidthStack, 1, 0);
 
549
  layout->addWidget(iDashStyle, 1, 1);
 
550
  layout->addLayout(arrowLayout, 2, 0);
 
551
  layout->addWidget(iArrowSizeStack, 2, 1);
 
552
 
 
553
  // --------------------------------------------------------------------
 
554
 
 
555
  QPixmap markIcon = ipeIcon("marks");
 
556
 
 
557
  iMarkShape = new QComboBox();
 
558
  iMarkShape->setToolTip(tr("Mark shape"));
 
559
  iMarkShape->setWhatsThis(tr(markShapeText));
 
560
  connect(iMarkShape, SIGNAL(activated(int)), SLOT(MarkShapeChanged(int)));
 
561
  iMarkShape->addItem(markIcon, tr("Circle"));
 
562
  iMarkShape->addItem(markIcon, tr("Disc"));
 
563
  iMarkShape->addItem(markIcon, tr("Box"));
 
564
  iMarkShape->addItem(markIcon, tr("Square"));
 
565
  iMarkShape->addItem(markIcon, tr("Cross"));
 
566
  iMarkShape->setCurrentIndex(1);
 
567
  iAttributes.iMarkShape = iMarkShape->currentIndex() + 1;
 
568
  iMarkShape->installEventFilter(this);
 
569
 
 
570
  iMarkSizeStack = new QStackedWidget();
 
571
  iMarkSizeStack->setToolTip(tr("Mark size"));
 
572
  iMarkSizeStack->setWhatsThis(tr(markSizeText));
 
573
  iMarkSize = new QComboBox();
 
574
  connect(iMarkSize, SIGNAL(activated(int)),
 
575
          SLOT(MarkSizeChanged(int)));
 
576
  iAbsMarkSize = new DecimalSpinBox(200, 100000, 1000);
 
577
  connect(iAbsMarkSize, SIGNAL(valueChanged(int)),
 
578
          SLOT(AbsMarkSizeChanged(int)));
 
579
  iMarkSize->installEventFilter(this);
 
580
  iAbsMarkSize->installEventFilter(this);
 
581
  iMarkSizeStack->addWidget(iMarkSize);
 
582
  iMarkSizeStack->addWidget(iAbsMarkSize);
 
583
 
 
584
  iTextSizeStack = new QStackedWidget();
 
585
  iTextSizeStack->setToolTip(tr("Font size"));
 
586
  iTextSizeStack->setWhatsThis(tr(textSizeText));
 
587
  iTextSize = new QComboBox();
 
588
  connect(iTextSize, SIGNAL(activated(int)),
 
589
          SLOT(TextSizeChanged(int)));
 
590
  iAbsTextSize = new DecimalSpinBox(4000, 50000, 1000);
 
591
  connect(iAbsTextSize, SIGNAL(valueChanged(int)),
 
592
          SLOT(AbsTextSizeChanged(int)));
 
593
  iTextSize->installEventFilter(this);
 
594
  iAbsTextSize->installEventFilter(this);
 
595
  iTextSizeStack->addWidget(iTextSize);
 
596
  iTextSizeStack->addWidget(iAbsTextSize);
 
597
 
 
598
  layout->addWidget(iMarkShape, 3, 0);
 
599
  layout->addWidget(iMarkSizeStack, 3, 1);
 
600
  layout->addWidget(iTextSizeStack, 4, 0);
 
601
 
 
602
  QToolButton *ab = new QToolButton();
 
603
  ab->setFocusPolicy(Qt::NoFocus);
 
604
  connect(ab, SIGNAL(clicked()),
 
605
          this, SLOT(ToggleAbsoluteAttributes()));
 
606
 
 
607
  QHBoxLayout *abLayout = new QHBoxLayout();
 
608
  abLayout->addStretch(100);
 
609
  abLayout->addWidget(ab);
 
610
 
 
611
  layout->addLayout(abLayout, 4, 1);
 
612
 
 
613
  layout->setRowStretch(5, 1);
 
614
 
 
615
  iPropertiesTools->setWidget(prop);
 
616
 
 
617
  // ------------------------------------------------------------
 
618
  // Bookmark and layer windows
 
619
  // ------------------------------------------------------------
 
620
 
 
621
  iBookmarks = new QListWidget();
 
622
  iBookmarks->setToolTip(tr("Bookmarks of this document"));
 
623
  iBookmarks->setFocusPolicy(Qt::NoFocus);
 
624
  connect(iBookmarks, SIGNAL(itemActivated(QListWidgetItem *)),
 
625
          this, SLOT(BookmarkSelected(QListWidgetItem *)));
 
626
  iBookmarkTools->setWidget(iBookmarks);
 
627
 
 
628
  iLayerList = new LayerBox();
 
629
  iLayerList->setFocusPolicy(Qt::NoFocus);
 
630
  iLayerList->setToolTip(tr("Layers of this page"));
 
631
  iLayerList->setWhatsThis(tr(layerListText));
 
632
  iLayerTools->setWidget(iLayerList);
 
633
 
 
634
  // QLabel *penguins = new QLabel();
 
635
  // penguins->setPixmap(penguinIcon(iLayerList->sizeHint().width()));
 
636
  // penguins->setWhatsThis(tr(penguinText));
 
637
 
 
638
  // ------------------------------------------------------------
 
639
  // File menu
 
640
  // ------------------------------------------------------------
 
641
 
 
642
  QAction *newWinAct = new QAction(tr("New &Window"), this);
 
643
  newWinAct->setShortcut(Key("File|New Window"));
 
644
  connect(newWinAct, SIGNAL(triggered()), SLOT(NewWindow()));
 
645
 
 
646
  QAction *saveAsAct = new QAction(tr("Save &as..."), this);
 
647
  saveAsAct->setShortcut(Key("File|Save as"));
 
648
  saveAsAct->setWhatsThis(tr(fileSaveText));
 
649
  connect(saveAsAct, SIGNAL(triggered()), SLOT(SaveAs()));
 
650
 
 
651
  QAction *saveAsBitmapAct = new QAction(tr("Save as &bitmap"), this);
 
652
  saveAsBitmapAct->setShortcut(Key("File|Save as bitmap"));
 
653
  connect(saveAsBitmapAct, SIGNAL(triggered()), SLOT(SaveAsBitmap()));
 
654
 
 
655
  QAction *runLatexAct = new QAction(tr("Run &Latex"), this);
 
656
  runLatexAct->setShortcut(Key("File|Run Latex"));
 
657
  connect(runLatexAct, SIGNAL(triggered()), SLOT(RunLatex()));
 
658
 
 
659
  QAction *closeAct = new QAction(tr("&Close"), this);
 
660
  closeAct->setShortcut(Key("File|Close"));
 
661
  connect(closeAct, SIGNAL(triggered()), SLOT(close()));
 
662
 
 
663
  QAction *exitAct = new QAction(tr("E&xit"), this);
 
664
  exitAct->setShortcut(Key("File|Exit"));
 
665
  connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
 
666
 
 
667
  iFileMenu->addAction(newWinAct);
 
668
  iFileMenu->addAction(newAct);
 
669
  iFileMenu->addAction(openAct);
 
670
  iFileMenu->addAction(saveAct);
 
671
  iFileMenu->addAction(saveAsAct);
 
672
  iFileMenu->addAction(saveAsBitmapAct);
 
673
  iFileMenu->addSeparator();
 
674
  iFileMenu->addAction(runLatexAct);
 
675
  iFileMenu->addSeparator();
 
676
  iFileMenu->addAction(closeAct);
 
677
  iFileMenu->addAction(exitAct);
 
678
 
 
679
  // ------------------------------------------------------------
 
680
  // Edit menu
 
681
  // ------------------------------------------------------------
 
682
 
 
683
  iAbsoluteAttributesAction = new QAction(tr("&Absolute attributes"), this);
 
684
  iAbsoluteAttributesAction->setShortcut(Key(
 
685
                                             "Edit|Absolute attributes"));
 
686
  iAbsoluteAttributesAction->setCheckable(true);
 
687
  connect(iAbsoluteAttributesAction, SIGNAL(toggled(bool)),
 
688
          SLOT(AbsoluteAttributes(bool)));
 
689
 
 
690
  iUndoAction = new IpeAction(ECmdUndo, undoIcon, tr("&Undo"), this);
 
691
  iUndoAction->setShortcut(Key("Edit|Undo"));
 
692
  connect(iUndoAction, SIGNAL(triggered(int)), SLOT(UndoCmd(int)));
 
693
 
 
694
  iRedoAction = new IpeAction(ECmdRedo, redoIcon, tr("&Redo"), this);
 
695
  iRedoAction->setShortcut(Key("Edit|Redo"));
 
696
  connect(iRedoAction, SIGNAL(triggered(int)), SLOT(UndoCmd(int)));
 
697
 
 
698
  iDeleteAction = new IpeAction(ECmdDelete, tr("&Delete"), this);
 
699
  iDeleteAction->setShortcut(Key("Edit|Delete"));
 
700
  connect(iDeleteAction, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
701
 
 
702
  iGroupAction = new IpeAction(ECmdGroup, tr("&Group"), this);
 
703
  iGroupAction->setShortcut(Key("Edit|Group"));
 
704
  connect(iGroupAction, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
705
 
 
706
  iUngroupAction = new IpeAction(ECmdUngroup, tr("Ungroup"), this);
 
707
  iUngroupAction->setShortcut(Key("Edit|Ungroup"));
 
708
  connect(iUngroupAction, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
709
 
 
710
  iFrontAction = new IpeAction(ECmdFront, tr("&Front"), this);
 
711
  iFrontAction->setShortcut(Key("Edit|Front"));
 
712
  connect(iFrontAction, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
713
 
 
714
  iBackAction = new IpeAction(ECmdBack, tr("&Back"), this);
 
715
  iBackAction->setShortcut(Key("Edit|Back"));
 
716
  connect(iBackAction, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
717
 
 
718
  QAction *forwardAction = new IpeAction(ECmdForward, tr("Forward"), this);
 
719
  forwardAction->setShortcut(Key("Edit|Forward"));
 
720
  connect(forwardAction, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
721
 
 
722
  QAction *backwardAction = new IpeAction(ECmdBackward, tr("Backward"), this);
 
723
  backwardAction->setShortcut(Key("Edit|Backward"));
 
724
  connect(backwardAction, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
725
 
 
726
  QAction *beforeAction = new IpeAction(ECmdBefore, tr("Just before"), this);
 
727
  beforeAction->setShortcut(Key("Edit|Before"));
 
728
  connect(beforeAction, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
729
 
 
730
  QAction *behindAction = new IpeAction(ECmdBehind, tr("Just behind"), this);
 
731
  behindAction->setShortcut(Key("Edit|Behind"));
 
732
  connect(behindAction, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
733
 
 
734
  iDuplicateAction = new IpeAction(ECmdDuplicate, tr("&Duplicate"), this);
 
735
  iDuplicateAction->setShortcut(Key("Edit|Duplicate"));
 
736
  connect(iDuplicateAction, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
737
 
 
738
  QAction *selectAllAct = new IpeAction(ECmdSelectAll,
 
739
                                        tr("Select &all"), this);
 
740
  selectAllAct->setShortcut(Key("Edit|Select all"));
 
741
  connect(selectAllAct, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
742
 
 
743
  iComposeAction = new IpeAction(ECmdComposePaths, tr("Co&mpose paths"), this);
 
744
  iComposeAction->setShortcut(Key("Edit|Compose paths"));
 
745
  connect(iComposeAction, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
746
 
 
747
  iJoinAction = new IpeAction(ECmdJoinPaths, tr("&Join paths"), this);
 
748
  iJoinAction->setShortcut(Key("Edit|Join paths"));
 
749
  connect(iJoinAction, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
750
 
 
751
  QAction *insertTextBoxAct = new QAction(tr("Insert text box"), this);
 
752
  insertTextBoxAct->setShortcut(Key("Edit|Insert text box"));
 
753
  connect(insertTextBoxAct, SIGNAL(triggered()), SLOT(InsertTextBox()));
 
754
 
 
755
  QAction *editObjectAct = new QAction(tr("Edit object"), this);
 
756
  editObjectAct->setShortcut(Key("Edit|Edit"));
 
757
  connect(editObjectAct, SIGNAL(triggered()), SLOT(EditObject()));
 
758
 
 
759
  QAction *docPropsAct = new QAction(tr("D&ocument properties"), this);
 
760
  docPropsAct->setShortcut(Key("Edit|Document properties"));
 
761
  connect(docPropsAct, SIGNAL(triggered()), SLOT(EditDocProps()));
 
762
 
 
763
  QAction *styleSheetsAct = new QAction(tr("St&yle sheets"), this);
 
764
  styleSheetsAct->setShortcut(Key("Edit|Style sheets"));
 
765
  connect(styleSheetsAct, SIGNAL(triggered()), SLOT(StyleSheets()));
 
766
 
 
767
  QAction *updateStylesAct = new QAction(tr("Update style sheets"), this);
 
768
  updateStylesAct->setShortcut(Key("Edit|Update style sheets"));
 
769
  connect(updateStylesAct, SIGNAL(triggered()), SLOT(UpdateStyleSheets()));
 
770
 
 
771
  iEditMenu->addAction(iAbsoluteAttributesAction);
 
772
  iEditMenu->addSeparator();
 
773
  iEditMenu->addAction(iUndoAction);
 
774
  iEditMenu->addAction(iRedoAction);
 
775
  iEditMenu->addSeparator();
 
776
  iEditMenu->addAction(iCutAction);
 
777
  iEditMenu->addAction(iCopyAction);
 
778
  iEditMenu->addAction(pasteAct);
 
779
  iEditMenu->addAction(iDeleteAction);
 
780
  iEditMenu->addSeparator();
 
781
  iEditMenu->addAction(iGroupAction);
 
782
  iEditMenu->addAction(iUngroupAction);
 
783
  iEditMenu->addAction(iFrontAction);
 
784
  iEditMenu->addAction(iBackAction);
 
785
  iEditMenu->addAction(forwardAction);
 
786
  iEditMenu->addAction(backwardAction);
 
787
  iEditMenu->addAction(beforeAction);
 
788
  iEditMenu->addAction(behindAction);
 
789
  iEditMenu->addAction(iDuplicateAction);
 
790
  iEditMenu->addAction(selectAllAct);
 
791
  iEditMenu->addSeparator();
 
792
  iEditMenu->addAction(iComposeAction);
 
793
  iEditMenu->addAction(iJoinAction);
 
794
  iEditMenu->addSeparator();
 
795
  iEditMenu->addAction(insertTextBoxAct);
 
796
  iEditMenu->addAction(editObjectAct);
 
797
  iEditMenu->addSeparator();
 
798
  iEditMenu->addAction(docPropsAct);
 
799
  iEditMenu->addAction(styleSheetsAct);
 
800
  iEditMenu->addAction(updateStylesAct);
 
801
 
 
802
  connect(iEditMenu, SIGNAL(aboutToShow()), SLOT(AboutToShowEditMenu()));
 
803
 
 
804
  // --------------------------------------------------------------------
 
805
  // Object (Mode) menu
 
806
  // --------------------------------------------------------------------
 
807
 
840
808
  for (int i = 0; i < IpeOverlayFactory::Num; ++i)
841
 
    iModeAction[i]->addTo(iModeMenu);
842
 
 
843
 
  menu->insertItem(tr("&Mode"), iModeMenu);
844
 
 
845
 
  iSnapMenu = new QPopupMenu;
846
 
  iSnapMenu->insertItem(tr("&Absolute grid/angle size"),
847
 
                        this, SLOT(AbsoluteSnapping()),
848
 
                        Key("Ctrl+Shift+T", "Snap|Absolute"),
849
 
                        EAbsoluteSnappingMenuId);
850
 
  iSnapMenu->insertSeparator();
851
 
  iSnapActionGroup->addTo(iSnapMenu);
852
 
  iSnapMenu->insertSeparator();
853
 
  iSnapMenu->insertItem(tr("Set origin"), this,
854
 
                        SLOT(SnapCmd(int)),
855
 
                        Key("F1", "Snap|Set origin"), ECmdSetOrigin);
856
 
  iSnapMenu->insertItem(tr("Set origin && snap"), this,
857
 
                        SLOT(SnapCmd(int)),
858
 
                        Key("none", "Snap|Set origin & snap"),
859
 
                        ECmdSetOriginSnap);
860
 
  iSnapMenu->insertItem(tr("Hide axes"), this,
861
 
                        SLOT(SnapCmd(int)),
862
 
                        Key("Shift+F1", "Snap|Hide axes"), ECmdResetOrigin);
863
 
  iSnapMenu->insertItem(tr("Set direction"), this,
864
 
                        SLOT(SnapCmd(int)),
865
 
                        Key("F2", "Snap|Set direction"), ECmdSetDirection);
866
 
  iSnapMenu->insertItem(tr("Set line"), this,
867
 
                        SLOT(SnapCmd(int)),
868
 
                        Key("F3", "Snap|Set line"), ECmdSetLine);
869
 
  iSnapMenu->insertItem(tr("Set line && snap"), this,
870
 
                        SLOT(SnapCmd(int)),
871
 
                        Key("Shift+F3", "Snap|Set line & snap"),
872
 
                        ECmdSetLineSnap);
873
 
  menu->insertItem(tr("&Snap"), iSnapMenu, ESnapMenuId);
874
 
 
875
 
  iZoomMenu = new QPopupMenu;
876
 
  iZoomMenu->insertItem(tr("&Grid visible"),
877
 
                        this, SLOT(GridVisible()),
878
 
                        Key("F12", "Zoom|Grid"),
879
 
                        EGridVisibleMenuId);
880
 
  iZoomMenu->insertItem(tr("&Coordinates visible"),
881
 
                        this, SLOT(CoordinatesVisible()),
882
 
                        Key("Shift+F12", "Zoom|Coordinates"),
883
 
                        ECoordinatesVisibleMenuId);
884
 
  iZoomMenu->insertSeparator();
885
 
  iZoomMenu->insertItem(tr("Zoom &in"), iResolution, SLOT(stepUp()),
886
 
                        Key("Ctrl+PgUp", "Zoom|Zoom in"));
887
 
  iZoomMenu->insertItem(tr("Zoom &out"), iResolution, SLOT(stepDown()),
888
 
                        Key("Ctrl+PgDown", "Zoom|Zoom out"));
889
 
  iZoomMenu->insertItem(tr("&Normal size"), this, SLOT(NormalSize()),
890
 
                        Key("/", "Zoom|Normal size"));
891
 
  iZoomMenu->insertItem(tr("Fit &page"), this, SLOT(FitPage()),
892
 
                        Key("\\", "Zoom|Fit page"));
893
 
  iZoomMenu->insertItem(tr("&Fit objects"),
894
 
                        this, SLOT(FitObjects()),
895
 
                        Key("=", "Zoom|Fit objects"));
896
 
  iZoomMenu->insertItem(tr("Fit &selection"),
897
 
                        this, SLOT(FitSelection()),
898
 
                        Key("F11", "Zoom|Fit selection"));
899
 
  iZoomMenu->insertSeparator();
900
 
  iZoomMenu->insertItem(tr("Pan &here"), this,
901
 
                        SLOT(SnapCmd(int)),
902
 
                        Key("x", "view|Pan here"), ECmdHere);
903
 
  menu->insertItem(tr("&Zoom"), iZoomMenu, EZoomMenuId);
904
 
 
905
 
  iLayerMenu = new QPopupMenu;
906
 
  iLayerMenu->insertItem(tr("&New layer"), this, SLOT(Cmd(int)),
907
 
                         Key("Ctrl+Shift+N", "Layers|New"),
908
 
                         ECmdNewLayer);
909
 
  iLayerMenu->insertItem(tr("&Rename layer"), this, SLOT(Cmd(int)),
910
 
                         Key("Ctrl+Shift+R", "Layers|Rename"),
911
 
                         ECmdRenameLayer);
912
 
  iLayerMenu->insertSeparator();
913
 
  iLayerMenu->insertItem(tr("&Select all in layer"),
914
 
                         this, SLOT(Cmd(int)),
915
 
                         Key("Ctrl+Shift+A", "Layers|Select all"),
916
 
                         ECmdSelectLayer);
917
 
  iLayerMenu->insertItem(tr("&Move objects to layer"),
918
 
                         this, SLOT(Cmd(int)),
919
 
                         Key("Ctrl+Shift+M", "Layers|Move objects"),
920
 
                         ECmdMoveToLayer);
921
 
  menu->insertItem(tr("&Layers"), iLayerMenu);
922
 
 
923
 
  iViewMenu = new QPopupMenu;
924
 
  iViewMenu->insertItem(tr("Next vie&w"), this, SLOT(NextView()),
925
 
                        Key("PgDown", "Views|Next view"));
926
 
  iViewMenu->insertItem(tr("&Previous view"), this, SLOT(PreviousView()),
927
 
                        Key("PgUp", "Views|Previous view"));
928
 
  iViewMenu->insertItem(tr("&First view"), this, SLOT(Cmd(int)),
929
 
                        Key("Home", "Views|First view"),
930
 
                        ECmdFirstView);
931
 
  iViewMenu->insertItem(tr("&Last view"), this, SLOT(Cmd(int)),
932
 
                        Key("End", "Views|Last view"),
933
 
                        ECmdLastView);
934
 
  iViewMenu->insertSeparator();
935
 
  iViewMenu->insertItem(tr("&New layer, new view"), this, SLOT(Cmd(int)),
936
 
                        Key("Ctrl+Shift+I", "Views|New layer, new view"),
937
 
                        ECmdNewLayerNewView);
938
 
  iViewMenu->insertItem(tr("New &view"), this, SLOT(Cmd(int)),
939
 
                        Key("none", "Views|New view"),
940
 
                        ECmdNewView);
941
 
  iViewMenu->insertItem(tr("&Delete view"), this, SLOT(Cmd(int)),
942
 
                        Key("none", "Views|Delete view"),
943
 
                        ECmdDeleteView);
944
 
  iViewMenu->insertSeparator();
945
 
  iViewMenu->insertItem(tr("&Edit views"), this,
946
 
                        SLOT(EditViews()),
947
 
                        Key("Ctrl+P", "Views|Edit views"));
948
 
  menu->insertItem(tr("&Views"), iViewMenu);
949
 
 
950
 
  iPageMenu = new QPopupMenu;
951
 
  iPageMenu->insertItem(tr("&Next page"), iPageNumber, SLOT(stepUp()),
952
 
                       Key("Shift+PgDown", "Page|Next"));
953
 
  iPageMenu->insertItem(tr("&Previous page"), iPageNumber, SLOT(stepDown()),
954
 
                       Key("Shift+PgUp", "Page|Previous"));
955
 
  iPageMenu->insertItem(tr("&First page"), this, SLOT(FirstPage()),
956
 
                        Key("Shift+Home", "Page|First"));
957
 
  iPageMenu->insertItem(tr("&Last page"), this, SLOT(LastPage()),
958
 
                        Key("Shift+End", "Page|Last"));
959
 
  iPageMenu->insertSeparator();
960
 
  iPageMenu->insertItem(tr("&Insert page"), this, SLOT(CreatePage()),
961
 
                       Key("Ctrl+I", "Page|Insert"));
962
 
  iPageMenu->insertItem(tr("&Cut page"), this, SLOT(CopyPage(int)),
963
 
                       Key("Ctrl+Shift+X", "Page|Cut"), 1);
964
 
  iPageMenu->insertItem(tr("Cop&y page"), this, SLOT(CopyPage(int)),
965
 
                       Key("Ctrl+Shift+C", "Page|Copy"), 0);
966
 
  iPageMenu->insertItem(tr("P&aste page"), this, SLOT(PastePage()),
967
 
                       Key("Ctrl+Shift+V", "Page|Paste"));
968
 
  iPageMenu->insertItem(tr("&Delete page"), this, SLOT(DeletePage()),
969
 
                       Key("none", "Page|Delete"));
970
 
  menu->insertItem(tr("&Pages"), iPageMenu);
971
 
 
972
 
  iIpeletMenu = new QPopupMenu;
973
 
  iPasteBitmapId = 0;
 
809
    iModeMenu->addAction(iModeAction[i]);
 
810
 
 
811
  // --------------------------------------------------------------------
 
812
  // Snap menu
 
813
  // --------------------------------------------------------------------
 
814
 
 
815
  iAbsoluteSnapAction = new QAction(tr("&Absolute grid/angle size"), this);
 
816
  iAbsoluteSnapAction->setShortcut(Key("Snap|Absolute"));
 
817
  iAbsoluteSnapAction->setCheckable(true);
 
818
  connect(iAbsoluteSnapAction, SIGNAL(toggled(bool)),
 
819
          SLOT(AbsoluteSnapping(bool)));
 
820
 
 
821
  QAction *setOriginAct = new IpeAction(ECmdSetOrigin, tr("Set origin"), this);
 
822
  connect(setOriginAct, SIGNAL(triggered(int)), SLOT(SnapCmd(int)));
 
823
  setOriginAct->setShortcut(Key("Snap|Set origin"));
 
824
 
 
825
  QAction *setOriginSnapAct =
 
826
    new IpeAction(ECmdSetOriginSnap, tr("Set origin && snap"), this);
 
827
  setOriginSnapAct->setShortcut(Key("Snap|Set origin & snap"));
 
828
  connect(setOriginSnapAct, SIGNAL(triggered(int)), SLOT(SnapCmd(int)));
 
829
 
 
830
  QAction *hideAxesAct = new IpeAction(ECmdResetOrigin, tr("Hide axes"), this);
 
831
  hideAxesAct->setShortcut(Key("Snap|Hide axes"));
 
832
  connect(hideAxesAct, SIGNAL(triggered(int)), SLOT(SnapCmd(int)));
 
833
 
 
834
  QAction *setDirectionAct =
 
835
    new IpeAction(ECmdSetDirection, tr("Set direction"), this);
 
836
  setDirectionAct->setShortcut(Key("Snap|Set direction"));
 
837
  connect(setDirectionAct, SIGNAL(triggered(int)), SLOT(SnapCmd(int)));
 
838
 
 
839
  QAction *resetDirectionAct =
 
840
    new IpeAction(ECmdResetDirection, tr("Reset direction"), this);
 
841
  resetDirectionAct->setShortcut(Key("Snap|Reset direction"));
 
842
  connect(resetDirectionAct, SIGNAL(triggered(int)), SLOT(SnapCmd(int)));
 
843
 
 
844
  QAction *setLineAct = new IpeAction(ECmdSetLine, tr("Set line"), this);
 
845
  setLineAct->setShortcut(Key("Snap|Set line"));
 
846
  connect(setLineAct, SIGNAL(triggered(int)), SLOT(SnapCmd(int)));
 
847
 
 
848
  QAction *setLineSnapAct =
 
849
    new IpeAction(ECmdSetLineSnap, tr("Set line && snap"), this);
 
850
  setLineSnapAct->setShortcut(Key("Snap|Set line & snap"));
 
851
  connect(setLineSnapAct, SIGNAL(triggered(int)), SLOT(SnapCmd(int)));
 
852
 
 
853
  iSnapMenu->addAction(iAbsoluteSnapAction);
 
854
  iSnapMenu->addSeparator();
 
855
  for (int i = 0; i < 5; ++i)
 
856
    iSnapMenu->addAction(iSnapAction[i]);
 
857
  iSnapMenu->addSeparator();
 
858
  // iSnapMenu->addAction(setOriginAct);
 
859
  iSnapMenu->addAction(setOriginSnapAct);
 
860
  iSnapMenu->addAction(hideAxesAct);
 
861
  iSnapMenu->addAction(setDirectionAct);
 
862
  iSnapMenu->addAction(resetDirectionAct);
 
863
  iSnapMenu->addAction(setLineAct);
 
864
  iSnapMenu->addAction(setLineSnapAct);
 
865
 
 
866
  // --------------------------------------------------------------------
 
867
  // Zoom menu
 
868
  // --------------------------------------------------------------------
 
869
 
 
870
  iGridVisibleAction = new QAction(tr("&Grid visible"), this);
 
871
  iGridVisibleAction->setShortcut(Key("Zoom|Grid"));
 
872
  iGridVisibleAction->setCheckable(true);
 
873
  connect(iGridVisibleAction, SIGNAL(toggled(bool)),
 
874
          SLOT(GridVisible(bool)));
 
875
 
 
876
  iCoordinatesVisibleAction = new QAction(tr("&Coordinates visible"), this);
 
877
  iCoordinatesVisibleAction->setShortcut(Key("Zoom|Coordinates"));
 
878
  iCoordinatesVisibleAction->setCheckable(true);
 
879
  connect(iCoordinatesVisibleAction, SIGNAL(toggled(bool)),
 
880
          SLOT(CoordinatesVisible(bool)));
 
881
 
 
882
  QAction *mouseIn[3];
 
883
  mouseIn[0] = new IpeAction(0, tr("points"), this);
 
884
  mouseIn[1] = new IpeAction(1, tr("millimeters"), this);
 
885
  mouseIn[2] = new IpeAction(2, tr("inches"), this);
 
886
  QMenu *sub = new QMenu();
 
887
  for (int i = 0; i < 3; ++i) {
 
888
    connect(mouseIn[i], SIGNAL(triggered(int)), SLOT(SetMouseDisplayIn(int)));
 
889
    sub->addAction(mouseIn[i]);
 
890
  }
 
891
  sub->setTitle(QLatin1String("Coordinates in"));
 
892
 
 
893
  QAction *zoomInAct = new QAction(tr("Zoom &in"), this);
 
894
  zoomInAct->setShortcut(Key("Zoom|Zoom in"));
 
895
  connect(zoomInAct, SIGNAL(triggered()), iResolution, SLOT(stepUp()));
 
896
 
 
897
  QAction *zoomOutAct = new QAction(tr("Zoom &out"), this);
 
898
  zoomOutAct->setShortcut(Key("Zoom|Zoom out"));
 
899
  connect(zoomOutAct, SIGNAL(triggered()), iResolution, SLOT(stepDown()));
 
900
 
 
901
  QAction *fitPageAct = new QAction(tr("Fit &page"), this);
 
902
  fitPageAct->setShortcut(Key("Zoom|Fit page"));
 
903
  connect(fitPageAct, SIGNAL(triggered()), SLOT(FitPage()));
 
904
 
 
905
  QAction *fitObjectsAct = new QAction(tr("&Fit objects"), this);
 
906
  fitObjectsAct->setShortcut(Key("Zoom|Fit objects"));
 
907
  connect(fitObjectsAct, SIGNAL(triggered()), SLOT(FitObjects()));
 
908
 
 
909
  QAction *fitSelectionAct = new QAction(tr("Fit &selection"), this);
 
910
  fitSelectionAct->setShortcut(Key("Zoom|Fit selection"));
 
911
  connect(fitSelectionAct, SIGNAL(triggered()), SLOT(FitSelection()));
 
912
 
 
913
  QAction *panHereAct = new IpeAction(ECmdHere, tr("Pan &here"), this);
 
914
  panHereAct->setShortcut(Key("Snap|Pan here"));
 
915
  connect(panHereAct, SIGNAL(triggered(int)), SLOT(SnapCmd(int)));
 
916
 
 
917
  iZoomMenu->addAction(iGridVisibleAction);
 
918
  iZoomMenu->addAction(iCoordinatesVisibleAction);
 
919
  iZoomMenu->addMenu(sub);
 
920
  iZoomMenu->addSeparator();
 
921
  iZoomMenu->addAction(zoomInAct);
 
922
  iZoomMenu->addAction(zoomOutAct);
 
923
  iZoomMenu->addAction(normalSizeAct);
 
924
  iZoomMenu->addAction(fitPageAct);
 
925
  iZoomMenu->addAction(fitObjectsAct);
 
926
  iZoomMenu->addAction(fitSelectionAct);
 
927
  iZoomMenu->addSeparator();
 
928
  iZoomMenu->addAction(panHereAct);
 
929
 
 
930
  // --------------------------------------------------------------------
 
931
  // Layer menu
 
932
  // --------------------------------------------------------------------
 
933
 
 
934
  QAction *newLayerAct = new IpeAction(ECmdNewLayer, tr("&New layer"), this);
 
935
  newLayerAct->setShortcut(Key("Layer|New"));
 
936
  connect(newLayerAct, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
937
 
 
938
  QAction *renameLayerAct =
 
939
    new IpeAction(ECmdRenameLayer, tr("&Rename layer"), this);
 
940
  renameLayerAct->setShortcut(Key("Layer|Rename"));
 
941
  connect(renameLayerAct, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
942
 
 
943
  QAction *selectLayerAct =
 
944
    new IpeAction(ECmdSelectLayer, tr("&Select all in layer"), this);
 
945
  selectLayerAct->setShortcut(Key("Layer|Select all"));
 
946
  connect(selectLayerAct, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
947
 
 
948
  QAction *moveToLayerAct =
 
949
    new IpeAction(ECmdMoveToLayer, tr("&Move objects to layer"), this);
 
950
  moveToLayerAct->setShortcut(Key("Layer|Move objects"));
 
951
  connect(moveToLayerAct, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
952
 
 
953
  iLayerMenu->addAction(newLayerAct);
 
954
  iLayerMenu->addAction(renameLayerAct);
 
955
  iLayerMenu->addSeparator();
 
956
  iLayerMenu->addAction(selectLayerAct);
 
957
  iLayerMenu->addAction(moveToLayerAct);
 
958
 
 
959
  // --------------------------------------------------------------------
 
960
  // View menu
 
961
  // --------------------------------------------------------------------
 
962
 
 
963
  QAction *nextViewAct = new QAction(tr("Next vie&w"), this);
 
964
  nextViewAct->setShortcut(Key("View|Next view"));
 
965
  connect(nextViewAct, SIGNAL(triggered()), SLOT(NextView()));
 
966
 
 
967
  QAction *previousViewAct = new QAction(tr("&Previous view"), this);
 
968
  previousViewAct->setShortcut(Key("View|Previous view"));
 
969
  connect(previousViewAct, SIGNAL(triggered()), SLOT(PreviousView()));
 
970
 
 
971
  QAction *firstViewAct =
 
972
    new IpeAction(ECmdFirstView, tr("&First view"), this);
 
973
  firstViewAct->setShortcut(Key("View|First view"));
 
974
  connect(firstViewAct, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
975
 
 
976
  QAction *lastViewAct =
 
977
    new IpeAction(ECmdLastView, tr("&Last view"), this);
 
978
  lastViewAct->setShortcut(Key("View|Last view"));
 
979
  connect(lastViewAct, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
980
 
 
981
  QAction *newLayerNewViewAct =
 
982
    new IpeAction(ECmdNewLayerNewView, tr("&New layer, new view"), this);
 
983
  newLayerNewViewAct->setShortcut(Key("View|New layer, new view"));
 
984
  connect(newLayerNewViewAct, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
985
 
 
986
  QAction *newViewAct = new IpeAction(ECmdNewView, tr("New &view"), this);
 
987
  newViewAct->setShortcut(Key("View|New view"));
 
988
  connect(newViewAct, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
989
 
 
990
  QAction *deleteViewAct =
 
991
    new IpeAction(ECmdDeleteView, tr("&Delete view"), this);
 
992
  deleteViewAct->setShortcut(Key("View|Delete view"));
 
993
  connect(deleteViewAct, SIGNAL(triggered(int)), SLOT(Cmd(int)));
 
994
 
 
995
  QAction *editEffectsAct = new QAction(tr("&Edit effects"), this);
 
996
  editEffectsAct->setShortcut(Key("View|Edit effects"));
 
997
  connect(editEffectsAct, SIGNAL(triggered()), SLOT(EditEffects()));
 
998
 
 
999
  iViewMenu->addAction(nextViewAct);
 
1000
  iViewMenu->addAction(previousViewAct);
 
1001
  iViewMenu->addAction(firstViewAct);
 
1002
  iViewMenu->addAction(lastViewAct);
 
1003
  iViewMenu->addSeparator();
 
1004
  iViewMenu->addAction(newLayerNewViewAct);
 
1005
  iViewMenu->addAction(newViewAct);
 
1006
  iViewMenu->addAction(deleteViewAct);
 
1007
  iViewMenu->addSeparator();
 
1008
  iViewMenu->addAction(editEffectsAct);
 
1009
 
 
1010
  // --------------------------------------------------------------------
 
1011
  // Page menu
 
1012
  // --------------------------------------------------------------------
 
1013
 
 
1014
  QAction *nextPageAct = new QAction(tr("&Next page"), this);
 
1015
  connect(nextPageAct, SIGNAL(triggered()), iPageNumber, SLOT(stepUp()));
 
1016
  nextPageAct->setShortcut(Key("Page|Next page"));
 
1017
 
 
1018
  QAction *previousPageAct = new QAction(tr("&Previous page"), this);
 
1019
  connect(previousPageAct, SIGNAL(triggered()), iPageNumber, SLOT(stepDown()));
 
1020
  previousPageAct->setShortcut(Key("Page|Previous page"));
 
1021
 
 
1022
  QAction *firstPageAct = new QAction(tr("&First page"), this);
 
1023
  connect(firstPageAct, SIGNAL(triggered()), SLOT(FirstPage()));
 
1024
  firstPageAct->setShortcut(Key("Page|First page"));
 
1025
 
 
1026
  QAction *lastPageAct = new QAction(tr("&Last page"), this);
 
1027
  connect(lastPageAct, SIGNAL(triggered()), SLOT(LastPage()));
 
1028
  lastPageAct->setShortcut(Key("Page|Last page"));
 
1029
 
 
1030
  QAction *insertPageAct = new QAction(tr("&Insert page"), this);
 
1031
  connect(insertPageAct, SIGNAL(triggered()), SLOT(CreatePage()));
 
1032
  insertPageAct->setShortcut(Key("Page|Insert page"));
 
1033
 
 
1034
  QAction *cutPageAct = new QAction(tr("&Cut page"), this);
 
1035
  connect(cutPageAct, SIGNAL(triggered()), SLOT(CutPage()));
 
1036
  cutPageAct->setShortcut(Key("Page|Cut page"));
 
1037
 
 
1038
  QAction *copyPageAct = new QAction(tr("Cop&y page"), this);
 
1039
  connect(copyPageAct, SIGNAL(triggered()), SLOT(CopyPage()));
 
1040
  copyPageAct->setShortcut(Key("Page|Copy page"));
 
1041
 
 
1042
  QAction *pastePageAct = new QAction(tr("P&aste page"), this);
 
1043
  connect(pastePageAct, SIGNAL(triggered()), SLOT(PastePage()));
 
1044
  pastePageAct->setShortcut(Key("Page|Paste page"));
 
1045
 
 
1046
  QAction *deletePageAct = new QAction(tr("&Delete page"), this);
 
1047
  connect(deletePageAct, SIGNAL(triggered()), SLOT(DeletePage()));
 
1048
  deletePageAct->setShortcut(Key("Page|Delete page"));
 
1049
 
 
1050
  QAction *editBookmarkAct = new QAction(tr("Edit &bookmarks"), this);
 
1051
  editBookmarkAct->setShortcut(Key("View|Edit bookmarks"));
 
1052
  connect(editBookmarkAct, SIGNAL(triggered()), SLOT(EditBookmarks()));
 
1053
 
 
1054
  iPageMenu->addAction(nextPageAct);
 
1055
  iPageMenu->addAction(previousPageAct);
 
1056
  iPageMenu->addAction(firstPageAct);
 
1057
  iPageMenu->addAction(lastPageAct);
 
1058
  iPageMenu->addSeparator();
 
1059
  iPageMenu->addAction(insertPageAct);
 
1060
  iPageMenu->addAction(cutPageAct);
 
1061
  iPageMenu->addAction(copyPageAct);
 
1062
  iPageMenu->addAction(pastePageAct);
 
1063
  iPageMenu->addAction(deletePageAct);
 
1064
  iPageMenu->addSeparator();
 
1065
  iPageMenu->addAction(editBookmarkAct);
 
1066
 
 
1067
  // --------------------------------------------------------------------
 
1068
  // Ipelet menu
 
1069
  // --------------------------------------------------------------------
 
1070
 
 
1071
  iPasteBitmapAction = 0;
974
1072
  for (uint i = 0; i < iIpeletMaster.size(); ++i) {
975
1073
    Ipelet *ipelet = iIpeletMaster[i];
 
1074
    IpeString keys = "Ipelet|";
 
1075
    keys += ipelet->Label();
976
1076
    if (ipelet->NumFunctions() > 1) {
977
 
      QPopupMenu *pop = new QPopupMenu;
 
1077
      QMenu *pop = new QMenu(QString::fromUtf8(ipelet->Label()));
 
1078
      bool isBitmap = (!qstrcmp(ipelet->Label(), "Insert image"));
 
1079
      keys += "|";
978
1080
      for (int j = 0; j < ipelet->NumFunctions(); ++j) {
979
 
        int id = pop->insertItem(ipelet->SubLabel(j),
980
 
                                 this, SLOT(RunIpelet(int)),
981
 
                                 Key(ipelet->KeySequence(j), "Ipelet"));
982
 
        pop->setItemParameter(id, i * 0x1000 + j);
 
1081
        QAction *a = new IpeAction(i * 0x1000 + j,
 
1082
                                   QString::fromUtf8(ipelet->SubLabel(j)),
 
1083
                                   this);
 
1084
        a->setShortcut(Key(keys + ipelet->SubLabel(j)));
 
1085
        connect(a, SIGNAL(triggered(int)), SLOT(RunIpelet(int)));
 
1086
        pop->addAction(a);
 
1087
        if (isBitmap && j == 2)
 
1088
          iPasteBitmapAction = a;
983
1089
      }
984
 
      if (!qstrcmp(ipelet->Label(), "Insert image")) {
 
1090
      if (isBitmap) {
985
1091
        // personal treatment
986
 
        iFileMenu->insertItem(ipelet->Label(), pop, -1, 6);
987
 
        iFileMenu->insertSeparator(6);
988
 
        iPasteBitmapId = i * 0x1000 + 2;
 
1092
        iFileMenu->insertMenu(runLatexAct, pop);
 
1093
        iFileMenu->insertSeparator(runLatexAct);
989
1094
      } else
990
 
        iIpeletMenu->insertItem(ipelet->Label(), pop);
 
1095
        iIpeletMenu->addMenu(pop);
991
1096
    } else {
992
 
      int id = iIpeletMenu->insertItem(ipelet->Label(),
993
 
                                       this, SLOT(RunIpelet(int)),
994
 
                                       Key(ipelet->KeySequence(0), "Ipelet"));
995
 
      iIpeletMenu->setItemParameter(id, i * 0x1000 + 1);
 
1097
      QAction *a = new IpeAction(i * 0x1000 + 1,
 
1098
                                 QString::fromUtf8(ipelet->Label()), this);
 
1099
      a->setShortcut(Key(keys));
 
1100
      connect(a, SIGNAL(triggered(int)), SLOT(RunIpelet(int)));
 
1101
      iIpeletMenu->addAction(a);
996
1102
    }
997
1103
  }
998
 
  menu->insertItem(tr("&Ipelets"), iIpeletMenu);
999
 
 
1000
 
  menu->insertSeparator();
1001
 
 
1002
 
  QPopupMenu* help = new QPopupMenu;
1003
 
  help->insertItem(tr("Ipe &manual"), this, SLOT(Manual()));
1004
 
  help->insertItem(tr("&What's this"), this, SLOT(whatsThis()));
1005
 
  help->insertSeparator();
1006
 
  help->insertItem(tr("Pre&ferences"), this, SLOT(EditPrefs()));
1007
 
  help->insertSeparator();
1008
 
  help->insertItem(tr("&About Ipe..."), this, SLOT(About()));
1009
 
  menu->insertItem(tr("&Help"), help);
1010
 
 
1011
 
  // --------------------------------------------------------------------
1012
 
 
1013
 
  iCanvas = new IpeCanvas(this, statusBar(), this);
 
1104
  QAction *a = new QAction(tr("About ipelets"), this);
 
1105
  a->setShortcut(Key("Ipelet|About ipelets"));
 
1106
  iIpeletMenu->addAction(a);
 
1107
  connect(a, SIGNAL(triggered()), SLOT(AboutIpelets()));
 
1108
 
 
1109
  // --------------------------------------------------------------------
 
1110
  // Help menu
 
1111
  // --------------------------------------------------------------------
 
1112
 
 
1113
  QAction *manualAct = new QAction(tr("Ipe &manual"), this);
 
1114
  manualAct->setShortcut(Key("Help|Ipe manual"));
 
1115
  connect(manualAct, SIGNAL(triggered()), SLOT(Manual()));
 
1116
 
 
1117
  QAction *preferencesAct = new QAction(tr("Pre&ferences"), this);
 
1118
  preferencesAct->setShortcut(Key("Help|Preferences"));
 
1119
  connect(preferencesAct, SIGNAL(triggered()), SLOT(EditPrefs()));
 
1120
 
 
1121
  QAction *aboutAct = new QAction(tr("&About Ipe..."), this);
 
1122
  aboutAct->setShortcut(Key("Help|About Ipe"));
 
1123
  connect(aboutAct, SIGNAL(triggered()), SLOT(About()));
 
1124
 
 
1125
  iHelpMenu->addAction(manualAct);
 
1126
  iHelpMenu->addAction(whatsThisAct);
 
1127
  iHelpMenu->addSeparator();
 
1128
  iHelpMenu->addAction(preferencesAct);
 
1129
  iHelpMenu->addSeparator();
 
1130
  iHelpMenu->addAction(aboutAct);
 
1131
 
 
1132
  // --------------------------------------------------------------------
 
1133
 
 
1134
  iCanvas = new IpeCanvas(this, statusBar(), prefs->iDoubleBuffer,
 
1135
                          this, prefs->iBitmapSize);
1014
1136
  setCentralWidget(iCanvas);
1015
 
  statusBar();
1016
 
  QWhatsThis::add(iCanvas, tr(canvasText));
 
1137
  iCanvas->setWhatsThis(tr(canvasText));
1017
1138
 
1018
1139
  iResolution->setValue(72000);
1019
1140
 
1034
1155
  iDoc = 0;
1035
1156
  SetCreator(iModeAction[0]);
1036
1157
 
1037
 
  connect(prefs, SIGNAL(Changed()),
1038
 
          this, SLOT(PreferencesChanged()));
1039
 
 
1040
 
  // filter all key events for focussable widgets
1041
 
  // installEventFilter(this);
1042
 
  QFocusData *fd = focusData();
1043
 
  int num = fd->count();
1044
 
  QWidget *w = fd->home();
1045
 
  while (num--) {
1046
 
    if (w) w->installEventFilter(this);
1047
 
    w = fd->next();
1048
 
  }
 
1158
  iMouse = new QLabel(statusBar());
 
1159
  iMouseIn = 0;
 
1160
  statusBar()->addPermanentWidget(iMouse, 0);
 
1161
 
 
1162
  connect(prefs, SIGNAL(Changed()), this, SLOT(PreferencesChanged()));
 
1163
 
 
1164
  installEventFilter(this);
1049
1165
}
1050
1166
 
1051
 
// ----------------------------------------------------------
 
1167
// --------------------------------------------------------------------
1052
1168
 
1053
1169
//! Destructor.
1054
1170
AppUi::~AppUi()