~ubuntu-branches/ubuntu/vivid/youker-assistant/vivid

« back to all changes in this revision

Viewing changes to src/sessiondispatcher.cpp

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2014-03-24 15:52:37 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140324155237-3kod0m3wr2a2ag39
Tags: 1.0.1-0ubuntu1
* New upstream release (LP: #1294936).
* Modify display mode of weather forecast and system settings.
* Add file manager and font style settings.
* Improve system settings and restoring default settings.
* Cache user account (not password).
* Change the position of window control buttons.
* Add configuration for Kingsoft KuaiPan cloud client.
* Add the instruction of Youker Assistant.
* Open related folders when scanning items got double-clicked.
* Notify users when operating the Kingsoft disk cloud configuration.
* Modify Dbus starting method.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "util.h"
34
34
#include "kfontdialog.h"
35
35
#include "logindialog.h"
 
36
#include "math.h"
36
37
 
37
38
QString selectedFont;
38
39
QString selectedFcitxFont;
64
65
//    skin_widget = new SkinsWidget(mSettings);
65
66
//    skinCenter = new SkinCenter();
66
67
//    connect(skin_widget, SIGNAL(skinSignalToQML(QString)), this, SLOT(handler_change_skin(QString)));
67
 
 
68
 
    QObject::connect(sessioniface,SIGNAL(display_scan_process(QString)),this,SLOT(handler_scan_process(QString)));
69
 
    QObject::connect(sessioniface,SIGNAL(scan_complete(QString)),this,SLOT(handler_scan_complete(QString)));
 
68
    //handler_change_titlebar_position
 
69
    QObject::connect(sessioniface, SIGNAL(change_titlebar_position(QString)), this, SLOT(handler_change_titlebar_position(QString)));
 
70
    QObject::connect(sessioniface, SIGNAL(display_scan_process(QString)), this, SLOT(handler_scan_process(QString)));
 
71
    QObject::connect(sessioniface, SIGNAL(scan_complete(QString)), this, SLOT(handler_scan_complete(QString)));
70
72
    QObject::connect(sessioniface, SIGNAL(access_weather(QString, QString)), this, SLOT(accord_flag_access_weather(QString, QString)));
71
 
    QObject::connect(sessioniface,SIGNAL(total_data_transmit(QString, QString)),this,SLOT(handler_total_data_transmit(QString,QString)));
 
73
    QObject::connect(sessioniface, SIGNAL(total_data_transmit(QString, QString)), this, SLOT(handler_total_data_transmit(QString,QString)));
72
74
 
73
75
    //Apt and Soft center cache
74
76
    QObject::connect(sessioniface, SIGNAL(data_transmit_by_cache(QString, QString, QString, QString)), this, SLOT(handler_append_cache_data_to_model(QString,QString,QString,QString)));
75
77
    QObject::connect(sessioniface, SIGNAL(cache_transmit_complete(QString)), this, SLOT(handler_cache_scan_over(QString)));
 
78
//    QObject::connect(sessioniface, SIGNAL(path_transmit_by_cache(QString, QString)), this, SLOT(handler_cache_path(QString, QString)));
76
79
 
77
80
    //Uninstall unneed package and old kernel package
78
81
    QObject::connect(sessioniface, SIGNAL(data_transmit_by_package(QString, QString, QString, QString)), this, SLOT(handler_append_package_data_to_model(QString,QString,QString,QString)));
86
89
    QObject::connect(sessioniface, SIGNAL(data_transmit_by_cookies(QString, QString, QString)), this, SLOT(handler_append_cookies_to_model(QString,QString,QString)));
87
90
    QObject::connect(sessioniface, SIGNAL(cookies_transmit_complete(QString)), this, SLOT(handler_cookies_scan_over(QString)));
88
91
 
 
92
    //cloud conf
 
93
    QObject::connect(sessioniface, SIGNAL(upload_cloud_conf_signal(QString)), this, SLOT(handler_upload_cloud_conf(QString)));
 
94
    QObject::connect(sessioniface, SIGNAL(download_cloud_conf_signal(QString)), this, SLOT(handler_download_cloud_conf(QString)));
 
95
 
89
96
    //login
90
 
    QObject::connect(httpauth, SIGNAL(response(QString,QString,QString,QString)), this, SLOT(handle_data_after_login_success(QString,QString,QString,QString)));
91
 
    QObject::connect(httpauth, SIGNAL(refresh(QString,QString)), this, SLOT(handle_data_after_search_success(QString,QString)));
 
97
    QObject::connect(httpauth, SIGNAL(response(/*QString,*/QString,QString,QString)), this, SLOT(handle_data_after_login_success(/*QString,*/QString,QString,QString)));
 
98
    QObject::connect(httpauth, SIGNAL(refresh(/*QString,*/QString)), this, SLOT(handle_data_after_search_success(/*QString,*/QString)));
92
99
    QObject::connect(httpauth, SIGNAL(error(int)), this, SLOT(handle_data_when_login_failed(int)));
93
100
    QObject::connect(httpauth, SIGNAL(failedCommunicate()), this, SLOT(resetTimerStatus()));
94
101
    QObject::connect(httpauth, SIGNAL(successCommunicate()), this, SLOT(searchCurrentInfo()));
110
117
    sessioniface->call("exit");
111
118
}
112
119
 
 
120
void SessionDispatcher::open_folder_qt(QString path) {
 
121
    sessioniface->call("open_folder", path);
 
122
}
 
123
 
 
124
void SessionDispatcher::download_kysoft_cloud_conf_qt() {
 
125
    sessioniface->call("download_kysoft_cloud_conf");
 
126
}
 
127
 
 
128
void SessionDispatcher::upload_kysoft_cloud_conf_qt() {
 
129
    sessioniface->call("upload_kysoft_cloud_conf");
 
130
}
 
131
 
 
132
//接收下载和使用云端配置的信号
 
133
void SessionDispatcher::handler_download_cloud_conf(QString download) {
 
134
    emit this->tellDownloadCloudConfToQML(download);
 
135
}
 
136
 
 
137
//接收上传配置到云端时的信号
 
138
void SessionDispatcher::handler_upload_cloud_conf(QString upload) {
 
139
    emit this->tellUploadCloudConfToQML(upload);
 
140
}
 
141
 
 
142
//准发发送信号告诉优客助手自己去改变自身的标题栏控制按钮位置
 
143
void SessionDispatcher::handler_change_titlebar_position(QString position) {
 
144
    emit this->startChangeControlBtnPosition(position);
 
145
}
 
146
 
113
147
//每30minutes连接服务器beat一次
114
148
void SessionDispatcher::connectHttpServer(){
115
149
    qDebug()<<"start to connect every 30 minutes...";
118
152
    mSettings->endGroup();
119
153
    mSettings->sync();
120
154
    //心跳
121
 
    QString requestData = QString("http://119.254.229.72/boxbeta/find_get.php?pp[type]=beat&pp[table]=yk_member&pp[id]=%1").arg(id);
 
155
    QString requestData = QString("http://www.ubuntukylin.com/boxbeta/find_get.php?pp[type]=beat&pp[table]=yk_member&pp[id]=%1").arg(id);
122
156
    QUrl url(requestData);
123
157
    httpauth->sendGetRequest(url);
124
158
}
126
160
//beat失败处理,beat不成功,界面的用户信息消失,改为登录界面,提示网络出错
127
161
void SessionDispatcher::resetTimerStatus() {
128
162
    //主动查询
129
 
    QString requestData = QString("http://119.254.229.72/boxbeta/find_get.php?pp[type]=network");
 
163
    QString requestData = QString("http://www.ubuntukylin.com/boxbeta/find_get.php?pp[type]=network");
130
164
    QUrl url(requestData);
131
165
    httpauth->sendGetRequest(url);
132
 
    //主动检测是否断开服务器了
133
 
//    QString requestData = QString("http://119.254.229.72/boxbeta/find_get.php?pp[type]=network");
134
 
//    QUrl url(requestData);
135
 
//    httpauth->sendGetRequest(url);
136
 
//    waitTime++;
137
 
//    if(waitTime >= 2){
138
 
//        waitTime = 0;
139
 
//        disconnect(timer, SIGNAL(timeout()), this, SLOT(connectHttpServer()));
140
 
//        if(timer->isActive()) {
141
 
//            timer->stop();
142
 
//        }
143
 
//        emit loginFailedStatus(99); //超时次数到,向主界面发送网络出现错误的信号
144
 
//        qDebug()<<"connect fail...";
145
 
//    }else{
146
 
//        qDebug() << "continue connect...";
147
 
//    }
148
 
//    waitTime++;
149
 
//    if(waitTime >= 2){
150
 
//        waitTime = 0;
151
 
//        disconnect(timer, SIGNAL(timeout()), this, SLOT(connectHttpServer()));
152
 
//        if(timer->isActive()) {
153
 
//            timer->stop();
154
 
//        }
155
 
//        emit loginFailedStatus(99); //超时次数到,向主界面发送网络出现错误的信号
156
 
//        qDebug()<<"connect fail...";
157
 
//    }else{
158
 
//        qDebug() << "continue connect...";
159
 
//    }
160
166
}
161
167
 
162
168
//查询当前的积分、等级....
166
172
    int id = mSettings->value("id").toInt();
167
173
    mSettings->endGroup();
168
174
    mSettings->sync();
169
 
    QString requestData = QString("http://119.254.229.72/boxbeta/find_get.php?pp[type]=getall&pp[table]=yk_member&pp[id]=%1").arg(id);
 
175
    QString requestData = QString("http://www.ubuntukylin.com/boxbeta/find_get.php?pp[type]=getall&pp[table]=yk_member&pp[id]=%1").arg(id);
170
176
    QUrl url(requestData);
171
177
    httpauth->sendGetRequest(url);
172
178
}
176
182
    sessioniface->call("display_slide_show");
177
183
}
178
184
 
179
 
//QString SessionDispatcher::get_currrent_date_qt() {
180
 
//    QDBusReply<QString> reply = sessioniface->call("get_currrent_date");
181
 
//    return reply.value();
182
 
//}
183
 
 
184
 
//QString SessionDispatcher::get_current_time_qt() {
185
 
//    QDBusReply<QString> reply = sessioniface->call("get_current_time");
186
 
//    return reply.value();
187
 
//}
188
 
 
189
185
//程序正常关闭之前,关闭定时器,获取id后发送退出信号给服务端
190
186
void SessionDispatcher::ready_exit_normally() {
191
187
    //关闭定时器
199
195
    int id = mSettings->value("id").toInt();
200
196
    mSettings->endGroup();
201
197
    mSettings->sync();
202
 
    QString requestData = QString("http://119.254.229.72/boxbeta/find_get.php?pp[type]=logout&pp[table]=yk_member&pp[id]=%1").arg(id);
 
198
    QString requestData = QString("http://www.ubuntukylin.com/boxbeta/find_get.php?pp[type]=logout&pp[table]=yk_member&pp[id]=%1").arg(id);
203
199
    QUrl url(requestData);
204
200
    httpauth->sendGetRequest(url);
205
201
}
211
207
 
212
208
//点击登录框的确定按钮后,开始发送数据给服务端进行登录验证
213
209
void SessionDispatcher::verify_user_and_password(QString user, QString pwd) {
214
 
//    username = user;
215
210
    //显示登录动态图
216
211
    emit showLoginAnimatedImage();
 
212
//    qDebug() << user;
 
213
//    qDebug() << pwd;
217
214
 
218
215
    //发送数据给服务端进行登录验证
219
 
    //method 1: get
220
 
    QString requestData = QString("http://119.254.229.72/boxbeta/find_get.php?pp[type]=login&pp[table]=yk_member&name=%1&password=%2").arg(user).arg(pwd);
 
216
    QString requestData = QString("http://www.ubuntukylin.com/boxbeta/find_get.php?pp[type]=login&pp[table]=yk_member&name=%1&password=%2").arg(user).arg(pwd);
221
217
    QUrl url(requestData);
222
218
    httpauth->sendGetRequest(url);
223
 
 
224
 
    //method 2: post
225
 
//    QString requestData = QString("%1%2%3%4").arg("name=").arg(user).arg("&password=").arg(pwd);
226
 
//    QUrl url("http://210.209.123.136/box/find.php");
227
 
//    QByteArray postData;
228
 
//    postData.append(requestData);
229
 
//    httpauth->sendPostRequest(url, postData);
230
219
}
231
220
 
232
221
//弹出登录框
236
225
    this->alert_x = window_x + (mainwindow_width / 2) - (alert_width_bg  / 2);
237
226
    this->alert_y = window_y + mainwindow_height - 400;
238
227
    logindialog->move(this->alert_x, this->alert_y);
239
 
    logindialog->show();
 
228
    logindialog->exec();
240
229
}
241
230
 
242
231
//退出登录
245
234
}
246
235
 
247
236
//用户登录成功后处理数据:显示界面、id写入本地配置、开启定时器
248
 
void SessionDispatcher::handle_data_after_login_success(QString id, QString level, QString name, QString score) {
 
237
void SessionDispatcher::handle_data_after_login_success(QString id,/* QString level, */QString name, QString score) {
249
238
    //登录成功后将用户信息显示在界面上
 
239
    bool ok;
 
240
    QString level = score_count_level(score.toInt(&ok, 10));
250
241
    emit updateLoginStatus(name, level, score);
251
242
 
252
243
    //将当前用户id写入本地配置文件中
262
253
}
263
254
 
264
255
//用户查询成功后处理数据:界面刷新数据
265
 
void SessionDispatcher::handle_data_after_search_success(QString level, QString score) {
 
256
void SessionDispatcher::handle_data_after_search_success(/*QString level, */QString score) {
266
257
    //查询成功后将用户信息更新在界面上
 
258
    bool ok;
 
259
    QString level = score_count_level(score.toInt(&ok, 10));
267
260
    emit refreshUserInfo(level, score);
268
261
    waitTime = 0;
269
262
}
270
263
 
271
264
//登录失败时或者测试网络失败,通知QML界面
272
265
void SessionDispatcher::handle_data_when_login_failed(int status) {
273
 
//    emit loginFailedStatus(status);
274
266
    if(status == 99) {
275
267
        waitTime++;
276
268
        if(waitTime >= 4){
283
275
            qDebug()<<"connect fail...";
284
276
        }else{
285
277
            qDebug() << "continue connect...";
286
 
            QString requestData = QString("http://119.254.229.72/boxbeta/find_get.php?pp[type]=network");
 
278
            QString requestData = QString("http://www.ubuntukylin.com/boxbeta/find_get.php?pp[type]=network");
287
279
            QUrl url(requestData);
288
280
            httpauth->sendGetRequest(url);
289
281
        }
293
285
    }
294
286
}
295
287
 
 
288
//根据积分计算用户等级
 
289
QString SessionDispatcher::score_count_level(int score) {
 
290
    return QString::number(qFloor(sqrt((score - 5) / 30 )));
 
291
}
 
292
 
296
293
QStringList SessionDispatcher::search_city_names_qt(QString search_name) {
297
294
    QDBusReply<QStringList> reply = sessioniface->call("search_city_names", search_name);
298
295
    return reply.value();
346
343
    emit tellQMLCaheOver(flag);
347
344
}
348
345
 
 
346
//void SessionDispatcher::handler_cache_path(QString flag, QString path) {
 
347
//    emit tellAbsPathToCacheModel(flag, path);
 
348
//}
 
349
 
349
350
void SessionDispatcher::handler_append_package_data_to_model(QString flag, QString pkgName, QString description, QString sizeValue) {
350
351
    emit appendPackageContentToCacheModel(flag, pkgName, description, sizeValue);
351
352
}
413
414
//}
414
415
 
415
416
QStringList SessionDispatcher::scan_of_large_qt(int size, QString abspath) {
416
 
    QDBusReply<QStringList> reply = sessioniface->call("scan_of_large", size, abspath);//large_scan_function
 
417
    QDBusReply<QStringList> reply = sessioniface->call("scan_of_large", size, abspath);
417
418
    return reply.value();
418
419
}
419
420
 
423
424
}
424
425
 
425
426
void SessionDispatcher::cookies_scan_function_qt(QString flag) {
426
 
//    QDBusReply<QStringList> reply = sessioniface->call("scan_cookies_function", flag);//cookies_scan_function
427
 
//    return reply.value();
428
427
    sessioniface->call("cookies_scan_function", flag);
429
428
}
430
429
 
431
 
//QStringList SessionDispatcher::scan_unneed_packages_qt() {
432
 
//    QDBusReply<QStringList> reply = sessioniface->call("scan_unneed_packages");
433
 
//    return reply.value();
434
 
//}
435
 
 
436
 
//QStringList SessionDispatcher::scan_apt_cruft_qt() {
437
 
//    QDBusReply<QStringList> reply = sessioniface->call("scan_apt_cruft");
438
 
//    return reply.value();
439
 
//}
440
 
 
441
 
//QStringList SessionDispatcher::scan_softwarecenter_cruft_qt() {
442
 
//    QDBusReply<QStringList> reply = sessioniface->call("scan_softwarecenter_cruft");
443
 
//    return reply.value();
444
 
//}
445
 
 
446
430
QStringList SessionDispatcher::get_cache_arglist(int i) {
447
431
    QStringList tmp;
448
432
    if(i == 0) {
480
464
    else if(i == 6) {
481
465
        tmp << "oldkernel" << "configfile";
482
466
    }
483
 
//    tmp << "unneed" << "oldkernel";
484
467
    return tmp;
485
468
}
486
469
 
492
475
    sessioniface->call("package_scan_function", argList);
493
476
}
494
477
 
495
 
//QStringList SessionDispatcher::scan_oldkernel_packages_qt() {
496
 
//    QDBusReply<QStringList> reply = sessioniface->call("oldkernel_scan_function");
497
 
//    return reply.value();
498
 
//}
499
 
 
500
478
QString SessionDispatcher::getHomePath() {
501
479
    QString homepath = QDir::homePath();
502
480
    return homepath;
575
553
    this->alert_y = window_y + mainwindow_height - 400;
576
554
    dialog->move(this->alert_x, this->alert_y);
577
555
    dialog->exec();
578
 
//    dialog->setModal(true);
579
 
//    dialog->show();
580
 
}
 
556
}
 
557
 
 
558
bool SessionDispatcher::showConfirmDialog(QString title, QString content, int window_x, int window_y) {
 
559
    WarningDialog *dialog = new WarningDialog(title, content);
 
560
    this->alert_x = window_x + (mainwindow_width / 2) - (alert_width  / 2);
 
561
    this->alert_y = window_y + mainwindow_height - 400;
 
562
    dialog->move(this->alert_x, this->alert_y);
 
563
    dialog-> QWidget::setAttribute(Qt::WA_DeleteOnClose);
 
564
    if(dialog->exec()==QDialog::Rejected) {
 
565
        return false;
 
566
    }
 
567
    else {
 
568
        return true;
 
569
    }
 
570
}
 
571
 
 
572
//void SessionDispatcher::handler_confirm_cloud_action() {
 
573
//    emit this->tellQMLCloudConfirm();
 
574
//}
581
575
 
582
576
QString SessionDispatcher::getSingleInfo(QString key) {
583
577
    QVariant info = systemInfo.value(key);
648
642
    }
649
643
}
650
644
 
 
645
void SessionDispatcher::set_default_launcher_have_showdesktopicon_qt() {
 
646
    sessioniface->call("set_default_launcher_have_showdesktopicon");
 
647
}
 
648
 
651
649
bool SessionDispatcher::set_launcher_autohide_qt(bool flag) {
652
650
    QDBusReply<bool> reply = sessioniface->call("set_launcher_autohide", flag);
653
651
    return reply.value();
728
726
    sessioniface->call("set_cursor_size", size);
729
727
}
730
728
 
 
729
//window theme
 
730
QStringList SessionDispatcher::get_window_themes_qt() {
 
731
    QDBusReply<QStringList> reply = sessioniface->call("get_window_themes");
 
732
    return reply.value();
 
733
}
 
734
 
 
735
QString SessionDispatcher::get_current_window_theme_qt() {
 
736
    QDBusReply<QString> reply = sessioniface->call("get_current_window_theme");
 
737
    return reply.value();
 
738
}
 
739
 
 
740
void SessionDispatcher::set_window_theme_qt(QString theme) {
 
741
    sessioniface->call("set_window_theme", theme);
 
742
}
 
743
 
731
744
/*-----------------------------font of beauty-----------------------------*/
732
745
QString SessionDispatcher::get_default_theme_sring_qt(QString flag/*QString schema, QString key*/) {
733
746
    if(flag == "icontheme") {
734
747
        QDBusReply<QString> reply = sessioniface->call("get_default_font_sring", "org.gnome.desktop.interface", "icon-theme");
735
748
        return reply.value();
736
749
    }
 
750
    else if(flag == "windowtheme") {
 
751
        QDBusReply<QString> reply = sessioniface->call("get_default_font_sring", "org.gnome.desktop.wm.preferences", "theme");
 
752
        return reply.value();
 
753
    }
737
754
    else if(flag == "mousetheme") {
738
755
        QDBusReply<QString> reply = sessioniface->call("get_default_font_sring", "org.gnome.desktop.interface", "cursor-theme");
739
756
        return reply.value();
740
757
    }
 
758
    else if(flag == "smoothstyle") {
 
759
        QDBusReply<QString> reply = sessioniface->call("get_default_font_sring", "org.gnome.settings-daemon.plugins.xsettings", "hinting");
 
760
        return reply.value();
 
761
    }
 
762
    else if(flag == "antialiasingstyle") {
 
763
        QDBusReply<QString> reply = sessioniface->call("get_default_font_sring", "org.gnome.settings-daemon.plugins.xsettings", "antialiasing");
 
764
        return reply.value();
 
765
    }
741
766
    return flag;
742
767
}
743
768
 
747
772
}
748
773
 
749
774
void SessionDispatcher::set_default_theme_qt(QString flag/*QString schema, QString key, QString type*/) {
750
 
//    sessioniface->call("set_default_font", schema, key, type);
751
775
    //-------------------字体-------------------
752
776
    if(flag == "defaultfont") {
753
777
        sessioniface->call("set_default_font", "org.gnome.desktop.interface", "font-name", "string");
767
791
    else if(flag == "titlebarfont") {
768
792
        sessioniface->call("set_default_font", "org.gnome.desktop.wm.preferences", "titlebar-font", "string");
769
793
    }
 
794
    else if(flag == "smoothstyle") {
 
795
        sessioniface->call("set_default_font", "org.gnome.settings-daemon.plugins.xsettings", "hinting", "string");
 
796
    }
 
797
    else if(flag == "antialiasingstyle") {
 
798
        sessioniface->call("set_default_font", "org.gnome.settings-daemon.plugins.xsettings", "antialiasing", "string");
 
799
    }
770
800
 
771
 
    //-------------------桌面图标-------------------
772
801
    else if(flag == "icontheme") {//图标主题
773
802
        sessioniface->call("set_default_font", "org.gnome.desktop.interface", "icon-theme", "string");
774
803
    }
 
804
    else if(flag == "windowtheme") {//窗口主题
 
805
        sessioniface->call("set_default_font", "org.gnome.desktop.wm.preferences", "theme", "string");
 
806
    }
775
807
    else if(flag == "mousetheme") {//鼠标指针主题
776
808
        sessioniface->call("set_default_font", "org.gnome.desktop.interface", "cursor-theme", "string");
777
809
    }
 
810
    else if(flag == "cursorsize") {//光标大小
 
811
        sessioniface->call("set_default_font", "org.gnome.desktop.interface", "cursor-size", "int");
 
812
    }
778
813
}
779
814
 
780
815
bool SessionDispatcher::get_default_desktop_bool_qt(QString schema, QString key) {
901
936
    return reply.value();
902
937
}
903
938
 
 
939
QStringList SessionDispatcher::get_smooth_style_list_qt() {
 
940
    QDBusReply<QStringList> reply = sessioniface->call("get_smooth_style_list");
 
941
    return reply.value();
 
942
}
 
943
 
 
944
QString SessionDispatcher::get_smooth_style_qt() {
 
945
    QDBusReply<QString> reply = sessioniface->call("get_smooth_style");
 
946
    return reply.value();
 
947
}
 
948
 
 
949
bool SessionDispatcher::set_smooth_style_qt(QString style) {
 
950
    QDBusReply<bool> reply = sessioniface->call("set_smooth_style", style);
 
951
    return reply.value();
 
952
}
 
953
 
 
954
QStringList SessionDispatcher::get_antialiasing_style_list_qt() {
 
955
    QDBusReply<QStringList> reply = sessioniface->call("get_antialiasing_style_list");
 
956
    return reply.value();
 
957
}
 
958
 
 
959
QString SessionDispatcher::get_antialiasing_style_qt() {
 
960
    QDBusReply<QString> reply = sessioniface->call("get_antialiasing_style");
 
961
    return reply.value();
 
962
}
 
963
 
 
964
bool SessionDispatcher::set_antialiasing_style_qt(QString style) {
 
965
    QDBusReply<bool> reply = sessioniface->call("set_antialiasing_style", style);
 
966
    return reply.value();
 
967
}
 
968
 
 
969
 
904
970
void SessionDispatcher::restore_default_font_signal(QString flag) {
905
971
    emit notifyFontStyleToQML(flag); //font_style
906
972
}
934
1000
        selectedFont.clear();
935
1001
        emit notifyFontStyleToQML(flag); //font_style
936
1002
    }
937
 
//    bool ok;
938
 
//    const QFont& font = QFontDialog::getFont(&ok, 0);
939
 
//    if(ok) {
940
 
//        QString fontsize = QString("%1").arg(font.pointSize());
941
 
//        QString fontstyle = font.family() + " " +  font.styleName() + " " + fontsize;
942
 
//        if(flag == "font")
943
 
//            set_font_qt(fontstyle);//set font
944
 
//        else if(flag == "desktopfont")
945
 
//            set_desktop_font_qt(fontstyle);//set desktopfont
946
 
//        else if(flag == "monospacefont")
947
 
//            set_monospace_font_qt(fontstyle);//set monospacefont
948
 
//        else if(flag == "documentfont")
949
 
//            set_document_font_qt(fontstyle);//set documentfont
950
 
//        else if(flag == "titlebarfont")
951
 
//            set_window_title_font_qt(fontstyle);//set titlebarfont
952
 
//        emit notifyFontStyleToQML(flag); //font_style
953
 
//    }
954
1003
}
955
1004
 
956
1005
QString SessionDispatcher::show_folder_dialog() {
977
1026
}
978
1027
 
979
1028
/*-----------------------------touchpad of beauty-----------------------------*/
980
 
QString SessionDispatcher::get_default_system_sring_qt(QString schema, QString key) {
981
 
    QDBusReply<QString> reply = sessioniface->call("get_default_system_sring", schema, key);
982
 
    return reply.value();
 
1029
QString SessionDispatcher::get_default_system_sring_qt(QString flag) {
 
1030
    if(flag == "wheel-action") {//菜单项旁显示图标
 
1031
        QDBusReply<QString> reply = sessioniface->call("get_default_system_sring", "org.compiz.gwd", "mouse-wheel-action");
 
1032
        return reply.value();
 
1033
    }
 
1034
    else if(flag == "double-click") {//标题栏双击动作
 
1035
        QDBusReply<QString> reply = sessioniface->call("get_default_system_sring", "org.gnome.desktop.wm.preferences", "action-double-click-titlebar");
 
1036
        return reply.value();
 
1037
    }
 
1038
    else if(flag == "middle-click") {//标题栏中键动作
 
1039
        QDBusReply<QString> reply = sessioniface->call("get_default_system_sring", "org.gnome.desktop.wm.preferences", "action-middle-click-titlebar");
 
1040
        return reply.value();
 
1041
    }
 
1042
    else if(flag == "right-click") {//标题栏右键动作
 
1043
        QDBusReply<QString> reply = sessioniface->call("get_default_system_sring", "org.gnome.desktop.wm.preferences", "action-right-click-titlebar");
 
1044
        return reply.value();
 
1045
    }
 
1046
    return flag;
983
1047
}
984
1048
 
985
1049
bool SessionDispatcher::get_default_system_bool_qt(QString schema, QString key) {
1000
1064
    else if(flag == "horiz-scroll-enabled") {//触摸板横向滚动
1001
1065
        sessioniface->call("set_default_system", "org.gnome.settings-daemon.peripherals.touchpad", "horiz-scroll-enabled", "boolean");
1002
1066
    }
 
1067
    else if(flag == "control-button-position") {//窗口控制按钮位置
 
1068
        sessioniface->call("set_default_system", "org.gnome.desktop.wm.preferences", "button-layout", "string");
 
1069
    }
 
1070
    else if(flag == "menu-with-icons") {//菜单项旁显示图标
 
1071
        sessioniface->call("set_default_system", "org.gnome.desktop.interface", "menus-have-icons", "boolean");
 
1072
    }
 
1073
    else if(flag == "wheel-action") {//标题栏鼠标滚轮动作
 
1074
        sessioniface->call("set_default_system", "org.compiz.gwd", "mouse-wheel-action", "string");
 
1075
    }
 
1076
    else if(flag == "double-click") {//标题栏双击动作
 
1077
        sessioniface->call("set_default_system", "org.gnome.desktop.wm.preferences", "action-double-click-titlebar", "string");
 
1078
    }
 
1079
    else if(flag == "middle-click") {//标题栏中键动作
 
1080
        sessioniface->call("set_default_system", "org.gnome.desktop.wm.preferences", "action-middle-click-titlebar", "string");
 
1081
    }
 
1082
    else if(flag == "right-click") {//标题栏右键动作
 
1083
        sessioniface->call("set_default_system", "org.gnome.desktop.wm.preferences", "action-right-click-titlebar", "string");
 
1084
    }
1003
1085
}
1004
1086
 
1005
1087
 
1040
1122
}
1041
1123
 
1042
1124
/*-----------------------------window of beauty-----------------------------*/
1043
 
bool SessionDispatcher::set_window_button_align_left_qt() {
1044
 
    QDBusReply<bool> reply = sessioniface->call("set_window_button_align_left");
1045
 
    return reply.value();
 
1125
void SessionDispatcher::set_window_button_align_left_qt() {
 
1126
    sessioniface->call("set_window_button_align_left");
1046
1127
}
1047
1128
 
1048
 
bool SessionDispatcher::set_window_button_align_right_qt() {
1049
 
    QDBusReply<bool> reply = sessioniface->call("set_window_button_align_right");
1050
 
    return reply.value();
 
1129
void SessionDispatcher::set_window_button_align_right_qt() {
 
1130
    sessioniface->call("set_window_button_align_right");
1051
1131
}
1052
1132
 
1053
1133
QString SessionDispatcher::get_window_button_align_qt() {
1065
1145
    return reply.value();
1066
1146
}
1067
1147
 
 
1148
QStringList SessionDispatcher::get_titlebar_wheel_qt() {
 
1149
    QDBusReply<QStringList> reply = sessioniface->call("get_titlebar_wheel");
 
1150
    return reply.value();
 
1151
}
 
1152
 
 
1153
QString SessionDispatcher::get_current_titlebar_wheel_qt() {
 
1154
    QDBusReply<QString> reply = sessioniface->call("get_current_titlebar_wheel");
 
1155
    return reply.value();
 
1156
}
 
1157
 
 
1158
void SessionDispatcher::set_titlebar_wheel_qt(QString value) {
 
1159
    sessioniface->call("set_titlebar_wheel", value);
 
1160
}
 
1161
 
 
1162
QStringList SessionDispatcher::get_titlebar_double_qt() {
 
1163
    QDBusReply<QStringList> reply = sessioniface->call("get_titlebar_double");
 
1164
    return reply.value();
 
1165
}
 
1166
 
 
1167
QString SessionDispatcher::get_current_titlebar_double_qt() {
 
1168
    QDBusReply<QString> reply = sessioniface->call("get_current_titlebar_double");
 
1169
    return reply.value();
 
1170
}
 
1171
 
 
1172
void SessionDispatcher::set_titlebar_double_qt(QString value) {
 
1173
    sessioniface->call("set_titlebar_double", value);
 
1174
}
 
1175
 
 
1176
QStringList SessionDispatcher::get_titlebar_middle_qt() {
 
1177
    QDBusReply<QStringList> reply = sessioniface->call("get_titlebar_middle");
 
1178
    return reply.value();
 
1179
}
 
1180
 
 
1181
QString SessionDispatcher::get_current_titlebar_middle_qt() {
 
1182
    QDBusReply<QString> reply = sessioniface->call("get_current_titlebar_middle");
 
1183
    return reply.value();
 
1184
}
 
1185
 
 
1186
void SessionDispatcher::set_titlebar_middle_qt(QString value) {
 
1187
    sessioniface->call("set_titlebar_middle", value);
 
1188
}
 
1189
 
 
1190
QStringList SessionDispatcher::get_titlebar_right_qt() {
 
1191
    QDBusReply<QStringList> reply = sessioniface->call("get_titlebar_right");
 
1192
    return reply.value();
 
1193
}
 
1194
 
 
1195
QString SessionDispatcher::get_current_titlebar_right_qt() {
 
1196
    QDBusReply<QString> reply = sessioniface->call("get_current_titlebar_right");
 
1197
    return reply.value();
 
1198
}
 
1199
 
 
1200
void SessionDispatcher::set_titlebar_right_qt(QString value) {
 
1201
    sessioniface->call("set_titlebar_right", value);
 
1202
}
 
1203
 
 
1204
 
1068
1205
/*-----------------------------sound of beauty-----------------------------*/
1069
1206
void SessionDispatcher::set_login_music_enable_qt(bool flag) {
1070
1207
    sessioniface->call("set_login_music_enable", flag);
1084
1221
    sessioniface->call("set_sound_theme", theme);
1085
1222
}
1086
1223
 
 
1224
/*-------------------filemanager of beauty-------------------*/
 
1225
//bool SessionDispatcher::get_default_filemanager_bool_qt(QString flag) {
 
1226
 
 
1227
//}
 
1228
 
 
1229
//int SessionDispatcher::get_default_filemanager_int_qt(QString flag) {
 
1230
 
 
1231
//}
 
1232
 
 
1233
void SessionDispatcher::set_default_filemanager_qt(QString flag) {
 
1234
    if(flag == "pathbar") {//路径输入框取代路径栏
 
1235
        sessioniface->call("set_default_filemanager", "org.gnome.nautilus.preferences", "always-use-location-entry", "boolean");
 
1236
    }
 
1237
    else if(flag == "media") {//自动挂载媒体
 
1238
        sessioniface->call("set_default_filemanager", "org.gnome.desktop.media-handling", "automount", "boolean");
 
1239
    }
 
1240
    else if(flag == "folder") {//自动打开文件夹
 
1241
        sessioniface->call("set_default_filemanager", "org.gnome.desktop.media-handling", "automount-open", "boolean");
 
1242
    }
 
1243
    else if(flag == "programs") {//提示自动运行的程序
 
1244
        sessioniface->call("set_default_filemanager", "org.gnome.desktop.media-handling", "autorun-never", "boolean");
 
1245
    }
 
1246
    else if(flag == "iconsize") {//缩略图图标尺寸(像素)
 
1247
        sessioniface->call("set_default_filemanager", "org.gnome.nautilus.icon-view", "thumbnail-size", "int");
 
1248
    }
 
1249
    else if(flag == "cachetime") {//缩略图缓存时间(天数)
 
1250
        sessioniface->call("set_default_filemanager", "org.gnome.desktop.thumbnail-cache", "maximum-age", "int");
 
1251
    }
 
1252
    else if(flag == "maxsize") {//最大缩略图缓存尺寸(MB)
 
1253
        sessioniface->call("set_default_filemanager", "org.gnome.desktop.thumbnail-cache", "maximum-size", "int");
 
1254
    }
 
1255
}
 
1256
 
 
1257
void SessionDispatcher::set_location_replace_pathbar_qt(bool flag) {
 
1258
    sessioniface->call("set_location_replace_pathbar", flag);
 
1259
}
 
1260
 
 
1261
bool SessionDispatcher::get_location_replace_pathbar_qt() {
 
1262
    QDBusReply<bool> reply = sessioniface->call("get_location_replace_pathbar");
 
1263
    return reply.value();
 
1264
}
 
1265
 
 
1266
void SessionDispatcher::set_auto_mount_media_qt(bool flag) {
 
1267
    sessioniface->call("set_auto_mount_media", flag);
 
1268
}
 
1269
 
 
1270
bool SessionDispatcher::get_auto_mount_media_qt() {
 
1271
    QDBusReply<bool> reply = sessioniface->call("get_auto_mount_media");
 
1272
    return reply.value();
 
1273
}
 
1274
 
 
1275
void SessionDispatcher::set_auto_open_folder_qt(bool flag) {
 
1276
    sessioniface->call("set_auto_open_folder", flag);
 
1277
}
 
1278
 
 
1279
bool SessionDispatcher::get_auto_open_folder_qt() {
 
1280
    QDBusReply<bool> reply = sessioniface->call("get_auto_open_folder");
 
1281
    return reply.value();
 
1282
}
 
1283
 
 
1284
void SessionDispatcher::set_prompt_autorun_programs_qt(bool flag) {
 
1285
    sessioniface->call("set_prompt_autorun_programs", flag);
 
1286
}
 
1287
 
 
1288
bool SessionDispatcher::get_prompt_autorun_programs_qt() {
 
1289
    QDBusReply<bool> reply = sessioniface->call("get_prompt_autorun_programs");
 
1290
    return reply.value();
 
1291
}
 
1292
 
 
1293
void SessionDispatcher::set_thumbnail_icon_size_qt(int size) {
 
1294
    sessioniface->call("set_thumbnail_icon_size", size);
 
1295
}
 
1296
 
 
1297
int SessionDispatcher::get_thumbnail_icon_size_qt() {
 
1298
    QDBusReply<int> reply = sessioniface->call("get_thumbnail_icon_size");
 
1299
    return reply.value();
 
1300
}
 
1301
 
 
1302
void SessionDispatcher::set_thumbnail_cache_time_qt(int value) {
 
1303
    sessioniface->call("set_thumbnail_cache_time", value);
 
1304
}
 
1305
 
 
1306
int SessionDispatcher::get_thumbnail_cache_time_qt() {
 
1307
    QDBusReply<int> reply = sessioniface->call("get_thumbnail_cache_time");
 
1308
    return reply.value();
 
1309
}
 
1310
 
 
1311
void SessionDispatcher::set_thumbnail_cache_size_qt(int size) {
 
1312
    sessioniface->call("set_thumbnail_cache_size", size);
 
1313
}
 
1314
 
 
1315
int SessionDispatcher::get_thumbnail_cache_size_qt() {
 
1316
    QDBusReply<int> reply = sessioniface->call("get_thumbnail_cache_size");
 
1317
    return reply.value();
 
1318
}
 
1319
 
1087
1320
//-----------------------monitorball------------------------
1088
1321
double SessionDispatcher::get_cpu_percent_qt() {
1089
1322
    QDBusReply<double> reply = sessioniface->call("get_cpu_percent");
1143
1376
void SessionDispatcher::get_forecast_weahter_qt() {
1144
1377
    getCityIdInfo();
1145
1378
 
1146
 
//    QStringList tmplist;
1147
 
//    tmplist << "Kobe" << "Lee";
1148
 
//    KThread *thread = new KThread(tmplist, sessioniface, "get_forecast_weahter", initCityId);
1149
 
//    thread->start();
1150
 
 
1151
1379
    bool flag = Util::id_exists_in_location_file(initCityId);
1152
1380
    if(flag) {//获取中国气象局数据
1153
1381
        QStringList tmplist;
1159
1387
        get_yahoo_forecast_dict_qt();
1160
1388
        emit startUpdateForecastWeahter("yahooforecast");
1161
1389
    }
1162
 
 
1163
 
//    QDBusReply<QMap<QString, QVariant> > reply = sessioniface->call("get_forecast_weahter", initCityId);
1164
 
//    forecastInfo = reply.value();
1165
1390
}
1166
1391
 
1167
1392
void SessionDispatcher::get_forecast_dict_qt() {
1174
1399
    yahooforecastInfo = reply.value();
1175
1400
}
1176
1401
 
1177
 
/*bool*/void SessionDispatcher::get_current_weather_qt() {
 
1402
void SessionDispatcher::get_current_weather_qt() {
1178
1403
    getCityIdInfo();
1179
 
//    qDebug() << initCityId;
1180
1404
    QStringList tmplist;
1181
1405
    tmplist << "Kobe" << "Lee";
1182
 
//0.3.3
 
1406
 
1183
1407
    bool flag = Util::id_exists_in_location_file(initCityId);
1184
1408
    if(flag) {//获取中国气象局数据
1185
 
//        sessioniface->call("get_current_weather", initCityId);
1186
 
//        qDebug() << initCityId;
1187
1409
        KThread *thread = new KThread(tmplist, sessioniface, "get_current_weather", initCityId);
1188
1410
        thread->start();
1189
1411
    }
1190
1412
    else {//获取雅虎气象数据
1191
1413
        QStringList latlon = this->getLatandLon(initCityId);
1192
 
//        qDebug() << latlon;
1193
 
//        qDebug() << initCityId;
1194
 
//        sessioniface->call("get_current_yahoo_weather", latlon, initCityId);
1195
1414
        KThread *thread = new KThread(latlon, sessioniface, "get_current_yahoo_weather", initCityId);
1196
1415
        thread->start();
1197
1416
    }
1198
 
 
1199
 
//    QDBusReply<QMap<QString, QVariant> > reply = sessioniface->call("get_current_weather", initCityId);
1200
 
//    currentInfo = reply.value();
1201
 
//    if(currentInfo.isEmpty()) {
1202
 
//        return false;
1203
 
//    }
1204
 
//    else {
1205
 
//        return true;
1206
 
//    }
1207
1417
}
1208
1418
 
1209
1419
void SessionDispatcher::get_current_weather_dict_qt() {
1214
1424
void SessionDispatcher::get_current_yahoo_weather_dict_qt() {
1215
1425
    QDBusReply<QMap<QString, QVariant> > reply = sessioniface->call("get_current_yahoo_weather_dict");
1216
1426
    yahoocurrentInfo = reply.value();
1217
 
//    qDebug() << "yahoo data->";
1218
 
//    qDebug() << yahoocurrentInfo;
1219
1427
}
1220
1428
 
1221
 
//QString SessionDispatcher::get_current_pm25_qt() {
1222
 
//    getCityIdInfo();
1223
 
//    QDBusReply<QString> reply = sessioniface->call("get_current_pm25", initCityId);
1224
 
//    return reply.value();
1225
 
//}
1226
 
 
1227
1429
void SessionDispatcher::get_current_pm25_qt() {
1228
1430
    getCityIdInfo();
1229
1431
    QStringList tmplist;
1230
1432
    tmplist << "Kobe" << "Lee";
1231
1433
    KThread *thread = new KThread(tmplist, sessioniface, "get_current_pm25", initCityId);
1232
1434
    thread->start();
1233
 
 
1234
 
//    QDBusReply<QString> reply = sessioniface->call("get_current_pm25", initCityId);
1235
 
//    return reply.value();
1236
1435
}
1237
1436
 
1238
1437
void SessionDispatcher::get_pm25_str_qt() {
1266
1465
        thread->start();
1267
1466
        return false;
1268
1467
    }
1269
 
 
1270
 
//    QDBusReply<bool> reply = sessioniface->call("update_weather_data", initCityId);
1271
 
//    return reply.value();
1272
 
}
1273
 
 
1274
 
void SessionDispatcher::update_forecast_weather() {
1275
 
//    emit startUpdateForecastWeahter();
1276
 
}
1277
 
 
1278
 
void SessionDispatcher::change_select_city_name_qt(QString cityName) {
1279
 
    sessioniface->call("change_select_city_name", cityName);
1280
1468
}
1281
1469
 
1282
1470
QString SessionDispatcher::getSingleWeatherInfo(QString key, QString flag) {
1341
1529
}
1342
1530
 
1343
1531
void SessionDispatcher::initConfigFile() {
1344
 
//    mSettings->beginGroup("account");
1345
 
//    QString id = mSettings->value("id").toString();
1346
 
//    if(id.isEmpty()) {
1347
 
//        mSettings->setValue("id", "0");
1348
 
//    }
1349
 
//    QString firststart = mSettings->value("firststart").toString();
1350
 
//    if(firststart.isEmpty()) {
1351
 
//        firststart = "true";
1352
 
//        mSettings->setValue("firststart", firststart);
1353
 
//    }
1354
 
//    QString current_date = mSettings->value("date").toString();
1355
 
//    if(current_date.isEmpty()) {
1356
 
//        current_date = this->get_currrent_date_qt();
1357
 
//        mSettings->setValue("date", current_date);
1358
 
//    }
1359
 
//    mSettings->endGroup();
1360
 
//    mSettings->sync();
1361
 
 
1362
 
 
1363
1532
    mSettings->beginGroup("user");
1364
1533
    QString id = mSettings->value("id").toString();
1365
1534
    if(id.isEmpty()) {
1433
1602
}
1434
1603
 
1435
1604
QStringList SessionDispatcher::getLatandLon(QString id) {
1436
 
//    QStringList tmp;
1437
 
//    mSettings->beginGroup("weather");
1438
 
//    tmp << mSettings->value("latitude").toString();
1439
 
//    tmp << mSettings->value("longitude").toString();
1440
 
//    mSettings->endGroup();
1441
 
//    mSettings->sync();
1442
 
//    return tmp;
1443
 
 
1444
1605
    QStringList tmp;
1445
1606
    bool flag = false;
1446
1607
    mSettings->beginGroup("weather");