mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
Compare Pane 'hpos' property
Introduce an hpos property on TabView::mainSplitter so we can use an animation to make the compare pane slide up and down when arriving and leaving. Will add the animation shortly, just pushing to save updates.
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
|
||||
TabView::TabView(Context *context, int type) :
|
||||
QWidget(context->tab), context(context), type(type),
|
||||
_sidebar(true), _tiled(false), _selected(false),
|
||||
_sidebar(true), _tiled(false), _selected(false), lastHeight(100),
|
||||
stack(NULL), splitter(NULL), mainSplitter(NULL),
|
||||
sidebar_(NULL), bottom_(NULL), page_(NULL), blank_(NULL)
|
||||
{
|
||||
@@ -128,6 +128,27 @@ TabView::setBottom(QWidget *widget)
|
||||
mainSplitter->setStretchFactor(1,1);
|
||||
}
|
||||
|
||||
// hide and show bottom - but with a little animation ...
|
||||
void
|
||||
TabView::setShowBottom(bool x)
|
||||
{
|
||||
// remember last height used when hidind
|
||||
if (!x && bottom_) lastHeight = bottom_->height();
|
||||
|
||||
// basic version for now .. remembers and sets horizontal position precisely
|
||||
// adding animation should be easy from here
|
||||
|
||||
if (bottom_) {
|
||||
if (x) {
|
||||
// set to the last value....
|
||||
bottom_->show();
|
||||
mainSplitter->setProperty("hpos", mainSplitter->maxhpos() - (lastHeight+22));
|
||||
} else {
|
||||
bottom_->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TabView::setBlank(BlankStatePage *blank)
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ class TabView : public QWidget
|
||||
bool isTiled() const { return _tiled; }
|
||||
|
||||
// bottom
|
||||
void setShowBottom(bool x) { if (bottom_) x ? bottom_->show() : bottom_->hide(); }
|
||||
void setShowBottom(bool x);
|
||||
bool isShowBottom() { if (bottom_) return bottom_->isVisible(); return false; }
|
||||
bool hasBottom() { return (bottom_!=NULL); }
|
||||
|
||||
@@ -116,6 +116,7 @@ class TabView : public QWidget
|
||||
bool _sidebar;
|
||||
bool _tiled;
|
||||
bool _selected;
|
||||
int lastHeight; // last height of splitter, default to 100...
|
||||
|
||||
QStackedWidget *stack;
|
||||
QSplitter *splitter;
|
||||
@@ -130,6 +131,8 @@ class TabView : public QWidget
|
||||
// we make our own view splitter for the bespoke handle
|
||||
class ViewSplitter : public QSplitter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ViewSplitter(Qt::Orientation orientation, QString name, QWidget *parent=0) :
|
||||
orientation(orientation), name(name), QSplitter(orientation, parent) {}
|
||||
@@ -140,6 +143,31 @@ protected:
|
||||
}
|
||||
int handleWidth() { return 23; };
|
||||
|
||||
public:
|
||||
Q_PROPERTY(int hpos READ hpos WRITE sethpos USER true)
|
||||
|
||||
// handle position
|
||||
int hpos() const { return sizes()[0]; }
|
||||
|
||||
void sethpos(int x) {
|
||||
if (x<0) return; //r requested size too small!
|
||||
QList<int> csizes = sizes();
|
||||
if (csizes.count() != 2) return; //don't have two widgets!
|
||||
int tot = csizes[0] + csizes[1];
|
||||
if (tot < x) return; // requested size too big!
|
||||
csizes[0] = x;
|
||||
csizes[1] = tot-x;
|
||||
setSizes(csizes);
|
||||
}
|
||||
|
||||
// max hpos
|
||||
int maxhpos() {
|
||||
QList<int> csizes = sizes();
|
||||
if (csizes.count() != 2) return 0; //don't have two widgets!
|
||||
int tot = csizes[0] + csizes[1];
|
||||
return tot - 1;
|
||||
}
|
||||
|
||||
private:
|
||||
Qt::Orientation orientation;
|
||||
QString name;
|
||||
|
||||
Reference in New Issue
Block a user