/*************************************************************************** * Copyright (C) 2003 by S�astien Laot * * slaout@linux62.org * * * * This program 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. * * * * 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include #include #include #include #include #include #include "basketstatusbar.h" #include "clickablelabel.h" #include "global.h" #include "bnpview.h" #include "basket.h" #include "tools.h" #include #include BasketStatusBar::BasketStatusBar(KStatusBar *bar) : m_bar(bar), m_extension(0), m_selectiontqStatus(0), m_locktqStatus(0), m_baskettqStatus(0), m_savedtqStatus(0) { } BasketStatusBar::BasketStatusBar(KParts::StatusBarExtension *extension) : m_bar(0), m_extension(extension), m_selectiontqStatus(0), m_locktqStatus(0), m_baskettqStatus(0), m_savedtqStatus(0) { } BasketStatusBar::~BasketStatusBar() { //delete m_extension; } KStatusBar *BasketStatusBar::statusBar () const { if(m_extension) return m_extension->statusBar(); else return m_bar; } void BasketStatusBar::addWidget(TQWidget * widget, int stretch, bool permanent) { if(m_extension) m_extension->addStatusBarItem(widget, stretch, permanent); else m_bar->addWidget(widget, stretch, permanent); } void BasketStatusBar::setupStatusBar() { TQWidget* tqparent = statusBar(); TQObjectList* lst = tqparent->queryList("KRSqueezedTextLabel"); //Tools::printChildren(tqparent); if(lst->count() == 0) { m_baskettqStatus = new TQLabel(tqparent); m_baskettqStatus->tqsetSizePolicy( TQSizePolicy(TQSizePolicy::Ignored, TQSizePolicy::Ignored, 0, 0, false) ); addWidget( m_baskettqStatus, 1, false ); // Fit all extra space and is hiddable } else m_baskettqStatus = static_cast(TQT_TQWIDGET(lst->at(0))); delete lst; m_selectiontqStatus = new TQLabel(i18n("Loading..."), tqparent); addWidget( m_selectiontqStatus, 0, true ); m_locktqStatus = new ClickableLabel(0/*this*/); m_locktqStatus->setMinimumSize(18, 18); m_locktqStatus->tqsetAlignment(TQt::AlignCenter); // addWidget( m_locktqStatus, 0, true ); connect( m_locktqStatus, TQT_SIGNAL(clicked()), Global::bnpView, TQT_SLOT(lockBasket()) ); m_savedStatusPixmap = SmallIcon("filesave"); m_savedtqStatus = new TQLabel(tqparent); m_savedtqStatus->setPixmap(m_savedStatusPixmap); m_savedtqStatus->setFixedSize(m_savedtqStatus->tqsizeHint()); m_savedtqStatus->clear(); //m_savedtqStatus->setPixmap(m_savedStatusIconSet.pixmap(TQIconSet::Small, TQIconSet::Disabled)); //m_savedtqStatus->setEnabled(false); addWidget( m_savedtqStatus, 0, true ); TQToolTip::add(m_savedtqStatus, "

" + i18n("Shows if there are changes that have not yet been saved.")); } void BasketStatusBar::postStatusbarMessage(const TQString& text) { if(statusBar()) statusBar()->message(text, 2000); } void BasketStatusBar::setStatusText(const TQString &txt) { if(m_baskettqStatus && m_baskettqStatus->text() != txt) m_baskettqStatus->setText(txt); } void BasketStatusBar::setStatusBarHint(const TQString &hint) { if (hint.isEmpty()) updateStatusBarHint(); else setStatusText(hint); } void BasketStatusBar::updateStatusBarHint() { TQString message = ""; if (Global::bnpView->currentBasket()->isDuringDrag()) message = i18n("Ctrl+drop: copy, Shift+drop: move, Shift+Ctrl+drop: link."); // Too much noise information: // else if (currentBasket()->inserterShown() && currentBasket()->inserterSplit() && !currentBasket()->inserterGroup()) // message = i18n("Click to insert a note, right click for more options. Click on the right of the line to group instead of insert."); // else if (currentBasket()->inserterShown() && currentBasket()->inserterSplit() && currentBasket()->inserterGroup()) // message = i18n("Click to group a note, right click for more options. Click on the left of the line to group instead of insert."); else if (Global::debugWindow) message = "DEBUG: " + Global::bnpView->currentBasket()->folderName(); setStatusText(message); } void BasketStatusBar::setLocktqStatus(bool isLocked) { if(!m_locktqStatus) return; if (isLocked) { m_locktqStatus->setPixmap(SmallIcon("encrypted.png")); TQToolTip::add(m_locktqStatus, i18n( "

This basket is locked.
Click to unlock it.

").replace(" ", " ") ); // TQToolTip::add(m_locktqStatus, i18n("This basket is locked.\nClick to unlock it.")); } else { m_locktqStatus->clear(); TQToolTip::add(m_locktqStatus, i18n( "

This basket is unlocked.
Click to lock it.

").replace(" ", " ") ); // TQToolTip::add(m_locktqStatus, i18n("This basket is unlocked.\nClick to lock it.")); } } void BasketStatusBar::setSelectiontqStatus(const TQString &s) { if (m_selectiontqStatus) m_selectiontqStatus->setText(s); } void BasketStatusBar::setUnsavedtqStatus(bool isUnsaved) { if (!m_savedtqStatus) return; if (isUnsaved) { if (m_savedtqStatus->pixmap() == 0) m_savedtqStatus->setPixmap(m_savedStatusPixmap); } else m_savedtqStatus->clear(); } #include "basketstatusbar.moc"