From: Dmintriy L. Kruglikov Date: Sun, 29 Jun 2008 10:45:00 +0000 (+0300) Subject: New MessageWindow and StatusBar. X-Git-Url: https://gitweb.ananas.su/?a=commitdiff_plain;h=bddcc9708889fb7e1b7148ea62f623c97bdbb9c1;p=projects%2Fananas-labs.git New MessageWindow and StatusBar. --- diff --git a/src/ananas/ananasmainform.cpp b/src/ananas/ananasmainform.cpp index ba95cee..34ddce4 100644 --- a/src/ananas/ananasmainform.cpp +++ b/src/ananas/ananasmainform.cpp @@ -37,7 +37,7 @@ #include #include #include - +#include #include "ananasmainform.h" #include "ananas.h" @@ -68,26 +68,39 @@ MainForm::MainForm( QWidget* parent, const char* name, WFlags fl ) ws->setScrollBarsEnabled( TRUE ); setCentralWidget( vb ); statusBar()->setName("statusbar"); - + statusBar()->setSizeGripEnabled( FALSE ); statusLabel1 = new QLabel(" Status ", this); statusLabel1->setMinimumSize(statusLabel1->sizeHint()); - - statusLabel2 = new QLabel(tr(" Info1 "),this); + statusLabel1->setText(" "); + statusLabel2 = new QLabel(tr(" TA: 34.45.3214 "),this); statusLabel2->setAlignment(AlignHCenter); statusLabel2->setMinimumSize(statusLabel2->sizeHint()); - statusLabel3 = new QLabel(tr(" Info2 "), this); + statusLabel2->setText(" "); + statusLabel3 = new QLabel(tr(" BI: 35.65.3214 "), this); statusLabel3->setAlignment(AlignHCenter); statusLabel3->setMinimumSize(statusLabel3->sizeHint()); + statusLabel3->setText(" "); //statusLabel3->clear(); - statusLabel4 = new QLabel(tr(" Icon "), this); + statusLabel4 = new QLabel(tr("00"), this); statusLabel4->setMinimumSize(statusLabel4->sizeHint()); + statusLabel4->setText("0"); statusLabel4->setAlignment(AlignHCenter); - statusLabel4->setPixmap(rcIcon("ru.png")); + statpb = new QPushButton( " ", this ); + statpb->setToggleButton ( true ); + statpb->setDefault ( false ); + statpb->setMaximumWidth(22); + statpb->setMaximumHeight(22); + + connect(statpb , SIGNAL(toggled(bool)), this, SLOT(statpbToggled()) ); + statusBar()->addWidget(statpb, 0); + statpb->hide(); statusBar()->addWidget(statusLabel1, 1); statusBar()->addWidget(statusLabel2); statusBar()->addWidget(statusLabel3); statusBar()->addWidget(statusLabel4, 0, true); + statpb->setFocusPolicy(QWidget::NoFocus); + if ( !name ) setName( "mainwindow" ); engine_settings.insertSearchPath( QSettings::Unix, QString(QDir::homeDirPath())+QString("/.ananas")); engine_settings.insertSearchPath( QSettings::Windows, "/ananasgroup/ananas" ); @@ -112,9 +125,11 @@ MainForm::MainForm( QWidget* parent, const char* name, WFlags fl ) bool MainForm::init() { - MessagesWindow *msgWindow = new MessagesWindow( this );// , WDestructiveClose ); + msgWindow = new MessagesWindow( this );// , WDestructiveClose ); moveDockWindow( msgWindow, DockBottom ); setMessageHandler( true ); + msgWindow->setCloseMode(0); + msgWindow->setMovingEnabled(false); msgWindow->hide(); if ( !initEngine() ) return false; connect( menubar, SIGNAL(activated(int)), &engine, SLOT(on_MenuBar(int)) ); @@ -136,6 +151,7 @@ MainForm::initEngine() engine.wl = wl; connect( &engine, SIGNAL( statusMessage( const QString & ) ), this, SLOT( statusMessage( const QString & ) ) ); connect( &engine, SIGNAL( statusMessage( const QString &, const int & ) ), this, SLOT( statusMessage( const QString & , const int & ) ) ); + connect( &engine, SIGNAL(statusIcon( const int &) ), this, SLOT( statusIcon( const int & )) ); md = engine.md; if ( !md ) return false; @@ -158,7 +174,7 @@ MainForm::initMenuBar() lang->setCheckable( TRUE ); // TODO!!! Check *qm files and complit list - statusLabel3->setText(QString("%1\n").arg(QTextCodec::locale())); + //statusLabel3->setText(QString("%1\n").arg(QTextCodec::locale())); e_lang = lang->insertItem( tr("EN"), 0, 0); lang->setItemChecked( e_lang, true ); r_lang = lang->insertItem( tr("RU"), 1, 1); @@ -236,6 +252,33 @@ void MainForm::InsertMainMenu(QString text, QObject *pop){ menubar->insertItem(text, (QPopupMenu *) pop); } +void +MainForm::statusIcon( const int &status ) +{ + statpb->show(); + statpb->setOn(true); + switch ( status ) + { + case 0: + statpb->setPixmap(rcIcon("msg_info.png")); + break; + case 1: + statpb->setPixmap(rcIcon("msg_warning.png")); + break; + case 2: + statpb->setPixmap(rcIcon("msg_error.png")); + break; + case 3: + statpb->setPixmap(rcIcon("msg_fatal.png")); + break; + default: + statpb->setPixmap(rcIcon("msg_fatal.png")); + break; + } + QTimer::singleShot( 3000, this, SLOT(hideMsgWindow()) ); + statusLabel4->setText(QString("%1").arg(statusLabel4->text().toInt() + 1)); +} + void MainForm::Exit(int code) @@ -292,6 +335,13 @@ MainForm::statusMessage( const QString &msg ) void +MainForm::hideMsgWindow() +{ + msgWindow->hide(); + statpb->setOn(false); +} + +void MainForm::setBackground( const QPixmap &pix ){ ws->setBackgroundPixmap( pix ); } @@ -320,16 +370,25 @@ MainForm::~MainForm() */ void MainForm::languageChange() { - setCaption(QString( tr("Ananas")+" "+ananas_libversion() )+": "+md->info( md_info_name ) ); + setCaption(md->info( md_info_name )+": "+QString( tr("Ananas")+" "+ananas_libversion()) ); int i; for (i=0; i < menuBar()->count(); ++i) { menuBar()->changeItem(i, QString(tr(menuBar()->text(i)))); - } //menuBar()->changeItem(6, QString( tr("&Windows"))); -// setCaption( tr( "Ananas VERSION" ) ); +} + +void MainForm::statpbToggled() +{ + if (statpb->isOn() == true) + { + msgWindow->show(); + }else{ + //statusLabel4->setText( "0" ); + msgWindow->hide(); + } } void MainForm::windowsMenuAboutToShow() @@ -431,6 +490,7 @@ void MainForm::setLang( int lang_id ) lang->setItemChecked( 1, false ); lang->setItemChecked( 2, false ); a_lang = "en"; + statusLabel3->setText(QString("%1\n").arg(QTextCodec::locale())); } if (lang_id == 1) { @@ -458,7 +518,8 @@ void MainForm::setLang( int lang_id ) qApp->installTranslator( &tr_plugins ); languageChange(); - statusBar()->message( QString(tr("Ananas"))+ QString(tr(" : %1")).arg(lang->text(lang_id)), 2000 ); + statusLabel3->setText(a_lang.upper()); + //statusBar()->message( QString(tr("Ananas"))+ QString(tr(" : %1")).arg(lang->text(lang_id)), 2000 ); } /* diff --git a/src/ananas/ananasmainform.h b/src/ananas/ananasmainform.h index ee9a4b8..adf8bda 100644 --- a/src/ananas/ananasmainform.h +++ b/src/ananas/ananasmainform.h @@ -38,11 +38,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include "ananas.h" #include "amenubar.h" #include "atoolbar.h" @@ -89,6 +91,8 @@ public: QLabel *statusLabel2; QLabel *statusLabel3; QLabel *statusLabel4; + QPushButton *statpb; + MessagesWindow *msgWindow; public slots: bool init(); @@ -104,6 +108,7 @@ public slots: void ShowCalendar(); void statusMessage( const QString &msg, const int &pos ); void statusMessage( const QString &msg ); + void statusIcon( const int &status ); void windowsMenuAboutToShow(); void windowsMenuActivated( int id ); @@ -115,6 +120,8 @@ public slots: protected: protected slots: virtual void languageChange(); + virtual void statpbToggled(); + virtual void hideMsgWindow(); private: QSettings engine_settings; diff --git a/src/lib/messageswindow.cpp b/src/lib/messageswindow.cpp index fb513c1..0f72b1e 100644 --- a/src/lib/messageswindow.cpp +++ b/src/lib/messageswindow.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include "messageswindow.h" #include "acfg.h" @@ -57,13 +58,14 @@ MessagesWindow::MessagesWindow( QWidget* parent, WFlags fl ) msgBrowser = new QTextBrowser( this, "msgBrowser" ); boxLayout()->addWidget( msgBrowser ); languageChange(); - setMinimumSize( QSize( 1, 1 ) ); - msgBrowser->setMinimumSize( QSize( 1, 1 ) ); + setMinimumSize( QSize( 1, 100 ) ); + msgBrowser->setMinimumSize( QSize( 1, 100 ) ); clearWState( WState_Polished ); setResizeEnabled( TRUE ); setExpanded(false); setCloseMode( QDockWindow::Always ); msgBrowser->show(); + msgBrowser->setText(QTime::currentTime().toString()+". System started"); msgwindow = this; connect(msgBrowser, SIGNAL(doubleClicked(int,int)), this, SLOT(on_click())); cfg_messageproc=messageproc; @@ -82,13 +84,14 @@ void MessagesWindow::message( int msgtype, const QString &msg) { char st[4][50]={ - "", - "", - "", - ""}; + "", + "", + "", + ""}; if (msgtype<0) msgtype=0; if (msgtype>3) msgtype=3; - msgBrowser->append( tr( st[ msgtype ] )+msg ); + msgBrowser->append( tr( st[ msgtype ] )+" ("+QTime::currentTime().toString()+") "+msg ); + msgBrowser->verticalScrollBar()->setValue(msgBrowser->verticalScrollBar()->maxValue()); show(); } @@ -100,25 +103,25 @@ MessagesWindow::message( int msgtype, const QString &msg) void MessagesWindow::languageChange() { setCaption( tr( "Messages window" ) ); - msgBrowser->setText( QString::null ); + //msgBrowser->setText( QString::null ); } void MessagesWindow::hideEvent ( QHideEvent *e ) { - msgBrowser->clear(); + //msgBrowser->clear(); QDockWindow::hideEvent( e ); } -void +void MessagesWindow::on_click() { setExpanded(!expanded); } -void +void MessagesWindow::setExpanded(bool exp) { if(exp) setFixedExtentHeight ( 150 ); diff --git a/src/plugins/engine.cpp b/src/plugins/engine.cpp index 088b223..33235aa 100644 --- a/src/plugins/engine.cpp +++ b/src/plugins/engine.cpp @@ -417,6 +417,7 @@ void aEngine::Message(int n, const QString &msg) { cfg_message(n, (const char *) msg.utf8()); + emit statusIcon( n ); } /*!