~roeldeconinck/mnemosyne-proj/import

« back to all changes in this revision

Viewing changes to mnemosyne/mnemosyne/pyqt_ui/activate_cards_dlg.py

  • Committer: Peter Bienstman
  • Date: 2011-08-24 17:39:01 UTC
  • Revision ID: peter.bienstman@ugent.be-20110824173901-mt7oqw34dq0s33e1
Tweaks for dialogs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
        ActivateCardsDialog.__init__(self, component_manager)
18
18
        QtGui.QDialog.__init__(self, self.main_widget())
19
19
        self.setupUi(self)
20
 
        # Restore sizes.
21
 
        config = self.config()
22
 
        width, height = config["activate_cards_dlg_size"]
23
 
        if width:
24
 
            self.resize(width, height)
25
 
        splitter_sizes = config["activate_cards_dlg_splitter"]
26
 
        if not splitter_sizes:
 
20
        self.setWindowFlags(self.windowFlags() \
 
21
            | QtCore.Qt.WindowMinMaxButtonsHint)
 
22
        self.setWindowFlags(self.windowFlags() \
 
23
            & ~ QtCore.Qt.WindowContextHelpButtonHint)        
 
24
        # Restore state.
 
25
        state = self.config()["activate_cards_dlg_state"]
 
26
        if state:
 
27
            self.restoreGeometry(state)
 
28
        splitter_state = self.config()["activate_cards_dlg_splitter_state"]
 
29
        if not splitter_state:
27
30
            self.splitter.setSizes([100, 350])
28
31
        else:
29
 
            self.splitter.setSizes(splitter_sizes)
 
32
            self.splitter.restoreState(splitter_state)
30
33
        # Initialise widgets.
31
34
        QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Delete),
32
35
                        self.saved_sets, self.delete_set)
140
143
            QtCore.Qt.MatchExactly)[0]
141
144
        self.saved_sets.setCurrentItem(item)
142
145
            
143
 
    def _store_layout(self):
144
 
        self.config()["activate_cards_dlg_size"] = \
145
 
            (self.width(), self.height())
146
 
        self.config()["activate_cards_dlg_splitter"] = \
147
 
            self.splitter.sizes()
 
146
    def _store_state(self):
 
147
        self.config()["activate_cards_dlg_state"] = \
 
148
            self.saveGeometry()
 
149
        self.config()["activate_cards_dlg_splitter_state"] = \
 
150
            self.splitter.saveState()
148
151
        
149
152
    def closeEvent(self, event):
150
 
        self._store_layout()
 
153
        # Generated when clicking the window's close button.
 
154
        self._store_state()
151
155
        
152
156
    def accept(self):
 
157
        # 'accept' does not generate a close event.
153
158
        self.database().set_current_criterion(\
154
159
            self.tab_widget.currentWidget().criterion())
155
 
        self._store_layout()
 
160
        self._store_state()
156
161
        return QtGui.QDialog.accept(self)
157
 
        
158
 
    def reject(self):
159
 
        self._store_layout()
160
 
        QtGui.QDialog.reject(self)