Commit 480a1042 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

create quick open only when needed

parent cc7dfeaf
......@@ -195,10 +195,6 @@ KateMainWindow::~KateMainWindow()
// disable all plugin guis, delete all pluginViews
KateApp::self()->pluginManager()->disableAllPluginsGUI(this);
// manually delete quick open, it's event filters will cause crash otherwise later
delete m_quickOpen;
m_quickOpen = nullptr;
// delete the view manager, before KateMainWindow's wrapper is dead
delete m_viewManager;
m_viewManager = nullptr;
......@@ -272,8 +268,6 @@ void KateMainWindow::setupMainWindow()
centralWidget()->layout()->addWidget(m_mainStackedWidget);
(static_cast<QBoxLayout *>(centralWidget()->layout()))->setStretchFactor(m_mainStackedWidget, 100);
m_quickOpen = new KateQuickOpen(this);
m_commandBar = new KateCommandBar(this);
m_viewManager = new KateViewManager(m_mainStackedWidget, this);
......@@ -1200,14 +1194,6 @@ void KateMainWindow::mousePressEvent(QMouseEvent *e)
}
}
void KateMainWindow::resizeEvent(QResizeEvent *event)
{
if (event && !m_quickOpen->isHidden()) {
m_quickOpen->updateViewGeometry();
event->accept();
}
}
void KateMainWindow::slotFocusPrevTab()
{
if (m_viewManager->activeViewSpace()) {
......@@ -1227,8 +1213,9 @@ void KateMainWindow::slotQuickOpen()
/**
* show quick open and pass focus to it
*/
m_quickOpen->update();
centralWidget()->setFocusProxy(m_quickOpen);
KateQuickOpen quickOpen(this);
centralWidget()->setFocusProxy(&quickOpen);
quickOpen.exec();
}
void KateMainWindow::slotCommandBarOpen()
......
......@@ -41,8 +41,6 @@ class KRecentFilesAction;
class KateViewManager;
class KateMwModOnHdDialog;
class KateQuickOpen;
enum KateQuickOpenModelList : int;
class KateCommandBar;
// Helper layout class to always provide minimum size
......@@ -542,11 +540,6 @@ private:
*/
QStackedWidget *m_mainStackedWidget = nullptr;
/**
* quick open to fast switch documents
*/
KateQuickOpen *m_quickOpen = nullptr;
/**
* quick command bar to quickly trigger any action
*/
......@@ -632,7 +625,6 @@ public Q_SLOTS:
protected:
bool event(QEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void resizeEvent(QResizeEvent *event) override;
};
#endif
......@@ -268,6 +268,9 @@ KateQuickOpen::KateQuickOpen(KateMainWindow *mainWindow)
// restore settings
slotfilterModeChanged(m_inputLine->filterMode());
slotListModeChanged(m_inputLine->listMode());
// fill stuff
update();
}
KateQuickOpen::~KateQuickOpen()
......@@ -366,29 +369,17 @@ void KateQuickOpen::slotListModeChanged(KateQuickOpenModel::List mode)
void KateQuickOpen::updateViewGeometry()
{
const QSize centralSize = m_mainWindow->size();
const QSize centralSize = parentWidget()->size();
// width: 2.4 of editor, height: 1/2 of editor
const QSize viewMaxSize(centralSize.width() / 2.4, centralSize.height() / 2);
const int rowHeight = m_listView->sizeHintForRow(0) == -1 ? 0 : m_listView->sizeHintForRow(0);
const int width = viewMaxSize.width();
const QSize viewSize(std::max(300, width), // never go below this
std::min(std::max(rowHeight * m_base_model->rowCount() + 2, rowHeight * 6), viewMaxSize.height()));
// Position should be central over window
const int xPos = std::max(0, (centralSize.width() - viewSize.width()) / 2);
const int yPos = std::max(0, (centralSize.height() - viewSize.height()) * 1 / 4);
const int xPos = std::max(0, (centralSize.width() - viewMaxSize.width()) / 2);
const int yPos = std::max(0, (centralSize.height() - viewMaxSize.height()) * 1 / 4);
// fix position and size
const QPoint p(xPos, yPos);
move(p + m_mainWindow->pos());
QPropertyAnimation *animation = new QPropertyAnimation(this, "size");
animation->setDuration(150);
animation->setStartValue(this->size());
animation->setEndValue(viewSize);
animation->start(QAbstractAnimation::DeleteWhenStopped);
move(p + parentWidget()->pos());
setFixedSize(viewMaxSize);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment