Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 1196 → Rev 1197

/branches/Version13x/Scribus/scribus/undomanager.h
30,6 → 30,7
#include "undoobject.h"
 
class UndoGui;
class PrefsContext;
 
typedef std::pair<UndoObject*, UndoState*> ActionPair;
typedef std::vector<ActionPair> ActionList;
69,6 → 70,8
/** @brief Should undo states be stored or ignored */
static bool _undoEnabled;
 
PrefsContext *prefs;
 
/** @brief Doc to which the currently active stack belongs */
QString currentDoc;
 
103,6 → 106,7
void connectGuis();
void disconnectGuis();
void initIcons();
void checkStackLength();
 
public:
/**
198,14 → 202,6
void showObject(int uid);
 
/**
* @brief Sets the length of the undo stack.
*
* Tells how many UndoStates are stored.
* @param steps number of UndoStates to store in the undo stack
*/
void setHistoryLength(int steps);
 
/**
* @brief Returns the maximum length of the undostack.
* @return the maximum length of the undostack
*/
290,6 → 286,14
*/
void redo(int steps);
 
/**
* @brief Sets the length of the undo stack.
*
* Tells how many UndoStates are stored.
* @param steps number of UndoStates to store in the undo stack
*/
void setHistoryLength(int steps);
 
signals:
/**
* @brief Emitted when a new undo action is stored to the undo stack.
/branches/Version13x/Scribus/scribus/undogui.cpp
166,7 → 166,11
 
void UndoWidget::popBack()
{
undoItems.erase(undoItems.end() - 1);
if (undoItems.size() > 0)
{
undoItems.erase(undoItems.end() - 1);
updateUndoMenu();
}
}
 
UndoWidget::~UndoWidget()
288,8 → 292,11
 
void UndoPalette::popBack()
{
undoList->removeItem(0);
currentSelection = undoList->numRows() - 1;
if (undoList->count() > 1)
{
undoList->removeItem(0);
currentSelection = undoList->numRows() - 1;
}
}
 
void UndoPalette::updateList()
/branches/Version13x/Scribus/scribus/libprefs/prefs.cpp
20,6 → 20,7
#include "cmsprefs.h"
#include "keymanager.h"
#include "tabtools.h"
#include "undomanager.h"
 
using namespace std;
 
306,6 → 307,7
GroupRandLayout->addWidget( GRText3, 0, 2 );
 
Layout21->addWidget( GroupRand );
QBoxLayout *asurLayout = new QHBoxLayout( 0, 0, 6, "asurLayout");
 
GroupAS = new QGroupBox( tr( "Autosave" ), tab_7, "GroupAS" );
GroupAS->setColumnLayout(0, Qt::Vertical );
324,7 → 326,28
ASText = new QLabel( ASTime, tr( "&Interval:" ), GroupAS, "ASText" );
GroupASLayout->addWidget( ASText, 1, 0 );
GroupASLayout->addWidget( ASTime, 1, 1 );
Layout21->addWidget( GroupAS );
asurLayout->addWidget(GroupAS);
 
urGroup = new QGroupBox(tr("Undo/Redo"), tab_7, "urGroup");
urGroup->setColumnLayout(0, Qt::Vertical);
urGroup->layout()->setSpacing(5);
urGroup->layout()->setMargin(10);
QGridLayout *urGroupLayout = new QGridLayout(urGroup->layout());
urGroupLayout->setAlignment(Qt::AlignTop);
urSpinBox = new QSpinBox(urGroup, "urSpinBox");
urSpinBox->setMinValue(0);
urSpinBox->setMaxValue(1000);
int urSBValue = UndoManager::instance()->getHistoryLength();
if (urSBValue == -1)
urSpinBox->setEnabled(false);
else
urSpinBox->setValue(urSBValue);
urLabel = new QLabel(urSpinBox, tr("Action history length"), urGroup, "urLabel");
urGroupLayout->addWidget(urLabel, 0, 0);
urGroupLayout->addWidget(urSpinBox, 0, 1);
asurLayout->addWidget(urGroup);
Layout21->addLayout(asurLayout);
 
tabLayout_7->addLayout( Layout21 );
addItem( tr("Document"), loadIcon("page.png"), tab_7);
 
618,6 → 641,8
QToolTip::add( ASon, tr( "When enabled, Scribus saves a backup copy of your file with the .bak extension\neach time the time period elapses" ) );
QToolTip::add( ASTime, tr( "Time period between saving automatically" ) );
 
QToolTip::add( urSpinBox, tr("Set the length of the action history in steps.\nIf set to 0 infinite amount of actions will be stored."));
 
QToolTip::add( PreviewSize, tr( "Choose the size of the preview in the scrapbook palette" ) );
QToolTip::add( SaveAtQuit, tr( "Save the scrapbook contents everytime after a change" ) );
 
656,6 → 681,7
connect(FileC3, SIGNAL(clicked()), this, SLOT(changeScripts()));
connect(FileC4, SIGNAL(clicked()), this, SLOT(changeTemplates()));
connect(CaliSlider, SIGNAL(valueChanged(int)), this, SLOT(setDisScale()));
connect(buttonOk, SIGNAL(clicked()), this, SLOT(setActionHistoryLength()));
setSize(prefsData->PageFormat);
setOrien(prefsData->Ausrichtung);
pageWidth->setValue(prefsData->PageBreite * Umrech);
1146,3 → 1172,8
selectedGUILang=langMgr.getAbbrevFromLang(newLang);
}
 
void Preferences::setActionHistoryLength()
{
UndoManager::instance()->setHistoryLength(urSpinBox->value());
}
 
/branches/Version13x/Scribus/scribus/libprefs/prefs.h
134,6 → 134,9
QCheckBox* ASon;
QLabel* ASText;
QSpinBox* ASTime;
QGroupBox* urGroup;
QLabel* urLabel;
QSpinBox* urSpinBox;
QGroupBox* CaliGroup;
QLabel* CaliText;
QLabel* CaliRuler;
220,6 → 223,7
 
private slots:
void setSelectedGUILang( const QString &newLang );
void setActionHistoryLength();
 
private:
LanguageManager langMgr;
/branches/Version13x/Scribus/scribus/scribus.cpp
156,6 → 156,10
setIcon(loadIcon("AppIcon.png"));
MenuItemsFile.clear();
 
PrefsPfad = getPreferencesLocation();
prefsFile = new PrefsFile(QDir::convertSeparators(PrefsPfad + "/prefs13.xml"));
convertToXMLPreferences(PrefsPfad);
 
initMenuBar();
initStatusBar();
initToolBars();
163,10 → 167,6
qApp->processEvents();
 
BuFromApp = false;
 
PrefsPfad = getPreferencesLocation();
prefsFile = new PrefsFile(QDir::convertSeparators(PrefsPfad + "/prefs13.xml"));
convertToXMLPreferences(PrefsPfad);
initFonts();
 
/branches/Version13x/Scribus/scribus/undomanager.cpp
22,8 → 22,11
#include "undomanager.moc"
#include "undogui.h"
#include "config.h"
#include "prefscontext.h"
#include "prefsfile.h"
#include <qvaluelist.h>
 
extern PrefsFile *prefsFile;
extern QPixmap loadIcon(QString nam);
 
UndoManager* UndoManager::_instance = 0;
54,9 → 57,12
UndoManager::UndoManager()
{
currentUndoObjectId = -1;
historyLength = 20;
if (!UndoManager::IGuides)
initIcons();
prefs = prefsFile->getContext("undo");
historyLength = prefs->getInt("historyLength", 10);
if (historyLength < 0)
historyLength = 10;
}
 
void UndoManager::registerGui(UndoGui* gui)
183,13 → 189,8
stacks[currentDoc].second.erase(stacks[currentDoc].second.begin(), stacks[currentDoc].first);
}
 
if (stacks[currentDoc].second.size() == static_cast<uint>(historyLength))
{
ActionList::iterator it = stacks[currentDoc].second.end() - 1;
delete (*it).second;
stacks[currentDoc].second.erase(it);
emit popBack();
}
checkStackLength();
 
stacks[currentDoc].second.insert(stacks[currentDoc].second.begin(), ActionPair(target, state));
stacks[currentDoc].first = stacks[currentDoc].second.begin();
}
273,15 → 274,37
 
void UndoManager::setHistoryLength(int steps)
{
if (steps > 0)
if (steps >= 0)
{
historyLength = steps;
prefs->set("historyLength", historyLength);
checkStackLength();
}
}
 
int UndoManager::getHistoryLength()
{
if (stacks.size() > 0 && stacks[currentDoc].first != stacks[currentDoc].second.begin())
return -1;
return historyLength;
}
 
void UndoManager::checkStackLength()
{
if ((stacks[currentDoc].second.size() >= static_cast<uint>(historyLength)) && (historyLength != 0))
{
while (stacks[currentDoc].second.size() >= static_cast<uint>(historyLength))
{
ActionList::iterator it = stacks[currentDoc].second.end() - 1;
if (stacks[currentDoc].first == it)
stacks[currentDoc].first = it - 1;
delete (*it).second;
stacks[currentDoc].second.erase(it);
emit popBack();
}
}
}
 
void UndoManager::deleteInstance()
{
if (_instance)