Resolved a small issue on the cache widget management

preferencesAboutTextFull
shibakaneki 13 years ago
parent 71b6a9d039
commit 104dfcd5bc
  1. 4
      src/board/UBBoardController.cpp
  2. 1
      src/domain/UBGraphicsScene.cpp
  3. 12
      src/gui/UBCachePropertiesWidget.cpp
  4. 1
      src/gui/UBCachePropertiesWidget.h
  5. 43
      src/gui/UBDockPalette.cpp
  6. 10
      src/gui/UBDockPalette.h
  7. 5
      src/gui/UBDockPaletteWidget.h
  8. 72
      src/gui/UBRightPalette.cpp
  9. 4
      src/gui/UBRightPalette.h

@ -484,7 +484,6 @@ void UBBoardController::addScene(UBDocumentProxy* proxy, int sceneIndex, bool re
if (scene) if (scene)
{ {
addScene(scene, replaceActiveIfEmpty); addScene(scene, replaceActiveIfEmpty);
emit pageChanged();
} }
} }
@ -1159,7 +1158,10 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
mPaletteManager->leftPalette()->pageNavigator()->setDocument(pDocumentProxy); mPaletteManager->leftPalette()->pageNavigator()->setDocument(pDocumentProxy);
if (sceneChange) if (sceneChange)
{
emit activeSceneChanged(); emit activeSceneChanged();
emit pageChanged();
}
} }

@ -1644,6 +1644,7 @@ void UBGraphicsScene::addCache()
cache->setVisible(true); cache->setVisible(true);
cache->setSelected(true); cache->setSelected(true);
UBApplication::boardController->notifyCache(true); UBApplication::boardController->notifyCache(true);
UBApplication::boardController->notifyPageChanged();
} }
void UBGraphicsScene::addMask() void UBGraphicsScene::addMask()

@ -108,9 +108,6 @@ UBCachePropertiesWidget::UBCachePropertiesWidget(QWidget *parent, const char *na
// Fill the empty space // Fill the empty space
mpPropertiesLayout->addStretch(1); mpPropertiesLayout->addStretch(1);
// Get the infos from the current cache
// ...
// Connect signals / slots // Connect signals / slots
connect(mpCloseButton, SIGNAL(clicked()), this, SLOT(onCloseClicked())); connect(mpCloseButton, SIGNAL(clicked()), this, SLOT(onCloseClicked()));
connect(mpColor, SIGNAL(clicked()), this, SLOT(onColorClicked())); connect(mpColor, SIGNAL(clicked()), this, SLOT(onColorClicked()));
@ -118,6 +115,7 @@ UBCachePropertiesWidget::UBCachePropertiesWidget(QWidget *parent, const char *na
connect(mpSquareButton, SIGNAL(clicked()), this, SLOT(updateShapeButtons())); connect(mpSquareButton, SIGNAL(clicked()), this, SLOT(updateShapeButtons()));
connect(mpSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(onSizeChanged(int))); connect(mpSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(onSizeChanged(int)));
connect(UBApplication::boardController, SIGNAL(pageChanged()), this, SLOT(updateCurrentCache())); connect(UBApplication::boardController, SIGNAL(pageChanged()), this, SLOT(updateCurrentCache()));
connect(UBApplication::boardController, SIGNAL(cacheEnabled()), this, SLOT(onCacheEnabled()));
} }
UBCachePropertiesWidget::~UBCachePropertiesWidget() UBCachePropertiesWidget::~UBCachePropertiesWidget()
@ -277,8 +275,8 @@ void UBCachePropertiesWidget::updateCurrentCache()
{ {
if("Cache" == it->data(Qt::UserRole).toString()) if("Cache" == it->data(Qt::UserRole).toString())
{ {
qDebug() << ">>> Setting cache parameters";
setEnabled(true); setEnabled(true);
emit showTab(name());
mpCurrentCache = dynamic_cast<UBGraphicsCache*>(it); mpCurrentCache = dynamic_cast<UBGraphicsCache*>(it);
if((NULL != mpCurrentCache) && (!mCaches.contains(mpCurrentCache))) if((NULL != mpCurrentCache) && (!mCaches.contains(mpCurrentCache)))
{ {
@ -305,6 +303,7 @@ void UBCachePropertiesWidget::updateCurrentCache()
} }
// If we fall here, that means that this page has no cache // If we fall here, that means that this page has no cache
emit hideTab(name());
mpCurrentCache = NULL; mpCurrentCache = NULL;
setDisabled(true); setDisabled(true);
} }
@ -316,3 +315,8 @@ void UBCachePropertiesWidget::onSizeChanged(int newSize)
mpCurrentCache->setShapeWidth(newSize); mpCurrentCache->setShapeWidth(newSize);
} }
} }
void UBCachePropertiesWidget::onCacheEnabled()
{
emit showTab(name());
}

@ -33,6 +33,7 @@ private slots:
void onColorClicked(); void onColorClicked();
void updateShapeButtons(); void updateShapeButtons();
void onSizeChanged(int newSize); void onSizeChanged(int newSize);
void onCacheEnabled();
private: private:
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;

@ -517,8 +517,10 @@ void UBDockPalette::addTabWidget(UBDockPaletteWidget *widget)
{ {
if(!mTabWidgets.contains(widget)) if(!mTabWidgets.contains(widget))
{ {
widget->setVisible(true);
mTabWidgets.append(widget); mTabWidgets.append(widget);
mpStackWidget->addWidget(widget); mpStackWidget->addWidget(widget);
mpStackWidget->setCurrentWidget(widget);
update(); update();
} }
} }
@ -532,6 +534,7 @@ void UBDockPalette::removeTab(const QString &widgetName)
{ {
mpStackWidget->removeWidget(pCrntWidget); mpStackWidget->removeWidget(pCrntWidget);
mTabWidgets.remove(i); mTabWidgets.remove(i);
pCrntWidget->hide();
update(); update();
break; break;
} }
@ -547,3 +550,43 @@ int UBDockPalette::tabSpacing()
{ {
return 2; return 2;
} }
// This method is used to show the tab widget
void UBDockPalette::onShowTabWidget(const QString &widgetName)
{
for(int i = 0; i < mRegisteredWidgets.size(); i++)
{
UBDockPaletteWidget* pCrntWidget = mRegisteredWidgets.at(i);
if(NULL != pCrntWidget && (pCrntWidget->name() == widgetName))
{
addTabWidget(pCrntWidget);
break;
}
}
}
// This method is used to hide the tab widget
void UBDockPalette::onHideTabWidget(const QString &widgetName)
{
removeTab(widgetName);
}
void UBDockPalette::connectSignals()
{
for(int i=0; i < mRegisteredWidgets.size(); i++)
{
connect(mRegisteredWidgets.at(i), SIGNAL(showTab(QString)), this, SLOT(onShowTabWidget(QString)));
connect(mRegisteredWidgets.at(i), SIGNAL(hideTab(QString)), this, SLOT(onHideTabWidget(QString)));
}
}
void UBDockPalette::registerWidget(UBDockPaletteWidget *widget)
{
if(!mRegisteredWidgets.contains(widget))
{
mRegisteredWidgets.append(widget);
// By default, the widget is hidden
widget->hide();
}
}

@ -71,10 +71,16 @@ public:
virtual void leaveEvent(QEvent *); virtual void leaveEvent(QEvent *);
void setBackgroundBrush(const QBrush& brush); void setBackgroundBrush(const QBrush& brush);
void registerWidget(UBDockPaletteWidget* widget);
public slots:
void onShowTabWidget(const QString& widgetName);
void onHideTabWidget(const QString& widgetName);
protected: protected:
void addTabWidget(UBDockPaletteWidget* widget); void addTabWidget(UBDockPaletteWidget* widget);
void removeTab(const QString& widgetName); void removeTab(const QString& widgetName);
void connectSignals();
virtual int border(); virtual int border();
virtual int radius(); virtual int radius();
@ -118,8 +124,10 @@ protected:
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;
/** The current tab index */ /** The current tab index */
int mCurrentTab; int mCurrentTab;
/** The tab widgets */ /** The visible tab widgets */
QVector<UBDockPaletteWidget*> mTabWidgets; QVector<UBDockPaletteWidget*> mTabWidgets;
/** The current widget */
QVector<UBDockPaletteWidget*> mRegisteredWidgets;
private slots: private slots:
void onToolbarPosUpdated(); void onToolbarPosUpdated();

@ -7,6 +7,7 @@
class UBDockPaletteWidget : public QWidget class UBDockPaletteWidget : public QWidget
{ {
Q_OBJECT
public: public:
UBDockPaletteWidget(QWidget* parent=0, const char* name="UBDockPaletteWidget"); UBDockPaletteWidget(QWidget* parent=0, const char* name="UBDockPaletteWidget");
~UBDockPaletteWidget(); ~UBDockPaletteWidget();
@ -15,6 +16,10 @@ public:
QPixmap iconToLeft(); QPixmap iconToLeft();
QString name(); QString name();
signals:
void hideTab(const QString& widgetName);
void showTab(const QString& widgetName);
protected: protected:
QPixmap mIconToRight; // arrow like this: > QPixmap mIconToRight; // arrow like this: >
QPixmap mIconToLeft; // arrow like this: < QPixmap mIconToLeft; // arrow like this: <

@ -28,16 +28,16 @@ UBRightPalette::UBRightPalette(QWidget *parent, const char *name):UBDockPalette(
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height()); resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height());
mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin()); mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin());
// Add the tab widgets // Create and register the widgets
mpLibWidget = new UBLibWidget(this); mpLibWidget = new UBLibWidget(this);
addTabWidget(mpLibWidget);
mpCachePropWidget = new UBCachePropertiesWidget(this); mpCachePropWidget = new UBCachePropertiesWidget(this);
mpCachePropWidget->hide(); registerWidget(mpLibWidget);
registerWidget(mpCachePropWidget);
// Add the visible widgets
addTabWidget(mpLibWidget);
// Connect signals/slots connectSignals();
connect(UBApplication::boardController, SIGNAL(cacheEnabled()), this, SLOT(onCacheEnabled()));
connect(mpCachePropWidget, SIGNAL(cacheListEmpty()), this, SLOT(onCacheDisabled()));
} }
UBRightPalette::~UBRightPalette() UBRightPalette::~UBRightPalette()
@ -85,32 +85,32 @@ void UBRightPalette::updateMaxWidth()
setMinimumHeight(parentWidget()->height()); setMinimumHeight(parentWidget()->height());
} }
void UBRightPalette::onCacheEnabled() //void UBRightPalette::onCacheEnabled()
{ //{
if(mpCachePropWidget->isHidden()) // if(mpCachePropWidget->isHidden())
{ // {
mpCachePropWidget->setVisible(true); // mpCachePropWidget->setVisible(true);
// Add the cache tab // // Add the cache tab
addTabWidget(mpCachePropWidget); // addTabWidget(mpCachePropWidget);
} // }
// Set the cache of the current page as the active one for the properties widget // // Set the cache of the current page as the active one for the properties widget
mpCachePropWidget->updateCurrentCache(); // mpCachePropWidget->updateCurrentCache();
// Show the cache properties widget // // Show the cache properties widget
for(int i = 0; i < mTabWidgets.size(); i++) // for(int i = 0; i < mTabWidgets.size(); i++)
{ // {
if((NULL != mTabWidgets.at(i)) && ("CachePropWidget" == mTabWidgets.at(i)->name())) // if((NULL != mTabWidgets.at(i)) && ("CachePropWidget" == mTabWidgets.at(i)->name()))
{ // {
showTabWidget(i); // showTabWidget(i);
break; // break;
} // }
} // }
} //}
void UBRightPalette::onCacheDisabled() //void UBRightPalette::onCacheDisabled()
{ //{
removeTab(mpCachePropWidget->name()); // removeTab(mpCachePropWidget->name());
mpCachePropWidget->hide(); // mpCachePropWidget->hide();
} //}

@ -37,8 +37,8 @@ protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
private slots: private slots:
void onCacheEnabled(); // void onCacheEnabled();
void onCacheDisabled(); // void onCacheDisabled();
private: private:
UBLibWidget* mpLibWidget; UBLibWidget* mpLibWidget;

Loading…
Cancel
Save