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)
{
addScene(scene, replaceActiveIfEmpty);
emit pageChanged();
}
}
@ -1159,7 +1158,10 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
mPaletteManager->leftPalette()->pageNavigator()->setDocument(pDocumentProxy);
if (sceneChange)
{
emit activeSceneChanged();
emit pageChanged();
}
}

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

@ -108,9 +108,6 @@ UBCachePropertiesWidget::UBCachePropertiesWidget(QWidget *parent, const char *na
// Fill the empty space
mpPropertiesLayout->addStretch(1);
// Get the infos from the current cache
// ...
// Connect signals / slots
connect(mpCloseButton, SIGNAL(clicked()), this, SLOT(onCloseClicked()));
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(mpSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(onSizeChanged(int)));
connect(UBApplication::boardController, SIGNAL(pageChanged()), this, SLOT(updateCurrentCache()));
connect(UBApplication::boardController, SIGNAL(cacheEnabled()), this, SLOT(onCacheEnabled()));
}
UBCachePropertiesWidget::~UBCachePropertiesWidget()
@ -277,8 +275,8 @@ void UBCachePropertiesWidget::updateCurrentCache()
{
if("Cache" == it->data(Qt::UserRole).toString())
{
qDebug() << ">>> Setting cache parameters";
setEnabled(true);
emit showTab(name());
mpCurrentCache = dynamic_cast<UBGraphicsCache*>(it);
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
emit hideTab(name());
mpCurrentCache = NULL;
setDisabled(true);
}
@ -316,3 +315,8 @@ void UBCachePropertiesWidget::onSizeChanged(int newSize)
mpCurrentCache->setShapeWidth(newSize);
}
}
void UBCachePropertiesWidget::onCacheEnabled()
{
emit showTab(name());
}

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

@ -517,8 +517,10 @@ void UBDockPalette::addTabWidget(UBDockPaletteWidget *widget)
{
if(!mTabWidgets.contains(widget))
{
widget->setVisible(true);
mTabWidgets.append(widget);
mpStackWidget->addWidget(widget);
mpStackWidget->setCurrentWidget(widget);
update();
}
}
@ -532,6 +534,7 @@ void UBDockPalette::removeTab(const QString &widgetName)
{
mpStackWidget->removeWidget(pCrntWidget);
mTabWidgets.remove(i);
pCrntWidget->hide();
update();
break;
}
@ -547,3 +550,43 @@ int UBDockPalette::tabSpacing()
{
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 *);
void setBackgroundBrush(const QBrush& brush);
void registerWidget(UBDockPaletteWidget* widget);
public slots:
void onShowTabWidget(const QString& widgetName);
void onHideTabWidget(const QString& widgetName);
protected:
void addTabWidget(UBDockPaletteWidget* widget);
void removeTab(const QString& widgetName);
void connectSignals();
virtual int border();
virtual int radius();
@ -118,8 +124,10 @@ protected:
QVBoxLayout* mpLayout;
/** The current tab index */
int mCurrentTab;
/** The tab widgets */
/** The visible tab widgets */
QVector<UBDockPaletteWidget*> mTabWidgets;
/** The current widget */
QVector<UBDockPaletteWidget*> mRegisteredWidgets;
private slots:
void onToolbarPosUpdated();

@ -7,6 +7,7 @@
class UBDockPaletteWidget : public QWidget
{
Q_OBJECT
public:
UBDockPaletteWidget(QWidget* parent=0, const char* name="UBDockPaletteWidget");
~UBDockPaletteWidget();
@ -15,6 +16,10 @@ public:
QPixmap iconToLeft();
QString name();
signals:
void hideTab(const QString& widgetName);
void showTab(const QString& widgetName);
protected:
QPixmap mIconToRight; // 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());
mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin());
// Add the tab widgets
// Create and register the widgets
mpLibWidget = new UBLibWidget(this);
addTabWidget(mpLibWidget);
mpCachePropWidget = new UBCachePropertiesWidget(this);
mpCachePropWidget->hide();
registerWidget(mpLibWidget);
registerWidget(mpCachePropWidget);
// Add the visible widgets
addTabWidget(mpLibWidget);
// Connect signals/slots
connect(UBApplication::boardController, SIGNAL(cacheEnabled()), this, SLOT(onCacheEnabled()));
connect(mpCachePropWidget, SIGNAL(cacheListEmpty()), this, SLOT(onCacheDisabled()));
connectSignals();
}
UBRightPalette::~UBRightPalette()
@ -85,32 +85,32 @@ void UBRightPalette::updateMaxWidth()
setMinimumHeight(parentWidget()->height());
}
void UBRightPalette::onCacheEnabled()
{
if(mpCachePropWidget->isHidden())
{
mpCachePropWidget->setVisible(true);
// Add the cache tab
addTabWidget(mpCachePropWidget);
}
// Set the cache of the current page as the active one for the properties widget
mpCachePropWidget->updateCurrentCache();
// Show the cache properties widget
for(int i = 0; i < mTabWidgets.size(); i++)
{
if((NULL != mTabWidgets.at(i)) && ("CachePropWidget" == mTabWidgets.at(i)->name()))
{
showTabWidget(i);
break;
}
}
}
void UBRightPalette::onCacheDisabled()
{
removeTab(mpCachePropWidget->name());
mpCachePropWidget->hide();
}
//void UBRightPalette::onCacheEnabled()
//{
// if(mpCachePropWidget->isHidden())
// {
// mpCachePropWidget->setVisible(true);
// // Add the cache tab
// addTabWidget(mpCachePropWidget);
// }
// // Set the cache of the current page as the active one for the properties widget
// mpCachePropWidget->updateCurrentCache();
// // Show the cache properties widget
// for(int i = 0; i < mTabWidgets.size(); i++)
// {
// if((NULL != mTabWidgets.at(i)) && ("CachePropWidget" == mTabWidgets.at(i)->name()))
// {
// showTabWidget(i);
// break;
// }
// }
//}
//void UBRightPalette::onCacheDisabled()
//{
// removeTab(mpCachePropWidget->name());
// mpCachePropWidget->hide();
//}

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

Loading…
Cancel
Save