Subversion Repositories Scribus

Rev

Rev 18438 | Rev 19960 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
3 paul 7
/***************************************************************************
8
                          texttoolb.cpp  -  description
9
                             -------------------
10
    begin                : Sun Mar 10 2002
11
    copyright            : (C) 2002 by Franz Schmid
12
    email                : Franz.Schmid@altmuehlnet.de
13
 ***************************************************************************/
14
 
15
/***************************************************************************
16
 *                                                                         *
17
 *   This program is free software; you can redistribute it and/or modify  *
18
 *   it under the terms of the GNU General Public License as published by  *
19
 *   the Free Software Foundation; either version 2 of the License, or     *
20
 *   (at your option) any later version.                                   *
21
 *                                                                         *
22
 ***************************************************************************/
23
 
9800 cbradney 24
#include <QToolTip>
10859 cbradney 25
#include <QEvent>
9768 cbradney 26
#include <QMenu>
9800 cbradney 27
#include <QPixmap>
18438 craig 28
#include <QToolButton>
3699 cbradney 29
 
10863 cbradney 30
#include "modetoolbar.h"
3699 cbradney 31
 
1770 cbradney 32
#include "autoformbuttongroup.h"
14509 cbradney 33
#include "ui/scmwmenumanager.h"
3699 cbradney 34
#include "polyprops.h"
3251 craig 35
#include "scraction.h"
3699 cbradney 36
#include "scribus.h"
37
#include "scribusdoc.h"
15850 fschmid 38
#include "scrspinbox.h"
10200 cbradney 39
#include "util.h"
3 paul 40
 
8501 cbradney 41
ModeToolBar::ModeToolBar(ScribusMainWindow* parent) : ScToolBar( tr("Tools"), "Tools", parent, Qt::Vertical)
3 paul 42
{
123 Franz 43
        SubMode = 0;
44
        ValCount = 32;
45
        static double AutoShapes0[] = {0.0, 0.0, 0.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0,
167 Franz 46
                                                                        100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 0.0, 100.0, 0.0, 100.0,
47
                                                                        0.0, 100.0, 0.0, 100.0, 0.0, 0.0, 0.0, 0.0};
123 Franz 48
        ShapeVals = AutoShapes0;
5781 cbradney 49
        m_ScMW=parent;
9800 cbradney 50
        this->addAction(m_ScMW->scrActions["toolsSelect"]);
51
        this->addAction(m_ScMW->scrActions["toolsInsertTextFrame"]);
52
        this->addAction(m_ScMW->scrActions["toolsInsertImageFrame"]);
12616 cbradney 53
        this->addAction(m_ScMW->scrActions["toolsInsertRenderFrame"]);
16856 craig 54
        this->addAction(m_ScMW->scrActions["toolsInsertTable"]);
1770 cbradney 55
 
9800 cbradney 56
        this->addAction(m_ScMW->scrActions["toolsInsertShape"]);
1770 cbradney 57
        Rechteck = new AutoformButtonGroup( NULL );
12024 fschmid 58
        m_ScMW->scrActions["toolsInsertShape"]->setMenu(Rechteck);
10653 fschmid 59
        QToolButton* tb = dynamic_cast<QToolButton*>(this->widgetForAction(m_ScMW->scrActions["toolsInsertShape"]));
17903 fschmid 60
        tb->setPopupMode(QToolButton::DelayedPopup);
8643 cbradney 61
        m_ScMW->scrActions["toolsInsertShape"]->setIcon(QIcon(Rechteck->getIconPixmap(0,16)));
1770 cbradney 62
 
9800 cbradney 63
        this->addAction(m_ScMW->scrActions["toolsInsertPolygon"]);
9842 fschmid 64
        insertPolygonButtonMenu = new QMenu();
10592 fschmid 65
        idInsertPolygonButtonMenu = insertPolygonButtonMenu->addAction( "Properties...", this, SLOT(GetPolyProps()));
9842 fschmid 66
        m_ScMW->scrActions["toolsInsertPolygon"]->setMenu(insertPolygonButtonMenu);
10653 fschmid 67
        QToolButton* tb2 = dynamic_cast<QToolButton*>(this->widgetForAction(m_ScMW->scrActions["toolsInsertPolygon"]));
17903 fschmid 68
        tb2->setPopupMode(QToolButton::DelayedPopup);
16215 fschmid 69
 
70
        this->addAction(m_ScMW->scrActions["toolsInsertArc"]);
16311 fschmid 71
        this->addAction(m_ScMW->scrActions["toolsInsertSpiral"]);
9800 cbradney 72
        this->addAction(m_ScMW->scrActions["toolsInsertLine"]);
73
        this->addAction(m_ScMW->scrActions["toolsInsertBezier"]);
74
        this->addAction(m_ScMW->scrActions["toolsInsertFreehandLine"]);
15850 fschmid 75
 
76
        propWidget = new QWidget();
77
        group1Layout = new QGridLayout( propWidget );
78
        group1Layout->setSpacing( 3 );
15856 fschmid 79
        group1Layout->setMargin( 2 );
15850 fschmid 80
        group1Layout->setAlignment( Qt::AlignTop );
81
        Angle = new ScrSpinBox( -180, 180, propWidget, 6 );
82
        Angle->setValue( 0 );
83
        AngleTxt = new QLabel( tr("Angle:"), propWidget );
84
        group1Layout->addWidget( Angle, 0, 1 );
85
        group1Layout->addWidget( AngleTxt, 0 , 0 );
86
        PWidth = new ScrSpinBox( 0, 100, propWidget, 0 );
15856 fschmid 87
        PWidth->setValue( 10 );
15850 fschmid 88
        PWidthTxt = new QLabel( tr("Width:"), propWidget );
89
        group1Layout->addWidget( PWidth, 1, 1 );
90
        group1Layout->addWidget( PWidthTxt, 1 , 0 );
91
        calPop = new QMenu();
92
        calValAct = new QWidgetAction(this);
93
        calValAct->setDefaultWidget(propWidget);
94
        calPop->addAction(calValAct);
15847 fschmid 95
        this->addAction(m_ScMW->scrActions["toolsInsertCalligraphicLine"]);
15850 fschmid 96
        m_ScMW->scrActions["toolsInsertCalligraphicLine"]->setMenu(calPop);
97
        QToolButton* tb3 = dynamic_cast<QToolButton*>(this->widgetForAction(m_ScMW->scrActions["toolsInsertCalligraphicLine"]));
17903 fschmid 98
        tb3->setPopupMode(QToolButton::DelayedPopup);
15850 fschmid 99
 
9800 cbradney 100
        this->addAction(m_ScMW->scrActions["toolsRotate"]);
101
        this->addAction(m_ScMW->scrActions["toolsZoom"]);
102
        this->addAction(m_ScMW->scrActions["toolsEditContents"]);
103
        this->addAction(m_ScMW->scrActions["toolsEditWithStoryEditor"]);
104
        this->addAction(m_ScMW->scrActions["toolsLinkTextFrame"]);
105
        this->addAction(m_ScMW->scrActions["toolsUnlinkTextFrame"]);
106
        this->addAction(m_ScMW->scrActions["toolsMeasurements"]);
107
        this->addAction(m_ScMW->scrActions["toolsCopyProperties"]);
108
        this->addAction(m_ScMW->scrActions["toolsEyeDropper"]);
1770 cbradney 109
 
2227 cbradney 110
        languageChange();
13165 fschmid 111
        connect(Rechteck, SIGNAL(FormSel(int, int, qreal *)), this, SLOT(SelShape(int, int, qreal *)));
15850 fschmid 112
        connect(Angle, SIGNAL(valueChanged(double)), this, SLOT(newCalValues()));
113
        connect(PWidth, SIGNAL(valueChanged(double)), this, SLOT(newCalValues()));
3 paul 114
}
115
 
15850 fschmid 116
void ModeToolBar::newCalValues()
117
{
19378 craig 118
        m_ScMW->doc->itemToolPrefs().calligraphicPenAngle = Angle->value();
119
        m_ScMW->doc->itemToolPrefs().calligraphicPenWidth = PWidth->value();
15850 fschmid 120
}
121
 
5279 cbradney 122
void ModeToolBar::GetPolyProps()
3 paul 123
{
16250 fschmid 124
        PolygonProps* dia = new PolygonProps(m_ScMW, m_ScMW->doc->itemToolPrefs().polyCorners, m_ScMW->doc->itemToolPrefs().polyFactor, m_ScMW->doc->itemToolPrefs().polyUseFactor, m_ScMW->doc->itemToolPrefs().polyRotation, m_ScMW->doc->itemToolPrefs().polyCurvature, m_ScMW->doc->itemToolPrefs().polyInnerRot, m_ScMW->doc->itemToolPrefs().polyOuterCurvature);
167 Franz 125
        if (dia->exec())
16191 fschmid 126
        {
16246 fschmid 127
                dia->getValues(&m_ScMW->doc->itemToolPrefs().polyCorners, &m_ScMW->doc->itemToolPrefs().polyFactor, &m_ScMW->doc->itemToolPrefs().polyUseFactor, &m_ScMW->doc->itemToolPrefs().polyRotation, &m_ScMW->doc->itemToolPrefs().polyCurvature, &m_ScMW->doc->itemToolPrefs().polyInnerRot, &m_ScMW->doc->itemToolPrefs().polyOuterCurvature);
16191 fschmid 128
                m_ScMW->scrActions["toolsInsertPolygon"]->trigger();
129
        }
3 paul 130
        delete dia;
131
}
132
 
13165 fschmid 133
void ModeToolBar::SelShape(int s, int c, qreal *vals)
123 Franz 134
{
8643 cbradney 135
        m_ScMW->scrActions["toolsInsertShape"]->setIcon(QIcon(Rechteck->getIconPixmap(s,16)));
123 Franz 136
        SubMode = s;
137
        ValCount = c;
138
        ShapeVals = vals;
10430 cbradney 139
        m_ScMW->scrActions["toolsInsertShape"]->setChecked(false);
140
        m_ScMW->scrActions["toolsInsertShape"]->setChecked(true);
123 Franz 141
}
142
 
10859 cbradney 143
void ModeToolBar::changeEvent(QEvent *e)
144
{
145
        if (e->type() == QEvent::LanguageChange)
146
        {
147
                languageChange();
148
        }
10903 cbradney 149
        else
150
                QWidget::changeEvent(e);
10859 cbradney 151
}
152
 
5279 cbradney 153
void ModeToolBar::languageChange()
2227 cbradney 154
{
15850 fschmid 155
        AngleTxt->setText(tr("Angle:"));
156
        PWidthTxt->setText(tr("Width:"));
10592 fschmid 157
        idInsertPolygonButtonMenu->setText( tr("Properties..."));
4567 tsoots 158
        ScToolBar::languageChange();
2227 cbradney 159
}