Visibility of palette based on children elements
preferencesAboutTextFull
Anatoly Mihalchenko 13 years ago
parent aa6a893ad5
commit 6bbecff5de
  1. 56
      src/board/UBBoardPaletteManager.cpp
  2. 5
      src/gui/UBCachePropertiesWidget.h
  3. 6
      src/gui/UBDockDownloadWidget.h
  4. 35
      src/gui/UBDockPalette.cpp
  5. 17
      src/gui/UBDockPalette.h
  6. 8
      src/gui/UBDockPaletteWidget.cpp
  7. 5
      src/gui/UBDockPaletteWidget.h
  8. 3
      src/gui/UBLeftPalette.cpp
  9. 6
      src/gui/UBLibWidget.h
  10. 9
      src/gui/UBNavigatorPalette.cpp
  11. 5
      src/gui/UBPageNavigationWidget.h
  12. 3
      src/gui/UBRightPalette.cpp
  13. 5
      src/gui/UBTeacherBarWidget.h

@ -173,24 +173,18 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
// Create the widgets for the dock palettes
mpPageNavigWidget = new UBPageNavigationWidget();
mpPageNavigWidget->registerMode(eUBDockPaletteWidget_BOARD);
// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpPageNavigWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
mpLibWidget = new UBLibWidget();
mpLibWidget ->registerMode(eUBDockPaletteWidget_BOARD);
mpLibWidget ->registerMode(eUBDockPaletteWidget_DESKTOP);
// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpLibWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
mpCachePropWidget = new UBCachePropertiesWidget();
mpCachePropWidget->registerMode(eUBDockPaletteWidget_BOARD);
// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpCachePropWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
mpTeacherBarWidget = new UBTeacherBarWidget();
mpTeacherBarWidget->registerMode(eUBDockPaletteWidget_BOARD);
// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpTeacherBarWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
mpDownloadWidget = new UBDockDownloadWidget();
mpDownloadWidget->registerMode(eUBDockPaletteWidget_BOARD);
// Add the dock palettes
mLeftPalette = new UBLeftPalette(mContainer);
@ -689,38 +683,10 @@ void UBBoardPaletteManager::addItem(const QUrl& pUrl)
}
void UBBoardPaletteManager::processPalettersWidget(UBDockPalette *paletter, eUBDockPaletteWidgetMode mode)
{
//-------------------------------//
// get full right palette widgets list, parse it, show all widgets for BOARD mode, and hide all other
QVector<UBDockPaletteWidget*> widgetsList = paletter->GetWidgetsList();
for(int i = 0; i < widgetsList.size(); i++)
{
UBDockPaletteWidget* pNextWidget = widgetsList.at(i);
if( pNextWidget != NULL )
{
if( pNextWidget->GetRegisteredModes().contains(mode) )
{
paletter->addTab(pNextWidget);
}
else
{
paletter->removeTab(pNextWidget->name());
}
}
}
//-------------------------------//
if(widgetsList.size() > 0)
paletter->showTabWidget(0);
paletter->update();
}
void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool isInit)
{
processPalettersWidget(mRightPalette, newMode);
processPalettersWidget(mLeftPalette, newMode);
bool rightPaletteVisible = mRightPalette->switchMode(newMode);
bool leftPaletteVisible = mLeftPalette->switchMode(newMode);
switch( newMode )
{
@ -741,10 +707,11 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
mKeyboardPalette->setParent(UBApplication::boardController->controlContainer());
}
mLeftPalette->setVisible(true);
mRightPalette->setVisible(true);
mLeftPalette->setVisible(leftPaletteVisible);
mRightPalette->setVisible(rightPaletteVisible);
#ifdef Q_WS_WIN
mRightPalette->setAdditionalVOffset(0);
if (rightPaletteVisible)
mRightPalette->setAdditionalVOffset(0);
#endif
if( !isInit )
@ -773,10 +740,11 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
mKeyboardPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
}
mLeftPalette->setVisible(false);
mRightPalette->setVisible(true);
mLeftPalette->setVisible(leftPaletteVisible);
mRightPalette->setVisible(rightPaletteVisible);
#ifdef Q_WS_WIN
mRightPalette->setAdditionalVOffset(30);
if (rightPaletteVisible)
mRightPalette->setAdditionalVOffset(30);
#endif
if( !isInit )
@ -805,8 +773,8 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
default:
{
mLeftPalette->setVisible(false);
mRightPalette->setVisible(false);
mLeftPalette->setVisible(leftPaletteVisible);
mRightPalette->setVisible(rightPaletteVisible);
mLeftPalette->setParent(0);
mRightPalette->assignParent(0);
if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)

@ -21,6 +21,11 @@ public:
UBCachePropertiesWidget(QWidget* parent=0, const char* name="UBCachePropertiesWidget");
~UBCachePropertiesWidget();
bool visibleInMode(eUBDockPaletteWidgetMode mode)
{
return mode == eUBDockPaletteWidget_BOARD;
}
public slots:
void updateCurrentCache();

@ -28,6 +28,12 @@ public:
UBDockDownloadWidget(QWidget* parent=0, const char* name="UBDockDownloadWidget");
~UBDockDownloadWidget();
bool visibleInMode(eUBDockPaletteWidgetMode mode)
{
return mode == eUBDockPaletteWidget_BOARD;
}
private:
QVBoxLayout* mpLayout;
UBDownloadWidget* mpDLWidget;

@ -28,7 +28,7 @@
/**
* \brief The constructor
*/
UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
UBDockPalette::UBDockPalette(eUBDockPaletteType paletteType, QWidget *parent, const char *name)
:QWidget(parent, Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint)
, mOrientation(eUBDockOrientation_Left)
, mPreferredWidth(100)
@ -41,6 +41,7 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
, mpStackWidget(NULL)
, mpLayout(NULL)
, mCurrentTab(0)
, mPaletteType(paletteType)
, mTabPalette(new UBTabDockPalete(this, parent))
{
setObjectName(name);
@ -729,6 +730,38 @@ void UBDockPalette::setVisible(bool visible)
mTabPalette->setVisible(visible);
}
bool UBDockPalette::switchMode(eUBDockPaletteWidgetMode mode)
{
bool hasVisibleElements = false;
//-------------------------------//
// get full right palette widgets list, parse it, show all widgets for BOARD mode, and hide all other
for(int i = 0; i < mRegisteredWidgets.size(); i++)
{
UBDockPaletteWidget* pNextWidget = mRegisteredWidgets.at(i);
if( pNextWidget != NULL )
{
if( pNextWidget->visibleInMode(mode) )
{
addTab(pNextWidget);
hasVisibleElements = true;
}
else
{
removeTab(pNextWidget->name());
}
}
}
//-------------------------------//
if(mRegisteredWidgets.size() > 0)
showTabWidget(0);
update();
return hasVisibleElements;
}
UBTabDockPalete::UBTabDockPalete(UBDockPalette *dockPalette, QWidget *parent) :
QWidget(parent)
, dock(dockPalette)

@ -75,13 +75,22 @@ private:
bool mFlotable;
};
typedef enum
{
eUBDockPaletteType_LEFT,
eUBDockPaletteType_RIGHT,
eUBDockPaletteType_NAVIGATOR,
} eUBDockPaletteType;
class UBDockPalette : public QWidget
{
Q_OBJECT
friend class UBTabDockPalete;
public:
UBDockPalette(QWidget* parent=0, const char* name="UBDockPalette");
UBDockPalette(eUBDockPaletteType paletteType, QWidget* parent=0, const char* name="UBDockPalette");
~UBDockPalette();
eUBDockOrientation orientation();
@ -107,6 +116,8 @@ public:
void connectSignals();
bool switchMode(eUBDockPaletteWidgetMode mode);
QVector<UBDockPaletteWidget*> GetWidgetsList() { return mRegisteredWidgets; }
public:
@ -115,6 +126,8 @@ public:
int getAdditionalVOffset() const {return mTabPalette->mVerticalOffset;}
void setAdditionalVOffset(int newOffset) {mTabPalette->mVerticalOffset = newOffset;}
eUBDockPaletteType paletteType(){return mPaletteType;}
public slots:
void onShowTabWidget(const QString& widgetName);
void onHideTabWidget(const QString& widgetName);
@ -178,7 +191,7 @@ private:
private:
UBTabDockPalete *mTabPalette;
eUBDockPaletteType mPaletteType;
};
#endif // UBDOCKPALETTE_H

@ -27,15 +27,9 @@ QString UBDockPaletteWidget::name()
return mName;
}
void UBDockPaletteWidget::registerMode(eUBDockPaletteWidgetMode mode)
{
if(!mRegisteredModes.contains(mode))
mRegisteredModes.append(mode);
}
void UBDockPaletteWidget::slot_changeMode(eUBDockPaletteWidgetMode newMode)
{
this->setVisible(mRegisteredModes.contains(newMode));
this->setVisible(this->visibleInMode( newMode ));
}

@ -25,9 +25,8 @@ public:
QPixmap iconToLeft();
QString name();
void registerMode(eUBDockPaletteWidgetMode mode);
virtual bool visibleInMode(eUBDockPaletteWidgetMode mode) = NULL;
QVector<eUBDockPaletteWidgetMode> GetRegisteredModes() { return mRegisteredModes; }
bool visibleState(){return mVisibleState;}
void setVisibleState(bool state){mVisibleState = state;}
@ -45,7 +44,7 @@ protected:
QString mName;
/* The current widget available mode list */
QVector<eUBDockPaletteWidgetMode> mRegisteredModes;
//QVector<eUBDockPaletteWidgetMode> mRegisteredModes;
bool mVisibleState;
};

@ -20,7 +20,8 @@
/**
* \brief The constructor
*/
UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name):UBDockPalette(parent)
UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name):
UBDockPalette(eUBDockPaletteType_LEFT, parent)
{
setObjectName(name);
setOrientation(eUBDockOrientation_Left);

@ -48,6 +48,12 @@ public:
UBLibNavigatorWidget* libNavigator() {return mNavigator;}
UBLibPathViewer* pathViewer() {return mpPathViewer;}
bool visibleInMode(eUBDockPaletteWidgetMode mode)
{
return mode == eUBDockPaletteWidget_BOARD
|| mode == eUBDockPaletteWidget_DESKTOP;
}
signals:
void resized();
void showLibElemProperties();

@ -23,12 +23,13 @@
* @param parent as the parent widget
* @param name as the object name
*/
UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):UBDockPalette(parent, name)
UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):
UBDockPalette(eUBDockPaletteType_NAVIGATOR, parent, name)
, mNavigator(NULL)
, mLayout(NULL)
, mHLayout(NULL)
, mPageNbr(NULL)
, mClock(NULL)
, mHLayout(NULL)
, mPageNbr(NULL)
, mClock(NULL)
{
setOrientation(eUBDockOrientation_Left);
setMaximumWidth(300);

@ -36,6 +36,11 @@ public:
void setDocument(UBDocumentProxy* document);
void refresh();
bool visibleInMode(eUBDockPaletteWidgetMode mode)
{
return mode == eUBDockPaletteWidget_BOARD;
}
signals:
void resizeRequest(QResizeEvent* event);

@ -22,7 +22,8 @@
/**
* \brief The constructor
*/
UBRightPalette::UBRightPalette(QWidget *parent, const char *name):UBDockPalette(parent)
UBRightPalette::UBRightPalette(QWidget *parent, const char *name):
UBDockPalette(eUBDockPaletteType_RIGHT, parent)
{
setObjectName(name);
setOrientation(eUBDockOrientation_Right);

@ -46,6 +46,11 @@ public:
UBTeacherBarWidget(QWidget* parent=0, const char* name="UBTeacherBarWidget");
~UBTeacherBarWidget();
bool visibleInMode(eUBDockPaletteWidgetMode mode)
{
return mode == eUBDockPaletteWidget_BOARD;
}
public slots:
void saveContent();
void loadContent();

Loading…
Cancel
Save