Commit 985d199a authored by Christoffer Ackelman's avatar Christoffer Ackelman Committed by Esteban Blanc

QT: Minor stylistic changes of the Operator row.

parent bfdf7e90
......@@ -60,7 +60,7 @@
#include <QDesktopWidget>
#include <QPushButton>
#define OP_HEIGHT_MIN 105
#define OP_HEIGHT_MIN 90
#define OP_HEIGHT_INC 20
#define OP_HEIGHT_STATUSBAR 20
......@@ -92,7 +92,7 @@ static void cnv_qt_text(char* in, char* out, int size)
*t = 0;
}
static void modifyBackground(QWidget* widget, QColor& color)
static void modifyBackground(QWidget* widget, QColor color)
{
QPalette pal = widget->palette();
pal.setColor(QPalette::Background, color);
......@@ -100,31 +100,41 @@ static void modifyBackground(QWidget* widget, QColor& color)
widget->setAutoFillBackground(true);
}
static void modifyForeground(QWidget* widget, QColor& color)
static void modifyBackground(QWidget* widget, QColor bg, QColor fg)
{
QPalette pal = widget->palette();
pal.setColor(QPalette::Foreground, color);
pal.setColor(QPalette::ButtonText, color);
pal.setColor(QPalette::Background, bg);
pal.setColor(QPalette::Foreground, fg);
pal.setColor(QPalette::ButtonText, fg);
widget->setPalette(pal);
widget->setAutoFillBackground(true);
}
void OpQt::alarm_box_helper(int i)
QVBoxLayout* OpQt::alarm_box_helper()
{
QHBoxLayout* aalarm_box_layout = new QHBoxLayout();
QWidget* aalarm_bbox1 = new QWidget();
modifyBackground(aalarm_label[i], red_color);
aalarm_info[i] = image_button(toplevel, "$pwr_exe/xtt_alarm_info.png");
fixed_put(aalarm_bbox1, aalarm_active[i], 0, 0);
fixed_put(aalarm_bbox1, aalarm_info[i], 21, 0);
fixed_put(aalarm_bbox1, new QLabel(""), 43, 0);
aalarm_box_layout->addWidget(aalarm_bbox1);
add_expanding(aalarm_box_layout, aalarm_label[i]);
aalarm_box[i] = layout_to_widget(aalarm_box_layout);
aalarm_label[i]->setFixedHeight(20);
aalarm_active[i]->setFixedHeight(20);
aalarm_info[i]->setFixedSize(20, 20);
QObject::connect(
aalarm_info[i], SIGNAL(clicked()), toplevel, SLOT(activate_info()));
QVBoxLayout* vbox = new QVBoxLayout();
for (int i = 0; i < 5; i++) {
QHBoxLayout* aalarm_box_layout = new QHBoxLayout();
aalarm_active[i] = new QLabel(toplevel);
aalarm_active[i]->setFixedSize(20, 20);
aalarm_active[i]->setPixmap(active_pixmap);
aalarm_box_layout->addWidget(aalarm_active[i]);
aalarm_info[i] = image_button(toplevel, "$pwr_exe/xtt_alarm_info.png");
aalarm_info[i]->setFixedSize(20, 20);
QObject::connect(
aalarm_info[i], SIGNAL(clicked()), toplevel, SLOT(activate_info()));
aalarm_box_layout->addWidget(aalarm_info[i]);
aalarm_label[i] = new QLabel("");
aalarm_label[i]->setFixedHeight(20);
modifyBackground(aalarm_label[i], QColor(255, 117, 117));
add_expanding(aalarm_box_layout, aalarm_label[i]);
aalarm_box[i] = layout_to_widget(aalarm_box_layout);
vbox->addWidget(aalarm_box[i]);
}
return vbox;
}
ClickableFrame::ClickableFrame() : QFrame() {}
......@@ -144,37 +154,29 @@ OpQt::OpQt(void* op_parent_ctx, char* opplace, pwr_tStatus* status)
memset(a_active, 0, sizeof(a_active));
memset(appl_buttons, 0, sizeof(appl_buttons));
red_color = QColor("#FF7575");
yellow_color = QColor("yellow");
green_color = QColor("green");
gray_color = QColor("gray");
toplevel = new OpQtWidget(this);
toplevel->setMinimumSize(1100, OP_HEIGHT_MIN + OP_HEIGHT_STATUSBAR);
toplevel->setWindowFlags(Qt::CustomizeWindowHint);
CoWowQt::SetWindowIcon(toplevel);
for (int i = 0; i < 5; i++) {
aalarm_active[i] = new_image_label(toplevel, "$pwr_exe/xtt_alarm_active.png");
aalarm_label[i] = new QLabel("");
}
pwr_tFileName fname;
dcli_translate_filename(fname, "$pwr_exe/xtt_alarm_active.png");
active_pixmap = QPixmap(fl(fname));
alarmcnt_label = new QLabel("");
aalarm_mark = new QLabel("A");
balarm_active = new_image_label(toplevel, "$pwr_exe/xtt_alarm_active.png");
balarm_active = new QLabel(toplevel);
balarm_active->setPixmap(active_pixmap);
balarm_mark = new QLabel("");
balarm_label = new QLabel("");
QVBoxLayout* vbox_aalarm = new QVBoxLayout();
for (int i = 0; i < 5; i++) {
alarm_box_helper(i);
vbox_aalarm->addWidget(aalarm_box[i]);
}
QVBoxLayout* vbox_aalarm = alarm_box_helper();
balarm_active->setFixedSize(20, 20);
balarm_info = image_button(toplevel, "$pwr_exe/xtt_alarm_info.png");
info_icon = QIcon(balarm_info->icon());
QHBoxLayout* balarm_box_layout = new QHBoxLayout();
QWidget* balarm_bbox = new QWidget();
......@@ -227,11 +229,13 @@ OpQt::OpQt(void* op_parent_ctx, char* opplace, pwr_tStatus* status)
QHBoxLayout* hbox_decrbutton = new QHBoxLayout();
hbox_decrbutton->addWidget(decr_button);
hbox_decrbutton->setAlignment(decr_button, Qt::AlignLeft);
QVBoxLayout* vbox_abutton = new QVBoxLayout();
vbox_abutton->addLayout(hbox_abutton);
vbox_abutton->addLayout(hbox_incrbutton);
vbox_abutton->addLayout(hbox_decrbutton);
vbox_abutton->addStretch(1);
QHBoxLayout* hbox_bbutton = new QHBoxLayout();
hbox_bbutton->addWidget(balarm_ack);
......@@ -246,7 +250,8 @@ OpQt::OpQt(void* op_parent_ctx, char* opplace, pwr_tStatus* status)
add_expanding(hbox_b, balarm_box);
QVBoxLayout* vbox_ala = new QVBoxLayout();
add_expanding(vbox_ala, hbox_a);
vbox_ala->addLayout(hbox_a);
vbox_ala->addStretch(1);
vbox_ala->addWidget(separator(QFrame::HLine));
vbox_ala->addLayout(hbox_b);
......@@ -399,10 +404,8 @@ OpQt::OpQt(void* op_parent_ctx, char* opplace, pwr_tStatus* status)
QHBoxLayout* node_hbox = new QHBoxLayout();
QFrame* node_ind = new QFrame();
modifyBackground(node_ind, gray_color);
node_ind->setFixedSize(20, 20);
QColor black = QColor("black");
modifyForeground(node_ind, black);
modifyBackground(node_ind, QColor(160, 160, 160), QColor(0, 0, 0));
node_ind->setFrameStyle(QFrame::Box | QFrame::Plain);
node_ind->setLineWidth(1);
......@@ -564,8 +567,6 @@ void OpQt::update_alarm_info()
return;
}
QColor bg_color = QColor("gray");
height = 22;
active_height = 22;
......@@ -609,20 +610,15 @@ void OpQt::update_alarm_info()
if (i < a_height) {
aalarm_box[i]->setVisible(true);
if (info.a_alarm_active[i]) {
aalarm_active[i]->setVisible(true);
} else {
aalarm_active[i]->setVisible(false);
}
if (!streq(info.a_alarm_moretext[i], "")) {
aalarm_info[i]->setVisible(true);
} else {
aalarm_info[i]->setVisible(false);
}
aalarm_active[i]->setPixmap(info.a_alarm_active[i] ? active_pixmap : QPixmap());
bool enable = !streq(info.a_alarm_moretext[i], "");
aalarm_info[i]->setIcon(enable ? info_icon : QIcon());
aalarm_info[i]->setEnabled(enable);
aalarm_info[i]->setFlat(!enable);
}
} else {
aalarm_label[i]->setText("");
aalarm_active[i]->setVisible(false);
aalarm_active[i]->setPixmap(QPixmap());
aalarm_box[i]->setVisible(false);
}
}
......@@ -649,7 +645,7 @@ void OpQt::update_alarm_info()
}
balarm_label->setText(convert_utf8(text));
modifyBackground(balarm_box, yellow_color);
modifyBackground(balarm_box, QColor(255, 255, 0));
balarm_box->setVisible(true);
balarm_mark->setText(fl("B"));
......@@ -665,8 +661,6 @@ void OpQt::update_alarm_info()
balarm_info->setVisible(false);
}
} else if (info.c_alarm_exist[0]) {
QColor blue_color("lightblue");
balarm_type = evlist_eEventType_Alarm;
balarm_prio = mh_eEventPrio_C;
strcpy(b_alarm_moretext, info.c_alarm_moretext[0]);
......@@ -685,7 +679,7 @@ void OpQt::update_alarm_info()
info.c_alarm_alias[0], ctext);
}
balarm_label->setText(convert_utf8(text));
modifyBackground(balarm_box, blue_color);
modifyBackground(balarm_box, QColor(0, 255, 255));
balarm_box->setVisible(true);
balarm_mark->setText(fl("C"));
......@@ -701,8 +695,6 @@ void OpQt::update_alarm_info()
balarm_info->setVisible(false);
}
} else if (info.d_alarm_exist[0]) {
QColor violet_color("violet");
balarm_type = evlist_eEventType_Alarm;
balarm_prio = mh_eEventPrio_D;
strcpy(b_alarm_moretext, info.d_alarm_moretext[0]);
......@@ -721,7 +713,7 @@ void OpQt::update_alarm_info()
info.d_alarm_alias[0], ctext);
}
balarm_label->setText(convert_utf8(text));
modifyBackground(balarm_box, violet_color);
modifyBackground(balarm_box, QColor(255, 128, 255));
balarm_box->setVisible(true);
balarm_mark->setText(fl("D"));
......@@ -755,10 +747,9 @@ void OpQt::update_alarm_info()
}
balarm_label->setText(convert_utf8(text));
if (balarm_type == evlist_eEventType_InfoSuccess) {
modifyBackground(balarm_box, green_color);
modifyBackground(balarm_box, QColor(0, 255, 0));
} else {
QColor white = QColor("white");
modifyBackground(balarm_box, white);
modifyBackground(balarm_box, QColor(255, 255, 255));
}
balarm_box->setVisible(true);
......@@ -776,7 +767,7 @@ void OpQt::update_alarm_info()
}
} else {
balarm_label->setText("");
modifyBackground(balarm_box, bg_color);
modifyBackground(balarm_box, QColor(160, 160, 160));
balarm_mark->setText("");
balarm_box->setVisible(false);
......@@ -988,7 +979,7 @@ void OpQtWidget::activate_aalarm_incr()
}
op->a_height++;
height = OP_HEIGHT_MIN + (op->a_height - 2) * OP_HEIGHT_INC
height = OP_HEIGHT_MIN + (op->a_height - 3) * OP_HEIGHT_INC
+ ((op->layout_mask & pwr_mOpWindLayoutMask_HideStatusBar) ? 0 : 1)
* OP_HEIGHT_STATUSBAR;
......@@ -1008,11 +999,7 @@ void OpQtWidget::activate_aalarm_incr()
if (i < op->a_height) {
if (op->a_exist[i]) {
op->aalarm_box[i]->setVisible(true);
if (op->a_active[i]) {
op->aalarm_active[i]->setVisible(true);
} else {
op->aalarm_active[i]->setVisible(false);
}
op->aalarm_active[i]->setPixmap(op->a_active[i] ? op->active_pixmap : QPixmap());
}
}
}
......@@ -1031,17 +1018,11 @@ void OpQtWidget::activate_aalarm_decr()
}
op->a_height--;
height = OP_HEIGHT_MIN + (op->a_height - 2) * OP_HEIGHT_INC
height = OP_HEIGHT_MIN + (op->a_height - 3) * OP_HEIGHT_INC
+ ((op->layout_mask & pwr_mOpWindLayoutMask_HideStatusBar) ? 0 : 1)
* OP_HEIGHT_STATUSBAR;
if (op->a_height <= 2) {
op->decr_button->setVisible(false);
}
else
{
op->decr_button->setVisible(true);
}
op->decr_button->setVisible(op->a_height > 2);
if (op->a_height <= 3) {
op->funcbox[3]->setVisible(false);
......@@ -1055,8 +1036,6 @@ void OpQtWidget::activate_aalarm_decr()
if (i >= op->a_height) {
if (op->a_exist[i]) {
op->aalarm_box[i]->setVisible(false);
op->aalarm_active[i]->setVisible(false);
op->aalarm_info[i]->setVisible(false);
}
}
}
......@@ -1205,30 +1184,15 @@ int OpQt::get_cmd(QMenu* w, char* cmd)
void OpQt::change_sup_color(void* imagew, op_eSupColor color)
{
QColor* col;
switch (color) {
case op_eSupColor_Gray:
col = &gray_color;
break;
case op_eSupColor_Green:
col = &green_color;
break;
case op_eSupColor_Yellow:
col = &yellow_color;
break;
case op_eSupColor_Red:
col = &red_color;
break;
case op_eSupColor_Black:
col = &gray_color;
break;
default:
col = &gray_color;
QColor col(160, 160, 160);
if (color == op_eSupColor_Green) {
col = QColor(0, 255, 0);
} else if (color == op_eSupColor_Yellow) {
col = QColor(255, 255, 0);
} else if (color == op_eSupColor_Red) {
col = QColor(255, 0, 0);
}
QColor black = QColor("black");
modifyBackground((QWidget*)imagew, *col);
modifyForeground((QWidget*)imagew, black);
modifyBackground((QWidget*)imagew, col, QColor(0, 0, 0));
}
void OpQt::set_title(char* user)
......
......@@ -71,12 +71,12 @@ public:
QLabel* alarmcnt_label;
QWidget* aalarm_mark;
QLabel* aalarm_label[5];
QWidget* aalarm_active[5];
QWidget* aalarm_info[5];
QLabel* aalarm_active[5];
QPushButton* aalarm_info[5];
QWidget* aalarm_box[5];
QLabel* balarm_label;
QWidget* balarm_active;
QWidget* balarm_info;
QLabel* balarm_active;
QPushButton* balarm_info;
QWidget* balarm_box;
QLabel* balarm_mark;
QVBoxLayout* appl_form;
......@@ -89,11 +89,8 @@ public:
QPushButton* appl_buttons[25];
QToolBar* tools;
QToolBar* tools2;
QColor red_color;
QColor yellow_color;
QColor green_color;
QColor gray_color;
QColor white_color;
QPixmap active_pixmap;
QIcon info_icon;
int a_height;
int a_exist[5];
int a_active[5];
......@@ -118,7 +115,7 @@ public:
void set_text_size();
private:
void alarm_box_helper(int i);
QVBoxLayout* alarm_box_helper();
OpQtWidget* toplevel;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment