diff options
author | dos-reis <gdr@axiomatics.org> | 2011-05-27 16:35:45 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-05-27 16:35:45 +0000 |
commit | 42118110a5e3e7fe4ce22f81df65452d19cb0152 (patch) | |
tree | a3985af5c6469de3a9f6100215d31ff33e2be66b | |
parent | 329773b981c42fb254f7b83fcd85c113d344697b (diff) | |
download | open-axiom-42118110a5e3e7fe4ce22f81df65452d19cb0152.tar.gz |
minor gui code cleanup
-rw-r--r-- | src/gui/conversation.C | 14 | ||||
-rw-r--r-- | src/gui/debate.C | 2 | ||||
-rw-r--r-- | src/gui/main-window.C | 15 |
3 files changed, 17 insertions, 14 deletions
diff --git a/src/gui/conversation.C b/src/gui/conversation.C index e8181deb..1034ccf8 100644 --- a/src/gui/conversation.C +++ b/src/gui/conversation.C @@ -184,7 +184,7 @@ namespace OpenAxiom { static QSize minimum_preferred_size(const Conversation* conv) { const QSize em = em_metrics(conv); - return QSize(columns * em.width(), 2 * lines * em.height()); + return QSize(columns * em.width(), lines * em.height()); } // Set a minimum preferred widget size, so no layout manager @@ -226,18 +226,9 @@ namespace OpenAxiom { return round_up_height(sz, view_height); } - static void - set_size_policy(Conversation* conv) { - conv->updateGeometry(); - conv->setSizePolicy(QSizePolicy::MinimumExpanding, - QSizePolicy::MinimumExpanding); - } - void Conversation::resizeEvent(QResizeEvent* e) { Base::resizeEvent(e); setMinimumSize(size()); - if (length() == 0) - return set_size_policy(this); const QSize sz = size(); if (e->oldSize() == sz) return; @@ -259,8 +250,7 @@ namespace OpenAxiom { w->show(); children.push_back(w); adjustSize(); - update(); - debate()->updateGeometry(); + updateGeometry(); return w; } diff --git a/src/gui/debate.C b/src/gui/debate.C index ce5bf878..50c6891a 100644 --- a/src/gui/debate.C +++ b/src/gui/debate.C @@ -41,9 +41,9 @@ namespace OpenAxiom { setViewportMargins(0, 0, 0, 0); viewport()->setAutoFillBackground(true); viewport()->setBackgroundRole(conv.backgroundRole()); - adjustSize(); setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + adjustSize(); } Debate::~Debate() { } diff --git a/src/gui/main-window.C b/src/gui/main-window.C index 21571532..9cb219bf 100644 --- a/src/gui/main-window.C +++ b/src/gui/main-window.C @@ -37,9 +37,22 @@ namespace OpenAxiom { + // Attempt to resize the main window so that on the first exposure + // the exchanges in this debate have the preferred geometry and the + // horizontal scroll bar is not needed. static void try_to_honor_widget_size(MainWindow* w, Debate* debate) { - w->resize(debate->size()); + // Force a show first, to provoke conversation size. + // That helps getting the sizes right. On the other hand, it + // makes for several resize event roundring leading to + // an awkward looking brief window showing. FIXME. + w->show(); + QSize diff = debate->exchanges()->size() - debate->viewport()->size(); + if (diff.width() < 0) + diff.setWidth(0); + if (diff.height() < 0) + diff.setHeight(0); + w->resize(w->size() + diff); } MainWindow::MainWindow() : tabs(this) { |