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;
}
QString fileName = proxy->persistencePath() + "/" + metadataFilename;
qWarning() << fileName;
qWarning() << "Persisting document path is" << fileName;
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
{

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

@ -120,7 +120,9 @@ UBApplication::UBApplication(const QString &id, int &argc, char **argv) : QtSing
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");
setApplicationName("OpenBoard");

@ -148,6 +148,7 @@ QSettings* UBSettings::getAppSettings()
UBSettings::sAppSettings->setIniCodec("utf-8");
}
qDebug() << "sAppSettings" << sAppSettings;
return UBSettings::sAppSettings;
}
@ -774,7 +775,8 @@ QString UBSettings::userDataDirectory()
{
static QString dataDirPath = "";
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 = replaceWildcard(dataDirPath);
@ -785,7 +787,9 @@ QString UBSettings::userDataDirectory()
}
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;
}
@ -879,6 +883,11 @@ QString UBSettings::userPodcastRecordingDirectory()
return dirPath;
}
QString UBSettings::organizationName()
{
return "Open Education Foundation";
}
QString UBSettings::userDocumentDirectory()
{
@ -887,6 +896,7 @@ QString UBSettings::userDocumentDirectory()
documentDirectory = userDataDirectory() + "/document";
checkDirectory(documentDirectory);
}
qDebug() << "userDocumentDirectory()" << documentDirectory;
return documentDirectory;
}

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

@ -70,9 +70,23 @@ void UBGraphicsGroupContainerItemDelegate::decorateMenu(QMenu *menu)
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();
}
void UBGraphicsGroupContainerItemDelegate::freeButtons()
{
UBGraphicsItemDelegate::freeButtons();
mDestroyGroupButton = 0;
mButtons.clear();
}
bool UBGraphicsGroupContainerItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event)
@ -93,3 +107,9 @@ bool UBGraphicsGroupContainerItemDelegate::mouseReleaseEvent(QGraphicsSceneMouse
return false;
}
void UBGraphicsGroupContainerItemDelegate::destroyGroup()
{
qDebug() << "Destroying group";
delegated()->destroy();
}

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

@ -29,12 +29,15 @@
#include "domain/UBItem.h"
#include "domain/UBGraphicsItemZLevelUndoCommand.h"
#include "domain/UBGraphicsGroupContainerItem.h"
#include "board/UBBoardController.h"
#include "core/UBSettings.h"
#include "core/UBApplication.h"
#include "gui/UBResources.h"
#include "gui/UBMainWindow.h"
#include "core/UBApplication.h"
#include "board/UBBoardView.h"
#include "board/UBDrawingController.h"
UBSelectionFrame::UBSelectionFrame()
: mThickness(UBSettings::settings()->objectFrameWidth)
@ -44,6 +47,7 @@ UBSelectionFrame::UBSelectionFrame()
, mDuplicateButton(0)
, mZOrderUpButton(0)
, mZOrderDownButton(0)
, mGroupButton(0)
, mRotateButton(0)
{
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){
if(!items.empty()){
qreal topItemLevel = items.at(0)->data(UBGraphicsItemData::ItemOwnZValue).toReal();
@ -453,7 +466,6 @@ QList<DelegateButton*> UBSelectionFrame::buttonsForFlags(UBGraphicsFlags fls) {
if (!mDeleteButton) {
mDeleteButton = new DelegateButton(":/images/close.svg", this, 0, Qt::TopLeftSection);
mButtons << mDeleteButton;
connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove()));
}
result << mDeleteButton;
@ -466,6 +478,15 @@ QList<DelegateButton*> UBSelectionFrame::buttonsForFlags(UBGraphicsFlags fls) {
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 (!mZOrderUpButton) {
mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", this, 0, Qt::BottomLeftSection);
@ -498,4 +519,14 @@ QList<DelegateButton*> UBSelectionFrame::buttonsForFlags(UBGraphicsFlags fls) {
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 increaseZlevelDown();
void increaseZlevelBottom();
void groupItems();
private:
void addSelectionUndo(QList<QGraphicsItem*> items, UBZLayerController::moveDestination dest);
@ -86,6 +87,8 @@ private:
QList<QGraphicsItem*> sortedByZ(const QList<QGraphicsItem*> &pItems);
QList<DelegateButton*> buttonsForFlags(UBGraphicsFlags fls);
QList<QGraphicsItem*> enclosedGraphicsItems();
private:
int mThickness;
@ -104,6 +107,7 @@ private:
DelegateButton *mDuplicateButton;
DelegateButton *mZOrderUpButton;
DelegateButton *mZOrderDownButton;
DelegateButton *mGroupButton;
DelegateButton *mRotateButton;

Loading…
Cancel
Save