Commit 59f61684 authored by kaniini's avatar kaniini

mainwindow: rework timeline widgets to be dock widgets

parent 61d22344
#include <QWidget>
#include <QButtonGroup>
#include <QDockWidget>
#include "core/account.h"
#include "mainwindow.h"
#include "composeform.h"
#include "iconutils.h"
#include "preferenceswindow.h"
#include "timelinewidget.h"
class TimelineContainerWidget : public QDockWidget {
public:
TimelineContainerWidget(QString timeline, Michabo::AccountManager *manager, QWidget * parent = nullptr);
private:
Michabo::AccountManager *m_manager;
Michabo::Account *m_account;
TimelineModel *m_timeline_model;
TimelineWidget *m_timeline;
};
TimelineContainerWidget::TimelineContainerWidget(QString timeline, Michabo::AccountManager *manager, QWidget *parent) :
QDockWidget (parent),
m_manager (manager),
m_timeline_model (new TimelineModel(m_manager, timeline)),
m_timeline (new TimelineWidget (m_manager, timeline, m_timeline_model))
{
setWindowTitle(timeline);
setWidget(m_timeline);
}
MainWindow::MainWindow(QWidget *parent,
Michabo::AccountManager *manager)
: QMainWindow(parent),
m_main_container(new QWidget()),
m_main_layout(new QVBoxLayout(m_main_container)),
m_identity_widget(new IdentityWidget(manager, m_main_container)),
m_timeline_selector_widget(new TimelineSelectorWidget(manager, m_main_container)),
//m_identity_widget(new IdentityWidget(manager, m_main_container)),
m_toolbar(new QToolBar(m_main_container)),
m_compose_button(new QToolButton(m_toolbar)),
m_refresh_button(new QToolButton(m_toolbar)),
......@@ -25,10 +47,10 @@ MainWindow::MainWindow(QWidget *parent,
{
// main layout
m_main_layout->setContentsMargins(0, 0, 0, 0);
m_main_layout->addWidget(m_identity_widget);
m_main_layout->addWidget(m_timeline_selector_widget);
//m_main_layout->addWidget(m_identity_widget);
addToolBar(Qt::BottomToolBarArea, m_toolbar);
setDockNestingEnabled(true);
// compose button
m_compose_button->setIcon(pixmap_from_theme (palette (), "michabo-action-compose",
......@@ -93,7 +115,19 @@ MainWindow::MainWindow(QWidget *parent,
setInstanceName(account);
});
// for now, generate three timeline containers
auto home_tl = new TimelineContainerWidget("home", m_account_manager);
addDockWidget(Qt::LeftDockWidgetArea, home_tl);
auto local_tl = new TimelineContainerWidget("public", m_account_manager);
addDockWidget(Qt::LeftDockWidgetArea, local_tl);
auto federated_tl = new TimelineContainerWidget("federated", m_account_manager);
addDockWidget(Qt::LeftDockWidgetArea, federated_tl);
// dummy widget to make Qt happy
setCentralWidget(m_main_container);
m_main_container->hide();
}
MainWindow::~MainWindow()
......
......@@ -26,8 +26,7 @@ public:
private:
QWidget *m_main_container;
QVBoxLayout *m_main_layout;
IdentityWidget *m_identity_widget;
TimelineSelectorWidget *m_timeline_selector_widget;
//IdentityWidget *m_identity_widget;
QToolBar *m_toolbar;
QToolButton *m_compose_button;
QToolButton *m_refresh_button;
......
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