r25058 by jghali - Code cleanup
scribus-commit
scribus-commit at lists.scribus.net
Thu Mar 24 21:42:51 UTC 2022
Author: jghali
Date: Thu Mar 24 21:42:50 2022
New Revision: 25058
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=25058
Log:
Code cleanup
Modified:
trunk/Scribus/scribus/numeration.h
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribus.h
trunk/Scribus/scribus/scribusview.cpp
trunk/Scribus/scribus/scribusview.h
Modified: trunk/Scribus/scribus/numeration.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25058&path=/trunk/Scribus/scribus/numeration.h
==============================================================================
--- trunk/Scribus/scribus/numeration.h (original)
+++ trunk/Scribus/scribus/numeration.h Thu Mar 24 21:42:50 2022
@@ -33,16 +33,16 @@
class Numeration
{
public:
- Numeration() : numFormat(Type_1_2_3), asterix(QString()), lead('0'), range(NSRdocument) {}
- Numeration(NumFormat f) : numFormat(f), asterix("*") {}
+ Numeration() = default;
+ Numeration(NumFormat f) : numFormat(f), asterix("*"), lead() {}
QString numString(int num) const;
- NumFormat numFormat;
+ NumFormat numFormat { Type_1_2_3 };
QString asterix;
- QChar lead;
+ QChar lead { '0' };
int len { 0 };
- NumerationRange range;
+ NumerationRange range { NSRdocument };
QString prefix;
QString suffix;
int start { 1 };
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25058&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Thu Mar 24 21:42:50 2022
@@ -82,6 +82,7 @@
#include <unistd.h>
#endif
+#include <array>
#include <iostream>
#include <sstream>
#include <csignal>
@@ -315,7 +316,7 @@
qApp->setStyleSheet(QString(stylesheet));
}
- qApp->setLayoutDirection(QLocale(ScCore->getGuiLanguage()).textDirection());
+ QApplication::setLayoutDirection(QLocale(ScCore->getGuiLanguage()).textDirection());
previewDinUse = false;
printDinUse = false;
internalCopy = false;
@@ -357,7 +358,7 @@
initDefaultValues();
initStatusBar();
- qApp->processEvents();
+ QApplication::processEvents();
actionManager->init(this);
@@ -1803,29 +1804,30 @@
ce->ignore();
return;
}
+
+ disconnect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(newActWin(QMdiSubWindow*)));
+
QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
- ScribusWin* tw;
- disconnect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(newActWin(QMdiSubWindow *)));
if (!windows.isEmpty())
{
+ ScribusWin* tw { nullptr };
int windowCount = windows.count();
for ( int i = 0; i < windowCount; ++i )
{
-// tw = qobject_cast<ScribusWin *>(windows.at(i));
QMdiSubWindow *tws = windows.at(i);
ScribusWin* scw = dynamic_cast<ScribusWin *>(tws->widget());
- if (scw)
+ if (!scw)
+ continue;
+
+ newActWin(windows.at(i));
+ tw = ActWin;
+ slotSelect();
+ tws->close();
+ if (tw == ActWin)
{
- newActWin(windows.at(i));
- tw = ActWin;
- slotSelect();
- tws->close();
- if (tw == ActWin)
- {
- ce->ignore();
- connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(newActWin(QMdiSubWindow*)));
- return;
- }
+ ce->ignore();
+ connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(newActWin(QMdiSubWindow*)));
+ return;
}
}
}
@@ -2255,7 +2257,7 @@
nftdialog* nftdia = new nftdialog(this, ScCore->getGuiLanguage());
if (nftdia->exec() && nftdia->isTemplateSelected())
{
- qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
nfttemplate* currentTemplate = nftdia->currentTemplate();
if (loadDoc(QDir::cleanPath(currentTemplate->file)))
{
@@ -2266,7 +2268,7 @@
QDir::setCurrent(PrefsManager::instance().documentDir());
removeRecent(QDir::cleanPath(currentTemplate->file));
}
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
}
delete nftdia;
}
@@ -2521,7 +2523,7 @@
void ScribusMainWindow::windowsMenuActivated(int id)
{
- QMdiSubWindow* windowWidget = mdiArea->subWindowList().at( id );
+ QMdiSubWindow* windowWidget = mdiArea->subWindowList().at(id);
if (windowWidget)
{
if (windowWidget->isShaded() || windowWidget->isMinimized())
@@ -3138,7 +3140,7 @@
activeTransaction = m_undoManager->beginTransaction(Um::ImportPage, Um::IGroup, Um::ImportPage, nullptr, Um::ILock);
m_mainWindowStatusLabel->setText( tr("Importing Pages..."));
- qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
std::vector<int> pageNs;
parsePagesString(dia->getPageNumbers(), &pageNs, dia->getPageCounter());
int startPage=0, nrToImport=pageNs.size();
@@ -3165,7 +3167,7 @@
startPage = doc->currentPage()->pageNr() + 1;
if (nrToImport > (doc->DocPages.count() - doc->currentPage()->pageNr()))
{
- qApp->setOverrideCursor(QCursor(Qt::ArrowCursor));
+ QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
ScMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("Import Page(s)"));
@@ -3195,7 +3197,7 @@
doIt = false;
m_mainWindowStatusLabel->setText("");
}
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
}
}
if (doIt)
@@ -3222,7 +3224,7 @@
doIt = false;
}
}
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
ret = doIt;
if (activeTransaction)
@@ -3295,7 +3297,7 @@
return false;
}
- qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
if (HaveDoc)
outlinePalette->buildReopenVals();
bool ret = false;
@@ -3321,7 +3323,7 @@
if (docNameUnmodified == platfName)
{
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
ScMessageBox::information(this, tr("Document is already opened"), tr("This document is already open. It will be set as the active document."));
windowsMenuActivated(i);
return true;
@@ -3335,7 +3337,7 @@
if (testResult == -1)
{
delete fileLoader;
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
QString title = tr("Fatal Error") ;
QString msg = "<qt>"+ tr("File %1 is not in an acceptable format").arg(filename)+"</qt>";
QString infoMsg = "<qt>" + tr("The file may be damaged or may have been produced in a later version of Scribus.") + "</qt>";
@@ -3349,7 +3351,7 @@
bool is12doc=false;
if (testResult == 0)
{
- qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+ QApplication::changeOverrideCursor(QCursor(Qt::ArrowCursor));
//Scribus 1.3.x warning, remove at a later stage
is12doc=true;
}
@@ -3411,7 +3413,7 @@
view = nullptr;
doc = nullptr;
setScriptRunning(false);
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
m_mainWindowStatusLabel->setText("");
mainWindowProgressBar->reset();
ActWin = nullptr;
@@ -3539,7 +3541,7 @@
}
if (missingMap.count() > 0)
{
- qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+ QApplication::changeOverrideCursor(QCursor(Qt::ArrowCursor));
QString mess = tr("Some color profiles used by this document are not installed:")+"\n\n";
for (auto it = missingMap.constBegin(); it != missingMap.constEnd(); ++it)
{
@@ -3698,7 +3700,7 @@
m_undoManager->switchStack(doc->documentFileName());
pagePalette->rebuild();
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
doc->setModified(false);
foreach (NotesStyle* NS, doc->m_docNotesStylesList)
doc->updateNotesFramesStyles(NS);
@@ -3738,7 +3740,7 @@
QString docDir = dirsContext->get("images", prefsDocDir.isEmpty() ? "." : prefsDocDir);
QStringList fileNames;
- CustomFDialog *dia = new CustomFDialog(qApp->activeWindow(), docDir, tr("Open"), formatD, fdShowPreview | fdExistingFilesI | fdDisableOk);
+ CustomFDialog *dia = new CustomFDialog(QApplication::activeWindow(), docDir, tr("Open"), formatD, fdShowPreview | fdExistingFilesI | fdDisableOk);
if (dia->exec() == QDialog::Accepted)
fileNames = dia->selectedFiles();
delete dia;
@@ -3881,8 +3883,8 @@
currItem->EmbeddedProfile.clear();
currItem->ImageProfile = doc->cmsSettings().DefaultImageRGBProfile;
currItem->ImageIntent = doc->cmsSettings().DefaultIntentImages;
- qApp->setOverrideCursor( QCursor(Qt::WaitCursor) );
- qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
+ QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
currItem->isInlineImage = true;
currItem->isTempFile = true;
@@ -3891,11 +3893,11 @@
// Call to showScaleAndOffset() is now very likely unnecessary
// due to mechanisms used to update properties in PP in 1.5.x+
//propertiesPalette->imagePal->showScaleAndOffset(currItem->imageXScale(), currItem->imageYScale(), currItem->imageXOffset(), currItem->imageYOffset());
- qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
view->DrawNew();
emit UpdateRequest(reqColorsUpdate | reqCmsOptionsUpdate);
currItem->emitAllToGUI();
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
}
void ScribusMainWindow::toogleInlineState()
@@ -4004,7 +4006,7 @@
if (doc==storyEditor->currentDocument())
storyEditor->close();
slotFileClose();
- qApp->processEvents();
+ QApplication::processEvents();
loadDoc(fn);
m_undoManager->clearStack();
}
@@ -4106,7 +4108,7 @@
m_mainWindowStatusLabel->setText( tr("Saving..."));
mainWindowProgressBar->reset();
bool ret = doc->save(fileName, savedFileName);
- qApp->processEvents();
+ QApplication::processEvents();
if (ret)
{
updateActiveWindowCaption(fileName);
@@ -4275,15 +4277,20 @@
QFileInfo fi(doc->documentFileName());
QString completeBaseName = fi.completeBaseName();
if (completeBaseName.endsWith(".sla", Qt::CaseInsensitive))
- if (completeBaseName.length() > 4) completeBaseName.chop(4);
+ {
+ if (completeBaseName.length() > 4)
+ completeBaseName.chop(4);
+ }
if (completeBaseName.endsWith(".gz", Qt::CaseInsensitive))
- if (completeBaseName.length() > 3) completeBaseName.chop(3);
+ {
+ if (completeBaseName.length() > 3)
+ completeBaseName.chop(3);
+ }
doc->Print_Options.filename = fi.path()+"/"+completeBaseName+".ps";
}
else
{
- QDir di = QDir();
- doc->Print_Options.filename = di.currentPath()+"/"+doc->documentFileName()+".ps";
+ doc->Print_Options.filename = QDir::currentPath() + "/" + doc->documentFileName() + ".ps";
}
}
doc->Print_Options.copies = 1;
@@ -4295,7 +4302,7 @@
if (printer->exec())
{
ReOrderText(doc, view);
- qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
doc->Print_Options.pageNumbers.clear();
if (printer->doPrintCurrentPage())
doc->Print_Options.pageNumbers.push_back(doc->currentPage()->pageNr()+1);
@@ -4308,7 +4315,7 @@
}
m_PrinterUsed = true;
done = doPrint(doc->Print_Options, printError);
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
if (!done)
{
QString message = tr("Printing failed!");
@@ -4342,13 +4349,13 @@
QString filename(options.filename);
if (options.toFile)
{
- qApp->setOverrideCursor(QCursor(Qt::ArrowCursor));
+ QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
if (!overwrite(this, filename))
{
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
return true;
}
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
}
ScCore->fileWatcher->forceScan();
ScCore->fileWatcher->stop();
@@ -4451,8 +4458,7 @@
{
if ((currItem->isSingleSel) && (currItem->isGroup()))
return;
- ScriXmlDoc ss;
- QString BufferS = ss.writeElem(doc, doc->m_Selection);
+ QString BufferS = ScriXmlDoc::writeElem(doc, doc->m_Selection);
if ((m_prefsManager.appPrefs.scrapbookPrefs.doCopyToScrapbook) && (!internalCopy))
{
scrapbookPalette->objFromCopyAction(BufferS, currItem->itemName());
@@ -4533,8 +4539,7 @@
tempSelection.removeItem(doc->m_Selection->itemAt(i));
}
- ScriXmlDoc ss;
- QString BufferS = ss.writeElem(doc, &tempSelection);
+ QString BufferS = ScriXmlDoc::writeElem(doc, &tempSelection);
if (!internalCopy)
{
if ((m_prefsManager.appPrefs.scrapbookPrefs.doCopyToScrapbook) && (!internalCopy))
@@ -4985,8 +4990,7 @@
bool hasExternalData = ScMimeData::clipboardHasKnownData();
if (HaveDoc && !doc->m_Selection->isEmpty())
{
- PageItem *currItem = nullptr;
- currItem = doc->m_Selection->itemAt(0);
+ const PageItem *currItem = doc->m_Selection->itemAt(0);
textFrameEditMode = ((doc->appMode == modeEdit) && (currItem->isTextFrame()));
tableEditMode = ((doc->appMode == modeEditTable) && (currItem->isTable()));
}
@@ -5251,7 +5255,7 @@
else if (where == 2)
wot = doc->Pages->count();
- qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
view->updatesOn(false);
const PageSet& pageSet = doc->pageSets()[doc->pagePositioning()];
ScPage* currentPage = doc->currentPage();
@@ -5274,7 +5278,7 @@
}
doc->setCurrentPage(currentPage);
view->updatesOn(true);
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
//Use wo, the dialog currently returns a page Index +1 due to old numbering scheme, function now does the -1 as required
doc->changed();
doc->addPageToAnnotLinks(wot, where, numPages);
@@ -6212,24 +6216,24 @@
void ScribusMainWindow::setAlignmentValue(int i)
{
contentPalette->updateTextAlignment(i);
- QString alignment[] = {"Left", "Center", "Right", "Block", "Forced"};
- for (int j=0; j<5; ++j)
- {
- QString actionName="align"+alignment[j];
+ std::array<QString, 5> alignment = {"Left", "Center", "Right", "Block", "Forced"};
+ for (size_t j = 0; j < alignment.size(); ++j)
+ {
+ QString actionName = "align" + alignment[j];
if (scrActions[actionName])
- scrActions[actionName]->setChecked(i==j);
+ scrActions[actionName]->setChecked(i == j);
}
}
void ScribusMainWindow::setDirectionValue(int i)
{
contentPalette->updateTextDirection(i);
- QString direction[] = {"Left", "Right"};
- for (int j=0; j<2; ++j)
- {
- QString actionName="direction"+direction[j];
+ std::array<QString, 2> direction = {"Left", "Right"};
+ for (size_t j = 0; j < direction.size(); ++j)
+ {
+ QString actionName = "direction" + direction[j];
if (scrActions[actionName])
- scrActions[actionName]->setChecked(i==j);
+ scrActions[actionName]->setChecked(i == j);
}
}
@@ -6250,7 +6254,7 @@
default:
currItem->SetFrameShape(c, vals);
doc->setRedrawBounding(currItem);
- currItem->FrameType = f+2;
+ currItem->FrameType = f + 2;
break;
}
currItem->update();
@@ -6378,9 +6382,10 @@
return;
doc->m_Selection->connectItemToGUI();
- PageItem *currItem = doc->m_Selection->itemAt(0);
+ const PageItem *currItem = doc->m_Selection->itemAt(0);
QTransform itemTrans = currItem->getTransform();
- double xOffset = 0.0, yOffset = 0.0;
+ double xOffset = 0.0;
+ double yOffset = 0.0;
switch (position)
{
case 1: //top left
@@ -6458,7 +6463,7 @@
styleName = newUIStyle;
QStyle * newStyle = QStyleFactory::create(styleName);
if (newStyle)
- ScQApp->setStyle(newStyle);
+ QApplication::setStyle(newStyle);
else
m_prefsManager.appPrefs.uiPrefs.style = oldPrefs.uiPrefs.style;
}
@@ -6470,9 +6475,9 @@
int newUIFontSize = m_prefsManager.guiFontSize();
if (oldPrefs.uiPrefs.applicationFontSize != newUIFontSize)
{
- QFont apf = qApp->font();
+ QFont apf = QApplication::font();
apf.setPointSize(newUIFontSize);
- qApp->setFont(apf);
+ QApplication::setFont(apf);
}
emit UpdateRequest(reqDefFontListUpdate);
if (m_prefsManager.appPrefs.uiPrefs.useTabs)
@@ -6566,10 +6571,10 @@
{
setStatusBarInfoText( tr("Updating Images"));
mainWindowProgressBar->reset();
- qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
- qApp->processEvents();
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+ QApplication::processEvents();
doc->recalcPicturesRes(ScribusDoc::RecalcPicRes_ApplyNewRes);
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
setStatusBarInfoText("");
mainWindowProgressBar->reset();
viewToolBar->setDoc(doc);
@@ -6928,7 +6933,7 @@
PSLib *pslib = new PSLib(doc, options, PSLib::OutputEPS);
if (pslib != nullptr)
{
- qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
int psRet = pslib->createPS(fn);
if (psRet == 1)
{
@@ -6936,7 +6941,7 @@
return_value = false;
}
delete pslib;
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
}
ScCore->fileWatcher->start();
return return_value;
@@ -7107,7 +7112,7 @@
if (!dia.exec())
return;
- qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
dia.updateDocOptions();
doc->pdfOptions().firstUse = false;
ReOrderText(doc, view);
@@ -7173,7 +7178,7 @@
QString realName = QDir::toNativeSeparators(path + "/" + name + tr("-Page%1").arg(pageNs[aa], 3, 10, QChar('0')) + "." + ext);
if (!getPDFDriver(realName, pageNs2, thumbs, errorMsg, &cancelled))
{
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
QString message = tr("Cannot write the file: \n%1").arg(doc->pdfOptions().fileName);
if (!errorMsg.isEmpty())
message = QString("%1\n%2").arg(message, errorMsg);
@@ -7187,7 +7192,7 @@
{
if (!getPDFDriver(fileName, pageNs, allThumbs, errorMsg))
{
- qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+ QApplication::changeOverrideCursor(QCursor(Qt::ArrowCursor));
QString message = tr("Cannot write the file: \n%1").arg(doc->pdfOptions().fileName);
if (!errorMsg.isEmpty())
message = QString("%1\n%2").arg(message, errorMsg);
@@ -7196,7 +7201,7 @@
}
if (doc->pdfOptions().useDocBleeds)
doc->pdfOptions().bleeds = optBleeds;
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
if (errorMsg.isEmpty() && doc->pdfOptions().openAfterExport && !doc->pdfOptions().doMultiFile)
{
QString pdfViewer(PrefsManager::instance().appPrefs.extToolPrefs.pdfViewerExecutable);
@@ -7928,7 +7933,7 @@
{
// changed from "this" to qApp->activeWindow() to be sure it will be opened
// with the current active window as parent. E.g. it won't hide StoryEditor etc. -- PV
- CustomFDialog *dia = new CustomFDialog(qApp->activeWindow(), workingDirectory, dialogCaption, fileFilter, optionFlags);
+ CustomFDialog *dia = new CustomFDialog(QApplication::activeWindow(), workingDirectory, dialogCaption, fileFilter, optionFlags);
if (!defaultFilename.isEmpty())
{
QString tmpFileName = defaultFilename;
@@ -7974,7 +7979,7 @@
}
this->repaint();
retVal = dia->selectedFile();
- qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
}
delete dia;
return retVal;
@@ -8041,8 +8046,8 @@
return;
if (doc->m_Selection->isEmpty())
return;
- ScriXmlDoc ss;
- QString objectString = ss.writeElem(doc, doc->m_Selection);
+
+ QString objectString = ScriXmlDoc::writeElem(doc, doc->m_Selection);
QDomDocument docu("scridoc");
docu.setContent(objectString);
QDomElement elem = docu.documentElement();
@@ -8201,10 +8206,9 @@
void ScribusMainWindow::ImageEffects()
{
- if (!HaveDoc)
- return;
- if (doc->m_Selection->isEmpty())
- return;
+ if (!HaveDoc || doc->m_Selection->isEmpty())
+ return;
+
PageItem *currItem = doc->m_Selection->itemAt(0);
EffectsDialog* dia = new EffectsDialog(this, currItem, doc);
if (dia->exec())
@@ -8218,8 +8222,8 @@
compress=true;
CollectForOutput_UI c(this, doc, QString(), withFonts, withProfiles, compress);
QString newFileName;
- QString errorMsg=c.collect(newFileName);
- qDebug()<<errorMsg;
+ QString errorMsg = c.collect(newFileName);
+ qDebug() << errorMsg;
return newFileName;
}
@@ -8441,7 +8445,7 @@
}
}
-bool ScribusMainWindow::isObjectSpecificUndo()
+bool ScribusMainWindow::isObjectSpecificUndo() const
{
return m_objectSpecificUndo;
}
@@ -8531,7 +8535,7 @@
m_prefsManager.languageChange();
CommonStrings::languageChange();
LanguageManager::instance()->languageChange();
- qApp->setLayoutDirection(QLocale(ScCore->getGuiLanguage()).textDirection());
+ QApplication::setLayoutDirection(QLocale(ScCore->getGuiLanguage()).textDirection());
//Update actions
if (actionManager != nullptr)
{
@@ -8592,7 +8596,7 @@
if (!doc->masterPageMode())
return;
editMasterPagesEnd();
- qApp->processEvents();
+ QApplication::processEvents();
}
void ScribusMainWindow::updateActiveWindowCaption(const QString &newCaption)
@@ -8734,7 +8738,7 @@
if (currItem->itemType() != PageItem::ImageFrame)
return;
- PageItem_ImageFrame* imageItem = currItem->asImageFrame();
+ const PageItem_ImageFrame* imageItem = currItem->asImageFrame();
if (!imageItem->imageIsAvailable)
return;
contentsBuffer.contentsFileName.clear();
@@ -8779,8 +8783,8 @@
imageItem->ImageProfile = doc->cmsSettings().DefaultImageRGBProfile;
imageItem->ImageIntent = doc->cmsSettings().DefaultIntentImages;
imageItem->effectsInUse = contentsBuffer.effects;
- qApp->setOverrideCursor( QCursor(Qt::WaitCursor) );
- qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
+ QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
doc->loadPict(contentsBuffer.contentsFileName, imageItem);
imageItem->setImageXYScale(contentsBuffer.LocalScX, contentsBuffer.LocalScY);
if (absolute == 0)
@@ -8792,13 +8796,13 @@
imageItem->ImageProfile = contentsBuffer.inputProfile;
imageItem->ImageIntent = contentsBuffer.renderingIntent;
imageItem->UseEmbedded = contentsBuffer.useEmbedded;
- qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+ QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
view->DrawNew();
propertiesPalette->updateColorList();
contentPalette->updateColorList();
emit UpdateRequest(reqCmsOptionsUpdate);
currItem->emitAllToGUI();
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
}
void ScribusMainWindow::slotInsertFrame()
@@ -8832,12 +8836,12 @@
UndoTransaction trans;
if (UndoManager::undoEnabled())
trans = m_undoManager->beginTransaction(Um::Selection, Um::IPolygon, Um::Transform, QString(), Um::IMove);
- qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
int count=td.getCount();
QTransform matrix(td.getTransformMatrix());
int basepoint=td.getBasepoint();
doc->itemSelection_Transform(count, matrix, basepoint);
- qApp->restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
if (trans)
{
trans.commit();
@@ -9147,9 +9151,9 @@
void ScribusMainWindow::manageColorsAndFills()
{
ColorList colorlist;
- QHash<QString, VGradient> *gradients;
- QHash<QString, ScPattern> *patterns;
- ScribusDoc* tmpDoc;
+ QHash<QString, VGradient>* gradients { nullptr };
+ QHash<QString, ScPattern> *patterns { nullptr };
+ ScribusDoc* tmpDoc { nullptr };
if (HaveDoc)
{
gradients = &doc->docGradients;
Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25058&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Thu Mar 24 21:42:50 2022
@@ -192,7 +192,7 @@
* @brief Returns true if application is in object specific undo mode, other wise returns false.
* @return true if application is in object specific undo mode, other wise returns false
*/
- bool isObjectSpecificUndo();
+ bool isObjectSpecificUndo() const;
void restore(UndoState* state, bool isUndo) override;
void restoreGrouping(SimpleState *state, bool isUndo);
void restoreUngrouping(SimpleState *state, bool isUndo);
Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25058&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Thu Mar 24 21:42:50 2022
@@ -145,9 +145,8 @@
setWidgetResizable(false);
m_canvasMode = CanvasMode::createForAppMode(this, m_doc->appMode);
setWidget(m_canvas);
- //already done by QScrollArea: widget()->installEventFilter(this);
+ // already done by QScrollArea: widget()->installEventFilter(this)
installEventFilter(this); // FIXME:av
- // viewport()->setBackgroundMode(Qt::PaletteBackground);
setFocusPolicy(Qt::ClickFocus);
QFont fo = QFont(font());
// #8058: Better not use too small font size on Windows
@@ -426,8 +425,6 @@
if (PrefsManager::instance().appPrefs.uiPrefs.stickyTools)
{
m_canvas->setForcedRedraw(true);
- // Doc->m_Selection->clear();
- // emit HaveSel();
m_canvas->resetRenderMode();
updateContents();
}
@@ -574,11 +571,6 @@
dragH = gh;
DraggedGroup = true;
getDragRectScreen(&gx, &gy, &gw, &gh);
- // QPoint evP = viewport()->mapToGlobal(e->pos());
- // evP -= QPoint(contentsX(), contentsY());
- // redrawMarker->setGeometry(QRect(evP.x() + 1, evP.y() + 1, qRound(gw), qRound(gh)).normalized());
- // if (!redrawMarker->isVisible())
- // redrawMarker->show();
emit ItemGeom();
}
}
@@ -593,48 +585,15 @@
text = e->mimeData()->text();
if (DraggedGroup)
{
- // double gx, gy, gw, gh;
FPoint dragPosDoc = m_canvas->globalToCanvas(widget()->mapToGlobal(e->position()));
dragX = dragPosDoc.x();
dragY = dragPosDoc.y();
- // getDragRectScreen(&gx, &gy, &gw, &gh);
- // QPoint evP = viewport()->mapToGlobal(e->pos());
- // evP -= QPoint(contentsX(), contentsY());
- // redrawMarker->setGeometry(QRect(evP.x() + 2, evP.y() + 2, qRound(gw - 2), qRound(gh - 2)).normalized());
- // if (!redrawMarker->isVisible())
- // redrawMarker->show();
- emit MousePos(dragX, dragY); //+Doc->minCanvasCoordinate.x(), dragY+Doc->minCanvasCoordinate.y());
+ emit MousePos(dragX, dragY);
QPoint pos = m_canvas->canvasToLocal(dragPosDoc);
horizRuler->draw(pos.x());
vertRuler->draw(pos.y());
// return;
}
- /* QUrl ur(text);
- QFileInfo fi = QFileInfo(ur.toLocalFile());
- QString ext = fi.extension(false).toUpper();
- QStrList imfo = QImageIO::inputFormats();
- if (ext == "JPG")
- ext = "JPEG";
- img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="TIF"));
- if (!SeleItemPos(e->pos()))
- {
- if (SelItem.count() != 0)
- Deselect(true);
- }
- else
- {
- item = SelItem.at(0);
- if (img)
- {
- if (item->PType != 2)
- Deselect(true);
- }
- else
- {
- if (item->PType != 4)
- Deselect(true);
- }
- } */
}
}
@@ -644,7 +603,6 @@
{
DraggedGroup = false;
m_canvas->resetRenderMode();
- // redrawMarker->hide();
updateContents();
}
}
@@ -1262,7 +1220,6 @@
void ScribusView::getDragRectScreen(double *x, double *y, double *w, double *h)
{
QPoint in(qRound(dragX * m_canvas->scale()), qRound(dragY * m_canvas->scale()));
- // in -= QPoint(qRound(Doc->minCanvasCoordinate.x() * m_canvas->scale()), qRound(Doc->minCanvasCoordinate.y() * m_canvas->scale()));
QPoint out = contentsToViewport(in);
*x = static_cast<double>(out.x());
*y = static_cast<double>(out.y());
@@ -1275,7 +1232,6 @@
double gx, gy, gh, gw;
m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
QPoint in(qRound(gx * m_canvas->scale()), qRound(gy * m_canvas->scale()));
- // in -= QPoint(qRound(Doc->minCanvasCoordinate.x() * m_canvas->scale()), qRound(Doc->minCanvasCoordinate.y() * m_canvas->scale()));
QPoint out = contentsToViewport(in);
*x = static_cast<double>(out.x());
*y = static_cast<double>(out.y());
@@ -1308,48 +1264,48 @@
//CB-->elsewhere, util, however, only used in the view for now
-bool ScribusView::PointOnLine(QPoint Start, QPoint End, QRect MArea)
+bool ScribusView::PointOnLine(QPoint start, QPoint end, QRect mArea)
{
QPoint an, en;
- if (Start.x() == End.x())
- {
- an = Start.y() > End.y() ? End : Start;
- en = an == End ? Start : End;
+ if (start.x() == end.x())
+ {
+ an = start.y() > end.y() ? end : start;
+ en = an == end ? start : end;
for (int i = an.y(); i < en.y(); ++i)
{
- if (MArea.contains(an.x(), i))
+ if (mArea.contains(an.x(), i))
return true;
}
}
- if (Start.y() == End.y())
- {
- an = Start.x() > End.x() ? End : Start;
- en = an == End ? Start : End;
+ if (start.y() == end.y())
+ {
+ an = start.x() > end.x() ? end : start;
+ en = an == end ? start : end;
for (int i = an.x(); i < en.x(); ++i)
{
- if (MArea.contains(i, an.y()))
+ if (mArea.contains(i, an.y()))
return true;
}
}
- if (abs(Start.x() - End.x()) > abs(Start.y() - End.y()))
- {
- an = Start.x() > End.x() ? End : Start;
- en = an == End ? Start : End;
+ if (abs(start.x() - end.x()) > abs(start.y() - end.y()))
+ {
+ an = start.x() > end.x() ? end : start;
+ en = an == end ? start : end;
double stg = (en.y() - an.y()) / static_cast<double>((en.x() - an.x()));
for (int i = an.x(); i < en.x(); ++i)
{
- if (MArea.contains(i, an.y() + qRound((i - an.x()) * stg)))
+ if (mArea.contains(i, an.y() + qRound((i - an.x()) * stg)))
return true;
}
}
else
{
- an = Start.y() > End.y() ? End : Start;
- en = an == End ? Start : End;
+ an = start.y() > end.y() ? end : start;
+ en = an == end ? start : end;
double stg = (en.x() - an.x()) / static_cast<double>((en.y() - an.y()));
for (int i = an.y(); i < en.y(); ++i)
{
- if (MArea.contains(an.x() + qRound((i - an.y()) * stg), i))
+ if (mArea.contains(an.x() + qRound((i - an.y()) * stg), i))
return true;
}
}
@@ -1868,7 +1824,7 @@
endEditButton->setGeometry(m_vhRulerHW + 1, height() - m_vhRulerHW - endEditButton->minimumSizeHint().height() - 1, endEditButton->minimumSizeHint().width(), endEditButton->minimumSizeHint().height());
m_canvas->setForcedRedraw(true);
m_canvas->resetRenderMode();
- // Per Qt doc, not painting should be done in a resizeEvent,
+ // Per Qt doc, no painting should be done in a resizeEvent,
// a paint event will be emitted right afterwards
// m_canvas->update();
}
@@ -2013,7 +1969,6 @@
int ws = static_cast<int>(m_doc->Pages->at(i)->width() * m_canvas->scale());
int hs = static_cast<int>(m_doc->Pages->at(i)->height() * m_canvas->scale());
QRect drawRect(x, y, visibleWidth(), visibleHeight());
- // drawRect.moveBy(qRound(-Doc->minCanvasCoordinate.x() * m_canvas->scale()), qRound(-Doc->minCanvasCoordinate.y() * m_canvas->scale()));
if (drawRect.intersects(QRect(xs, ys, ws, hs)))
pag.append(i+1);
}
@@ -2186,7 +2141,8 @@
int zoomY = qRound(y + h / 2);
rememberOldZoomLocation(zoomX, zoomY);
- int zoomPointX(m_oldZoomX), zoomPointY(m_oldZoomY);
+ int zoomPointX(m_oldZoomX);
+ int zoomPointY(m_oldZoomY);
if (m_doc->m_Selection->count() != 0)
{
QRectF selRect = m_doc->m_Selection->getVisualGroupRect();
@@ -2195,7 +2151,7 @@
}
else if (m_doc->currentPage() != nullptr)
{
- ScPage* currentPage = m_doc->currentPage();
+ const ScPage* currentPage = m_doc->currentPage();
zoomPointX = qRound(currentPage->xOffset() + currentPage->width() / 2.0);
zoomPointY = qRound(currentPage->yOffset() + currentPage->height() / 2.0);
}
@@ -3140,17 +3096,17 @@
gItem->gXpos = currItem->gXpos;
gItem->gYpos = currItem->gYpos;
if (currItem->isGroupChild())
- currItem->parentGroup()->groupItemList.insert(ind+1, gItem);
+ currItem->parentGroup()->groupItemList.insert(ind + 1, gItem);
else
- m_doc->Items->insert(ind+1, gItem);
+ m_doc->Items->insert(ind + 1, gItem);
}
else if (newGroupedItems.count() > 0)
{
newGroupedItems.at(0)->Parent = currItem->Parent;
if (currItem->isGroupChild())
- currItem->parentGroup()->groupItemList.insert(ind+1, newGroupedItems.at(0));
+ currItem->parentGroup()->groupItemList.insert(ind + 1, newGroupedItems.at(0));
else
- m_doc->Items->insert(ind+1, newGroupedItems.at(0));
+ m_doc->Items->insert(ind + 1, newGroupedItems.at(0));
}
int toDeleteItemCount = delItems.count();
@@ -3296,8 +3252,6 @@
unitChange();
}
-
-
double ScribusView::scale() const
{
@@ -3538,7 +3492,7 @@
{
QPoint globalPoint = m_canvas->canvasToGlobal(QPointF(canvasX, canvasY));
double oldScale = m_canvas->scale();
- double newScale = (scale > (Prefs->opToolPrefs.magMax / 100) * Prefs->displayPrefs.displayScale) ? ((Prefs->opToolPrefs.magMax / 100) * Prefs->displayPrefs.displayScale) : scale;
+ double newScale = (scale > (Prefs->opToolPrefs.magMax / 100.0) * Prefs->displayPrefs.displayScale) ? ((Prefs->opToolPrefs.magMax / 100.0) * Prefs->displayPrefs.displayScale) : scale;
undoManager->setUndoEnabled(false);
updatesOn(false);
setScale(newScale);
Modified: trunk/Scribus/scribus/scribusview.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25058&path=/trunk/Scribus/scribus/scribusview.h
==============================================================================
--- trunk/Scribus/scribus/scribusview.h (original)
+++ trunk/Scribus/scribus/scribusview.h Thu Mar 24 21:42:50 2022
@@ -182,7 +182,7 @@
void setNewRulerOrigin(QMouseEvent *m);
void getDragRectScreen(double *x, double *y, double *w, double *h);
void getGroupRectScreen(double *x, double *y, double *w, double *h);
- bool PointOnLine(QPoint Start, QPoint Ende, QRect MArea);
+ bool PointOnLine(QPoint start, QPoint end, QRect mArea);
void TransformPoly(int mode, int rot = 1, double scaling = 1.0);
bool slotSetCurs(int x, int y);
// \brief return a resize cursor if the mouse is on a handle.
More information about the scribus-commit
mailing list