File indexing completed on 2024-05-05 16:38:59
0001 /* This file is part of the KDE project 0002 Copyright (C) 1998-2002 Carsten Pfeiffer <pfeiffer@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License as published by the Free Software Foundation, version 2. 0007 0008 This program is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 General Public License for more details. 0012 0013 You should have received a copy of the GNU General Public License 0014 along with this program; see the file COPYING. If not, write to 0015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0016 Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #include "aboutwidget.h" 0020 #include <ui_aboutwidget.h> 0021 0022 #include <KWindowSystem> 0023 0024 #include <QDateTime> 0025 #include <QMouseEvent> 0026 #include <QPixmap> 0027 #include <QStandardPaths> 0028 0029 #include "version.h" 0030 0031 0032 AboutWidget::AboutWidget( QWidget *parent ) 0033 : QFrame( parent ) 0034 { 0035 // setup the widget based on its .ui file 0036 ui = new Ui::AboutWidget; 0037 ui->setupUi(this); 0038 0039 0040 // now the properties that couldn't be set in the .ui file 0041 0042 // KDE specific settings for "window" display (it's just a frame, not a real window) 0043 KWindowSystem::setType(winId(), NET::Override); 0044 KWindowSystem::setState(winId(), NET::KeepAbove | NET::SkipTaskbar); 0045 0046 // these settings are difficult to set in designer 0047 QPalette whitePalette((QColor(Qt::white))); 0048 setPalette(whitePalette); 0049 ui->groupBox->setPalette(whitePalette); 0050 ui->groupBox->setBackgroundRole(QPalette::Window); 0051 0052 // fill the labels 0053 ui->lblAuthors->setText("Kuickshow " KUICKSHOWVERSION " was brought to you by"); 0054 ui->urlHomepage->setText("Carsten Pfeiffer"); 0055 ui->urlHomepage->setUrl(HOMEPAGE_URL); 0056 ui->lblCopyright->setText("(C) 1998-2009"); 0057 0058 // load & show the logo 0059 int hour = QTime::currentTime().hour(); 0060 QString file; 0061 0062 if ( hour >= 10 && hour < 16 ) 0063 file = QStandardPaths::locate(QStandardPaths::AppDataLocation, "pics/kuickshow-day.jpg"); 0064 else 0065 file = QStandardPaths::locate(QStandardPaths::AppDataLocation, "pics/kuickshow-night.jpg"); 0066 0067 QPixmap image; 0068 if(image.load(file)) { 0069 ui->picLogo->setPixmap(image); 0070 } else { 0071 qWarning("KuickShow: about-image not found/unreadable."); 0072 } 0073 } 0074 0075 AboutWidget::~AboutWidget() 0076 { 0077 delete ui; 0078 } 0079 0080 0081 void AboutWidget::mouseReleaseEvent(QMouseEvent* event) 0082 { 0083 // Clicking anywhere on the frame except for the URL widget removes it. 0084 // Note: This only works as intended if the frame is displayed as a window. If it is used in another window's 0085 // layout, it'll just remove itself from that window (and probably mess up the layout in the process). 0086 if(!ui->urlHomepage->geometry().contains(event->pos())) 0087 deleteLater(); 0088 }