mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Position tile config menu (#4558)
* Move tile config dialog near the cog icon * Ensure config dialog remains within GC window
This commit is contained in:
@@ -87,7 +87,7 @@ OverviewWindow::OverviewWindow(Context *context, int scope, bool blank) : GcChar
|
||||
connect(importChart, SIGNAL(triggered(bool)), this, SLOT(importChart()));
|
||||
connect(settings, SIGNAL(triggered(bool)), this, SLOT(settings()));
|
||||
connect(mincolsEdit, SIGNAL(valueChanged(int)), this, SLOT(setMinimumColumns(int)));
|
||||
connect(space, SIGNAL(itemConfigRequested(ChartSpaceItem*)), this, SLOT(configItem(ChartSpaceItem*)));
|
||||
connect(space, SIGNAL(itemConfigRequested(ChartSpaceItem*, QPoint)), this, SLOT(configItem(ChartSpaceItem*, QPoint)));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -174,9 +174,9 @@ nodice:
|
||||
}
|
||||
|
||||
void
|
||||
OverviewWindow::configItem(ChartSpaceItem *item)
|
||||
OverviewWindow::configItem(ChartSpaceItem *item, QPoint pos)
|
||||
{
|
||||
OverviewConfigDialog *p = new OverviewConfigDialog(item);
|
||||
OverviewConfigDialog *p = new OverviewConfigDialog(item, pos);
|
||||
p->exec(); // no mem leak as delete on close
|
||||
}
|
||||
|
||||
@@ -570,7 +570,7 @@ badconfig:
|
||||
//
|
||||
// Config dialog that pops up when you click on the config button
|
||||
//
|
||||
OverviewConfigDialog::OverviewConfigDialog(ChartSpaceItem*item) : QDialog(NULL), item(item)
|
||||
OverviewConfigDialog::OverviewConfigDialog(ChartSpaceItem*item, QPoint pos) : QDialog(NULL), item(item), pos(pos)
|
||||
{
|
||||
if (item->type == OverviewItemType::USERCHART) setWindowTitle(tr("Chart Settings"));
|
||||
else setWindowTitle(tr("Tile Settings"));
|
||||
@@ -618,6 +618,21 @@ OverviewConfigDialog::OverviewConfigDialog(ChartSpaceItem*item) : QDialog(NULL),
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
OverviewConfigDialog::showEvent(QShowEvent*)
|
||||
{
|
||||
QSize gcWindowSize = item->parent->context->mainWindow->size();
|
||||
QPoint gcWindowPosn = item->parent->context->mainWindow->pos();
|
||||
|
||||
int xLimit = gcWindowPosn.x() + gcWindowSize.width() - geometry().width() -10;
|
||||
int yLimit = gcWindowPosn.y() + gcWindowSize.height() - geometry().height() -10;
|
||||
|
||||
int xDialog = (pos.x() > xLimit) ? xLimit : pos.x();
|
||||
int yDialog = (pos.y() > yLimit) ? yLimit : pos.y();
|
||||
|
||||
move(xDialog, yDialog);
|
||||
}
|
||||
|
||||
OverviewConfigDialog::~OverviewConfigDialog()
|
||||
{
|
||||
if (item) {
|
||||
|
||||
@@ -63,7 +63,7 @@ class OverviewWindow : public GcChartWindow
|
||||
void settings();
|
||||
|
||||
// config item requested
|
||||
void configItem(ChartSpaceItem *);
|
||||
void configItem(ChartSpaceItem *, QPoint);
|
||||
|
||||
private:
|
||||
|
||||
@@ -81,7 +81,7 @@ class OverviewConfigDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OverviewConfigDialog(ChartSpaceItem*);
|
||||
OverviewConfigDialog(ChartSpaceItem*, QPoint pos);
|
||||
~OverviewConfigDialog();
|
||||
|
||||
|
||||
@@ -91,7 +91,12 @@ class OverviewConfigDialog : public QDialog
|
||||
void exportChart();
|
||||
void close();
|
||||
|
||||
protected:
|
||||
|
||||
void showEvent(QShowEvent*) override;
|
||||
|
||||
private:
|
||||
QPoint pos;
|
||||
ChartSpaceItem *item;
|
||||
QVBoxLayout *main;
|
||||
QPushButton *remove, *ok, *exp;
|
||||
|
||||
@@ -46,7 +46,7 @@ AthleteView::AthleteView(Context *context) : ChartSpace(context, OverviewScope::
|
||||
configChanged(0);
|
||||
|
||||
// athlete config dialog...
|
||||
connect(this, SIGNAL(itemConfigRequested(ChartSpaceItem*)), this, SLOT(configItem(ChartSpaceItem*)));
|
||||
connect(this, SIGNAL(itemConfigRequested(ChartSpaceItem*, QPoint)), this, SLOT(configItem(ChartSpaceItem*, QPoint)));
|
||||
// new athlete
|
||||
connect(context->mainWindow, SIGNAL(newAthlete(QString)), this, SLOT(newAthlete(QString)));
|
||||
// delete athlete
|
||||
@@ -93,7 +93,7 @@ AthleteView::configChanged(qint32)
|
||||
}
|
||||
|
||||
void
|
||||
AthleteView::configItem(ChartSpaceItem*item)
|
||||
AthleteView::configItem(ChartSpaceItem*item, QPoint)
|
||||
{
|
||||
AthleteCard *card = static_cast<AthleteCard*>(item);
|
||||
card->configAthlete();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ChartSpace.h"
|
||||
#include "OverviewItems.h"
|
||||
#include <QPoint>
|
||||
|
||||
class AthleteView : public ChartSpace
|
||||
{
|
||||
@@ -10,7 +11,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void configChanged(qint32);
|
||||
void configItem(ChartSpaceItem*);
|
||||
void configItem(ChartSpaceItem*, QPoint);
|
||||
void newAthlete(QString);
|
||||
void deleteAthlete(QString);
|
||||
|
||||
|
||||
@@ -1011,7 +1011,7 @@ ChartSpace::eventFilter(QObject *, QEvent *event)
|
||||
if (item && item->inCorner()) {
|
||||
|
||||
block = false; // reeentry is allowed
|
||||
emit itemConfigRequested(item);
|
||||
emit itemConfigRequested(item, static_cast<QGraphicsSceneMouseEvent*>(event)->screenPos());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ class ChartSpace : public QWidget
|
||||
|
||||
|
||||
signals:
|
||||
void itemConfigRequested(ChartSpaceItem*);
|
||||
void itemConfigRequested(ChartSpaceItem*, QPoint);
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user