left and right dock palette remember their own width

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent f5287497d2
commit 6c8c984327
  1. 10
      src/board/UBBoardPaletteManager.cpp
  2. 3
      src/core/UBSettings.cpp
  3. 3
      src/core/UBSettings.h
  4. 186
      src/gui/UBDockPalette.cpp
  5. 13
      src/gui/UBLeftPalette.cpp
  6. 1
      src/gui/UBLibraryWidget.cpp
  7. 9
      src/gui/UBRightPalette.cpp

@ -229,9 +229,6 @@ void UBBoardPaletteManager::setupPalettes()
mKeyboardPalette = new UBKeyboardPalette(0); mKeyboardPalette = new UBKeyboardPalette(0);
#ifndef Q_WS_WIN #ifndef Q_WS_WIN
connect(mKeyboardPalette, SIGNAL(closed()), mKeyboardPalette, SLOT(onDeactivated())); connect(mKeyboardPalette, SIGNAL(closed()), mKeyboardPalette, SLOT(onDeactivated()));
#endif
#ifndef Q_WS_MAC
// mKeyboardPalette->setParent(mContainer);
#endif #endif
} }
@ -764,13 +761,6 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
emit signal_changeMode(newMode); emit signal_changeMode(newMode);
} }
/*
void UBBoardPaletteManager::slot_changeMode(eUBDockPaletteWidgetMode newMode)
{
emit signal_changeMode(newMode);
}
*/
void UBBoardPaletteManager::addItem(const QPixmap& pPixmap, const QPointF& pos, qreal scaleFactor, const QUrl& sourceUrl) void UBBoardPaletteManager::addItem(const QPixmap& pPixmap, const QPointF& pos, qreal scaleFactor, const QUrl& sourceUrl)
{ {
mItemUrl = sourceUrl; mItemUrl = sourceUrl;

@ -205,7 +205,8 @@ void UBSettings::init()
appEnableSoftwareUpdates = new UBSetting(this, "App", "EnableSoftwareUpdates", true); appEnableSoftwareUpdates = new UBSetting(this, "App", "EnableSoftwareUpdates", true);
appToolBarOrientationVertical = new UBSetting(this, "App", "ToolBarOrientationVertical", false); appToolBarOrientationVertical = new UBSetting(this, "App", "ToolBarOrientationVertical", false);
navigPaletteWidth = new UBSetting(this, "Board", "NavigPaletteWidth", 270); navigPaletteWidth = new UBSetting(this, "Board", "NavigPaletteWidth", 270);
libPaletteWidth = new UBSetting(this, "Board", "LibPaletteWidth", 270); rightLibPaletteWidth = new UBSetting(this, "Board", "RightLibPaletteWidth", 270);
leftLibPaletteWidth = new UBSetting(this, "Board", "LeftLibPaletteWidth",270);
appIsInSoftwareUpdateProcess = new UBSetting(this, "App", "IsInSoftwareUpdateProcess", false); appIsInSoftwareUpdateProcess = new UBSetting(this, "App", "IsInSoftwareUpdateProcess", false);
appLastSessionDocumentUUID = new UBSetting(this, "App", "LastSessionDocumentUUID", ""); appLastSessionDocumentUUID = new UBSetting(this, "App", "LastSessionDocumentUUID", "");

@ -315,7 +315,8 @@ class UBSettings : public QObject
UBSetting* soundThumbnailWidth; UBSetting* soundThumbnailWidth;
UBSetting* navigPaletteWidth; UBSetting* navigPaletteWidth;
UBSetting* libPaletteWidth; UBSetting* rightLibPaletteWidth;
UBSetting* leftLibPaletteWidth;
UBSetting* communityUser; UBSetting* communityUser;
UBSetting* communityPsw; UBSetting* communityPsw;

@ -56,7 +56,7 @@ UBDockPalette::UBDockPalette(eUBDockPaletteType paletteType, QWidget *parent, co
mTabWidgets.clear(); mTabWidgets.clear();
// We let 2 pixels in order to keep a small border for the resizing // We let 2 pixels in order to keep a small border for the resizing
setMinimumWidth(/*2*border() + 2*/0); setMinimumWidth(0);
if (parent) if (parent)
{ {
@ -131,138 +131,6 @@ void UBDockPalette::setOrientation(eUBDockOrientation orientation)
} }
} }
/**
* \brief Handle the mouse move event
* @param as the mouse event
*/
//void UBDockPalette::mouseMoveEvent(QMouseEvent *event)
//{
// QPoint p = event->pos();
// if(mCanResize && ((mMousePressPos - p).manhattanLength() > QApplication::startDragDistance()))
// {
// switch(mOrientation)
// {
// case eUBDockOrientation_Left:
// if(p.x() < collapseWidth() && p.x() >= minimumWidth())
// {
// resize(border(), height());
// mLastWidth = collapseWidth() + 1;
// mResized = true;
// }
// else if(p.x() <= maximumWidth() && p.x() >= minimumWidth())
// {
// resize(p.x(), height());
// mResized = true;
// }
// break;
// case eUBDockOrientation_Right:
// if((this->x() + p.x() > parentWidget()->width() - collapseWidth()) && (this->x() + p.x() < parentWidget()->width()))
// {
// resize(border(), height());
// mLastWidth = collapseWidth() + 1;
// mResized = true;
// }
// else if((this->x() + p.x() >= parentWidget()->width() - maximumWidth()) && (this->x() + p.x() <= parentWidget()->width() - this->minimumWidth()))
// {
// resize(parentWidget()->width() - (this->x() + p.x()), height());
// mResized = true;
// }
// break;
// case eUBDockOrientation_Top:
// case eUBDockOrientation_Bottom:
// if(p.y() <= maximumHeight())
// {
// resize(width(), p.y());
// mResized = true;
// }
// break;
// default:
// break;
// }
// }
//}
/**
* \brief Handle the mouse press event
* @param as the mouse event
*/
//void UBDockPalette::mousePressEvent(QMouseEvent *event)
//{
// mClickTime = QTime::currentTime();
// // The goal here is to verify if the user can resize the widget.
// // It is only possible to resize it if the border is selected
// QPoint p = event->pos();
// mMousePressPos = p;
// mResized = false;
// switch(mOrientation)
// {
// case eUBDockOrientation_Left:
// if((p.x() >= width() - 2 * border()) && (p.x() <= width()))
// {
// mCanResize = true;
// }
// break;
// case eUBDockOrientation_Right:
// if((p.x() >= 0) && (p.x() <= 2 * border()))
// {
// mCanResize = true;
// }
// break;
// case eUBDockOrientation_Top:
// // Not supported yet
// break;
// case eUBDockOrientation_Bottom:
// // Not supported yet
// break;
// default:
// break;
// }
//}
/**
* \brief Handle the mouse release event
* @param event as the mouse event
*/
//void UBDockPalette::mouseReleaseEvent(QMouseEvent *event)
//{
// Q_UNUSED(event);
// if(!mResized && mClickTime.elapsed() < CLICKTIME)
// {
// int nbTabs = mTabWidgets.size();
// int clickedTab = 0;
// // If the clicked position is in the tab, perform the related action
// if(eUBDockOrientation_Left == mOrientation)
// {
// if(mMousePressPos.x() >= width() - 2*border() &&
// mMousePressPos.y() >= mHTab &&
// mMousePressPos.x() <= width() &&
// mMousePressPos.y() <= mHTab + nbTabs*TABSIZE + (nbTabs -1)*tabSpacing())
// {
// clickedTab = (mMousePressPos.y() - mHTab)/(TABSIZE+tabSpacing());
// tabClicked(clickedTab);
// }
// }
// else if(eUBDockOrientation_Right == mOrientation)
// {
// if(mMousePressPos.x() >= 0 &&
// mMousePressPos.x() <= 2*border() &&
// mMousePressPos.y() >= mHTab &&
// mMousePressPos.y() <= mHTab + nbTabs*TABSIZE + (nbTabs -1)*tabSpacing())
// {
// clickedTab = (mMousePressPos.y() - mHTab)/(TABSIZE+tabSpacing());
// tabClicked(clickedTab);
// }
// }
// }
// mCanResize = false;
//}
/** /**
* \brief Handle the resize event * \brief Handle the resize event
* @param event as the resize event * @param event as the resize event
@ -356,52 +224,6 @@ void UBDockPalette::paintEvent(QPaintEvent *event)
mHTab = height() - border() - nbTabs*TABSIZE - (nbTabs-1)*tabSpacing(); mHTab = height() - border() - nbTabs*TABSIZE - (nbTabs-1)*tabSpacing();
} }
painter.drawPath(path); painter.drawPath(path);
// for(int i = 0; i < mTabWidgets.size(); i++)
// {
// UBDockPaletteWidget* pCrntWidget = mTabWidgets.at(i);
// if(NULL != pCrntWidget)
// {
// if(mOrientation == eUBDockOrientation_Left)
// {
// path.addRoundedRect(width()-4*border(), mHTab + i*TABSIZE + i*tabSpacing(), 4*border(), TABSIZE, radius(), radius());
// painter.drawPath(path);
// QPixmap iconPixmap;
// if(mCollapseWidth >= width())
// {
// // Get the collapsed icon
// iconPixmap = pCrntWidget->iconToRight();
// }
// else
// {
// // Get the expanded icon
// iconPixmap = pCrntWidget->iconToLeft();
// }
// painter.drawPixmap(width() - 2*border() + 1, mHTab + i*TABSIZE + i*tabSpacing() + 1 , 2*border() - 4, TABSIZE - 2, iconPixmap);
// }
// else if(mOrientation == eUBDockOrientation_Right)
// {
// path.addRoundedRect(0.0, mHTab + i*TABSIZE + i*tabSpacing(), 4*border(), TABSIZE, radius(), radius());
// painter.drawPath(path);
// QPixmap iconPixmap;
// if(mCollapseWidth >= width())
// {
// // Get the collapsed icon
// iconPixmap = pCrntWidget->iconToLeft();
// }
// else
// {
// // Get the expanded icon
// iconPixmap = pCrntWidget->iconToRight();
// }
// painter.drawPixmap(2, mHTab + i*TABSIZE + i*tabSpacing() + 1, 2*border() - 4, TABSIZE - 2, iconPixmap);
// }
// else
// {
// painter.drawRoundedRect(border(), border(), width() - 2 * border(), height() - 2 * border(), radius(), radius());
// }
// }
// }
} }
} }
@ -758,12 +580,11 @@ UBTabDockPalete::UBTabDockPalete(UBDockPalette *dockPalette, QWidget *parent) :
{ {
int numTabs = dock->mTabWidgets.size(); int numTabs = dock->mTabWidgets.size();
resize(2 * dock->border(), (numTabs * TABSIZE) + qMax(numTabs - 1, 0) * dock->tabSpacing()); resize(2 * dock->border(), (numTabs * TABSIZE) + qMax(numTabs - 1, 0) * dock->tabSpacing());
// move(dock->width(), 20);
setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_TranslucentBackground);
} }
void UBTabDockPalete::paintEvent(QPaintEvent */*event*/) void UBTabDockPalete::paintEvent(QPaintEvent *)
{ {
int nTabs = dock->mTabWidgets.size(); int nTabs = dock->mTabWidgets.size();
if (nTabs <= 0) { if (nTabs <= 0) {
@ -945,6 +766,3 @@ void UBTabDockPalete::mouseReleaseEvent(QMouseEvent *event)
dock->mCanResize = false; dock->mCanResize = false;
} }

@ -23,14 +23,13 @@
UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name): UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name):
UBDockPalette(eUBDockPaletteType_LEFT, parent) UBDockPalette(eUBDockPaletteType_LEFT, parent)
{ {
setObjectName(name); setObjectName(name);
setOrientation(eUBDockOrientation_Left); setOrientation(eUBDockOrientation_Left);
mLastWidth = 270;
mCollapseWidth = 150;
resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), parentWidget()->height()); mLastWidth = UBSettings::settings()->leftLibPaletteWidth->get().toInt();
// mpLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin()); mCollapseWidth = 150;
resize(mLastWidth, parentWidget()->height());
} }
/** /**
@ -55,6 +54,6 @@ void UBLeftPalette::updateMaxWidth()
*/ */
void UBLeftPalette::resizeEvent(QResizeEvent *event) void UBLeftPalette::resizeEvent(QResizeEvent *event)
{ {
UBSettings::settings()->leftLibPaletteWidth->set(width());
UBDockPalette::resizeEvent(event); UBDockPalette::resizeEvent(event);
// UBSettings::settings()->navigPaletteWidth->set(width());
} }

@ -91,7 +91,6 @@ void UBLibraryWidget::init()
connect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); connect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
connect(UBDownloadManager::downloadManager(), SIGNAL(addDownloadedFileToLibrary(bool,QUrl,QString,QByteArray)), this, SLOT(onAddDownloadedFileToLibrary(bool,QUrl,QString,QByteArray))); connect(UBDownloadManager::downloadManager(), SIGNAL(addDownloadedFileToLibrary(bool,QUrl,QString,QByteArray)), this, SLOT(onAddDownloadedFileToLibrary(bool,QUrl,QString,QByteArray)));
connect(UBApplication::boardController, SIGNAL(displayMetadata(QMap<QString,QString>)), this, SLOT(onDisplayMetadata(QMap<QString,QString>))); connect(UBApplication::boardController, SIGNAL(displayMetadata(QMap<QString,QString>)), this, SLOT(onDisplayMetadata(QMap<QString,QString>)));
connect(mLibraryController,SIGNAL(updateItemsList()),this,SLOT(onRefreshCurrentFolder())); connect(mLibraryController,SIGNAL(updateItemsList()),this,SLOT(onRefreshCurrentFolder()));
} }

@ -27,10 +27,11 @@ UBRightPalette::UBRightPalette(QWidget *parent, const char *name):
{ {
setObjectName(name); setObjectName(name);
setOrientation(eUBDockOrientation_Right); setOrientation(eUBDockOrientation_Right);
mLastWidth = UBSettings::settings()->rightLibPaletteWidth->get().toInt();
mCollapseWidth = 150; mCollapseWidth = 150;
mLastWidth = 270;
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height()); resize(mLastWidth, parentWidget()->height());
// mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin());
} }
/** /**
@ -59,7 +60,7 @@ void UBRightPalette::mouseMoveEvent(QMouseEvent *event)
void UBRightPalette::resizeEvent(QResizeEvent *event) void UBRightPalette::resizeEvent(QResizeEvent *event)
{ {
UBDockPalette::resizeEvent(event); UBDockPalette::resizeEvent(event);
UBSettings::settings()->libPaletteWidth->set(width()); UBSettings::settings()->rightLibPaletteWidth->set(width());
emit resized(); emit resized();
} }

Loading…
Cancel
Save