1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
/********************************************************************
* Copyright (C) 2005, 2006 Piotr Pszczolkowski
*-------------------------------------------------------------------
* This file is part of BSCommander (Beesoft Commander).
*
* BsC is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* BsC 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BsC; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************/
/*------- include files:
-------------------------------------------------------------------*/
#include "About.h"
#include "Shared.h"
#include "Busy.h"
#include "Config.h"
#include <qfile.h>
#include <qlabel.h>
#include <qtabbar.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qtextstream.h>
#include <qapplication.h>
#include <qwidgetstack.h>
#include <qtextbrowser.h>
#include <qdesktopwidget.h>
/*------- local constants:
-------------------------------------------------------------------*/
const QString About::CAPTION = QT_TR_NOOP( "About Beesoft Commander" );
const QString About::TAB_ABOUT_LABEL = QT_TR_NOOP( "&About" );
const QString About::TAB_AUTHORS_LABEL = QT_TR_NOOP( "A&uthors" );
const QString About::TAB_LICENCE_LABEL = QT_TR_NOOP( "&Licence agreement" );
const QString About::ABOUT[] = {
Shared::ProgramName + ", ver." + Shared::ProgramVersion,
"(c) 2005, 2006 Piotr Pszczolkowski",
"www.beesoft.org/bsc.html"
};
const QString About::AUTHORS [] = {
QT_TR_NOOP( "<b><font color=blue>Project home page: www.beesoft.org</font></b>" ),
"\n",
QT_TR_NOOP( "<b>Piotr Pszczolkowski - piotr@beesoft.org</b>" ),
QT_TR_NOOP( "\tProject administrator" ),
QT_TR_NOOP( "\tProgramming" ),
" ",
QT_TR_NOOP( "<b>Translators:<b>" ),
"\tJan Petrik (Czech Republic - Czech translation)",
"\tAlexey V. Schentzev (AShen) (Novorossiysk, Russia - Russian translation)",
"\tJavier Gutierrez Canas (Spain - Spanish translation)",
};
//*******************************************************************
// About
//*******************************************************************
About::About( QWidget* const parent )
: QDialog ( parent )
, d_return_button( new QPushButton( tr(Shared::CloseBtnLabel), this ))
, d_widget_stack ( new QWidgetStack( this ))
, d_tab_bar ( new QTabBar( this ))
{
setCaption( CAPTION );
setFont( Config::instance()->lfs_default_font() );
QVBoxLayout* const main_layout = new QVBoxLayout( this );
if( main_layout ) {
main_layout->setMargin( Shared::LayoutMargin );
main_layout->setSpacing( Shared::LayoutSpacing );
QLabel* const label = new QLabel( "<h1><font color= red>" + Shared::ProgramName + "</font></h1>", this );
if( label ) {
label->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
main_layout->addWidget( label );
}
/* Srodkowa czesc dialogu zawierajaca informacje o programie. */
QVBoxLayout* const info_layout = new QVBoxLayout;
if( info_layout ) {
main_layout->addLayout( info_layout );
main_layout->setStretchFactor( info_layout, Shared::OverStretch );
d_tab_bar->setShape( QTabBar::TriangularAbove );
d_tab_bar->addTab( new QTab( tr(TAB_ABOUT_LABEL) ));
d_tab_bar->addTab( new QTab( tr(TAB_AUTHORS_LABEL) ));
d_tab_bar->addTab( new QTab( tr(TAB_LICENCE_LABEL) ));
connect( d_tab_bar, SIGNAL( selected( int ) ), this, SLOT( set_current_tab( int )));
info_layout->addWidget( d_tab_bar );
QTextBrowser* const about_browser = new QTextBrowser( this );
set_about_text( about_browser );
d_widget_stack->addWidget( about_browser, 0 );
QTextBrowser* const authors_browser = new QTextBrowser( this );
set_authors_text( authors_browser );
d_widget_stack->addWidget( authors_browser, 1 );
QTextBrowser* const licence_browser = new QTextBrowser( this );
set_licence_text( licence_browser );
d_widget_stack->addWidget( licence_browser, 2 );
info_layout->addWidget( d_widget_stack );
}
/* Dolna czesc dialogu zawierajaca po prawej stronie */
/* przycisk konczacy prace. */
QHBoxLayout* const button_layout = new QHBoxLayout;
if( button_layout ) {
main_layout->addLayout( button_layout );
button_layout->addStretch( Shared::OverStretch );
button_layout->addWidget( d_return_button );
Shared::add_icon( d_return_button, Shared::CloseIcon );
connect( d_return_button, SIGNAL( clicked() ), this, SLOT( accept() ));
}
}
}
// end of About
//*******************************************************************
// set_about_text PRIVATE
//*******************************************************************
void About::set_about_text( QTextBrowser* const browser )
{
const int N = sizeof( ABOUT ) / sizeof( ABOUT[0] );
for( int i = 0; i < N; ++i ) {
browser->append( tr(ABOUT[i]) );
}
}
// end of set_about_text
//*******************************************************************
// set_authors_text PRIVATE
//*******************************************************************
void About::set_authors_text( QTextBrowser* const browser )
{
const int N = sizeof( AUTHORS ) / sizeof( AUTHORS[0] );
for( int i = 0; i < N; ++i ) {
browser->append( tr(AUTHORS[i]) );
}
}
// end of set_authors_text
//*******************************************************************
// set_licence_text PRIVATE
//*******************************************************************
void About::set_licence_text( QTextBrowser* const browser )
{
QString location = qApp->applicationDirPath();
if( "/usr/bin" == location ) {
location = "/usr/share/bsc";
}
QFile file( location + "/" + Shared::LicenceFileName );
if( TRUE == file.open( IO_ReadOnly )) {
QTextStream ts( &file );
Busy::set_busy( TRUE );
browser->setText( ts.read() );
Busy::set_busy( FALSE );
file.close();
}
}
// end of set_licence_text
//*******************************************************************
// set_current_tab PRIVATE slot
//*******************************************************************
void About::set_current_tab( const int idx )
{
d_widget_stack->raiseWidget( idx );
}
// end of set_current_tab
//*******************************************************************
// polish PRIVATE
//*******************************************************************
void About::polish()
{
Shared::polish( this, 40, 30 );
}
// end of polish
|