ui: subwindow when resize mainwindow
* disable drop in qtlineedit
fixes bug where when file is dropped in the lineedit with text,
the the file will be added as text midst the existing text
* move message to start from script before layout loading so it will load right
(only when started without script on linux)
* center subwindow when mainwindow size changes
This commit is contained in:
@@ -22,5 +22,5 @@ export LD_LIBRARY_PATH="$SOURCETRAIL_PATH/lib:$LD_LIBRARY_PATH"
|
||||
export QT_XKB_CONFIG_ROOT="/usr/share/X11/xkb:$QT_XKB_CONFIG_ROOT"
|
||||
export QT_QPA_PLATFORM_PLUGIN_PATH="$SOURCETRAIL_PATH/lib/platforms"
|
||||
export QT_QPA_FONTDIR="$SOURCETRAIL_PATH/data/fonts:$QT_QPA_FONTDIR"
|
||||
export SOURCETRAIL_VIA_SCRIPT
|
||||
export SOURCETRAIL_VIA_SCRIPT=1
|
||||
exec "$SOURCETRAIL_PATH/Sourcetrail" $@
|
||||
|
||||
@@ -29,6 +29,7 @@ QtListItemWidget::QtListItemWidget(QtDirectoryListBox* list, QListWidgetItem* it
|
||||
m_data->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||
m_data->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_data->setObjectName("field");
|
||||
m_data->setAcceptDrops(false);
|
||||
|
||||
m_button = new QtIconButton(
|
||||
(ResourcePaths::getGuiPath().str() + "window/dots.png").c_str(),
|
||||
@@ -72,7 +73,7 @@ void QtListItemWidget::setText(QString text)
|
||||
|
||||
void QtListItemWidget::setFocus()
|
||||
{
|
||||
m_data->setFocus(Qt::OtherFocusReason);
|
||||
m_data->setFocus(Qt::OtherFocusReason);
|
||||
}
|
||||
|
||||
void QtListItemWidget::handleButtonPress()
|
||||
|
||||
@@ -101,14 +101,21 @@ QtMainWindow::QtMainWindow()
|
||||
, m_showDockWidgetTitleBars(true)
|
||||
, m_windowStack(this)
|
||||
{
|
||||
setObjectName("QtMainWindow");
|
||||
setObjectName("QtMainWindow");
|
||||
setCentralWidget(nullptr);
|
||||
setDockNestingEnabled(true);
|
||||
|
||||
setWindowIcon(QIcon((ResourcePaths::getGuiPath().str() + "icon/logo_1024_1024.png").c_str()));
|
||||
setWindowFlags(Qt::Widget);
|
||||
|
||||
QApplication* app = dynamic_cast<QApplication*>(QCoreApplication::instance());
|
||||
#ifdef __linux__
|
||||
if (std::getenv("SOURCETRAIL_VIA_SCRIPT") == nullptr)
|
||||
{
|
||||
QMessageBox::warning(this, "Run Sourcetrail via Script", "Please run Sourcetrail via Sourcetrail.sh");
|
||||
}
|
||||
#endif
|
||||
|
||||
QApplication* app = dynamic_cast<QApplication*>(QCoreApplication::instance());
|
||||
app->installEventFilter(new MouseReleaseFilter(this));
|
||||
|
||||
app->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath().concat(FilePath("main.css"))).c_str());
|
||||
@@ -125,13 +132,6 @@ QtMainWindow::QtMainWindow()
|
||||
// Need to call loadLayout here for right DockWidget size on Linux
|
||||
// Seconde call is in Application.cpp
|
||||
loadLayout();
|
||||
|
||||
#ifdef __linux__
|
||||
if (std::getenv("SOURCETRAIL_VIA_SCRIPT") == nullptr)
|
||||
{
|
||||
QMessageBox::warning(this, "Run Sourcetrail via Script", "Please run Sourcetrail via Sourcetrail.sh");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QtMainWindow::~QtMainWindow()
|
||||
@@ -323,7 +323,13 @@ void QtMainWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
log->setEnabled(false);
|
||||
}
|
||||
MessageWindowClosed().dispatch();
|
||||
MessageWindowClosed().dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
m_windowStack.centerSubWindows();
|
||||
QMainWindow::resizeEvent(event);
|
||||
}
|
||||
|
||||
void QtMainWindow::about()
|
||||
|
||||
@@ -78,6 +78,7 @@ protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
void closeEvent(QCloseEvent* event);
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
|
||||
public slots:
|
||||
void about();
|
||||
|
||||
@@ -73,24 +73,7 @@ QtWindow::QtWindow(bool isSubWindow, QWidget* parent)
|
||||
|
||||
resize(sizeHint());
|
||||
|
||||
if (parentWidget())
|
||||
{
|
||||
if (m_isSubWindow)
|
||||
{
|
||||
move(
|
||||
parentWidget()->width() / 2 - sizeHint().width() / 2,
|
||||
parentWidget()->height() / 2 - sizeHint().height() / 2
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
move(
|
||||
|
||||
parentWidget()->pos().x() + parentWidget()->width() / 2 - sizeHint().width() / 2,
|
||||
parentWidget()->pos().y() + parentWidget()->height() / 2 - sizeHint().height() / 2
|
||||
);
|
||||
}
|
||||
}
|
||||
moveToCenter();
|
||||
|
||||
this->raise();
|
||||
}
|
||||
@@ -192,7 +175,34 @@ void QtWindow::setScrollAble(bool scrollAble)
|
||||
|
||||
bool QtWindow::isScrollAble() const
|
||||
{
|
||||
return m_scrollAble;
|
||||
return m_scrollAble;
|
||||
}
|
||||
|
||||
bool QtWindow::isSubWindow() const
|
||||
{
|
||||
return m_isSubWindow;
|
||||
}
|
||||
|
||||
void QtWindow::moveToCenter()
|
||||
{
|
||||
if (parentWidget())
|
||||
{
|
||||
if (m_isSubWindow)
|
||||
{
|
||||
move(
|
||||
parentWidget()->width() / 2 - sizeHint().width() / 2,
|
||||
parentWidget()->height() / 2 - sizeHint().height() / 2
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
move(
|
||||
|
||||
parentWidget()->pos().x() + parentWidget()->width() / 2 - sizeHint().width() / 2,
|
||||
parentWidget()->pos().y() + parentWidget()->height() / 2 - sizeHint().height() / 2
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtWindow::updateTitle(QString title)
|
||||
@@ -485,24 +495,7 @@ void QtWindow::setupDone()
|
||||
QSize size(qMax(actualSize.width(), preferredSize.width()), qMax(actualSize.height(), preferredSize.height()));
|
||||
resize(size);
|
||||
|
||||
if (parentWidget())
|
||||
{
|
||||
if (m_isSubWindow)
|
||||
{
|
||||
move(
|
||||
parentWidget()->width() / 2 - size.width() / 2,
|
||||
parentWidget()->height() / 2 - size.height() / 2
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
move(
|
||||
|
||||
parentWidget()->pos().x() + parentWidget()->width() / 2 - size.width() / 2,
|
||||
parentWidget()->pos().y() + parentWidget()->height() / 2 - size.height() / 2
|
||||
);
|
||||
}
|
||||
}
|
||||
moveToCenter();
|
||||
}
|
||||
|
||||
void QtWindow::addLogo()
|
||||
|
||||
@@ -30,6 +30,9 @@ public:
|
||||
void setScrollAble(bool scrollAble);
|
||||
|
||||
bool isScrollAble() const;
|
||||
bool isSubWindow() const;
|
||||
|
||||
void moveToCenter();
|
||||
|
||||
void updateTitle(QString title);
|
||||
void updateSubTitle(QString subTitle);
|
||||
@@ -107,7 +110,7 @@ private:
|
||||
QPoint m_dragPosition;
|
||||
bool m_mousePressedInWindow;
|
||||
|
||||
QSizeGrip* m_sizeGrip;
|
||||
QSizeGrip* m_sizeGrip;
|
||||
};
|
||||
|
||||
#endif // QT_WINDOW_H
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "qt/window/QtWindowStack.h"
|
||||
|
||||
#include "qt/window/QtWindow.h"
|
||||
|
||||
|
||||
QtWindowStackElement::QtWindowStackElement(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
@@ -71,6 +73,21 @@ void QtWindowStack::popWindow()
|
||||
}
|
||||
}
|
||||
|
||||
void QtWindowStack::centerSubWindows()
|
||||
{
|
||||
for (QtWindowStackElement* window : m_stack)
|
||||
{
|
||||
QtWindow* qtWindow = dynamic_cast<QtWindow*>(window);
|
||||
if (qtWindow)
|
||||
{
|
||||
if (qtWindow->isSubWindow())
|
||||
{
|
||||
qtWindow->moveToCenter();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtWindowStack::clearWindows()
|
||||
{
|
||||
for (QtWindowStackElement* window : m_stack)
|
||||
|
||||
@@ -31,7 +31,10 @@ public:
|
||||
|
||||
QtWindowStackElement* getTopWindow();
|
||||
QtWindowStackElement* getBottomWindow();
|
||||
size_t getWindowCount();
|
||||
|
||||
size_t getWindowCount();
|
||||
|
||||
void centerSubWindows();
|
||||
|
||||
public slots:
|
||||
void pushWindow(QtWindowStackElement* window);
|
||||
|
||||
Reference in New Issue
Block a user