Commit b7a21fa1 authored by Eric Armbruster's avatar Eric Armbruster 🍁
Browse files

Remove additional welcomeview

parent 2cda9f65
/*
SPDX-FileCopyrightText: 2022 Christoph Cullmann <cullmann@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "katewelcomeview.h"
#include "katemainwindow.h"
#include "kateviewmanager.h"
#include "kateviewspace.h"
#include <QPushButton>
#include <QTimer>
KateWelcomeView::KateWelcomeView()
{
// setup ui & ensure proper title for tab & co.
m_ui.setupUi(this);
setWindowTitle(i18n("Welcome"));
// new file action, view manager will trigger close of the welcome view
m_ui.fileNew->setText(i18n("New File"));
m_ui.fileNew->setIcon(QIcon::fromTheme(QStringLiteral("file-new")));
connect(m_ui.fileNew, &QPushButton::clicked, this, [this]() {
// we ensure that we use the current view space
viewSpace()->viewManager()->slotDocumentNew();
});
// open file action, view manager will trigger close of the welcome view
m_ui.fileOpen->setText(i18n("Open File..."));
m_ui.fileOpen->setIcon(QIcon::fromTheme(QStringLiteral("file-open")));
connect(m_ui.fileOpen, &QPushButton::clicked, this, [this]() {
// we ensure that we use the current view space
viewSpace()->viewManager()->slotDocumentOpen();
});
}
KateViewSpace *KateWelcomeView::viewSpace()
{
// this view can be re-parented, search upwards the current view space
auto p = parent();
while (p) {
if (auto vs = qobject_cast<KateViewSpace *>(p)) {
return vs;
}
p = p->parent();
}
Q_ASSERT(false);
return nullptr;
}
/*
SPDX-FileCopyrightText: 2022 Christoph Cullmann <cullmann@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include "ui_welcome.h"
class KateViewSpace;
/**
* Placeholder if a view space has no real views.
* Allows for a nice welcome experience :P
* The KateViewManager will ensure we instantiate the welcome view when needed and remove it later on.
*/
class KateWelcomeView : public QWidget
{
Q_OBJECT
public:
/**
* Construct new output, we do that once per main window
*/
KateWelcomeView();
public Q_SLOTS:
/**
* Welcome view can always be closed.
* @return can always be closed
*/
bool shouldClose()
{
return true;
}
private:
/**
* Get the view space we belong to.
* As we can in principle be dragged around.
* @return view space we belong to
*/
KateViewSpace *viewSpace();
private:
// designer UI for this widget
Ui::WelcomeViewWidget m_ui;
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WelcomeViewWidget</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>990</width>
<height>593</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Kate - KDE Advance Text Editor</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Start</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="fileNew">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="fileOpen">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Recent</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Supports Markdown
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