File indexing completed on 2024-05-12 16:35:16
0001 /* This file is part of the KDE project 0002 Copyright (C) 2003 Norbert Andres<nandres@web.de> 0003 (C) 2002 Philipp Mueller <philipp.mueller@gmx.de> 0004 (C) 2002 Ariya Hidayat <ariya@kde.org> 0005 (C) 1999-2002 Laurent Montel <montel@kde.org> 0006 (C) 1998-1999 Torben Weis <weis@kde.org> 0007 0008 This library is free software; you can redistribute it and/or 0009 modify it under the terms of the GNU Library General Public 0010 License as published by the Free Software Foundation; either 0011 version 2 of the License, or (at your option) any later version. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Library General Public License for more details. 0017 0018 You should have received a copy of the GNU Library General Public License 0019 along with this library; see the file COPYING.LIB. If not, write to 0020 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0021 Boston, MA 02110-1301, USA. 0022 */ 0023 0024 // Local 0025 #include "AngleDialog.h" 0026 0027 #include <QLabel> 0028 #include <QPushButton> 0029 #include <QSpinBox> 0030 #include <QVBoxLayout> 0031 0032 #include <KLocalizedString> 0033 0034 #include <KoCanvasBase.h> 0035 0036 #include "Cell.h" 0037 #include "ui/Selection.h" 0038 #include "Sheet.h" 0039 0040 #include "commands/StyleCommand.h" 0041 #include "commands/RowColumnManipulators.h" 0042 0043 using namespace Calligra::Sheets; 0044 0045 AngleDialog::AngleDialog(QWidget* parent, Selection* selection) 0046 : KoDialog(parent) 0047 { 0048 setCaption(i18n("Change Angle")); 0049 setModal(true); 0050 setButtons(Ok | Cancel | Default); 0051 0052 m_selection = selection; 0053 0054 QWidget *page = new QWidget(); 0055 setMainWidget(page); 0056 0057 QVBoxLayout *lay = new QVBoxLayout(page); 0058 lay->setMargin(0); 0059 QLabel *label = new QLabel(i18n("Angle:"), page); 0060 lay->addWidget(label); 0061 0062 m_pAngle = new QSpinBox(page); 0063 m_pAngle->setRange(-90, 90); 0064 m_pAngle->setSingleStep(1); 0065 m_pAngle->setSuffix(" "); 0066 lay->addWidget(m_pAngle); 0067 0068 QWidget* spacer = new QWidget(page); 0069 spacer->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); 0070 lay->addWidget(spacer); 0071 0072 m_pAngle->setFocus(); 0073 0074 connect(this, SIGNAL(okClicked()), this, SLOT(slotOk())); 0075 connect(this, SIGNAL(defaultClicked()), this, SLOT(slotDefault())); 0076 int angle = - Cell(m_selection->activeSheet(), m_selection->marker()).style().angle(); 0077 m_pAngle->setValue(angle); 0078 } 0079 0080 void AngleDialog::slotOk() 0081 { 0082 KUndo2Command* macroCommand = new KUndo2Command(kundo2_i18n("Change Angle")); 0083 0084 StyleCommand* manipulator = new StyleCommand(macroCommand); 0085 manipulator->setSheet(m_selection->activeSheet()); 0086 manipulator->setAngle(-m_pAngle->value()); 0087 manipulator->add(*m_selection); 0088 0089 AdjustColumnRowManipulator* manipulator2 = new AdjustColumnRowManipulator(macroCommand); 0090 manipulator2->setSheet(m_selection->activeSheet()); 0091 manipulator2->setAdjustColumn(true); 0092 manipulator2->setAdjustRow(true); 0093 manipulator2->add(*m_selection); 0094 0095 m_selection->canvas()->addCommand(macroCommand); 0096 accept(); 0097 } 0098 0099 void AngleDialog::slotDefault() 0100 { 0101 m_pAngle->setValue(0); 0102 }