Commit 39ed185f authored by Christoffer Ackelman's avatar Christoffer Ackelman

QT: Style changes on the operator row.

parent 76859dba
......@@ -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,11 +154,6 @@ 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);
......@@ -156,26 +161,23 @@ OpQt::OpQt(void* op_parent_ctx, char* opplace, pwr_tStatus* status)
CoWowQt::SetWindowIcon(toplevel);
QRect xtt_monitor_geometry = QApplication::desktop()->screenGeometry();
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();
......@@ -228,11 +230,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);
......@@ -247,7 +251,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);
......@@ -400,10 +405,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);
......@@ -573,8 +576,6 @@ void OpQt::update_alarm_info()
return;
}
QColor bg_color = QColor("gray");
height = 22;
active_height = 22;
......@@ -618,20 +619,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);
}
}
......@@ -658,7 +654,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"));
......@@ -674,8 +670,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]);
......@@ -694,7 +688,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"));
......@@ -710,8 +704,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]);
......@@ -730,7 +722,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"));
......@@ -764,10 +756,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);
......@@ -785,7 +776,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);
......@@ -978,7 +969,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;
......@@ -993,11 +984,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());
}
}
}
......@@ -1014,7 +1001,7 @@ 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;
......@@ -1029,8 +1016,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);
}
}
}
......@@ -1179,30 +1164,16 @@ 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, 117, 117);
}
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)
......@@ -1245,4 +1216,4 @@ void OpQt::set_text_size()
appl_buttons[i]->setFont(fd);
}
}
}
\ No newline at end of file
}
......@@ -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];
......@@ -117,7 +114,7 @@ public:
void set_text_size();
private:
void alarm_box_helper(int i);
QVBoxLayout* alarm_box_helper();
OpQtWidget* toplevel;
};
......@@ -178,4 +175,4 @@ protected:
void mousePressEvent(QMouseEvent* event);
};
#endif
\ No newline at end of file
#endif
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