Merge remote-tracking branch 'upstream/master'

preferencesAboutTextFull
Mario Izquierdo (mariodebian) 13 years ago
commit fd322cdf43
  1. 31
      src/board/UBBoardView.cpp
  2. 2
      src/board/UBBoardView.h
  3. 1
      src/core/UBSettings.cpp
  4. 2
      src/core/UBSettings.h
  5. 2
      src/domain/UBGraphicsScene.cpp
  6. 123
      src/domain/UBGraphicsTextItemDelegate.cpp
  7. 5
      src/domain/UBGraphicsTextItemDelegate.h
  8. 15
      src/frameworks/UBFileSystemUtils.cpp
  9. 2
      src/gui/UBDocumentThumbnailWidget.cpp
  10. 4
      src/gui/UBKeyboardPalette.cpp

@ -72,6 +72,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent)
, mController (pController) , mController (pController)
, mIsCreatingTextZone (false) , mIsCreatingTextZone (false)
, mIsCreatingSceneGrabZone (false) , mIsCreatingSceneGrabZone (false)
, mOkOnWidget(false)
{ {
init (); init ();
@ -738,16 +739,27 @@ void UBBoardView::dragMoveEvent (QDragMoveEvent *event)
QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y()); QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y());
UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos); UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos);
if (graphicsWidget && graphicsWidget->acceptDrops()){ if (graphicsWidget) {
if (isDropableData(event->mimeData())) { if (graphicsWidget->acceptDrops()) {
if (!mOkOnWidget) {
if (!isDropableData(event->mimeData())) {
mOkOnWidget = false;
event->ignore();
return;
} else {
mOkOnWidget = true;
}
}
QPoint newPoint(graphicsWidget->mapFromScene(mapToScene(event->pos())).toPoint()); QPoint newPoint(graphicsWidget->mapFromScene(mapToScene(event->pos())).toPoint());
QDragMoveEvent newEvent(newPoint, event->dropAction(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers()); QDragMoveEvent newEvent(newPoint, event->dropAction(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers());
QApplication::sendEvent(graphicsWidget->widgetWebView(),&newEvent); QApplication::sendEvent(graphicsWidget->widgetWebView(),&newEvent);
} else { } else {
mOkOnWidget = false;
event->ignore(); event->ignore();
} }
} else { } else {
event->acceptProposedAction(); event->acceptProposedAction();
mOkOnWidget = false;
} }
} }
@ -804,6 +816,9 @@ QString UBBoardView::fileExtention(const QString &filename)
} }
QString UBBoardView::typeForExtention(const QString &extention) QString UBBoardView::typeForExtention(const QString &extention)
{ {
if (extention.isEmpty())
return QString();
QString result = QString(); QString result = QString();
if (audioExtentions.contains(extention)) { if (audioExtentions.contains(extention)) {
@ -812,24 +827,26 @@ QString UBBoardView::typeForExtention(const QString &extention)
result = videoAlias; result = videoAlias;
} else if (imageExtentions.contains(extention)) { } else if (imageExtentions.contains(extention)) {
result = imageAlias; result = imageAlias;
} else if (htmlExtentions.contains(extention)) { // } else if (htmlExtentions.contains(extention)) {
result = htmlAlias; // result = htmlAlias;
} }
return result; return result;
} }
bool UBBoardView::isDropableData(const QMimeData *pMimeData) bool UBBoardView::isDropableData(const QMimeData *pMimeData)
{ {
if (pMimeData->hasUrls()) if (pMimeData->hasUrls()) {
if (!typeForExtention(fileExtention(pMimeData->urls().at(0).toLocalFile())).isNull()) if (!typeForExtention(fileExtention(pMimeData->urls().at(0).toLocalFile())).isNull()) {
return true; return true;
}
}
return false; return false;
} }
void UBBoardView::dropEvent (QDropEvent *event) void UBBoardView::dropEvent (QDropEvent *event)
{ {
qDebug() << event->source(); mOkOnWidget = false;
QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y()); QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y());
UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos); UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos);

@ -116,6 +116,8 @@ class UBBoardView : public QGraphicsView
bool isAbsurdPoint(QPoint point); bool isAbsurdPoint(QPoint point);
bool mVirtualKeyboardActive; bool mVirtualKeyboardActive;
bool mOkOnWidget;
QString typeForExtention(const QString &extention); QString typeForExtention(const QString &extention);
QString fileExtention(const QString &filename); QString fileExtention(const QString &filename);

@ -363,6 +363,7 @@ void UBSettings::init()
intranetPodcastPublishingUrl = new UBSetting(this, "IntranetPodcast", "PublishingUrl", ""); intranetPodcastPublishingUrl = new UBSetting(this, "IntranetPodcast", "PublishingUrl", "");
intranetPodcastAuthor = new UBSetting(this, "IntranetPodcast", "Author", ""); intranetPodcastAuthor = new UBSetting(this, "IntranetPodcast", "Author", "");
KeyboardLocale = new UBSetting(this, "Board", "StartupKeyboardLocale", 0);
} }

@ -318,6 +318,8 @@ class UBSettings : public QObject
static int libPaletteWidth; static int libPaletteWidth;
*/ */
UBSetting* KeyboardLocale;
public slots: public slots:
void setPenWidthIndex(int index); void setPenWidthIndex(int index);

@ -1938,7 +1938,7 @@ void UBGraphicsScene::keyReleaseEvent(QKeyEvent * keyEvent)
QList<QGraphicsItem*> si = selectedItems(); QList<QGraphicsItem*> si = selectedItems();
if (si.size() > 0 && !keyEvent->isAccepted()) if ((si.size() > 0) && (keyEvent->isAccepted()))
{ {
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
if (keyEvent->key() == Qt::Key_Backspace) if (keyEvent->key() == Qt::Key_Backspace)

@ -35,6 +35,7 @@ const int UBGraphicsTextItemDelegate::sMinPointSize = 8;
UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDelegated, QObject * parent) UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDelegated, QObject * parent)
: UBGraphicsItemDelegate(pDelegated,0, parent, true) : UBGraphicsItemDelegate(pDelegated,0, parent, true)
, mLastFontPixelSize(-1) , mLastFontPixelSize(-1)
, delta(5)
{ {
delegated()->setData(UBGraphicsItemData::ItemEditable, QVariant(true)); delegated()->setData(UBGraphicsItemData::ItemEditable, QVariant(true));
delegated()->setPlainText(""); delegated()->setPlainText("");
@ -231,82 +232,12 @@ void UBGraphicsTextItemDelegate::pickColor()
void UBGraphicsTextItemDelegate::decreaseSize() void UBGraphicsTextItemDelegate::decreaseSize()
{ {
QTextCursor cursor = delegated()->textCursor(); ChangeTextSize(-delta);
QTextCharFormat textFormat;
QFont curFont = cursor.charFormat().font();
int pointSize = curFont.pointSize();
pointSize -= 5;
// QFontInfo fi(delegated()->font());
// int pixelSize = fi.pixelSize();
// if (-1 == mLastFontPixelSize)
// mLastFontPixelSize = pixelSize;
// int newPixelSize = sMinPixelSize;
// while (newPixelSize * 1.5 < pixelSize)
// newPixelSize *= 1.5;
// if (newPixelSize < mLastFontPixelSize && mLastFontPixelSize < pixelSize)
// newPixelSize = mLastFontPixelSize;
// if (pixelSize > newPixelSize)
// {
// QFont font = delegated()->font();
// font.setPixelSize(newPixelSize);
// delegated()->setFont(font);
// UBSettings::settings()->setFontPixelSize(newPixelSize);
// delegated()->document()->adjustSize();
// delegated()->contentsChanged();dddd
// }
curFont.setPointSize(pointSize);
textFormat.setFont(curFont);
cursor.mergeCharFormat(textFormat);
delegated()->setTextCursor(cursor);
UBSettings::settings()->setFontPixelSize(curFont.pixelSize());
UBSettings::settings()->setFontPointSize(pointSize);
delegated()->document()->adjustSize();
delegated()->setFont(curFont);
} }
void UBGraphicsTextItemDelegate::increaseSize() void UBGraphicsTextItemDelegate::increaseSize()
{ {
QTextCursor cursor = delegated()->textCursor(); ChangeTextSize(delta);
QTextCharFormat textFormat;
QFont curFont = cursor.charFormat().font();
int pointSize = curFont.pointSize();
pointSize += 5;
// QFontInfo fi(cursor.charFormat().font());
// int pixelSize = fi.pixelSize();
// if (-1 == mLastFontPixelSize)
// mLastFontPixelSize = pixelSize;
// int newPixelSize = sMinPixelSize;
// while (newPixelSize <= pixelSize)
// newPixelSize *= 1.5;
// if (pixelSize < mLastFontPixelSize && mLastFontPixelSize < newPixelSize)
// newPixelSize = mLastFontPixelSize;
curFont.setPointSize(pointSize);
textFormat.setFont(curFont);
cursor.mergeCharFormat(textFormat);
delegated()->setTextCursor(cursor);
// UBSettings::settings()->setFontPixelSize(curFont.pixelSize());
UBSettings::settings()->setFontPointSize(pointSize);
delegated()->document()->adjustSize();
delegated()->setFont(curFont);
// delegated()->contentsChanged();
} }
UBGraphicsTextItem* UBGraphicsTextItemDelegate::delegated() UBGraphicsTextItem* UBGraphicsTextItemDelegate::delegated()
@ -349,3 +280,51 @@ void UBGraphicsTextItemDelegate::positionHandles()
UBGraphicsItemDelegate::positionHandles(); UBGraphicsItemDelegate::positionHandles();
setEditable(isEditable()); setEditable(isEditable());
} }
void UBGraphicsTextItemDelegate::ChangeTextSize(int delta)
{
if (0 == delta)
return;
QTextCursor cursor = delegated()->textCursor();
QTextCharFormat textFormat;
int anchorPos = cursor.anchor();
int cursorPos = cursor.position();
if (0 == anchorPos-cursorPos)
{
cursor.setPosition (0, QTextCursor::MoveAnchor);
cursor.setPosition (cursor.document()->characterCount()-1, QTextCursor::KeepAnchor);
}
int startPos = qMin(cursor.anchor(), cursor.position());
int endPos = qMax(cursor.anchor(), cursor.position());
for (int i = startPos; i < endPos ; i++)
{
// selecting single symbol
cursor.setPosition (i, QTextCursor::MoveAnchor);
cursor.setPosition (i+1, QTextCursor::KeepAnchor);
//setting new parameners
QFont curFont = cursor.charFormat().font();
int pointSize = curFont.pointSize() + delta;
curFont.setPointSize(pointSize);
textFormat.setFont(curFont);
cursor.mergeCharFormat(textFormat);
delegated()->setTextCursor(cursor);
UBSettings::settings()->setFontPointSize(pointSize);
delegated()->document()->adjustSize();
delegated()->setFont(curFont);
}
//returning initial selection
cursor.setPosition (anchorPos, QTextCursor::MoveAnchor);
cursor.setPosition (cursorPos, QTextCursor::KeepAnchor);
delegated()->setTextCursor(cursor);
}

@ -61,6 +61,8 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
private: private:
void customize(QFontDialog &fontDialog); void customize(QFontDialog &fontDialog);
void ChangeTextSize(int delta);
QFont createDefaultFont(); QFont createDefaultFont();
QAction *mEditableAction; QAction *mEditableAction;
@ -72,6 +74,9 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
void decreaseSize(); void decreaseSize();
void increaseSize(); void increaseSize();
private:
const int delta;
}; };
#endif /* UBGRAPHICSTEXTITEMDELEGATE_H_ */ #endif /* UBGRAPHICSTEXTITEMDELEGATE_H_ */

@ -60,20 +60,23 @@ bool UBFileSystemUtils::copyFile(const QString &source, const QString &Destinati
qDebug() << "file" << source << "does not present in fs"; qDebug() << "file" << source << "does not present in fs";
return false; return false;
} }
if (QFile::exists(Destination)) {
if (QFileInfo(Destination).isFile() && overwrite) { QString normalizedDestination = Destination;
QFile::remove(Destination); if (QFile::exists(normalizedDestination)) {
if (QFileInfo(normalizedDestination).isFile() && overwrite) {
QFile::remove(normalizedDestination);
} }
} else { } else {
int pos = Destination.lastIndexOf(QDir::separator()); normalizedDestination = normalizedDestination.replace(QString("\\"), QString("/"));
int pos = normalizedDestination.lastIndexOf("/");
if (pos != -1) { if (pos != -1) {
QString newpath = Destination.left(pos); QString newpath = normalizedDestination.left(pos);
if (!QDir().mkpath(newpath)) { if (!QDir().mkpath(newpath)) {
qDebug() << "can't create a new path at " << newpath; qDebug() << "can't create a new path at " << newpath;
} }
} }
} }
return QFile::copy(source, Destination); return QFile::copy(source, normalizedDestination);
} }
QString UBFileSystemUtils::defaultTempDirPath() QString UBFileSystemUtils::defaultTempDirPath()

@ -254,4 +254,6 @@ void UBDocumentThumbnailWidget::hightlightItem(int index)
if (thumbnail) if (thumbnail)
thumbnail->highlight(); thumbnail->highlight();
} }
selectItemAt(index);
} }

@ -54,7 +54,7 @@ UBKeyboardPalette::UBKeyboardPalette(QWidget *parent)
createCtrlButtons(); createCtrlButtons();
nCurrentLocale = 0; nCurrentLocale = UBSettings::settings()->KeyboardLocale->get().toInt();
setInput(locales[nCurrentLocale]); setInput(locales[nCurrentLocale]);
setContentsMargins( 22, 22, 22, 22 ); setContentsMargins( 22, 22, 22, 22 );
@ -166,6 +166,8 @@ void UBKeyboardPalette::setLocale(int nLocale)
setInput(locales[nCurrentLocale]); setInput(locales[nCurrentLocale]);
onLocaleChanged(locales[nCurrentLocale]); onLocaleChanged(locales[nCurrentLocale]);
update(); update();
UBSettings::settings()->KeyboardLocale->set(nCurrentLocale);
} }
emit localeChanged(nLocale); emit localeChanged(nLocale);
} }

Loading…
Cancel
Save