Duplicated group button functionality on the frame

preferencesAboutTextFull
Ilia Ryabokon 11 years ago
parent ab828a1824
commit 241ddb92a1
  1. 2
      src/adaptors/UBMetadataDcSubsetAdaptor.cpp
  2. 3
      src/board/UBBoardController.cpp
  3. 4
      src/core/UBApplication.cpp
  4. 14
      src/core/UBSettings.cpp
  5. 1
      src/core/UBSettings.h
  6. 20
      src/domain/UBGraphicsGroupContainerItemDelegate.cpp
  7. 5
      src/domain/UBGraphicsGroupContainerItemDelegate.h
  8. 33
      src/domain/UBSelectionFrame.cpp
  9. 4
      src/domain/UBSelectionFrame.h

@ -85,7 +85,7 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy)
return; return;
} }
QString fileName = proxy->persistencePath() + "/" + metadataFilename; QString fileName = proxy->persistencePath() + "/" + metadataFilename;
qWarning() << fileName; qWarning() << "Persisting document path is" << fileName;
QFile file(fileName); QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
{ {

@ -1804,8 +1804,7 @@ void UBBoardController::autosaveTimeout()
void UBBoardController::appMainModeChanged(UBApplicationController::MainMode md) void UBBoardController::appMainModeChanged(UBApplicationController::MainMode md)
{ {
// int timerInterval = autosaveTimeoutFromSettings(); int timerInterval = autosaveTimeoutFromSettings();
int timerInterval = 50000;
if (!timerInterval) { if (!timerInterval) {
return; return;
} }

@ -120,7 +120,9 @@ UBApplication::UBApplication(const QString &id, int &argc, char **argv) : QtSing
staticMemoryCleaner = new QObject(0); // deleted in UBApplication destructor staticMemoryCleaner = new QObject(0); // deleted in UBApplication destructor
setOrganizationName("Open Education Foundation"); setOrganizationName(UBSettings::organizationName());
qDebug() << "organization name" << organizationName();
qDebug() << "application" << this;
setOrganizationDomain("oe-f.org"); setOrganizationDomain("oe-f.org");
setApplicationName("OpenBoard"); setApplicationName("OpenBoard");

@ -148,6 +148,7 @@ QSettings* UBSettings::getAppSettings()
UBSettings::sAppSettings->setIniCodec("utf-8"); UBSettings::sAppSettings->setIniCodec("utf-8");
} }
qDebug() << "sAppSettings" << sAppSettings;
return UBSettings::sAppSettings; return UBSettings::sAppSettings;
} }
@ -774,7 +775,8 @@ QString UBSettings::userDataDirectory()
{ {
static QString dataDirPath = ""; static QString dataDirPath = "";
if(dataDirPath.isEmpty()){ if(dataDirPath.isEmpty()){
if (sAppSettings && getAppSettings()->contains("App/DataDirectory")) { if (getAppSettings() && getAppSettings()->contains("App/DataDirectory")) {
qDebug() << "getAppSettings()->contains(App/DataDirectory):" << getAppSettings()->contains("App/DataDirectory");
dataDirPath = getAppSettings()->value("App/DataDirectory").toString(); dataDirPath = getAppSettings()->value("App/DataDirectory").toString();
dataDirPath = replaceWildcard(dataDirPath); dataDirPath = replaceWildcard(dataDirPath);
@ -785,7 +787,9 @@ QString UBSettings::userDataDirectory()
} }
dataDirPath = UBFileSystemUtils::normalizeFilePath(QDesktopServices::storageLocation(QDesktopServices::DataLocation)); dataDirPath = UBFileSystemUtils::normalizeFilePath(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
dataDirPath.replace(qApp->organizationName() + "/", ""); qDebug() << "organization name" << UBSettings::organizationName();
qDebug() << "application" << qApp;
dataDirPath.replace(UBSettings::organizationName() + "/", "");
} }
return dataDirPath; return dataDirPath;
} }
@ -879,6 +883,11 @@ QString UBSettings::userPodcastRecordingDirectory()
return dirPath; return dirPath;
} }
QString UBSettings::organizationName()
{
return "Open Education Foundation";
}
QString UBSettings::userDocumentDirectory() QString UBSettings::userDocumentDirectory()
{ {
@ -887,6 +896,7 @@ QString UBSettings::userDocumentDirectory()
documentDirectory = userDataDirectory() + "/document"; documentDirectory = userDataDirectory() + "/document";
checkDirectory(documentDirectory); checkDirectory(documentDirectory);
} }
qDebug() << "userDocumentDirectory()" << documentDirectory;
return documentDirectory; return documentDirectory;
} }

@ -137,6 +137,7 @@ class UBSettings : public QObject
static QString userInteractiveDirectory(); static QString userInteractiveDirectory();
static QString userInteractiveFavoritesDirectory(); static QString userInteractiveFavoritesDirectory();
static QString userPodcastRecordingDirectory(); static QString userPodcastRecordingDirectory();
static QString organizationName();
QString userGipLibraryDirectory(); QString userGipLibraryDirectory();

@ -70,9 +70,23 @@ void UBGraphicsGroupContainerItemDelegate::decorateMenu(QMenu *menu)
void UBGraphicsGroupContainerItemDelegate::buildButtons() void UBGraphicsGroupContainerItemDelegate::buildButtons()
{ {
if (!mDestroyGroupButton) {
mDestroyGroupButton = new DelegateButton(":/images/minus.svg", mDelegated, mFrame, Qt::TopLeftSection);
mDestroyGroupButton->setShowProgressIndicator(false);
connect(mDestroyGroupButton, SIGNAL(clicked()), this, SLOT(destroyGroup()));
mButtons << mDestroyGroupButton;
}
UBGraphicsItemDelegate::buildButtons(); UBGraphicsItemDelegate::buildButtons();
} }
void UBGraphicsGroupContainerItemDelegate::freeButtons()
{
UBGraphicsItemDelegate::freeButtons();
mDestroyGroupButton = 0;
mButtons.clear();
}
bool UBGraphicsGroupContainerItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event) bool UBGraphicsGroupContainerItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
@ -93,3 +107,9 @@ bool UBGraphicsGroupContainerItemDelegate::mouseReleaseEvent(QGraphicsSceneMouse
return false; return false;
} }
void UBGraphicsGroupContainerItemDelegate::destroyGroup()
{
qDebug() << "Destroying group";
delegated()->destroy();
}

@ -43,11 +43,16 @@ public:
protected: protected:
virtual void decorateMenu(QMenu *menu); virtual void decorateMenu(QMenu *menu);
virtual void buildButtons(); virtual void buildButtons();
virtual void freeButtons();
virtual bool mousePressEvent(QGraphicsSceneMouseEvent *event); virtual bool mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual bool mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual bool mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual bool mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private slots:
void destroyGroup();
private: private:
DelegateButton *mDestroyGroupButton; DelegateButton *mDestroyGroupButton;
}; };

@ -29,12 +29,15 @@
#include "domain/UBItem.h" #include "domain/UBItem.h"
#include "domain/UBGraphicsItemZLevelUndoCommand.h" #include "domain/UBGraphicsItemZLevelUndoCommand.h"
#include "domain/UBGraphicsGroupContainerItem.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "gui/UBResources.h" #include "gui/UBResources.h"
#include "gui/UBMainWindow.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardView.h" #include "board/UBBoardView.h"
#include "board/UBDrawingController.h"
UBSelectionFrame::UBSelectionFrame() UBSelectionFrame::UBSelectionFrame()
: mThickness(UBSettings::settings()->objectFrameWidth) : mThickness(UBSettings::settings()->objectFrameWidth)
@ -44,6 +47,7 @@ UBSelectionFrame::UBSelectionFrame()
, mDuplicateButton(0) , mDuplicateButton(0)
, mZOrderUpButton(0) , mZOrderUpButton(0)
, mZOrderDownButton(0) , mZOrderDownButton(0)
, mGroupButton(0)
, mRotateButton(0) , mRotateButton(0)
{ {
setLocalBrush(QBrush(UBSettings::paletteColor)); setLocalBrush(QBrush(UBSettings::paletteColor));
@ -314,6 +318,15 @@ void UBSelectionFrame::increaseZlevelBottom()
// } // }
} }
void UBSelectionFrame::groupItems()
{
UBGraphicsGroupContainerItem *groupItem = ubscene()->createGroup(enclosedGraphicsItems());
groupItem->setSelected(true);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
qDebug() << "Grouping items";
}
void UBSelectionFrame::addSelectionUndo(QList<QGraphicsItem*> items, UBZLayerController::moveDestination dest){ void UBSelectionFrame::addSelectionUndo(QList<QGraphicsItem*> items, UBZLayerController::moveDestination dest){
if(!items.empty()){ if(!items.empty()){
qreal topItemLevel = items.at(0)->data(UBGraphicsItemData::ItemOwnZValue).toReal(); qreal topItemLevel = items.at(0)->data(UBGraphicsItemData::ItemOwnZValue).toReal();
@ -453,7 +466,6 @@ QList<DelegateButton*> UBSelectionFrame::buttonsForFlags(UBGraphicsFlags fls) {
if (!mDeleteButton) { if (!mDeleteButton) {
mDeleteButton = new DelegateButton(":/images/close.svg", this, 0, Qt::TopLeftSection); mDeleteButton = new DelegateButton(":/images/close.svg", this, 0, Qt::TopLeftSection);
mButtons << mDeleteButton;
connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove())); connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove()));
} }
result << mDeleteButton; result << mDeleteButton;
@ -466,6 +478,15 @@ QList<DelegateButton*> UBSelectionFrame::buttonsForFlags(UBGraphicsFlags fls) {
result << mDuplicateButton; result << mDuplicateButton;
} }
if (mEnclosedtems.count() >= 1) {
if (!mGroupButton) {
mGroupButton = new DelegateButton(":/images/plus.svg", this, 0, Qt::TopLeftSection);
mGroupButton->setShowProgressIndicator(false);
connect(mGroupButton, SIGNAL(clicked()), this, SLOT(groupItems()));
}
result << mGroupButton;
}
if (fls | GF_ZORDER_MANIPULATIONS_ALLOWED) { if (fls | GF_ZORDER_MANIPULATIONS_ALLOWED) {
if (!mZOrderUpButton) { if (!mZOrderUpButton) {
mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", this, 0, Qt::BottomLeftSection); mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", this, 0, Qt::BottomLeftSection);
@ -498,4 +519,14 @@ QList<DelegateButton*> UBSelectionFrame::buttonsForFlags(UBGraphicsFlags fls) {
return result; return result;
} }
QList<QGraphicsItem*> UBSelectionFrame::enclosedGraphicsItems()
{
QList<QGraphicsItem*> result;
foreach (UBGraphicsItemDelegate *d, mEnclosedtems) {
result << d->delegated();
}
return result;
}

@ -72,6 +72,7 @@ private slots:
void increaseZlevelTop(); void increaseZlevelTop();
void increaseZlevelDown(); void increaseZlevelDown();
void increaseZlevelBottom(); void increaseZlevelBottom();
void groupItems();
private: private:
void addSelectionUndo(QList<QGraphicsItem*> items, UBZLayerController::moveDestination dest); void addSelectionUndo(QList<QGraphicsItem*> items, UBZLayerController::moveDestination dest);
@ -86,6 +87,8 @@ private:
QList<QGraphicsItem*> sortedByZ(const QList<QGraphicsItem*> &pItems); QList<QGraphicsItem*> sortedByZ(const QList<QGraphicsItem*> &pItems);
QList<DelegateButton*> buttonsForFlags(UBGraphicsFlags fls); QList<DelegateButton*> buttonsForFlags(UBGraphicsFlags fls);
QList<QGraphicsItem*> enclosedGraphicsItems();
private: private:
int mThickness; int mThickness;
@ -104,6 +107,7 @@ private:
DelegateButton *mDuplicateButton; DelegateButton *mDuplicateButton;
DelegateButton *mZOrderUpButton; DelegateButton *mZOrderUpButton;
DelegateButton *mZOrderDownButton; DelegateButton *mZOrderDownButton;
DelegateButton *mGroupButton;
DelegateButton *mRotateButton; DelegateButton *mRotateButton;

Loading…
Cancel
Save