Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
4f53a68d
Commit
4f53a68d
authored
Dec 04, 2018
by
Christoffer Ackelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QT: Fixed CoWow ListWidget calling both apply/ok and then cancel.
parent
f955dc2c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
25 deletions
+20
-25
xtt/lib/cow/qt/cow_wow_qt.cqt
xtt/lib/cow/qt/cow_wow_qt.cqt
+19
-23
xtt/lib/cow/qt/cow_wow_qt.h
xtt/lib/cow/qt/cow_wow_qt.h
+1
-2
No files found.
xtt/lib/cow/qt/cow_wow_qt.cqt
View file @
4f53a68d
...
...
@@ -205,6 +205,8 @@ void CoWowListWidgetQt::list_row_activated_cb(QTreeWidgetItem* item, int i)
void CoWowListWidgetQt::list_apply_cb()
{
button_pressed = 0;
QString selected_text;
QList<QTreeWidgetItem*> selected_items = list->selectedItems();
...
...
@@ -213,21 +215,16 @@ void CoWowListWidgetQt::list_apply_cb()
selected_text = item->text(0);
}
if (action_cb) {
(action_cb)(parent_ctx, qPrintableLatin1(selected_text),
ok
_pressed);
(action_cb)(parent_ctx, qPrintableLatin1(selected_text),
button
_pressed);
}
close();
}
void CoWowListWidgetQt::list_ok_cb()
{
ok
_pressed = 1;
button
_pressed = 1;
list_apply_cb();
}
void CoWowListWidgetQt::list_cancel_cb()
{
if (cancel_cb) {
(cancel_cb)(parent_ctx);
}
close();
}
CoWowListWidgetQt::CoWowListWidgetQt(QWidget* parent, const char* title,
...
...
@@ -236,22 +233,18 @@ CoWowListWidgetQt::CoWowListWidgetQt(QWidget* parent, const char* title,
: QWidget(), action_cb(action_cb), cancel_cb(cancel_cb),
parent_ctx(parent_ctx)
{
QVBoxLayout* vbox = new QVBoxLayout(this);
QHBoxLayout* hbox = new QHBoxLayout();
QDialogButtonBox* buttons = new QDialogButtonBox();
QPushButton* ok_button = new QPushButton("OK");
connect(ok_button, SIGNAL(clicked()), this, SLOT(list_ok_cb()));
hbox->addWidget(ok_button, 1, Qt::AlignRight);
buttons->addButton(QDialogButtonBox::Ok);
connect(buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(list_ok_cb()));
if (show_apply_button) {
QPushButton* apply_button = new QPushButton(translate_utf8("Apply"));
connect(apply_button, SIGNAL(clicked()), this, SLOT(list_apply_cb()));
hbox->addWidget(apply_button, 0);
buttons->addButton(QDialogButtonBox::Apply);
connect(buttons->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(list_apply_cb()));
}
QPushButton* cancel_button = new QPushButton("Cancel");
connect(cancel_button, SIGNAL(clicked()), this, SLOT(list_cancel_cb()));
hbox->addWidget(cancel_button, 0);
buttons->addButton(QDialogButtonBox::Cancel);
connect(buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(close()));
list = new QTreeWidget();
...
...
@@ -271,8 +264,9 @@ CoWowListWidgetQt::CoWowListWidgetQt(QWidget* parent, const char* title,
connect(list, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this,
SLOT(list_row_activated_cb(QTreeWidgetItem*, int)));
QVBoxLayout* vbox = new QVBoxLayout(this);
vbox->addWidget(list, 1, Qt::AlignTop);
vbox->add
Layout(hbox
);
vbox->add
Widget(buttons
);
setLayout(vbox);
...
...
@@ -288,14 +282,16 @@ CoWowListWidgetQt::CoWowListWidgetQt(QWidget* parent, const char* title,
void CoWowListWidgetQt::focusInEvent(QFocusEvent* event)
{
QWidget::focusInEvent(event);
pop(this);
QWidget::focusInEvent(event);
}
void CoWowListWidgetQt::closeEvent(QCloseEvent* event)
{
if (button_pressed < 0 && cancel_cb) {
(cancel_cb)(parent_ctx);
}
QWidget::closeEvent(event);
list_cancel_cb();
}
void* CoWowQt::CreateList(const char* title, const char* texts, int textsize,
...
...
xtt/lib/cow/qt/cow_wow_qt.h
View file @
4f53a68d
...
...
@@ -152,13 +152,12 @@ private:
void
(
*
action_cb
)(
void
*
,
char
*
,
int
);
void
(
*
cancel_cb
)(
void
*
);
void
*
parent_ctx
;
int
ok_pressed
;
int
button_pressed
=
-
1
;
public
slots
:
void
list_row_activated_cb
(
QTreeWidgetItem
*
item
,
int
i
);
void
list_apply_cb
();
void
list_ok_cb
();
void
list_cancel_cb
();
};
class
CoWowQtObject
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment