~feng-kylin/youker-assistant/youker-assistant

« back to all changes in this revision

Viewing changes to mainui/cameramanager.cpp

  • Committer: kobe
  • Date: 2015-02-13 07:37:10 UTC
  • Revision ID: xiangli@ubuntukylin.com-20150213073710-0jyp02ilyi5njj10
Qt Version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "cameramanager.h"
 
2
#include "mainwindow.h"
 
3
#include <QDebug>
 
4
#include <QVBoxLayout>
 
5
#include "../dbusproxy/youkersessiondbus.h"
 
6
 
 
7
CameraManager::CameraManager(QWidget *parent, SessionDispatcher *proxy)
 
8
:QDialog(parent),sessionproxy(proxy)
 
9
{
 
10
 
 
11
//    m_Dlg.setupUi(this);
 
12
    this->setFixedSize(500, 271);
 
13
    setWindowFlags(Qt::FramelessWindowHint);
 
14
 
 
15
    title_bar = new KylinTitleBar();
 
16
    initTitleBar();
 
17
    msg_label = new QLabel();
 
18
    msg_label->setWordWrap(true);//QLabel自动换行
 
19
    msg_label->setFixedWidth(480);
 
20
    QPalette pa;
 
21
    pa.setColor(QPalette::WindowText,Qt::red);
 
22
    msg_label->setPalette(pa);
 
23
 
 
24
    msg_label->hide();
 
25
    tip_label = new QLabel();
 
26
    tip_label->setWordWrap(true);//QLabel自动换行
 
27
    tip_label->setFixedWidth(480);
 
28
    description_label = new QLabel();
 
29
    description_label->setWordWrap(true);//QLabel自动换行
 
30
    description_label->setFixedWidth(480);
 
31
 
 
32
    okBtn = new QPushButton();
 
33
    viewBtn = new QPushButton();
 
34
    okBtn->setFixedSize(91, 25);
 
35
    okBtn->setObjectName("blackButton");
 
36
    okBtn->setFocusPolicy(Qt::NoFocus);
 
37
    viewBtn->setFixedSize(91, 25);
 
38
    viewBtn->setObjectName("blackButton");
 
39
    viewBtn->setFocusPolicy(Qt::NoFocus);
 
40
 
 
41
    QHBoxLayout *h_layout = new QHBoxLayout();
 
42
    h_layout->addStretch();
 
43
    h_layout->addWidget(okBtn);
 
44
    h_layout->addWidget(viewBtn);
 
45
    h_layout->addStretch();
 
46
    h_layout->setSpacing(50);
 
47
    h_layout->setMargin(0);
 
48
    h_layout->setContentsMargins(0,0,0,0);
 
49
 
 
50
    QVBoxLayout *v_layout  = new QVBoxLayout();
 
51
    v_layout->addWidget(msg_label);
 
52
    v_layout->addWidget(tip_label);
 
53
    v_layout->addWidget(description_label);
 
54
    v_layout->addLayout(h_layout);
 
55
    v_layout->setSpacing(30);
 
56
    v_layout->setMargin(0);
 
57
    v_layout->setContentsMargins(10, 40, 10, 0);
 
58
 
 
59
    QVBoxLayout *main_layout  = new QVBoxLayout();
 
60
    main_layout->addWidget(title_bar);
 
61
    main_layout->addLayout(v_layout);
 
62
    main_layout->addStretch();
 
63
    main_layout->setSpacing(0);
 
64
    main_layout->setMargin(0);
 
65
    main_layout->setContentsMargins(0, 0, 0, 0);
 
66
    setLayout(main_layout);
 
67
    this->setLanguage();
 
68
    this->initConnect();
 
69
}
 
70
 
 
71
CameraManager::~CameraManager()
 
72
{
 
73
}
 
74
 
 
75
void CameraManager::setLanguage()
 
76
{
 
77
    msg_label->setText(tr("NO found camara"));
 
78
    tip_label->setText(tr("An application to take pictures with the device camera."));
 
79
    description_label->setText(tr("Press the [ESC] button to take picture and turn the camera off , the photo saved in home directory by default."));
 
80
    okBtn->setText(tr("Open camera"));
 
81
    viewBtn->setText(tr("View Photos"));
 
82
}
 
83
 
 
84
void CameraManager::setOKButtonEnable(bool enable)
 
85
{
 
86
    if(enable)
 
87
    {
 
88
        msg_label->hide();
 
89
        okBtn->setEnabled(true);
 
90
    }
 
91
    else
 
92
    {
 
93
        msg_label->show();
 
94
        okBtn->setEnabled(false);
 
95
    }
 
96
}
 
97
 
 
98
void CameraManager::onOKButtonClicked()
 
99
{
 
100
    sessionproxy->call_camera_qt();
 
101
}
 
102
 
 
103
void CameraManager::onViewButtonClicked()
 
104
{
 
105
    sessionproxy->open_folder_qt(sessionproxy->getHomePath());
 
106
}
 
107
 
 
108
void CameraManager::initConnect()
 
109
{
 
110
    connect(title_bar,SIGNAL(closeDialog()), this, SLOT(onCloseButtonClicked()));
 
111
    connect(okBtn,SIGNAL(clicked()), this, SLOT(onOKButtonClicked()));
 
112
    connect(viewBtn,SIGNAL(clicked()), this, SLOT(onViewButtonClicked()));
 
113
}
 
114
 
 
115
void CameraManager::onCloseButtonClicked()
 
116
{
 
117
    this->close();
 
118
}
 
119
 
 
120
void CameraManager::initTitleBar()
 
121
{
 
122
    title_bar->setTitleWidth(500);
 
123
    title_bar->setTitleName(tr("Camera Manager"));
 
124
    title_bar->setTitleBackgound(":/background/res/skin/1.png");
 
125
}