1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
/** \file status_widget.cc */
//
// Copyright (C) 2010 Piotr Galiszewski
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
// Local includes
#include "status_widget.h"
#include "../tabs_manager.h"
// System includes
#include <QtGui/QApplication>
#include <QtGui/QDialogButtonBox>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QStackedWidget>
#include <QtGui/QStyle>
#include <QtGui/QVBoxLayout>
namespace aptitude
{
namespace gui
{
namespace qt
{
status_widget::status_widget(QWidget *parent)
: QWidget(parent)
{
create_gui();
update_changes_summary();
}
status_widget::~status_widget()
{
}
void status_widget::create_gui()
{
stacked_widget = new QStackedWidget();
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(stacked_widget);
create_changes_widget();
create_progress_widget();
}
void status_widget::create_changes_widget()
{
changes_widget = new QWidget();
QHBoxLayout *main_layout = new QHBoxLayout(changes_widget);
changes_summary = new QLabel();
main_layout->addWidget(changes_summary);
QDialogButtonBox *buttons = new QDialogButtonBox(Qt::Horizontal, this);
main_layout->addWidget(buttons);
// TODO: find proper icons
show_changes_button = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogApplyButton), "Show Changes", this);
apply_changes_button = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogApplyButton), "Apply Changes", this);
resolve_dependencies_button = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogApplyButton), "Resolve Dependeincies", this);
cancel_button = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogCancelButton), "Cancel", this);
connect(show_changes_button, SIGNAL(clicked()), this, SLOT(show_changes_button_clicked()));
connect(apply_changes_button, SIGNAL(clicked()), this, SLOT(apply_changes_button_clicked()));
connect(resolve_dependencies_button, SIGNAL(clicked()), this, SLOT(resolve_dependencies_button_clicked()));
connect(cancel_button, SIGNAL(clicked()), this, SLOT(cancel_button_clicked()));
buttons->addButton(show_changes_button, QDialogButtonBox::ApplyRole);
buttons->addButton(apply_changes_button, QDialogButtonBox::ApplyRole);
buttons->addButton(resolve_dependencies_button, QDialogButtonBox::ApplyRole);
buttons->addButton(cancel_button, QDialogButtonBox::RejectRole);
stacked_widget->addWidget(changes_widget);
}
void status_widget::create_progress_widget()
{
progress_widget = new QWidget();
stacked_widget->addWidget(progress_widget);
}
void status_widget::update_changes_summary()
{
changes_summary->setText("Short changes summary");
resolve_dependencies_button->hide();
show_changes_button->setEnabled(false);
apply_changes_button->setEnabled(false);
}
void status_widget::apply_changes_button_clicked()
{
tabs_manager::get_instance()->open_perform_changes_tab(this);
}
void status_widget::cancel_button_clicked()
{
}
void status_widget::resolve_dependencies_button_clicked()
{
tabs_manager::get_instance()->open_resolver_tab(this);
}
void status_widget::show_changes_button_clicked()
{
tabs_manager::get_instance()->open_changes_preview_tab(this);
}
// TODO: add proper logic hear
void status_widget::current_tab_changed(tab::tab_type type)
{
if(type == tab::tab_resolver)
{
apply_changes_button->show();
resolve_dependencies_button->hide();
}
else if(type == tab::tab_preview)
{
show_changes_button->setEnabled(false);
apply_changes_button->hide();
resolve_dependencies_button->show();
}
else
{
apply_changes_button->hide();
resolve_dependencies_button->show();
}
}
}
}
}
#include "status_widget.moc"
|