mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
Basic Compare Pane Hide/Show
.. just committing before adding animation and the compare pane content.
This commit is contained in:
23
src/ComparePane.cpp
Normal file
23
src/ComparePane.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Mark Liversedge (liversedge@gmail.com)
|
||||
*
|
||||
* 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 2 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, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "ComparePane.h"
|
||||
|
||||
ComparePane::ComparePane(QWidget *parent, CompareMode mode) : mode_(mode), QWidget(parent)
|
||||
{
|
||||
}
|
||||
47
src/ComparePane.h
Normal file
47
src/ComparePane.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Mark Liversedge (liversedge@gmail.com)
|
||||
*
|
||||
* 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 2 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, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _GC_ComparePane_h
|
||||
#define _GC_ComparePane_h 1
|
||||
|
||||
#include <QWidget>
|
||||
#include "GcSideBarItem.h"
|
||||
|
||||
class ComparePane : public QWidget
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
enum mode { season, interval };
|
||||
typedef enum mode CompareMode;
|
||||
|
||||
ComparePane(QWidget *parent, CompareMode mode=interval);
|
||||
|
||||
protected:
|
||||
|
||||
signals:
|
||||
|
||||
private slots:
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
CompareMode mode_; // remember the mode we were created as...
|
||||
};
|
||||
|
||||
#endif // _GC_ComparePane_h
|
||||
@@ -197,7 +197,7 @@ GcSubSplitter::createHandle()
|
||||
if(_insertedWidget != 0) {
|
||||
GcSplitterItem* _item = dynamic_cast<GcSplitterItem*>(_insertedWidget);
|
||||
if(_item != 0) {
|
||||
_item->splitterHandle = new GcSplitterHandle(_item->title, _item, orientation(), this);
|
||||
_item->splitterHandle = new GcSplitterHandle(_item->title, orientation(), this);
|
||||
_item->splitterHandle->addActions(_item->actions());
|
||||
_item->controlAction = new QAction(_item->icon, _item->title, this);
|
||||
_item->controlAction->setStatusTip(_item->title);
|
||||
@@ -212,12 +212,12 @@ GcSubSplitter::createHandle()
|
||||
return QSplitter::createHandle();
|
||||
}
|
||||
|
||||
GcSplitterHandle::GcSplitterHandle(QString title, GcSplitterItem *widget, Qt::Orientation orientation, GcSubSplitter *parent) : QSplitterHandle(orientation, parent), widget(widget), title(title)
|
||||
GcSplitterHandle::GcSplitterHandle(QString title, Qt::Orientation orientation, QSplitter *parent) : QSplitterHandle(orientation, parent), title(title)
|
||||
{
|
||||
setContentsMargins(0,0,0,0);
|
||||
setFixedHeight(23);
|
||||
|
||||
gcSplitter = parent;
|
||||
gcSplitter = (GcSubSplitter*)parent;
|
||||
|
||||
titleLayout = new QHBoxLayout(this);
|
||||
titleLayout->setContentsMargins(0,0,0,0);
|
||||
|
||||
@@ -91,7 +91,7 @@ class GcSplitterHandle : public QSplitterHandle
|
||||
friend class ::GcSplitterItem;
|
||||
|
||||
public:
|
||||
GcSplitterHandle(QString title, GcSplitterItem *widget, Qt::Orientation orientation, GcSubSplitter *parent = 0);
|
||||
GcSplitterHandle(QString title, Qt::Orientation orientation, QSplitter *parent = 0);
|
||||
|
||||
QSize sizeHint() const;
|
||||
GcSubSplitter *splitter() const;
|
||||
@@ -106,8 +106,6 @@ protected:
|
||||
private:
|
||||
void paintBackground(QPaintEvent *);
|
||||
|
||||
GcSplitterItem *widget;
|
||||
|
||||
QHBoxLayout *titleLayout;
|
||||
GcLabel *titleLabel;
|
||||
|
||||
|
||||
@@ -647,24 +647,28 @@ void
|
||||
MainWindow::toggleSidebar()
|
||||
{
|
||||
tab->toggleSidebar();
|
||||
setToolButtons();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::showSidebar(bool want)
|
||||
{
|
||||
tab->setSidebarEnabled(want);
|
||||
setToolButtons();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::toggleLowbar()
|
||||
{
|
||||
//XXX tab->toggleSidebar();
|
||||
if (tab->hasBottom()) tab->setShowBottom(!tab->isShowBottom());
|
||||
setToolButtons();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::showLowbar(bool want)
|
||||
{
|
||||
//XXX tab->setLowbarEnabled(want);
|
||||
if (tab->hasBottom()) tab->setShowBottom(want);
|
||||
setToolButtons();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -792,7 +796,7 @@ MainWindow::toggleStyle()
|
||||
{
|
||||
tab->toggleTile();
|
||||
styleAction->setChecked(tab->isTiled());
|
||||
setStyle();
|
||||
setToolButtons();
|
||||
}
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
@@ -940,37 +944,42 @@ void
|
||||
MainWindow::selectAnalysis()
|
||||
{
|
||||
tab->selectView(1);
|
||||
setStyle();
|
||||
setToolButtons();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::selectTrain()
|
||||
{
|
||||
tab->selectView(3);
|
||||
setStyle();
|
||||
setToolButtons();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::selectDiary()
|
||||
{
|
||||
tab->selectView(2);
|
||||
setStyle();
|
||||
setToolButtons();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::selectHome()
|
||||
{
|
||||
tab->selectView(0);
|
||||
setStyle();
|
||||
setToolButtons();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::setStyle()
|
||||
MainWindow::setToolButtons()
|
||||
{
|
||||
int select = tab->isTiled() ? 1 : 0;
|
||||
int lowselected = tab->isShowBottom() ? 1 : 0;
|
||||
|
||||
styleAction->setChecked(select);
|
||||
showhideLowbar->setChecked(lowselected);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
styleSelector->setSelected(select, true);
|
||||
lowbar->setSelected(lowselected);
|
||||
#else
|
||||
if (styleSelector->isSegmentSelected(select) == false)
|
||||
styleSelector->setSegmentSelected(select, true);
|
||||
|
||||
@@ -105,7 +105,7 @@ class MainWindow : public QMainWindow
|
||||
void showToolbar(bool want);
|
||||
void resetWindowLayout();
|
||||
void toggleStyle();
|
||||
void setStyle();
|
||||
void setToolButtons(); // set toolbar buttons to match tabview
|
||||
void setStyleFromSegment(int); // special case for linux/win qtsegmentcontrol toggline
|
||||
void toggleLowbar();
|
||||
void showLowbar(bool want);
|
||||
|
||||
@@ -109,6 +109,9 @@ Tab::close()
|
||||
* MainWindow integration with Tab / TabView (mostly pass through)
|
||||
*****************************************************************************/
|
||||
|
||||
void Tab::setShowBottom(bool x) { view(currentView())->setShowBottom(x); }
|
||||
bool Tab::isShowBottom() { return view(currentView())->isShowBottom(); }
|
||||
bool Tab::hasBottom() { return view(currentView())->hasBottom(); }
|
||||
void Tab::setSidebarEnabled(bool x) { view(currentView())->setSidebarEnabled(x); }
|
||||
bool Tab::isSidebarEnabled() { return view(currentView())->sidebarEnabled(); }
|
||||
void Tab::toggleSidebar() { view(currentView())->setSidebarEnabled(!view(currentView())->sidebarEnabled()); }
|
||||
|
||||
@@ -53,6 +53,11 @@ class Tab: public QWidget
|
||||
void setSidebarEnabled(bool);
|
||||
bool isSidebarEnabled();
|
||||
|
||||
// bottom
|
||||
void setShowBottom(bool);
|
||||
bool isShowBottom();
|
||||
bool hasBottom();
|
||||
|
||||
// layout
|
||||
void resetLayout();
|
||||
void addChart(GcWinID);
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
TabView::TabView(Context *context, int type) :
|
||||
QWidget(context->tab), context(context), type(type),
|
||||
_sidebar(true), _tiled(false), _selected(false),
|
||||
stack(NULL), splitter(NULL), sidebar_(NULL), page_(NULL), blank_(NULL)
|
||||
stack(NULL), splitter(NULL), mainSplitter(NULL),
|
||||
sidebar_(NULL), bottom_(NULL), page_(NULL), blank_(NULL)
|
||||
{
|
||||
// setup the basic widget
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
@@ -57,6 +58,12 @@ TabView::TabView(Context *context, int type) :
|
||||
splitter->setOpaqueResize(true); // redraw when released, snappier UI
|
||||
stack->insertWidget(0, splitter); // splitter always at index 0
|
||||
|
||||
mainSplitter = new ViewSplitter(Qt::Vertical, "Compare Intervals", this);
|
||||
mainSplitter->setHandleWidth(23);
|
||||
mainSplitter->setFrameStyle(QFrame::NoFrame);
|
||||
mainSplitter->setContentsMargins(0, 0, 0, 0); // attempting to follow some UI guides
|
||||
mainSplitter->setOpaqueResize(true); // redraw when released, snappier UI
|
||||
|
||||
connect(splitter,SIGNAL(splitterMoved(int,int)), this, SLOT(splitterMoved(int,int)));
|
||||
}
|
||||
|
||||
@@ -98,18 +105,27 @@ TabView::setPage(HomeWindow *page)
|
||||
{
|
||||
page_ = page;
|
||||
|
||||
// add to mainSplitter
|
||||
// now reset the splitter
|
||||
splitter->insertWidget(-1, page);
|
||||
splitter->setStretchFactor(0,0);
|
||||
splitter->setStretchFactor(1,1);
|
||||
splitter->setCollapsible(0, true);
|
||||
splitter->setCollapsible(1, true);
|
||||
mainSplitter->insertWidget(-1, page);
|
||||
mainSplitter->setStretchFactor(0,0);
|
||||
mainSplitter->setCollapsible(0, false);
|
||||
splitter->insertWidget(-1, mainSplitter);
|
||||
QString setting = QString("%1/%2").arg(GC_SETTINGS_SPLITTER_SIZES).arg(type);
|
||||
QVariant splitterSizes = appsettings->cvalue(context->athlete->cyclist, setting);
|
||||
if (splitterSizes.toByteArray().size() > 1 ) {
|
||||
splitter->restoreState(splitterSizes.toByteArray());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TabView::setBottom(QWidget *widget)
|
||||
{
|
||||
bottom_ = widget;
|
||||
bottom_->hide();
|
||||
mainSplitter->insertWidget(-1, bottom_);
|
||||
mainSplitter->setCollapsible(1, true); // XXX we need a ComparePane widget ...
|
||||
mainSplitter->setStretchFactor(1,1);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -25,9 +25,11 @@
|
||||
#include <QStackedWidget>
|
||||
|
||||
#include "HomeWindow.h"
|
||||
#include "GcSideBarItem.h"
|
||||
#include "GcWindowRegistry.h"
|
||||
|
||||
class Tab;
|
||||
class ViewSplitter;
|
||||
class Context;
|
||||
class BlankStatePage;
|
||||
|
||||
@@ -52,6 +54,8 @@ class TabView : public QWidget
|
||||
HomeWindow *page() { return page_;}
|
||||
void setBlank(BlankStatePage *blank);
|
||||
BlankStatePage *blank() { return blank_; }
|
||||
void setBottom(QWidget *bottom);
|
||||
QWidget *bottom() { return bottom_; }
|
||||
|
||||
// sidebar
|
||||
void setSidebarEnabled(bool x) { _sidebar=x; sidebarChanged(); }
|
||||
@@ -61,6 +65,11 @@ class TabView : public QWidget
|
||||
void setTiled(bool x) { _tiled=x; tileModeChanged(); }
|
||||
bool isTiled() const { return _tiled; }
|
||||
|
||||
// bottom
|
||||
void setShowBottom(bool x) { if (bottom_) x ? bottom_->show() : bottom_->hide(); }
|
||||
bool isShowBottom() { if (bottom_) return bottom_->isVisible(); return false; }
|
||||
bool hasBottom() { return (bottom_!=NULL); }
|
||||
|
||||
// select / deselect view
|
||||
void setSelected(bool x) { _selected=x; selectionChanged(); }
|
||||
bool isSelected() const { return _selected; }
|
||||
@@ -110,10 +119,31 @@ class TabView : public QWidget
|
||||
|
||||
QStackedWidget *stack;
|
||||
QSplitter *splitter;
|
||||
ViewSplitter *mainSplitter;
|
||||
QWidget *sidebar_;
|
||||
QWidget *bottom_;
|
||||
HomeWindow *page_;
|
||||
BlankStatePage *blank_;
|
||||
|
||||
};
|
||||
|
||||
// we make our own view splitter for the bespoke handle
|
||||
class ViewSplitter : public QSplitter
|
||||
{
|
||||
public:
|
||||
ViewSplitter(Qt::Orientation orientation, QString name, QWidget *parent=0) :
|
||||
orientation(orientation), name(name), QSplitter(orientation, parent) {}
|
||||
|
||||
protected:
|
||||
QSplitterHandle *createHandle() {
|
||||
qDebug()<<"create a handle"<<name;
|
||||
return new GcSplitterHandle(name, orientation, this);
|
||||
}
|
||||
int handleWidth() { return 23; };
|
||||
|
||||
private:
|
||||
Qt::Orientation orientation;
|
||||
QString name;
|
||||
};
|
||||
|
||||
#endif // _GC_TabView_h
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "LTMSidebar.h"
|
||||
#include "BlankState.h"
|
||||
#include "TrainDB.h"
|
||||
#include "ComparePane.h"
|
||||
|
||||
AnalysisView::AnalysisView(Context *context, QStackedWidget *controls) : TabView(context, VIEW_ANALYSIS)
|
||||
{
|
||||
@@ -35,6 +36,8 @@ AnalysisView::AnalysisView(Context *context, QStackedWidget *controls) : TabView
|
||||
setSidebar(s);
|
||||
setPage(a);
|
||||
setBlank(b);
|
||||
//setBottom(new ComparePane(this, ComparePane::interval));
|
||||
setBottom(new QWidget(this));
|
||||
}
|
||||
|
||||
AnalysisView::~AnalysisView()
|
||||
|
||||
@@ -251,6 +251,7 @@ HEADERS += \
|
||||
Colors.h \
|
||||
ColorButton.h \
|
||||
CommPort.h \
|
||||
ComparePane.h \
|
||||
Computrainer.h \
|
||||
Computrainer3dpFile.h \
|
||||
ConfigDialog.h \
|
||||
@@ -438,6 +439,7 @@ SOURCES += \
|
||||
Colors.cpp \
|
||||
ColorButton.cpp \
|
||||
CommPort.cpp \
|
||||
ComparePane.cpp \
|
||||
Computrainer.cpp \
|
||||
Computrainer3dpFile.cpp \
|
||||
ConfigDialog.cpp \
|
||||
|
||||
Reference in New Issue
Block a user