summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-11-18 20:04:44 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-11-18 20:04:53 +0100
commitd26048617d78396cc6381eaf06f19fee484d811c (patch)
tree46fd10052fb16b389abd560f71d10c6e546624d7
parenta0e74e725cd483c1f78b640db9c6148158d2b442 (diff)
gui: resize dialog boxes to fit text
-rw-r--r--gui/main-window.cpp22
-rw-r--r--gui/main.cpp1
2 files changed, 14 insertions, 9 deletions
diff --git a/gui/main-window.cpp b/gui/main-window.cpp
index d3e0baa8..2489c983 100644
--- a/gui/main-window.cpp
+++ b/gui/main-window.cpp
@@ -21,6 +21,7 @@
#include <QString>
#include <QChar>
#include <QSignalBlocker>
+#include <QStatusBar>
#ifdef _WIN32
# include <windows.h>
@@ -42,7 +43,10 @@ MainWindow::MainWindow() :
menu_action_mappings(&tray_menu)
{
ui.setupUi(this);
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ adjustSize();
setFixedSize(size());
+ setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | windowFlags());
updateButtonState(false, false);
if (group::ini_directory().size() == 0)
@@ -575,9 +579,10 @@ bool mk_dialog(mem<dylib> lib, ptr<t>& orig)
{
t* dialog = reinterpret_cast<t*>(lib->Dialog());
dialog->setWindowFlags(Qt::Dialog);
- // HACK: prevent stderr whining by adding a few pixels
- dialog->setFixedSize(dialog->size() + QSize(4, 4));
- dialog->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ dialog->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ dialog->adjustSize();
+ dialog->setFixedSize(dialog->size());
+ dialog->setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | dialog->windowFlags());
dialog->show();
orig.reset(dialog);
@@ -620,11 +625,12 @@ static bool mk_window(ptr<t>* place, Args&&... params)
else
{
*place = make_unique<t>(std::forward<Args>(params)...);
- (*place)->setWindowFlags(Qt::Dialog);
- // HACK: prevent stderr whining by adding a few pixels
- (*place)->setFixedSize((*place)->size() + QSize(4, 4));
- (*place)->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- (*place)->show();
+ auto& dialog = *place;
+ dialog->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ dialog->adjustSize();
+ dialog->setFixedSize(dialog->size());
+ dialog->setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | dialog->windowFlags());
+ dialog->show();
return true;
}
}
diff --git a/gui/main.cpp b/gui/main.cpp
index 8bc09537..acf82808 100644
--- a/gui/main.cpp
+++ b/gui/main.cpp
@@ -17,7 +17,6 @@ using namespace options;
#include <QCommandLineParser>
#include <QStyleFactory>
#include <QStringList>
-#include <QMessageBox>
#include <QDebug>
#include <memory>
#include <cstring>