Don't show file changed notifications while an operation is ongoing

Reloading a file during operations is usually fatal.

+ Enhanced the "show all hierarchy levels tip window."
This commit is contained in:
Matthias Koefferlein 2017-09-21 22:05:42 +02:00
parent daacd9ea6f
commit 8cd612ba36
4 changed files with 180 additions and 120 deletions

View File

@ -1100,6 +1100,18 @@ MainWindow::dock_widget_visibility_changed (bool /*visible*/)
void void
MainWindow::file_changed_timer () MainWindow::file_changed_timer ()
{ {
// Don't evaluate file changed notifications while an operation is busy -
// otherwise we'd interfere with such operations.
if (mp_pr->is_busy ()) {
// Restart the timer to get notified again
m_file_changed_timer.setInterval (200);
m_file_changed_timer.start ();
return;
}
// Prevent recursive signals // Prevent recursive signals
m_file_changed_timer.blockSignals (true); m_file_changed_timer.blockSignals (true);
@ -1260,23 +1272,24 @@ MainWindow::about_to_exec ()
config_get (cfg_full_hier_new_cell, f); config_get (cfg_full_hier_new_cell, f);
if (!f) { if (!f) {
TipDialog td (this, TipDialog td (this,
tl::to_string (QObject::tr ("With the current settings, only the top cell's boundary is shown initially.\n" tl::to_string (QObject::tr ("<html><body>"
"\n" "<p>With the current settings, only the top cell's content is shown initially, but the child cells are not drawn.</p>"
"This can be confusing, since the layout itself becomes visible only after selecting " "<p>This can be confusing, since the full layout becomes visible only after selecting "
"all hierarchy levels manually.\n" "all hierarchy levels manually.</p>"
"\n" "<p>This setting can be changed now. It can also be changed any time later using \"File/Setup\", \"Navigation/New Cell\": "
"This setting can be changed now. It can also be changed any time later using \"File/Setup\", \"Navigation/New Cell\": " "\"Select all hierarchy levels\".</p>"
"\"Select all hierarchy levels\".\n" "<ul>"
"\n" "<li>Press <b>Yes</b> to enable <b>Show full hierarchy</b> mode now.</li>\n"
"Press 'Yes' to switch to 'show full hierarchy by default' mode.\n" "<li>With <b>No</b>, the mode will remain <b>Show top level only</b>.</li>"
"With 'No', the behaviour will remain 'cell boundary only'.")), "</ul>"
"</body></html>")),
"only-top-level-shown-by-default", "only-top-level-shown-by-default",
lay::TipDialog::yesnocancel_buttons); lay::TipDialog::yesno_buttons);
lay::TipDialog::button_type button = lay::TipDialog::null_button; lay::TipDialog::button_type button = lay::TipDialog::null_button;
td.exec_dialog (button); if (td.exec_dialog (button)) {
if (button == lay::TipDialog::yes_button) { if (button == lay::TipDialog::yes_button) {
config_set (cfg_full_hier_new_cell, true); config_set (cfg_full_hier_new_cell, true);
} else if (button == lay::TipDialog::cancel_button) { }
// Don't bother the user with more dialogs. // Don't bother the user with more dialogs.
return; return;
} }

View File

@ -86,6 +86,12 @@ ProgressReporter::set_progress_bar (lay::ProgressBar *pb)
void void
ProgressReporter::register_object (tl::Progress *progress) ProgressReporter::register_object (tl::Progress *progress)
{ {
if (mp_objects.empty ()) {
// to avoid recursions of any kind, disallow any user interaction except
// cancelling the operation
QApplication::instance ()->installEventFilter (this);
}
mp_objects.push_back (progress); // this keeps the outmost one visible. push_front would make the latest one visible. mp_objects.push_back (progress); // this keeps the outmost one visible. push_front would make the latest one visible.
// mp_objects.push_front (progress); // mp_objects.push_front (progress);
@ -119,11 +125,15 @@ ProgressReporter::unregister_object (tl::Progress *progress)
} }
update_and_yield (); update_and_yield ();
return; break;
} }
} }
if (mp_objects.empty ()) {
QApplication::instance ()->removeEventFilter (this);
}
} }
void void
@ -207,16 +217,6 @@ ProgressReporter::set_visible (bool vis)
m_pw_visible = vis; m_pw_visible = vis;
} }
if (QApplication::instance()) {
if (vis) {
// to avoid recursions of any kind, disallow any user interaction except
// cancelling the operation
QApplication::instance ()->installEventFilter (this);
} else {
QApplication::instance ()->removeEventFilter (this);
}
}
} }
bool bool

View File

@ -73,6 +73,11 @@ public:
void signal_break (); void signal_break ();
void set_progress_bar (lay::ProgressBar *pb); void set_progress_bar (lay::ProgressBar *pb);
bool is_busy () const
{
return !mp_objects.empty ();
}
private: private:
std::list <tl::Progress *> mp_objects; std::list <tl::Progress *> mp_objects;
tl::Clock m_start_time; tl::Clock m_start_time;

View File

@ -1,58 +1,77 @@
<ui version="4.0" > <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TipDialog</class> <class>TipDialog</class>
<widget class="QDialog" name="TipDialog" > <widget class="QDialog" name="TipDialog">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>549</width> <width>549</width>
<height>291</height> <height>334</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>Tip</string> <string>Tip</string>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout">
<property name="margin" > <property name="leftMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="spacing" > <property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<item row="1" column="1" > <item row="1" column="1">
<widget class="QFrame" name="frame_2" > <widget class="QFrame" name="frame_2">
<property name="frameShape" > <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow" > <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout">
<property name="margin" > <property name="spacing">
<number>9</number>
</property>
<property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item> <item>
<widget class="QLabel" name="tip_text" > <widget class="QLabel" name="tip_text">
<property name="text" > <property name="text">
<string>TextLabel</string> <string>TextLabel</string>
</property> </property>
<property name="wordWrap" > <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeType" > <property name="sizeType">
<enum>QSizePolicy::Expanding</enum> <enum>QSizePolicy::Expanding</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>391</width> <width>391</width>
<height>91</height> <height>91</height>
@ -63,30 +82,39 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="2" > <item row="4" column="0" colspan="2">
<widget class="QFrame" name="frame" > <widget class="QFrame" name="frame">
<property name="frameShape" > <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow" > <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout">
<property name="margin" > <property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing" > <property name="topMargin">
<number>6</number> <number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property> </property>
<item> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType" > <property name="sizeType">
<enum>QSizePolicy::Expanding</enum> <enum>QSizePolicy::Expanding</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>381</width> <width>381</width>
<height>31</height> <height>31</height>
@ -95,42 +123,42 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="yes_button" > <widget class="QPushButton" name="yes_button">
<property name="text" > <property name="text">
<string>Yes</string> <string>Yes</string>
</property> </property>
<property name="default" > <property name="default">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="no_button" > <widget class="QPushButton" name="no_button">
<property name="text" > <property name="text">
<string>No</string> <string>No</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="ok_button" > <widget class="QPushButton" name="ok_button">
<property name="text" > <property name="text">
<string>Ok</string> <string>Ok</string>
</property> </property>
<property name="default" > <property name="default">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="cancel_button" > <widget class="QPushButton" name="cancel_button">
<property name="text" > <property name="text">
<string>Cancel</string> <string>Cancel</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="close_button" > <widget class="QPushButton" name="close_button">
<property name="text" > <property name="text">
<string>Close</string> <string>Close</string>
</property> </property>
</widget> </widget>
@ -138,45 +166,52 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0" > <item row="1" column="0">
<widget class="QFrame" name="frame_3" > <widget class="QFrame" name="frame_3">
<property name="sizePolicy" > <property name="sizePolicy">
<sizepolicy> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<hsizetype>0</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="frameShape" > <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow" > <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout">
<property name="margin" > <property name="spacing">
<number>9</number>
</property>
<property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item> <item>
<widget class="QLabel" name="label" > <widget class="QLabel" name="label">
<property name="text" > <property name="text">
<string/> <string/>
</property> </property>
<property name="pixmap" > <property name="pixmap">
<pixmap resource="layResources.qrc" >:/bulb.png</pixmap> <pixmap resource="../../lay/lay/layResources.qrc">:/bulb.png</pixmap>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>40</height>
@ -187,15 +222,15 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2" > <item row="3" column="0" colspan="2">
<spacer> <spacer>
<property name="orientation" > <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeType" > <property name="sizeType">
<enum>QSizePolicy::Fixed</enum> <enum>QSizePolicy::Fixed</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>531</width> <width>531</width>
<height>20</height> <height>20</height>
@ -203,15 +238,15 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="0" colspan="2" > <item row="0" column="0" colspan="2">
<spacer> <spacer>
<property name="orientation" > <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeType" > <property name="sizeType">
<enum>QSizePolicy::Fixed</enum> <enum>QSizePolicy::Fixed</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>481</width> <width>481</width>
<height>24</height> <height>24</height>
@ -219,30 +254,39 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="0" colspan="2" > <item row="2" column="0" colspan="2">
<widget class="QFrame" name="frame_4" > <widget class="QFrame" name="frame_4">
<property name="frameShape" > <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow" > <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout">
<property name="margin" > <property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing" > <property name="topMargin">
<number>6</number> <number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property> </property>
<item> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType" > <property name="sizeType">
<enum>QSizePolicy::Fixed</enum> <enum>QSizePolicy::Fixed</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>15</width> <width>15</width>
<height>20</height> <height>20</height>
@ -251,17 +295,15 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="dont_show_cbx" > <widget class="QCheckBox" name="dont_show_cbx">
<property name="sizePolicy" > <property name="sizePolicy">
<sizepolicy> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<hsizetype>5</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text" > <property name="text">
<string>Don't show this window again (use "Help/Show All Tips" to show it again)</string> <string>Don't show this window again (use &quot;Help/Show All Tips&quot; to show it again)</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -271,7 +313,7 @@
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="layResources.qrc" /> <include location="../../lay/lay/layResources.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>
@ -280,11 +322,11 @@
<receiver>TipDialog</receiver> <receiver>TipDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>489</x> <x>489</x>
<y>278</y> <y>278</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>267</x> <x>267</x>
<y>149</y> <y>149</y>
</hint> </hint>