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