|
|
|
@ -13,46 +13,46 @@ static QString shorten(const QString &str, int max_len) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
MapPanel::MapPanel(QWidget* parent) : QWidget(parent) { |
|
|
|
|
stack = new QStackedWidget; |
|
|
|
|
QStackedLayout *stack = new QStackedLayout(this); |
|
|
|
|
|
|
|
|
|
QWidget * main_widget = new QWidget; |
|
|
|
|
QWidget *main_widget = new QWidget; |
|
|
|
|
QVBoxLayout *main_layout = new QVBoxLayout(main_widget); |
|
|
|
|
const int icon_size = 200; |
|
|
|
|
|
|
|
|
|
// Home
|
|
|
|
|
QHBoxLayout *home_layout = new QHBoxLayout; |
|
|
|
|
home_button = new QPushButton; |
|
|
|
|
home_button->setIconSize(QSize(icon_size, icon_size)); |
|
|
|
|
home_layout->addWidget(home_button); |
|
|
|
|
|
|
|
|
|
home_address = new QLabel; |
|
|
|
|
home_address->setWordWrap(true); |
|
|
|
|
home_layout->addSpacing(30); |
|
|
|
|
home_layout->addWidget(home_address); |
|
|
|
|
home_layout->addStretch(); |
|
|
|
|
|
|
|
|
|
// Work
|
|
|
|
|
QHBoxLayout *work_layout = new QHBoxLayout; |
|
|
|
|
work_button = new QPushButton; |
|
|
|
|
work_button->setIconSize(QSize(icon_size, icon_size)); |
|
|
|
|
work_layout->addWidget(work_button); |
|
|
|
|
|
|
|
|
|
work_address = new QLabel; |
|
|
|
|
work_address->setWordWrap(true); |
|
|
|
|
work_layout->addSpacing(30); |
|
|
|
|
work_layout->addWidget(work_address); |
|
|
|
|
work_layout->addStretch(); |
|
|
|
|
main_layout->setSpacing(20); |
|
|
|
|
|
|
|
|
|
// Home & Work layout
|
|
|
|
|
QHBoxLayout *home_work_layout = new QHBoxLayout; |
|
|
|
|
home_work_layout->addLayout(home_layout, 1); |
|
|
|
|
home_work_layout->addSpacing(50); |
|
|
|
|
home_work_layout->addLayout(work_layout, 1); |
|
|
|
|
{ |
|
|
|
|
// Home
|
|
|
|
|
home_button = new QPushButton; |
|
|
|
|
home_button->setIconSize(QSize(MAP_PANEL_ICON_SIZE, MAP_PANEL_ICON_SIZE)); |
|
|
|
|
home_address = new QLabel; |
|
|
|
|
home_address->setWordWrap(true); |
|
|
|
|
|
|
|
|
|
QHBoxLayout *home_layout = new QHBoxLayout; |
|
|
|
|
home_layout->addWidget(home_button); |
|
|
|
|
home_layout->addSpacing(30); |
|
|
|
|
home_layout->addWidget(home_address); |
|
|
|
|
home_layout->addStretch(); |
|
|
|
|
|
|
|
|
|
// Work
|
|
|
|
|
work_button = new QPushButton; |
|
|
|
|
work_button->setIconSize(QSize(MAP_PANEL_ICON_SIZE, MAP_PANEL_ICON_SIZE)); |
|
|
|
|
work_address = new QLabel; |
|
|
|
|
work_address->setWordWrap(true); |
|
|
|
|
|
|
|
|
|
QHBoxLayout *work_layout = new QHBoxLayout; |
|
|
|
|
work_layout->addWidget(work_button); |
|
|
|
|
work_layout->addSpacing(30); |
|
|
|
|
work_layout->addWidget(work_address); |
|
|
|
|
work_layout->addStretch(); |
|
|
|
|
|
|
|
|
|
home_work_layout->addLayout(home_layout, 1); |
|
|
|
|
home_work_layout->addSpacing(50); |
|
|
|
|
home_work_layout->addLayout(work_layout, 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
main_layout->addLayout(home_work_layout); |
|
|
|
|
main_layout->addSpacing(20); |
|
|
|
|
main_layout->addWidget(horizontal_line()); |
|
|
|
|
main_layout->addSpacing(20); |
|
|
|
|
|
|
|
|
|
// Current route
|
|
|
|
|
{ |
|
|
|
@ -81,7 +81,6 @@ MapPanel::MapPanel(QWidget* parent) : QWidget(parent) { |
|
|
|
|
QLabel *recents_title = new QLabel(tr("Recent Destinations")); |
|
|
|
|
recents_title->setStyleSheet("font-size: 55px"); |
|
|
|
|
main_layout->addWidget(recents_title); |
|
|
|
|
main_layout->addSpacing(20); |
|
|
|
|
|
|
|
|
|
recent_layout = new QVBoxLayout; |
|
|
|
|
QWidget *recent_widget = new LayoutWidget(recent_layout, this); |
|
|
|
@ -119,9 +118,6 @@ MapPanel::MapPanel(QWidget* parent) : QWidget(parent) { |
|
|
|
|
stack->setCurrentIndex(prime_type ? 0 : 1); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
QVBoxLayout *wrapper = new QVBoxLayout(this); |
|
|
|
|
wrapper->addWidget(stack); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clear(); |
|
|
|
|
|
|
|
|
@ -207,8 +203,9 @@ void MapPanel::refresh() { |
|
|
|
|
prev_destinations = cur_destinations; |
|
|
|
|
clear(); |
|
|
|
|
|
|
|
|
|
// add favorites before recents
|
|
|
|
|
bool has_recents = false; |
|
|
|
|
for (auto &save_type: {"favorite", "recent"}) { |
|
|
|
|
for (auto &save_type: {NAV_TYPE_FAVORITE, NAV_TYPE_RECENT}) { |
|
|
|
|
for (auto location : doc.array()) { |
|
|
|
|
auto obj = location.toObject(); |
|
|
|
|
|
|
|
|
@ -219,7 +216,7 @@ void MapPanel::refresh() { |
|
|
|
|
|
|
|
|
|
if (type != save_type) continue; |
|
|
|
|
|
|
|
|
|
if (type == "favorite" && label == "home") { |
|
|
|
|
if (type == NAV_TYPE_FAVORITE && label == NAV_FAVORITE_LABEL_HOME) { |
|
|
|
|
home_address->setText(name); |
|
|
|
|
home_address->setStyleSheet(R"(font-size: 50px; color: white;)"); |
|
|
|
|
home_button->setIcon(QPixmap("../assets/navigation/home.png")); |
|
|
|
@ -227,7 +224,7 @@ void MapPanel::refresh() { |
|
|
|
|
navigateTo(obj); |
|
|
|
|
emit closeSettings(); |
|
|
|
|
}); |
|
|
|
|
} else if (type == "favorite" && label == "work") { |
|
|
|
|
} else if (type == NAV_TYPE_FAVORITE && label == NAV_FAVORITE_LABEL_WORK) { |
|
|
|
|
work_address->setText(name); |
|
|
|
|
work_address->setStyleSheet(R"(font-size: 50px; color: white;)"); |
|
|
|
|
work_button->setIcon(QPixmap("../assets/navigation/work.png")); |
|
|
|
@ -245,7 +242,7 @@ void MapPanel::refresh() { |
|
|
|
|
sp.setRetainSizeWhenHidden(true); |
|
|
|
|
star->setSizePolicy(sp); |
|
|
|
|
|
|
|
|
|
star->setVisible(type == "favorite"); |
|
|
|
|
star->setVisible(type == NAV_TYPE_FAVORITE); |
|
|
|
|
star->setStyleSheet(R"(font-size: 60px;)"); |
|
|
|
|
layout->addWidget(star); |
|
|
|
|
layout->addSpacing(10); |
|
|
|
@ -284,7 +281,6 @@ void MapPanel::refresh() { |
|
|
|
|
has_recents = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!has_recents) { |
|
|
|
|