Commit d1b52cf9 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Added a class that can be used to modify the style of QT widgets.

parent a468c5aa
......@@ -41,6 +41,7 @@
#include "co_error.h"
#include "cow_qt_helpers.h"
#include "cow_style_qt.h"
#include "cow_xhelp_qt.h"
#include "pn_viewer_qt.h"
......@@ -70,6 +71,7 @@ int main(int argc, char* argv[])
char dev_name[20] = "eth1";
QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle());
ctx = (tViewer*)calloc(1, sizeof(tViewer));
......
......@@ -36,6 +36,8 @@
#include "co_error.h"
#include "cow_style_qt.h"
#include "xtt_tbl_qt.h"
#include <QApplication>
......@@ -84,6 +86,7 @@ int main(int argc, char* argv[])
}
QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle());
setlocale(LC_NUMERIC, "POSIX");
setlocale(LC_TIME, "en_US");
......
......@@ -45,6 +45,7 @@
#include "cow_login_qt.h"
#include "cow_msgwindow_qt.h"
#include "cow_qt_helpers.h"
#include "cow_style_qt.h"
#include "cow_xhelp_qt.h"
#include "wb_erep.h"
......@@ -85,10 +86,9 @@ int main(int argc, char* argv[])
}
QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle());
WbQt(argc, argv);
int res = app.exec();
debug_print("app.exec() finished executing!\n");
return res;
return app.exec();
}
WbQt::WbQt(int argc, char* argv[]) : mainwindow(0)
......
......@@ -40,6 +40,8 @@
#include <stdlib.h>
#include <string.h>
#include "cow_style_qt.h"
#include "wb_log_qt.h"
#include "wb_wnav_qt.h"
......@@ -76,6 +78,7 @@ CmdQt::CmdQt(int argc, char* argv[])
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle());
new CmdQt(argc, argv);
return app.exec();
}
\ No newline at end of file
......@@ -42,6 +42,8 @@
#include "wb_nav_qt.h"
#include <QScrollArea>
#include <qlocalsocket.h>
NavQt::NavQt(void* nav_parent_ctx, QWidget* nav_parent_wid,
......@@ -52,10 +54,10 @@ NavQt::NavQt(void* nav_parent_ctx, QWidget* nav_parent_wid,
trace_obj = new NavQtTraceObject(this);
debug_print("creating a scrolledbrowwidgetqt\n");
QWidget* scrolledbrow
= scrolledbrowwidgetqt_new(Nav::init_brow_cb, this, &brow_widget);
QScrollArea* scrolledbrow = ((QScrollArea*) scrolledbrowwidgetqt_new(Nav::init_brow_cb, this, &brow_widget));
scrolledbrow->setStyleSheet("QMainWindow{border: 3px solid black;}");
scrolledbrow->setFrameShape(QFrame::Box);
scrolledbrow->setLineWidth(3);
form_widget = scrolledbrow;
......
......@@ -42,6 +42,8 @@
#include "wb_pal_qt.h"
#include <QScrollArea>
#include <qlocalsocket.h>
PalQt::PalQt(void* pal_parent_ctx, QWidget* pal_parent_wid,
......@@ -52,15 +54,15 @@ PalQt::PalQt(void* pal_parent_ctx, QWidget* pal_parent_wid,
trace_obj = new PalQtTraceObject(this);
debug_print("creating a scrolledbrowwidgetqt\n");
QWidget* scrolledbrow
= scrolledbrowwidgetqt_new(Pal::init_brow_cb, this, &brow_widget);
QScrollArea* scrolledbrow = ((QScrollArea*) scrolledbrowwidgetqt_new(Pal::init_brow_cb, this, &brow_widget));
brow_widget->setToolTip(fl("PalQt"));
showNow(brow_widget);
scrolledbrow->setFrameShape(QFrame::Box);
scrolledbrow->setLineWidth(3);
form_widget = scrolledbrow;
form_widget->setStyleSheet("QMainWindow{border: 3px solid black;}");
showNow(brow_widget);
server = new QLocalServer(trace_obj);
server->listen("STRING");
......
......@@ -41,6 +41,7 @@
#include <string.h>
#include "cow_qt_helpers.h"
#include "cow_style_qt.h"
#include "wb_foe_msg.h"
#include "wb_foe_qt.h"
......@@ -108,6 +109,7 @@ int wb_utl_qt::create_mainwindow(int argc, char** argv)
if (!qt_initialized) {
QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle());
qt_initialized = 1;
app.exec();
}
......
......@@ -68,7 +68,7 @@
void WNavQt::pop()
{
::pop(toplevel);
::pop(form_widget);
}
WNavQt::WNavQt(void* xn_parent_ctx, QWidget* xn_parent_wid, const char* xn_name,
......@@ -92,10 +92,12 @@ WNavQt::WNavQt(void* xn_parent_ctx, QWidget* xn_parent_wid, const char* xn_name,
scrolledbrow->setFrameShape(QFrame::Box);
scrolledbrow->setLineWidth(3);
form_widget = scrolledbrow;
showNow(brow_widget);
// Create the root item
*w = scrolledbrow;
*w = form_widget;
serverString = new QLocalServer(trace_obj);
serverString->listen("STRING");
......@@ -113,7 +115,7 @@ WNavQt::WNavQt(void* xn_parent_ctx, QWidget* xn_parent_wid, const char* xn_name,
serverAttrRef->listen("PWR_ATTRREF");
QObject::connect(serverAttrRef, SIGNAL(newConnection()), trace_obj,
SLOT(sel_convert_cb()));
gbl.load_config(this);
if (root_menu && !ldhses) {
......@@ -122,8 +124,7 @@ WNavQt::WNavQt(void* xn_parent_ctx, QWidget* xn_parent_wid, const char* xn_name,
wow = new CoWowQt(parent_wid);
toplevel = scrolledbrow;
toplevel->setToolTip(fl("wb_wnav widget"));
form_widget->setToolTip(fl("wb_wnav widget"));
*status = 1;
}
......@@ -227,7 +228,7 @@ Ge* WNavQt::ge_new(char* graph_name, int nojournal)
options |= ge_mOption_IgnoreJournal;
}
return new GeQt(NULL, toplevel, ldhses, 0, options, graph_name);
return new GeQt(NULL, form_widget, ldhses, 0, options, graph_name);
}
WGe* WNavQt::wge_new(char* name, char* filename, char* object_name, int modal)
......@@ -458,14 +459,14 @@ void WNavQt::wge_modal_loop(WGe* wge)
void WNavQt::message_dialog(char* title, char* text)
{
QMessageBox::critical(
toplevel->window(), translate_utf8(title), translate_utf8(text));
form_widget->window(), translate_utf8(title), translate_utf8(text));
}
int WNavQt::confirm_dialog(
char* title, char* text, int display_cancel, int* cancel)
{
QMessageBox::StandardButton reply = QMessageBox::question(
toplevel, translate_utf8(title), translate_utf8(text));
form_widget, translate_utf8(title), translate_utf8(text));
if (reply == QMessageBox::Yes) {
return 1;
......@@ -479,7 +480,7 @@ int WNavQt::continue_dialog(char* title, char* text)
{
// Create a question window
QMessageBox::StandardButton reply = QMessageBox::question(
toplevel, fl(title), fl(text), QMessageBox::Ok | QMessageBox::Cancel);
form_widget, fl(title), fl(text), QMessageBox::Ok | QMessageBox::Cancel);
if (reply == QMessageBox::Ok) {
return 1;
} else {
......@@ -490,7 +491,7 @@ int WNavQt::continue_dialog(char* title, char* text)
int WNavQt::prompt_dialog(char* title, char* text, char** value)
{
bool ok;
QString str = QInputDialog::getText(toplevel, translate_utf8(title),
QString str = QInputDialog::getText(form_widget, translate_utf8(title),
translate_utf8(text), QLineEdit::Normal, "", &ok);
if (ok) {
strcpy(*value, qPrintableLatin1(str));
......
......@@ -104,7 +104,6 @@ public:
WAttText* watttext_new(pwr_tAttrRef aref, int editmode, pwr_tStatus* status);
private:
QWidget* toplevel;
QWidget* parent_wid;
WNavQtTraceObject* trace_obj;
};
......
......@@ -2016,7 +2016,7 @@ WttQt::WttQt(void* wt_parent_ctx, QWidget* wt_parent_wid, const char* wt_name,
menu_pasteinto_w = addMenuItem(
toplevel, edit, "Paste Into", SLOT(activate_pasteinto()), "CTRL+SHIFT+V");
menu_rename_w = addMenuItem(
toplevel, edit, "Rename", SLOT(open_change_name()), "CTRL+SHIFT+N");
toplevel, edit, "Rename", SLOT(activate_rename()), "CTRL+SHIFT+N");
// Functions menu
QMenu* functions = menu_bar->addMenu(translate_utf8("&Functions"));
......
......@@ -41,6 +41,7 @@
#include "co_help_qt.h"
#include "cow_qt_helpers.h"
#include "cow_style_qt.h"
#include "cow_xhelp_qt.h"
#include <QApplication>
......@@ -57,6 +58,7 @@ int main(int argc, char* argv[])
int sts;
QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle());
setlocale(LC_NUMERIC, "POSIX");
setlocale(LC_TIME, "en_US");
......
......@@ -41,6 +41,7 @@
#include "cow_qt_helpers.h"
#include "cow_rtmon_qt.h"
#include "cow_style_qt.h"
#include "cow_xhelp_qt.h"
#include <QApplication>
......@@ -81,6 +82,7 @@ int main(int argc, char* argv[])
}
QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle());
setlocale(LC_NUMERIC, "POSIX");
setlocale(LC_TIME, "en_US");
......
......@@ -41,6 +41,7 @@
#include "cow_msgwindow.h"
#include "cow_qt_helpers.h"
#include "cow_statusmon_nodelist_qt.h"
#include "cow_style_qt.h"
#include "cow_xhelp_qt.h"
#include <QApplication>
......@@ -106,6 +107,7 @@ int main(int argc, char* argv[])
}
QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle());
setlocale(LC_NUMERIC, "POSIX");
setlocale(LC_TIME, "en_US");
......
......@@ -41,6 +41,7 @@
#include "cow_login_qt.h"
#include "cow_qt_helpers.h"
#include "cow_style_qt.h"
#include "cow_xhelp_qt.h"
#include "xtt_hotkey_qt.h"
......@@ -552,6 +553,7 @@ int main(int argc, char* argv[])
int sts;
QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle());
new XttQt(argc, argv, &sts);
app.exec();
exit(sts);
......
......@@ -42,6 +42,7 @@
#include "co_dcli.h"
#include "cow_qt_helpers.h"
#include "cow_style_qt.h"
#include "xtt_xnav_qt.h"
......@@ -124,6 +125,7 @@ int main(int argc, char* argv[])
}
QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle());
setlocale(LC_TIME, "en_US");
setlocale(LC_NUMERIC, "POSIX");
......
......@@ -40,6 +40,7 @@
#include "cow_msgwindow_qt.h"
#include "cow_qt_helpers.h"
#include "cow_style_qt.h"
#include "cow_xhelp_qt.h"
#include "ge_qt.h"
......@@ -71,6 +72,7 @@ int main(int argc, char* argv[])
pwr_tFileName fname;
QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle());
setlocale(LC_NUMERIC, "POSIX");
setlocale(LC_TIME, "en_US");
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2017 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#include "cow_style_qt.h"
int PwrStyle::pixelMetric(PixelMetric which, const QStyleOption *option, const QWidget *widget) const
{
switch(which) {
case PM_LayoutLeftMargin:
case PM_LayoutTopMargin:
case PM_LayoutRightMargin:
case PM_LayoutBottomMargin:
return 0;
default:
return QGtkStyle::pixelMetric(which, option, widget);
}
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2017 SSAB EMEA AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef cow_style_qt_h
#define cow_style_qt_h
#include <QGtkStyle>
class PwrStyle : public QGtkStyle
{
Q_OBJECT
public:
PwrStyle() : QGtkStyle() {}
int pixelMetric(PixelMetric which, const QStyleOption *option,
const QWidget *widget = 0) const;
};
#endif
\ No newline at end of file
......@@ -388,25 +388,20 @@ int GlowDrawQt::event_handler(QEvent* event)
return 1;
}
QObject* parent = m_wind->window;
QObject* windowParent = m_wind->window;
QObject* navWindowParent = nav_wind->window;
bool windowEvent = false;
while (parent != NULL) {
if (QApplication::focusWidget() == parent) {
windowEvent = true;
break;
}
parent = parent->parent();
}
bool navWindowEvent = false;
if (!windowEvent) {
parent = nav_wind->window;
while (parent != NULL) {
if (QApplication::focusWidget() == parent) {
navWindowEvent = true;
if (QApplication::focusWidget() != NULL) {
while (!(windowParent == NULL && navWindowParent == NULL)) {
windowEvent = (QApplication::focusWidget() == windowParent);
navWindowEvent = (QApplication::focusWidget() == navWindowParent);
if (windowEvent || navWindowEvent) {
break;
}
parent = parent->parent();
windowParent = (windowParent == NULL) ? NULL : windowParent->parent();
navWindowParent
= (navWindowParent == NULL) ? NULL : navWindowParent->parent();
}
}
......
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