Commit 966746cf authored by kaniini's avatar kaniini

split out onboarding to a separate window

parent 22ae752d
......@@ -27,6 +27,7 @@ michabo_ui_sources = [
'ui/mainwindow.cc',
'ui/notificationimpl.cc',
'ui/onboardingwidget.cc',
'ui/onboardingwindow.cc',
'ui/preferenceswindow.cc',
'ui/threadwindow.cc',
'ui/timelineselectorwidget.cc',
......
#include "mainwindow.h"
#include "onboardingwindow.h"
#include "notificationimpl.h"
#include "core/account.h"
#include "core/accountmanager.h"
......@@ -24,8 +25,13 @@ int main(int argc, char *argv[])
NotificationImpl notifications;
QObject::connect(&manager, &Michabo::AccountManager::notification, &notifications, &NotificationImpl::showNotification);
MainWindow w (nullptr, &manager);
w.show();
MainWindow mainwin (nullptr, &manager);
OnboardingWindow onboardwin (nullptr, &manager, &mainwin);
if (manager.hasAccounts())
mainwin.show();
else
onboardwin.show();
return a.exec();
}
......@@ -3,7 +3,6 @@
#include "core/account.h"
#include "mainwindow.h"
#include "onboardingwidget.h"
#include "composeform.h"
#include "iconutils.h"
#include "preferenceswindow.h"
......@@ -13,9 +12,6 @@ MainWindow::MainWindow(QWidget *parent,
: QMainWindow(parent),
m_main_container(new QWidget()),
m_main_layout(new QVBoxLayout(m_main_container)),
m_onboarding_container(new QWidget()),
m_onboarding_layout(new QVBoxLayout(m_onboarding_container)),
m_onboarding_widget(new OnboardingWidget(manager, m_main_container)),
m_identity_widget(new IdentityWidget(manager, m_main_container)),
m_timeline_selector_widget(new TimelineSelectorWidget(manager, m_main_container)),
m_toolbar(new QToolBar(m_main_container)),
......@@ -27,9 +23,6 @@ MainWindow::MainWindow(QWidget *parent,
m_about_window(new AboutWindow()),
m_account_manager(manager)
{
// onboarding layout
m_onboarding_layout->addWidget(m_onboarding_widget);
// main layout
m_main_layout->setContentsMargins(0, 0, 0, 0);
m_main_layout->addWidget(m_identity_widget);
......@@ -89,10 +82,6 @@ MainWindow::MainWindow(QWidget *parent,
m_toolbar->addWidget(m_prefs_button);
// layout selection
QObject::connect(m_account_manager, &Michabo::AccountManager::accountAdded, [=] () {
updateLayout();
});
QObject::connect(m_account_manager, &Michabo::AccountManager::fetchedInstanceMetadata, [=] (Michabo::Account *account) {
if (account != m_account_manager->selectedAccount())
return;
......@@ -103,7 +92,7 @@ MainWindow::MainWindow(QWidget *parent,
setInstanceName(account);
});
updateLayout();
setCentralWidget(m_main_container);
}
MainWindow::~MainWindow()
......@@ -111,22 +100,6 @@ MainWindow::~MainWindow()
}
void MainWindow::updateLayout()
{
if (! m_account_manager->hasAccounts())
{
qDebug() << "Using onboarding layout.";
setCentralWidget(m_onboarding_container);
return;
}
qDebug() << "Using main layout.";
setCentralWidget(m_main_container);
resize(300, 600);
}
void MainWindow::setInstanceName(Michabo::Account *account)
{
QString instance_name = account->instance_name();
......
......@@ -2,7 +2,6 @@
#define MAINWINDOW_H
#include "core/accountmanager.h"
#include "onboardingwidget.h"
#include "identitywidget.h"
#include "timelineselectorwidget.h"
#include "preferenceswindow.h"
......@@ -27,9 +26,6 @@ public:
private:
QWidget *m_main_container;
QVBoxLayout *m_main_layout;
QWidget *m_onboarding_container;
QVBoxLayout *m_onboarding_layout;
OnboardingWidget *m_onboarding_widget;
IdentityWidget *m_identity_widget;
TimelineSelectorWidget *m_timeline_selector_widget;
QToolBar *m_toolbar;
......@@ -41,7 +37,6 @@ private:
AboutWindow *m_about_window;
Michabo::AccountManager *m_account_manager;
void updateLayout();
void setInstanceName(Michabo::Account *account);
};
......
#include "onboardingwindow.h"
OnboardingWindow::OnboardingWindow (QWidget * parent, Michabo::AccountManager * manager, MainWindow * mainwin) :
QWidget (parent),
m_account_manager (manager),
m_main_window (mainwin),
m_onboarding_widget (new OnboardingWidget (m_account_manager, this)),
m_layout (new QVBoxLayout (this))
{
setWindowTitle("Michabo");
m_layout->addWidget(m_onboarding_widget);
QObject::connect(m_account_manager, &Michabo::AccountManager::accountAdded, [=] () {
hide();
m_main_window->show();
});
}
#ifndef UI_ONBOARDINGWINDOW_H
#define UI_ONBOARDINGWINDOW_H
#include "mainwindow.h"
#include "onboardingwidget.h"
class OnboardingWindow : public QWidget {
public:
OnboardingWindow (QWidget * parent = nullptr, Michabo::AccountManager * manager = nullptr, MainWindow * mainwin = nullptr);
private:
Michabo::AccountManager *m_account_manager;
MainWindow *m_main_window;
OnboardingWidget *m_onboarding_widget;
QVBoxLayout *m_layout;
};
#endif
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