-
Notifications
You must be signed in to change notification settings - Fork 796
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(browser,sidebar,ui): implement real tabs (#1081)
Adds actual independent tabs instead of swapping sidebar and webview.
- Loading branch information
Showing
26 changed files
with
1,439 additions
and
628 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
add_subdirectory(browser) | ||
add_subdirectory(core) | ||
add_subdirectory(registry) | ||
add_subdirectory(sidebar) | ||
add_subdirectory(ui) | ||
add_subdirectory(util) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
add_library(Sidebar | ||
container.cpp | ||
proxyview.cpp | ||
view.cpp | ||
viewprovider.cpp | ||
) | ||
|
||
target_link_libraries(Sidebar) | ||
|
||
find_package(Qt5 COMPONENTS Widgets REQUIRED) | ||
target_link_libraries(Sidebar Qt5::Widgets) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2019 Oleg Shparber | ||
** Contact: https://go.zealdocs.org/l/contact | ||
** | ||
** This file is part of Zeal. | ||
** | ||
** Zeal is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Zeal is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Zeal. If not, see <https://www.gnu.org/licenses/>. | ||
** | ||
****************************************************************************/ | ||
|
||
#include "container.h" | ||
|
||
#include "view.h" | ||
|
||
#include <core/application.h> | ||
#include <core/settings.h> | ||
#include <ui/widgets/layouthelper.h> | ||
|
||
#include <QLabel> | ||
#include <QSplitter> | ||
#include <QVBoxLayout> | ||
|
||
#include <type_traits> | ||
|
||
using namespace Zeal; | ||
using namespace Zeal::Sidebar; | ||
|
||
Container::Container(QWidget *parent) | ||
: QWidget(parent) | ||
{ | ||
setMinimumWidth(150); | ||
|
||
// Setup splitter. | ||
m_splitter = new QSplitter(); | ||
m_splitter->setOrientation(Qt::Vertical); | ||
connect(m_splitter, &QSplitter::splitterMoved, this, [this]() { | ||
Core::Application::instance()->settings()->tocSplitterState = m_splitter->saveState(); | ||
}); | ||
|
||
// Setup main layout. | ||
auto layout = WidgetUi::LayoutHelper::createBorderlessLayout<QVBoxLayout>(); | ||
layout->addWidget(m_splitter); | ||
setLayout(layout); | ||
} | ||
|
||
Container::~Container() | ||
{ | ||
|
||
} | ||
|
||
void Container::addView(View *view) | ||
{ | ||
if (m_views.contains(view)) | ||
return; | ||
|
||
m_views.append(view); | ||
m_splitter->addWidget(view); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2019 Oleg Shparber | ||
** Contact: https://go.zealdocs.org/l/contact | ||
** | ||
** This file is part of Zeal. | ||
** | ||
** Zeal is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Zeal is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Zeal. If not, see <https://www.gnu.org/licenses/>. | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef ZEAL_SIDEBAR_CONTAINER_H | ||
#define ZEAL_SIDEBAR_CONTAINER_H | ||
|
||
#include <QWidget> | ||
|
||
class QSplitter; | ||
|
||
namespace Zeal { | ||
namespace Sidebar { | ||
|
||
class View; | ||
|
||
// TODO: Implement view groups (alt. naming: tabs, pages) (move splitter into a group?). | ||
class Container : public QWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit Container(QWidget *parent = nullptr); | ||
~Container() override; | ||
|
||
void addView(View *view); | ||
|
||
public slots: | ||
|
||
signals: | ||
|
||
private: | ||
Q_DISABLE_COPY(Container) | ||
|
||
QSplitter *m_splitter = nullptr; | ||
|
||
QList<View *> m_views; | ||
}; | ||
|
||
} // namespace Sidebar | ||
} // namespace Zeal | ||
|
||
#endif // ZEAL_SIDEBAR_CONTAINER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2019 Oleg Shparber | ||
** Contact: https://go.zealdocs.org/l/contact | ||
** | ||
** This file is part of Zeal. | ||
** | ||
** Zeal is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Zeal is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Zeal. If not, see <https://www.gnu.org/licenses/>. | ||
** | ||
****************************************************************************/ | ||
|
||
#include "proxyview.h" | ||
|
||
#include "viewprovider.h" | ||
|
||
#include <ui/widgets/layouthelper.h> | ||
|
||
#include <QVBoxLayout> | ||
|
||
using namespace Zeal; | ||
using namespace Zeal::Sidebar; | ||
|
||
ProxyView::ProxyView(ViewProvider *provider, const QString &id, QWidget *parent) | ||
: View(parent) | ||
, m_viewProvider(provider) | ||
, m_viewId(id) | ||
{ | ||
setLayout(WidgetUi::LayoutHelper::createBorderlessLayout<QVBoxLayout>()); | ||
|
||
connect(m_viewProvider, &ViewProvider::viewChanged, this, [this]() { | ||
auto view = m_viewProvider->view(m_viewId); | ||
if (view == nullptr) { | ||
qWarning("ViewProvider returned invalid view!"); | ||
return; | ||
} | ||
|
||
if (m_view == view) | ||
return; | ||
|
||
clearCurrentView(); | ||
layout()->addWidget(view); | ||
view->show(); | ||
m_view = view; | ||
}); | ||
} | ||
|
||
ProxyView::~ProxyView() | ||
{ | ||
clearCurrentView(); | ||
} | ||
|
||
void ProxyView::clearCurrentView() | ||
{ | ||
// Unparent the view, because we don't own it. | ||
QLayout *l = layout(); | ||
if (l->isEmpty()) | ||
return; | ||
|
||
m_view->hide(); | ||
l->removeWidget(m_view); | ||
m_view->setParent(nullptr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2019 Oleg Shparber | ||
** Contact: https://go.zealdocs.org/l/contact | ||
** | ||
** This file is part of Zeal. | ||
** | ||
** Zeal is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Zeal is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Zeal. If not, see <https://www.gnu.org/licenses/>. | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef ZEAL_SIDEBAR_PROXYVIEW_H | ||
#define ZEAL_SIDEBAR_PROXYVIEW_H | ||
|
||
#include "view.h" | ||
|
||
namespace Zeal { | ||
namespace Sidebar { | ||
|
||
class ViewProvider; | ||
|
||
class ProxyView final : public View | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit ProxyView(ViewProvider *provider, const QString &id = QString(), QWidget *parent = nullptr); | ||
~ProxyView() override; | ||
|
||
private: | ||
Q_DISABLE_COPY(ProxyView) | ||
|
||
void clearCurrentView(); | ||
|
||
ViewProvider *m_viewProvider = nullptr; | ||
QString m_viewId; | ||
|
||
View *m_view = nullptr; | ||
}; | ||
|
||
} // namespace Sidebar | ||
} // namespace Zeal | ||
|
||
#endif // ZEAL_SIDEBAR_PROXYVIEW_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2019 Oleg Shparber | ||
** Contact: https://go.zealdocs.org/l/contact | ||
** | ||
** This file is part of Zeal. | ||
** | ||
** Zeal is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Zeal is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Zeal. If not, see <https://www.gnu.org/licenses/>. | ||
** | ||
****************************************************************************/ | ||
|
||
#include "view.h" | ||
|
||
using namespace Zeal::Sidebar; | ||
|
||
View::View(QWidget *parent) | ||
: QWidget(parent) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2019 Oleg Shparber | ||
** Contact: https://go.zealdocs.org/l/contact | ||
** | ||
** This file is part of Zeal. | ||
** | ||
** Zeal is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Zeal is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Zeal. If not, see <https://www.gnu.org/licenses/>. | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef ZEAL_SIDEBAR_VIEW_H | ||
#define ZEAL_SIDEBAR_VIEW_H | ||
|
||
#include <QWidget> | ||
|
||
namespace Zeal { | ||
namespace Sidebar { | ||
|
||
class View : public QWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit View(QWidget *parent = nullptr); | ||
|
||
private: | ||
Q_DISABLE_COPY(View) | ||
}; | ||
|
||
} // namespace Sidebar | ||
} // namespace Zeal | ||
|
||
#endif // ZEAL_SIDEBAR_VIEW_H |
Oops, something went wrong.