File indexing completed on 2024-04-28 04:55:39
0001 /* 0002 This file is part of Choqok, the KDE micro-blogging client 0003 0004 SPDX-FileCopyrightText: 2008-2012 Mehrdad Momeny <mehrdad.momeny@gmail.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0007 */ 0008 0009 #include "choqokmainwindow.h" 0010 0011 #include <QStatusBar> 0012 #include <QTabWidget> 0013 0014 #include "choqokbehaviorsettings.h" 0015 #include "libchoqokdebug.h" 0016 #include "microblogwidget.h" 0017 0018 #ifdef QTINDICATE_BUILD 0019 #include "indicatormanager.h" 0020 #endif 0021 0022 using namespace Choqok::UI; 0023 0024 static const int TIMEOUT = 5000; 0025 0026 Choqok::UI::MainWindow::MainWindow() 0027 : KXmlGuiWindow() 0028 { 0029 mainWidget = new QTabWidget(this); 0030 mainWidget->setDocumentMode(true); 0031 mainWidget->setMovable(true); 0032 #ifdef QTINDICATE_BUILD 0033 Choqok::MessageIndicatorManager::self(); 0034 #endif 0035 } 0036 0037 Choqok::UI::MainWindow::~MainWindow() 0038 { 0039 0040 } 0041 0042 QSize MainWindow::sizeHint() const 0043 { 0044 return QSize(350, 400); 0045 } 0046 0047 void MainWindow::showStatusMessage(const QString &message, bool isPermanent) 0048 { 0049 if (isPermanent) { 0050 statusBar()->showMessage(message); 0051 } else { 0052 statusBar()->showMessage(message, TIMEOUT); 0053 } 0054 } 0055 0056 void MainWindow::hideEvent(QHideEvent *event) 0057 { 0058 Q_UNUSED(event); 0059 if (!this->isVisible()) { 0060 qCDebug(CHOQOK); 0061 if (Choqok::BehaviorSettings::markAllAsReadOnHideToSystray()) { 0062 Q_EMIT markAllAsRead(); 0063 } 0064 Q_EMIT removeOldPosts(); 0065 } 0066 } 0067 0068 Choqok::UI::MicroBlogWidget *MainWindow::currentMicroBlog() 0069 { 0070 return qobject_cast<Choqok::UI::MicroBlogWidget *>(mainWidget->currentWidget()); 0071 } 0072 0073 void Choqok::UI::MainWindow::activateChoqok() 0074 { 0075 showNormal(); 0076 activateWindow(); 0077 raise(); 0078 } 0079 0080 QList<Choqok::UI::MicroBlogWidget *> Choqok::UI::MainWindow::microBlogsWidgetsList() 0081 { 0082 QList<Choqok::UI::MicroBlogWidget *> lst; 0083 if (mainWidget->currentWidget()) 0084 for (int i = 0; i < mainWidget->count(); i++) { 0085 lst.append(qobject_cast<Choqok::UI::MicroBlogWidget *>(mainWidget->widget(i))); 0086 } 0087 return lst; 0088 } 0089 0090 void Choqok::UI::MainWindow::activateTab(int k) 0091 { 0092 if (mainWidget->count() >= k) { 0093 mainWidget->setCurrentIndex(k); 0094 } 0095 } 0096 0097 #include "moc_choqokmainwindow.cpp"