23
23
#include <QDoubleSpinBox>
24
24
#include <QRadioButton>
25
25
#include <QHBoxLayout>
26
#include "../dbusproxy/youkersessiondbus.h"
28
PanelWidget::PanelWidget(QWidget *parent, SessionDispatcher *proxy, QString cur_desktop, bool has_battery) :
29
QWidget(parent),desktop(cur_desktop),
27
PanelWidget::PanelWidget(QWidget *parent, QString cur_desktop, bool has_battery) :
28
SettingModulePage(parent),desktop(cur_desktop)
33
30
blur_label = new QLabel();
34
31
transparency_label = new QLabel();
35
32
date_format_label = new QLabel();
369
371
show_places_label->setText(tr("Show places") + ":");
372
bool PanelWidget::getStatus()
377
void PanelWidget::initData()
374
void PanelWidget::initSettingData()
379
376
if(this->desktop == "mate" || this->desktop == "MATE" || this->desktop == "UKUI" || this->desktop == "ukui") {
380
app_switcher->switchedOn = sessionproxy->get_show_apps_qt();
381
desktop_switcher->switchedOn = sessionproxy->get_show_desktop_qt();
382
icon_switcher->switchedOn = sessionproxy->get_show_icon_qt();
383
places_switcher->switchedOn = sessionproxy->get_show_places_qt();
377
emit this->requestMateOrUnityPanelData(true);
379
// app_switcher->switchedOn = sessionproxy->get_show_apps_qt();
380
// desktop_switcher->switchedOn = sessionproxy->get_show_desktop_qt();
381
// icon_switcher->switchedOn = sessionproxy->get_show_icon_qt();
382
// places_switcher->switchedOn = sessionproxy->get_show_places_qt();
386
int default_value = sessionproxy->get_dash_blur_experimental_qt();
385
emit this->requestMateOrUnityPanelData(false);
387
/*int default_value = sessionproxy->get_dash_blur_experimental_qt();
387
388
if(default_value == 2) {
388
389
smart_radio->setChecked(true);
389
390
static_radio->setChecked(false);
419
420
date_switcher->switchedOn = sessionproxy->get_show_date_qt();
421
422
QString cur_power = sessionproxy->get_power_icon_policy_qt();
422
/*QStringList */powerlist = sessionproxy->get_all_power_icon_policy_qt();
423
m_powerlist = sessionproxy->get_all_power_icon_policy_qt();
423
424
battery_combo->clear();
424
425
battery_combo->clearEditText();
425
battery_combo->addItems(powerlist);
426
QList<QString>::Iterator ite = powerlist.begin(), iteend = powerlist.end();
426
battery_combo->addItems(m_powerlist);
427
QList<QString>::Iterator ite = m_powerlist.begin(), iteend = m_powerlist.end();
428
429
for(;ite != iteend; ite++,index++)
433
434
battery_combo->setCurrentIndex(index);
435
436
battery_percentage_switcher->switchedOn = sessionproxy->get_show_power_percentage_qt();
436
battery_time_switcher->switchedOn = sessionproxy->get_show_power_time_qt();
437
battery_time_switcher->switchedOn = sessionproxy->get_show_power_time_qt();*/
440
441
this->initConnect();
444
void PanelWidget::onSendMatePanelValue(bool app, bool desktop, bool icon, bool places)
446
app_switcher->switchedOn = app;
447
desktop_switcher->switchedOn = desktop;
448
icon_switcher->switchedOn = icon;
449
places_switcher->switchedOn = places;
452
void PanelWidget::onSendUnityBlurAndTransparencyValue(int blur, double transparent)
455
smart_radio->setChecked(true);
456
static_radio->setChecked(false);
457
clear_radio->setChecked(false);
460
static_radio->setChecked(true);
461
smart_radio->setChecked(false);
462
clear_radio->setChecked(false);
465
clear_radio->setChecked(true);
466
static_radio->setChecked(false);
467
smart_radio->setChecked(false);
469
transparency_slider->setValue(transparent);
472
void PanelWidget::onSendUnityTimeValue(const QString &time_format, const QStringList &timelist, bool showSecond, bool showWeek, bool showDate)
474
QStringList m_timelist = timelist;
476
date_combo->clearEditText();
477
date_combo->addItems(m_timelist);
478
QList<QString>::Iterator it = m_timelist.begin(), itend = m_timelist.end();
480
for(;it != itend; it++,initIndex++)
482
if(*it == time_format)
485
date_combo->setCurrentIndex(initIndex);
487
second_switcher->switchedOn = showSecond;
488
week_switcher->switchedOn = showWeek;
489
date_switcher->switchedOn = showDate;
492
void PanelWidget::onSendUnityPanelPowerValue(const QString &cur_power, const QStringList &powerlist, bool showPower, bool showBatteryTime)
495
m_powerlist = powerlist;
496
battery_combo->clear();
497
battery_combo->clearEditText();
498
battery_combo->addItems(m_powerlist);
499
QList<QString>::Iterator ite = m_powerlist.begin(), iteend = m_powerlist.end();
501
for(;ite != iteend; ite++,index++)
503
if(*ite == cur_power)
506
battery_combo->setCurrentIndex(index);
508
battery_percentage_switcher->switchedOn = showPower;
509
battery_time_switcher->switchedOn = showBatteryTime;
443
512
void PanelWidget::initConnect() {
444
513
// connect(back_btn, SIGNAL(clicked()), this, SIGNAL(showSettingMainWidget()));
445
connect(smart_radio, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/)));
446
connect(static_radio, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/)));
447
connect(clear_radio, SIGNAL(clicked(/*bool*/)), this, SLOT(setRadioButtonRowStatus(/*bool*/)));
514
connect(smart_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus()));
515
connect(static_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus()));
516
connect(clear_radio, SIGNAL(clicked()), this, SLOT(setRadioButtonRowStatus()));
448
517
connect(transparency_slider, SIGNAL(valueChanged(double)), this, SLOT(setTransparencyValue(double)));
449
518
connect(date_combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(setDateFormat(QString)));
450
519
connect(second_switcher, SIGNAL(clicked()), this, SLOT(setDisplaySeconds()));
458
527
connect(icon_switcher, SIGNAL(clicked()), this, SLOT(showIcon()));
459
528
connect(places_switcher, SIGNAL(clicked()), this, SLOT(showPlaces()));
461
connect(sessionproxy, SIGNAL(string_value_notify(QString, QString)), this, SLOT(panelwidget_notify_string(QString, QString)));
462
connect(sessionproxy, SIGNAL(bool_value_notify(QString, bool)), this, SLOT(panelwidget_notify_bool(QString, bool)));
530
// connect(sessionproxy, SIGNAL(string_value_notify(QString, QString)), this, SLOT(panelwidget_notify_string(QString, QString)));
531
// connect(sessionproxy, SIGNAL(bool_value_notify(QString, bool)), this, SLOT(panelwidget_notify_bool(QString, bool)));
465
534
void PanelWidget::panelwidget_notify_string(QString key, QString value)
467
536
if (key == "icon-policy") {
468
QList<QString>::Iterator it = powerlist.begin(), itend = powerlist.end();
537
QList<QString>::Iterator it = m_powerlist.begin(), itend = m_powerlist.end();
470
539
bool exist = false;
471
540
for(;it != itend; it++)
519
588
void PanelWidget::setTransparencyValue(double value)
521
sessionproxy->set_panel_transparency_qt(value);
590
emit resetPanelTransparencyValue(value);
591
// sessionproxy->set_panel_transparency_qt(value);
524
596
void PanelWidget::setDateFormat(QString selected) {
525
sessionproxy->set_time_format_qt(selected);
597
emit resetDateFormat(selected);
598
// sessionproxy->set_time_format_qt(selected);
528
601
void PanelWidget::setShowBatteryIcon(QString selected) {
529
sessionproxy->set_power_icon_policy_qt(selected);
602
emit resetShowBatteryIcon(selected);
603
// sessionproxy->set_power_icon_policy_qt(selected);
607
//TODO: 设计一个枚举变量作为标记,用一个函数去调用dbus设置各个值
532
608
void PanelWidget::setRadioButtonRowStatus(/*bool status*/)
534
610
QObject *obj = sender(); //返回发出信号的对象,用QObject类型接收
536
612
QString obj_name = pbtn->objectName();
537
613
if(obj_name == "smart_radio")
539
sessionproxy->set_dash_blur_experimental_qt(2);
615
emit resetDashBlurExperimental(2);
616
// sessionproxy->set_dash_blur_experimental_qt(2);
541
618
else if(obj_name == "static_radio")
543
sessionproxy->set_dash_blur_experimental_qt(1);
620
emit resetDashBlurExperimental(1);
621
// sessionproxy->set_dash_blur_experimental_qt(1);
545
623
else if(obj_name == "clear_radio")
547
sessionproxy->set_dash_blur_experimental_qt(0);
625
emit resetDashBlurExperimental(0);
626
// sessionproxy->set_dash_blur_experimental_qt(0);
551
630
void PanelWidget::setDisplaySeconds()
553
sessionproxy->set_show_seconds_qt(second_switcher->switchedOn);
632
emit resetDisplaySeconds(second_switcher->switchedOn);
633
// sessionproxy->set_show_seconds_qt(second_switcher->switchedOn);
556
636
void PanelWidget::setDisplayWeek()
558
sessionproxy->set_show_week_qt(week_switcher->switchedOn);
638
emit resetDisplayWeek(week_switcher->switchedOn);
639
// sessionproxy->set_show_week_qt(week_switcher->switchedOn);
561
642
void PanelWidget::setDisplayDate()
563
sessionproxy->set_show_date_qt(date_switcher->switchedOn);
644
emit resetDisplayDate(date_switcher->switchedOn);
645
// sessionproxy->set_show_date_qt(date_switcher->switchedOn);
566
648
void PanelWidget::setDisplayBatteryPercentage()
568
sessionproxy->set_show_power_percentage_qt(battery_percentage_switcher->switchedOn);
650
emit resetDisplayBatteryPercentage(battery_percentage_switcher->switchedOn);
651
// sessionproxy->set_show_power_percentage_qt(battery_percentage_switcher->switchedOn);
571
654
void PanelWidget::setDisplayBatteryTime()
573
sessionproxy->set_show_power_time_qt(battery_time_switcher->switchedOn);
656
emit resetDisplayBatteryTime(battery_time_switcher->switchedOn);
657
// sessionproxy->set_show_power_time_qt(battery_time_switcher->switchedOn);
576
660
void PanelWidget::showApplications()
578
sessionproxy->set_show_apps_qt(app_switcher->switchedOn);
662
emit resetShowApplications(app_switcher->switchedOn);
663
// sessionproxy->set_show_apps_qt(app_switcher->switchedOn);
581
666
void PanelWidget::showDesktop()
583
sessionproxy->set_show_desktop_qt(desktop_switcher->switchedOn);
668
emit resetShowDesktop(desktop_switcher->switchedOn);
669
// sessionproxy->set_show_desktop_qt(desktop_switcher->switchedOn);
586
672
void PanelWidget::showIcon()
588
sessionproxy->set_show_icon_qt(icon_switcher->switchedOn);
674
emit resetShowIcon(icon_switcher->switchedOn);
675
// sessionproxy->set_show_icon_qt(icon_switcher->switchedOn);
591
678
void PanelWidget::showPlaces()
593
sessionproxy->set_show_places_qt(places_switcher->switchedOn);
680
emit resetShowPlaces(places_switcher->switchedOn);
681
// sessionproxy->set_show_places_qt(places_switcher->switchedOn);