UBLeftPalette.cpp 1.75 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include "UBLeftPalette.h"
16
#include "core/UBSettings.h"
17

18 19
#include "core/memcheck.h"

20 21 22
/**
 * \brief The constructor
 */
23 24
UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name):
    UBDockPalette(eUBDockPaletteType_LEFT, parent)
25
{
26 27
    setObjectName(name);
    setOrientation(eUBDockOrientation_Left);
28

29 30
    mLastWidth = UBSettings::settings()->leftLibPaletteWidth->get().toInt();
    mCollapseWidth = 150;
31

Claudio Valerio's avatar
Claudio Valerio committed
32 33 34 35
    if(UBSettings::settings()->leftLibPaletteIsCollapsed->get().toBool())
    	resize(0,parentWidget()->height());
    else
    	resize(mLastWidth, parentWidget()->height());
36 37
}

38 39 40
/**
 * \brief The destructor
 */
41 42
UBLeftPalette::~UBLeftPalette()
{
43

44 45
}

46 47 48
/**
 * \brief Update the maximum width
 */
49 50
void UBLeftPalette::updateMaxWidth()
{
Ivan Ilin's avatar
Ivan Ilin committed
51
    setMaximumWidth(270);
52 53
}

54 55 56 57
/**
 * \brief Handle the resize event
 * @param event as the resize event
 */
58 59
void UBLeftPalette::resizeEvent(QResizeEvent *event)
{
Claudio Valerio's avatar
Claudio Valerio committed
60 61 62 63
	int newWidth = width();
	if(newWidth > mCollapseWidth)
		UBSettings::settings()->leftLibPaletteWidth->set(newWidth);
    UBSettings::settings()->leftLibPaletteIsCollapsed->set(newWidth == 0);
64 65
    UBDockPalette::resizeEvent(event);
}