Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 9602 → Rev 9603

/branches/Version135x/Scribus/scribus/plugins/saveastemplateplugin/satemplate.cpp
8,7 → 8,6
* Riku Leino, tsoots@gmail.com *
***************************************************************************/
#include "satemplate.h"
//#include "satemplate.moc"
#include "satdialog.h"
 
#include "scpaths.h"
197,8 → 196,9
xml += "</templates>\n";
if ( tmplXml.open( QIODevice::WriteOnly ) )
{
Q3TextStream stream(&tmplXml);
stream.setEncoding(Q3TextStream::UnicodeUTF8);
QTextStream stream(&tmplXml);
// stream.setEncoding(Q3TextStream::UnicodeUTF8);
stream.setCodec(QTextCodec::codecForName("UTF-8"));
stream << xml;
tmplXml.close();
}
233,7 → 233,7
QFile tmplXml(tmplXmlFile);
if (tmplXml.open(QIODevice::ReadOnly))
{
Q3TextStream stream(&tmplXml);
QTextStream stream(&tmplXml);
QString tmp = stream.readLine();
QString file = "";
while (!tmp.isNull())
246,8 → 246,9
tmplXml.close();
if ( tmplXml.open( QIODevice::WriteOnly ) )
{
Q3TextStream stream2(&tmplXml);
stream2.setEncoding(Q3TextStream::UnicodeUTF8);
QTextStream stream2(&tmplXml);
// stream2.setEncoding(Q3TextStream::UnicodeUTF8);
stream2.setCodec(QTextCodec::codecForName("UTF-8"));
stream2 << file;
tmplXml.close();
}
/branches/Version135x/Scribus/scribus/plugins/saveastemplateplugin/satdialog.ui
0,0 → 1,182
<ui version="4.0" >
<class>satdialog</class>
<widget class="QDialog" name="satdialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>390</width>
<height>503</height>
</rect>
</property>
<property name="windowTitle" >
<string>Save as Template</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="10" column="1" >
<widget class="QLineEdit" name="emailEdit" />
</item>
<item row="9" column="1" >
<widget class="QLineEdit" name="authorEdit" />
</item>
<item row="10" column="0" >
<widget class="QLabel" name="emailLabel" >
<property name="text" >
<string>Email</string>
</property>
</widget>
</item>
<item row="9" column="0" >
<widget class="QLabel" name="authorLabel" >
<property name="text" >
<string>Author</string>
</property>
</widget>
</item>
<item row="8" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item rowspan="2" row="7" column="1" >
<widget class="QTextEdit" name="usageEdit" />
</item>
<item rowspan="2" row="5" column="1" >
<widget class="QTextEdit" name="descrEdit" />
</item>
<item row="4" column="1" >
<widget class="QLineEdit" name="colorsEdit" />
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="psizeEdit" />
</item>
<item row="2" column="1" >
<widget class="QComboBox" name="catsCombo" />
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="nameEdit" />
</item>
<item row="1" column="0" colspan="2" >
<widget class="QCheckBox" name="detailButton" >
<property name="text" >
<string>&amp;More Details</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Name</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="catsLabel" >
<property name="text" >
<string>Category</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="psizeLabel" >
<property name="text" >
<string>Page Size</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="colorsLabel" >
<property name="text" >
<string>Colors</string>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="descrLabel" >
<property name="text" >
<string>Description</string>
</property>
</widget>
</item>
<item row="7" column="0" >
<widget class="QLabel" name="usageLabel" >
<property name="text" >
<string>Usage</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2" >
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>satdialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>satdialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: branches/Version135x/Scribus/scribus/plugins/saveastemplateplugin/satemplate.h
===================================================================
--- branches/Version135x/Scribus/scribus/plugins/saveastemplateplugin/satemplate.h (revision 9602)
+++ branches/Version135x/Scribus/scribus/plugins/saveastemplateplugin/satemplate.h (revision 9603)
@@ -7,13 +7,10 @@
#ifndef MYPLUGIN_H
#define MYPLUGIN_H
-#include <qobject.h>
-#include <qdatetime.h>
-#include <qdir.h>
-
#include "pluginapi.h"
#include "scplugin.h"
+
class PLUGIN_API SaveAsTemplatePlugin : public ScActionPlugin
{
Q_OBJECT
/branches/Version135x/Scribus/scribus/plugins/saveastemplateplugin/satdialog.cpp
8,203 → 8,58
* Riku Leino, tsoots@gmail.com *
***************************************************************************/
#include "satdialog.h"
//#include "satdialog.moc"
#include "scribusapi.h"
#include "prefsmanager.h"
#include <prefsfile.h>
//Added by qt3to4:
#include <Q3HBoxLayout>
#include <QPixmap>
#include <QLabel>
#include <Q3VBoxLayout>
#include "prefsfile.h"
 
 
extern QPixmap SCRIBUS_API loadIcon(QString nam);
 
satdialog::satdialog(QWidget* parent, QString tmplName, int pageW, int pageH) : QDialog(parent, "satdialog", true)
{
setupUi(this);
setCaption( tr("Save as Template"));
setIcon(loadIcon("AppIcon.png"));
readPrefs();
Q3BoxLayout* blo = new Q3VBoxLayout(this,0,5,"blo");
QWidget* top = new QWidget(this);
top->setMaximumHeight(5);
middle = new QWidget(this);
middle->setMinimumWidth(250);
Q3BoxLayout* middlelo = new Q3HBoxLayout(middle,0,5);
QWidget* left = new QWidget(middle);
center = new QWidget(middle);
QWidget* right = new QWidget(middle);
middlelo->addWidget(left);
middlelo->addWidget(center);
middlelo->addWidget(right);
QWidget* bottom = new QWidget(this);
bottom->setMinimumHeight(40);
bottom->setMaximumHeight(40);
blo->addWidget(top);
blo->addWidget(middle);
blo->addWidget(bottom);
Q3BoxLayout* mlo = new Q3VBoxLayout(center,0,5);
mlo->insertSpacing(0,5);
nameLabel = new QLabel( tr("Name"),center);
mlo->addWidget(nameLabel);
nameEdit = new QLineEdit(center);
nameEdit->setText(tmplName);
mlo->addWidget(nameEdit);
catsLabel = new QLabel( tr("Category"), center);
mlo->addWidget(catsLabel);
catsCombo = new QComboBox(center,"catsCombo");
mlo->addWidget(catsCombo);
setupCategories();
psizeLabel = new QLabel( tr("Page Size"),center);
mlo->addWidget(psizeLabel);
psizeEdit = new QLineEdit(center);
mlo->addWidget(psizeEdit);
setupPageSize(pageW, pageH);
colorsLabel = new QLabel( tr("Colors"),center);
mlo->addWidget(colorsLabel);
colorsEdit = new QLineEdit(center);
mlo->addWidget(colorsEdit);
descrLabel = new QLabel( tr("Description"),center);
mlo->addWidget(descrLabel);
descrEdit = new Q3TextEdit(center);
mlo->addWidget(descrEdit);
usageLabel = new QLabel( tr("Usage"),center);
mlo->addWidget(usageLabel);
usageEdit = new Q3TextEdit(center);
mlo->addWidget(usageEdit);
authorLabel = new QLabel( tr("Author"),center);
mlo->addWidget(authorLabel);
authorEdit = new QLineEdit(center);
mlo->addWidget(authorEdit);
authorEdit->setText(author);
emailLabel = new QLabel( tr("Email"),center);
mlo->addWidget(emailLabel);
emailEdit = new QLineEdit(center);
mlo->addWidget(emailEdit);
emailEdit->setText(email);
mlo->addStretch(10);
mlo->insertSpacing(-1,5);
Q3BoxLayout* tlo = new Q3HBoxLayout(bottom,0,5);
detailButton = new QPushButton( tr("More Details"), bottom);
tlo->addWidget(detailButton);
tlo->addStretch(10);
okButton = new QPushButton( tr("OK"),bottom);
okButton->setDefault(true);
tlo->addWidget(okButton);
tlo->insertSpacing(0,5);
tlo->insertSpacing(-1,5);
if (isFullDetail)
fullDetail();
else
minimumDetail();
 
// Slots and signals connections
connect(detailButton, SIGNAL(clicked()), this, SLOT(detailClicked()));
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(detailButton, SIGNAL(stateChanged(int)), this, SLOT(detailClicked(int)));
}
 
void satdialog::detailClicked()
void satdialog::detailClicked(int state)
{
if (isFullDetail) {
minimumDetail();
} else {
fullDetail();
}
isFullDetail = !isFullDetail;
}
isFullDetail = state == Qt::Checked;
 
void satdialog::fullDetail()
{
detailButton->setText( tr("Less Details"));
psizeLabel->setHidden(false);
psizeLabel->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
catsLabel->setHidden(false);
catsLabel->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
colorsLabel->setHidden(false);
colorsLabel->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
descrLabel->setHidden(false);
descrLabel->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
usageLabel->setHidden(false);
usageLabel->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
authorLabel->setHidden(false);
authorLabel->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
emailLabel->setHidden(false);
emailLabel->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
psizeEdit->setHidden(false);
psizeEdit->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
catsCombo->setHidden(false);
catsCombo->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
colorsEdit->setHidden(false);
colorsEdit->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
descrEdit->setHidden(false);
descrEdit->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
usageEdit->setHidden(false);
usageEdit->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
authorEdit->setHidden(false);
authorEdit->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
emailEdit->show();
emailEdit->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
layout()->activate();
// resize(minimumSizeHint());
setFixedSize(minimumSizeHint());
psizeLabel->setVisible(isFullDetail);
catsLabel->setVisible(isFullDetail);
colorsLabel->setVisible(isFullDetail);
descrLabel->setVisible(isFullDetail);
usageLabel->setVisible(isFullDetail);
authorLabel->setVisible(isFullDetail);
emailLabel->setVisible(isFullDetail);
psizeEdit->setVisible(isFullDetail);
catsCombo->setVisible(isFullDetail);
colorsEdit->setVisible(isFullDetail);
descrEdit->setVisible(isFullDetail);
usageEdit->setVisible(isFullDetail);
authorEdit->setVisible(isFullDetail);
emailEdit->setVisible(isFullDetail);
}
 
void satdialog::minimumDetail()
void satdialog::readPrefs()
{
detailButton->setText( tr("More Details"));
catsLabel->hide();
catsLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
psizeLabel->hide();
psizeLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
colorsLabel->hide();
colorsLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
descrLabel->hide();
descrLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
usageLabel->hide();
usageLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
authorLabel->hide();
authorLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
emailLabel->hide();
emailLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
catsCombo->hide();
catsCombo->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
psizeEdit->hide();
psizeEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
colorsEdit->hide();
colorsEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
descrEdit->hide();
descrEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
usageEdit->hide();
usageEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
authorEdit->hide();
authorEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
emailEdit->hide();
emailEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
 
layout()->activate();
setFixedSize(minimumSizeHint());
 
adjustSize(); // TODO Get rid of this
}
 
void satdialog::readPrefs()
{
prefs = PrefsManager::instance()->prefsFile->getPluginContext("satemplate");
author = prefs->get("author", "");
email = prefs->get("email", "");
isFullDetail = prefs->getBool("isFullDetail", false);
detailClicked(isFullDetail ? Qt::Checked : Qt::Unchecked);
detailButton->setCheckState(isFullDetail ? Qt::Checked : Qt::Unchecked);
}
 
void satdialog::writePrefs()
/branches/Version135x/Scribus/scribus/plugins/saveastemplateplugin/CMakeLists.txt
3,6 → 3,10
${CMAKE_SOURCE_DIR}/scribus
)
 
SET(SAVEASTEMPLATE_PLUGIN_UI_SRC
satdialog.ui
)
 
SET(SAVEASTEMPLATE_PLUGIN_MOC_CLASSES
satdialog.h
satemplate.h
15,11 → 19,13
 
SET(SCRIBUS_SAVEASTEMPLATE_PLUGIN "saveastemplateplugin")
 
QT4_WRAP_UI(SAVEASTEMPLATE_PLUGIN_UI_SOURCES ${SAVEASTEMPLATE_PLUGIN_UI_SRC} )
#IF(QT4_WRAP_CPP)
QT4_WRAP_CPP(SAVEASTEMPLATE_PLUGIN_MOC_SOURCES ${SAVEASTEMPLATE_PLUGIN_MOC_CLASSES})
#ENDIF(QT4_WRAP_CPP)
 
ADD_LIBRARY(${SCRIBUS_SAVEASTEMPLATE_PLUGIN} MODULE ${SAVEASTEMPLATE_PLUGIN_SOURCES} ${SAVEASTEMPLATE_PLUGIN_MOC_SOURCES})
ADD_LIBRARY(${SCRIBUS_SAVEASTEMPLATE_PLUGIN} MODULE ${SAVEASTEMPLATE_PLUGIN_SOURCES}
${SAVEASTEMPLATE_PLUGIN_MOC_SOURCES} ${SAVEASTEMPLATE_PLUGIN_UI_SOURCES})
 
IF(APPLE)
TARGET_LINK_LIBRARIES(${SCRIBUS_SAVEASTEMPLATE_PLUGIN} "-undefined dynamic_lookup")
/branches/Version135x/Scribus/scribus/plugins/saveastemplateplugin/satdialog.h
10,27 → 10,12
#ifndef SATDIALOG_H
#define SATDIALOG_H
 
#include <vector>
#include <utility>
#include <qfile.h>
#include <q3frame.h>
#include <qdir.h>
#include <q3textstream.h>
#include <qcombobox.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qdialog.h>
#include <qlineedit.h>
#include <q3textedit.h>
#include <qwidget.h>
#include "ui_satdialog.h"
#include <prefscontext.h>
 
typedef std::pair<QString*,QString*> Pair;
 
class satdialog : public QDialog
class satdialog : public QDialog, public Ui::satdialog
{
Q_OBJECT
 
39,35 → 24,15
~satdialog();
 
std::vector<Pair*> cats;
QLineEdit* nameEdit;
QComboBox* catsCombo;
QLineEdit* psizeEdit;
QLineEdit* colorsEdit;
Q3TextEdit* descrEdit;
Q3TextEdit* usageEdit;
QLineEdit* authorEdit;
QLineEdit* emailEdit;
private slots:
void detailClicked();
void detailClicked(int);
 
private:
PrefsContext* prefs;
QLabel* nameLabel;
QLabel* psizeLabel;
QLabel* colorsLabel;
QLabel* descrLabel;
QLabel* usageLabel;
QLabel* authorLabel;
QLabel* emailLabel;
QLabel* catsLabel;
QPushButton* okButton;
QPushButton* detailButton;
QWidget* center;
QWidget* middle;
QString author;
QString email;
bool isFullDetail;
void fullDetail();
void minimumDetail();
 
void readPrefs();
void writePrefs();
void setupCategories();