128 lines
3.7 KiB
C++
128 lines
3.7 KiB
C++
/* This file is part of FediPotato.
|
|
* Copyright © 2020 tastytea <tastytea@tastytea.de>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, version 3.
|
|
*
|
|
* This program 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 Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "window_main.hpp"
|
|
#include "channel.hpp"
|
|
#include "dialog_about.hpp"
|
|
|
|
#include <QDesktopServices>
|
|
#include <QUrl>
|
|
#include <QStandardItem>
|
|
#include <QFont>
|
|
#include <QDebug>
|
|
|
|
namespace FediPotato
|
|
{
|
|
|
|
MainWindow::MainWindow(QMainWindow *parent)
|
|
: QMainWindow(parent)
|
|
, _model_channel(new QStandardItemModel(this))
|
|
{
|
|
setupUi(this);
|
|
|
|
add_account();
|
|
}
|
|
|
|
void MainWindow::add_account()
|
|
{
|
|
QStandardItem *item_root{_model_channel->invisibleRootItem()};
|
|
auto *item_account{new ChannelItem("@user@example.com", id_channel::none)};
|
|
item_root->appendRow(item_account);
|
|
|
|
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
|
item_account->appendRow(new ChannelItem("Home Timeline",
|
|
id_channel::tl_home));
|
|
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
|
item_account->appendRow(new ChannelItem("Instance Timeline",
|
|
id_channel::tl_instance));
|
|
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
|
item_account->appendRow(new ChannelItem("Federated Timeline",
|
|
id_channel::tl_federated));
|
|
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
|
item_account->appendRow(new ChannelItem("Conversations",
|
|
id_channel::conversations));
|
|
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
|
item_account->appendRow(new ChannelItem("#tea",
|
|
id_channel::hashtag));
|
|
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
|
item_account->appendRow(new ChannelItem("#FediPotato",
|
|
id_channel::hashtag));
|
|
|
|
treeview_channel->setModel(_model_channel);
|
|
treeview_channel->expandAll();
|
|
|
|
QFont font_channel{treeview_channel->font()};
|
|
font_channel.setPointSize(font_channel.pointSize() + 2);
|
|
treeview_channel->setFont(font_channel);
|
|
}
|
|
|
|
void MainWindow::show_about()
|
|
{
|
|
auto *dlg{new AboutDialog()}; // NOLINT(cppcoreguidelines-owning-memory)
|
|
dlg->show();
|
|
}
|
|
|
|
void MainWindow::open_website()
|
|
{
|
|
QDesktopServices::openUrl(QUrl("http://fedipotato.org/"));
|
|
}
|
|
|
|
void MainWindow::clicked_channel(const QModelIndex &index)
|
|
{
|
|
auto item{dynamic_cast<ChannelItem*>(_model_channel->itemFromIndex(index))};
|
|
|
|
switch (item->identifier())
|
|
{
|
|
case id_channel::none:
|
|
{
|
|
qDebug() << "None.";
|
|
break;
|
|
}
|
|
case id_channel::tl_home:
|
|
{
|
|
qDebug() << "Home TL.";
|
|
break;
|
|
}
|
|
case id_channel::tl_instance:
|
|
{
|
|
qDebug() << "Instance TL.";
|
|
break;
|
|
}
|
|
case id_channel::tl_federated:
|
|
{
|
|
qDebug() << "Federated TL.";
|
|
break;
|
|
}
|
|
case id_channel::conversations:
|
|
{
|
|
qDebug() << "Conversations.";
|
|
break;
|
|
}
|
|
case id_channel::hashtag:
|
|
{
|
|
qDebug() << "Hashtag.";
|
|
break;
|
|
}
|
|
case id_channel::filter:
|
|
{
|
|
qDebug() << "Filter.";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace FediPotato
|