Skip to content

Commit

Permalink
Move cancel button for widgets away from save.
Browse files Browse the repository at this point in the history
Add confirm cancel on form.
  • Loading branch information
NathanW2 committed Aug 10, 2018
1 parent a042f60 commit 20e7754
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
15 changes: 13 additions & 2 deletions src/roam/editorwidgets/featureformwidget.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import functools

from PyQt4.QtCore import pyqtSignal, QSize, Qt
from PyQt4.QtGui import QToolBar, QWidget, QSizePolicy, QLabel, QIcon
from PyQt4.QtGui import QToolBar, QWidget, QSizePolicy, QLabel, QIcon, QAction

from roam.popupdialogs import PickActionDialog
from roam.popupdialogs import DeleteFeatureDialog
from roam.editorwidgets.core import LargeEditorWidget
from roam.flickwidget import FlickCharm
Expand Down Expand Up @@ -42,7 +43,7 @@ def __init__(self, parent=None):

spacer = QWidget()
spacer2 = QWidget()
spacer2.setMinimumWidth(20)
spacer2.setMinimumWidth(40)
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
spacer2.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
toolbar.addWidget(spacer)
Expand Down Expand Up @@ -162,6 +163,16 @@ def initWidget(self, widget, config):
widget.featuredeleted.connect(self.emit_finished)

def cancelform(self, *args):
dlg = PickActionDialog(msg="Discard form changes?")
self.expandAction = QAction(QIcon(":/icons/expand"), "Expand Panel", self)
discardaction = QAction("Discard", self, triggered=self._cancel_form)
discardaction.setObjectName("discard")
noaction = QAction("No", self)

dlg.addactions([noaction, discardaction])
dlg.exec_()

def _cancel_form(self, *args):
self.emit_cancel(*args)

def updatefromconfig(self):
Expand Down
1 change: 1 addition & 0 deletions src/roam/popupdialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(self, msg=None, parent=None, wrap=None):

def addAction(self, action, row, column):
button = QToolButton(self)
button.setObjectName(action.objectName())
button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
button.setProperty("action", True)
button.setIconSize(QSize(64, 64))
Expand Down
9 changes: 8 additions & 1 deletion src/roam/roam_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ def appstyle():
$FONT
}
QToolButton#discard {
qproperty-icon: url(":/widgets/cancel");
background-color: rgb(255, 134, 125);
color: white;
font: 75 17pt "Segoe UI";
}
QToolButton {
padding: 4px;
color: #4f4f4f;
Expand Down
26 changes: 13 additions & 13 deletions src/roam/ui/ui_list.ui
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ QListView::item:selected {
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="fieldnameLabel">
<property name="text">
<string>{field Name}</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="header" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="closebutton">
<property name="sizePolicy">
Expand Down Expand Up @@ -100,6 +87,19 @@ QListView::item:selected {
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fieldnameLabel">
<property name="text">
<string>{field Name}</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="header" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="saveButton">
<property name="sizePolicy">
Expand Down

0 comments on commit 20e7754

Please sign in to comment.