Commit 410b1fbc authored by Eugene Popov's avatar Eugene Popov 🇺🇦 Committed by Christoph Cullmann
Browse files

[WelcomeView] Add help panel

This MR adds some useful content to the welcome screen:
* link to home page
* link to information about the application
* link on how to join the development
* link to handbook

Also, if the window isn't wide enough to fit this panel, then it's hidden (i.e. the UI is still responsive).
parent 6366362e
Pipeline #250197 passed with stage
in 25 minutes and 38 seconds
......@@ -21,7 +21,7 @@
#include <KIO/OpenFileManagerWindowJob>
#include <QClipboard>
#include <QDir>
#include <QDesktopServices>
#include <QGraphicsOpacityEffect>
#include <QLabel>
#include <QMenu>
......@@ -92,6 +92,21 @@ WelcomeView::WelcomeView(KateViewManager *viewManager, QWidget *parent)
recentFilesAction->clear();
});
labelHomepage->setText(QStringLiteral("<a href='#'>%1</a>").arg(labelHomepage->text()));
connect(labelHomepage, &QLabel::linkActivated, this, [aboutData]() {
QDesktopServices::openUrl(QUrl(aboutData.homepage()));
});
labelContribute->setText(QStringLiteral("<a href='#'>%1</a>").arg(labelContribute->text()));
connect(labelContribute, &QLabel::linkActivated, this, []() {
QDesktopServices::openUrl(QUrl(QStringLiteral("https://kate-editor.org/join-us")));
});
labelHandbook->setText(QStringLiteral("<a href='#'>%1</a>").arg(labelHandbook->text()));
connect(labelHandbook, &QLabel::linkActivated, this, [this]() {
m_viewManager->mainWindow()->appHelpActivated();
});
onPluginViewChanged();
const KTextEditor::MainWindow *mainWindow = m_viewManager->mainWindow()->wrapper();
......@@ -260,6 +275,7 @@ void WelcomeView::updateFonts()
panelTitleFont.setPointSize(panelTitleFont.pointSize() + 2);
labelRecentItems->setFont(panelTitleFont);
labelSavedSessions->setFont(panelTitleFont);
labelHelp->setFont(panelTitleFont);
QFont placeholderFont = font();
placeholderFont.setPointSize(qRound(placeholderFont.pointSize() * 1.3));
......@@ -271,18 +287,38 @@ void WelcomeView::updateFonts()
bool WelcomeView::updateLayout()
{
// Align labelHelp with labelRecentFiles
labelHelp->setMinimumHeight(labelRecentItems->height());
bool result = false;
// show/hide widgetHeader depending on the view height
if (widgetHeader->isVisible()) {
if (height() <= frameContent->height()) {
widgetHeader->hide();
return true;
result = true;
}
} else {
if (height() > frameContent->height() + widgetHeader->height() + layoutContent->spacing()) {
const int implicitHeight = frameContent->height() + widgetHeader->height() + layoutContent->spacing();
if (height() > implicitHeight) {
widgetHeader->show();
result = true;
}
}
// show/hide widgetHelp depending on the view height
if (widgetHelp->isVisible()) {
if (width() <= frameContent->width()) {
widgetHelp->hide();
result = true;
}
} else {
const int implicitWidth = frameContent->width() + widgetHelp->width() + layoutPanels->horizontalSpacing();
if (width() > implicitWidth) {
widgetHelp->show();
return true;
}
}
return false;
return result;
}
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>796</width>
<width>1011</width>
<height>803</height>
</rect>
</property>
......@@ -27,7 +27,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>796</width>
<width>1011</width>
<height>803</height>
</rect>
</property>
......@@ -75,13 +75,7 @@
</item>
<item row="1" column="1">
<widget class="QFrame" name="frameContent">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="layoutContent">
<layout class="QVBoxLayout" name="layoutContent" stretch="0,1,0">
<property name="spacing">
<number>20</number>
</property>
......@@ -157,170 +151,245 @@
</widget>
</item>
<item>
<widget class="QWidget" name="widgetRecentItems" native="true">
<layout class="QGridLayout" name="layoutRecentItems" rowstretch="0,0,0,0,1" columnstretch="0,1,0">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>20</number>
</property>
<item row="1" column="0">
<widget class="QPushButton" name="buttonNewFile">
<property name="text">
<string>New File</string>
<layout class="QGridLayout" name="layoutPanels" rowstretch="1,0">
<property name="spacing">
<number>20</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="widgetRecentItems" native="true">
<layout class="QGridLayout" name="layoutRecentItems" rowstretch="0,0,0,0,1" columnstretch="0,1,0">
<property name="leftMargin">
<number>0</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="buttonOpenFolder">
<property name="text">
<string>Open Folder...</string>
<property name="topMargin">
<number>0</number>
</property>
</widget>
</item>
<item row="0" column="1" alignment="Qt::AlignBottom">
<widget class="QLabel" name="labelRecentItems">
<property name="text">
<string>Recent Documents</string>
<property name="rightMargin">
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="buttonOpenFile">
<property name="text">
<string>Open File...</string>
<property name="bottomMargin">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="4" colspan="2">
<widget class="QListView" name="listViewRecentFiles">
<property name="minimumSize">
<size>
<width>400</width>
<height>200</height>
</size>
<property name="horizontalSpacing">
<number>20</number>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
<item row="1" column="0">
<widget class="QPushButton" name="buttonNewFile">
<property name="text">
<string>New File</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="buttonOpenFolder">
<property name="text">
<string>Open Folder...</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelRecentItems">
<property name="text">
<string>Recent Files</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="buttonOpenFile">
<property name="text">
<string>Open File...</string>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="4" colspan="2">
<widget class="QListView" name="listViewRecentFiles">
<property name="minimumSize">
<size>
<width>400</width>
<height>200</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="spacer3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="buttonClearRecentFiles">
<property name="toolTip">
<string>Clear Recent Files</string>
</property>
<property name="icon">
<iconset theme="edit-clear-all">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1" rowspan="2">
<widget class="QWidget" name="widgetHelp" native="true">
<layout class="QVBoxLayout" name="layoutHelp" stretch="0,0,0,0,1">
<property name="leftMargin">
<number>0</number>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
<property name="topMargin">
<number>0</number>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
<property name="rightMargin">
<number>0</number>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="spacer3">
<property name="orientation">
<enum>Qt::Vertical</enum>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
<item>
<widget class="QLabel" name="labelHelp">
<property name="text">
<string>Help</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelHomepage">
<property name="text">
<string>Visit homepage</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelContribute">
<property name="text">
<string>Get involved</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelHandbook">
<property name="text">
<string>Read handbook</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer11">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QWidget" name="widgetSavedSessions" native="true">
<layout class="QGridLayout" name="layoutSavedSessions" rowstretch="0,0,0,1" columnstretch="0,1">
<property name="leftMargin">
<number>0</number>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="buttonClearRecentFiles">
<property name="toolTip">
<string>Clear Recent Files</string>
<property name="topMargin">
<number>0</number>
</property>
<property name="icon">
<iconset theme="edit-clear-all">
<normaloff>.</normaloff>.</iconset>
<property name="rightMargin">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widgetSavedSessions" native="true">
<layout class="QGridLayout" name="layoutSavedSessions" rowstretch="0,0,0,1" columnstretch="0,1">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>20</number>
</property>
<item row="0" column="1" alignment="Qt::AlignBottom">
<widget class="QLabel" name="labelSavedSessions">
<property name="text">
<string>Saved Sessions</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="buttonNewSession">
<property name="text">
<string>New Session</string>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="3">
<widget class="QListView" name="listViewSavedSessions">
<property name="minimumSize">
<size>
<width>0</width>
<height>200</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="buttonManageSessions">
<property name="text">
<string>Manage Sessions...</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="spacer8">
<property name="orientation">
<enum>Qt::Vertical</enum>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
<property name="horizontalSpacing">
<number>20</number>
</property>
</spacer>
</item>
</layout>
</widget>
<item row="0" column="1">
<widget class="QLabel" name="labelSavedSessions">
<property name="text">
<string>Saved Sessions</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="buttonNewSession">
<property name="text">
<string>New Session</string>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="3">
<widget class="QListView" name="listViewSavedSessions">
<property name="minimumSize">
<size>
<width>0</width>
<height>200</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="buttonManageSessions">
<property name="text">
<string>Manage Sessions...</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="spacer8">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widgetFooter" native="true">
......
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