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 // Create the widgets for the dock palettes
mpPageNavigWidget = new UBPageNavigationWidget(); mpPageNavigWidget = new UBPageNavigationWidget();
mpPageNavigWidget->registerMode(eUBDockPaletteWidget_BOARD);
// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpPageNavigWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode))); // connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpPageNavigWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
mpLibWidget = new UBLibWidget(); mpLibWidget = new UBLibWidget();
mpLibWidget ->registerMode(eUBDockPaletteWidget_BOARD);
mpLibWidget ->registerMode(eUBDockPaletteWidget_DESKTOP);
// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpLibWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode))); // connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpLibWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
mpCachePropWidget = new UBCachePropertiesWidget(); mpCachePropWidget = new UBCachePropertiesWidget();
mpCachePropWidget->registerMode(eUBDockPaletteWidget_BOARD);
// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpCachePropWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode))); // connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpCachePropWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
mpTeacherBarWidget = new UBTeacherBarWidget(); mpTeacherBarWidget = new UBTeacherBarWidget();
mpTeacherBarWidget->registerMode(eUBDockPaletteWidget_BOARD);
// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpTeacherBarWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode))); // connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpTeacherBarWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
mpDownloadWidget = new UBDockDownloadWidget(); mpDownloadWidget = new UBDockDownloadWidget();
mpDownloadWidget->registerMode(eUBDockPaletteWidget_BOARD);
// Add the dock palettes // Add the dock palettes
mLeftPalette = new UBLeftPalette(mContainer); 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) void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool isInit)
{ {
processPalettersWidget(mRightPalette, newMode); bool rightPaletteVisible = mRightPalette->switchMode(newMode);
processPalettersWidget(mLeftPalette, newMode); bool leftPaletteVisible = mLeftPalette->switchMode(newMode);
switch( newMode ) switch( newMode )
{ {
@ -741,10 +707,11 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
mKeyboardPalette->setParent(UBApplication::boardController->controlContainer()); mKeyboardPalette->setParent(UBApplication::boardController->controlContainer());
} }
mLeftPalette->setVisible(true); mLeftPalette->setVisible(leftPaletteVisible);
mRightPalette->setVisible(true); mRightPalette->setVisible(rightPaletteVisible);
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
mRightPalette->setAdditionalVOffset(0); if (rightPaletteVisible)
mRightPalette->setAdditionalVOffset(0);
#endif #endif
if( !isInit ) if( !isInit )
@ -773,10 +740,11 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
mKeyboardPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); mKeyboardPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
} }
mLeftPalette->setVisible(false); mLeftPalette->setVisible(leftPaletteVisible);
mRightPalette->setVisible(true); mRightPalette->setVisible(rightPaletteVisible);
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
mRightPalette->setAdditionalVOffset(30); if (rightPaletteVisible)
mRightPalette->setAdditionalVOffset(30);
#endif #endif
if( !isInit ) if( !isInit )
@ -805,8 +773,8 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
default: default:
{ {
mLeftPalette->setVisible(false); mLeftPalette->setVisible(leftPaletteVisible);
mRightPalette->setVisible(false); mRightPalette->setVisible(rightPaletteVisible);
mLeftPalette->setParent(0); mLeftPalette->setParent(0);
mRightPalette->assignParent(0); mRightPalette->assignParent(0);
if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)

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

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

@ -28,7 +28,7 @@
/** /**
* \brief The constructor * \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) :QWidget(parent, Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint)
, mOrientation(eUBDockOrientation_Left) , mOrientation(eUBDockOrientation_Left)
, mPreferredWidth(100) , mPreferredWidth(100)
@ -41,6 +41,7 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
, mpStackWidget(NULL) , mpStackWidget(NULL)
, mpLayout(NULL) , mpLayout(NULL)
, mCurrentTab(0) , mCurrentTab(0)
, mPaletteType(paletteType)
, mTabPalette(new UBTabDockPalete(this, parent)) , mTabPalette(new UBTabDockPalete(this, parent))
{ {
setObjectName(name); setObjectName(name);
@ -729,6 +730,38 @@ void UBDockPalette::setVisible(bool visible)
mTabPalette->setVisible(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) : UBTabDockPalete::UBTabDockPalete(UBDockPalette *dockPalette, QWidget *parent) :
QWidget(parent) QWidget(parent)
, dock(dockPalette) , dock(dockPalette)

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

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

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

@ -20,7 +20,8 @@
/** /**
* \brief The constructor * \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); setObjectName(name);
setOrientation(eUBDockOrientation_Left); setOrientation(eUBDockOrientation_Left);

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

@ -23,12 +23,13 @@
* @param parent as the parent widget * @param parent as the parent widget
* @param name as the object name * @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) , mNavigator(NULL)
, mLayout(NULL) , mLayout(NULL)
, mHLayout(NULL) , mHLayout(NULL)
, mPageNbr(NULL) , mPageNbr(NULL)
, mClock(NULL) , mClock(NULL)
{ {
setOrientation(eUBDockOrientation_Left); setOrientation(eUBDockOrientation_Left);
setMaximumWidth(300); setMaximumWidth(300);

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

@ -22,7 +22,8 @@
/** /**
* \brief The constructor * \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); setObjectName(name);
setOrientation(eUBDockOrientation_Right); setOrientation(eUBDockOrientation_Right);

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

Loading…
Cancel
Save