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

QT: Style changes on the operator row.

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