From kde-commits Thu Jul 01 13:26:50 2010 From: Dario Abatianni Date: Thu, 01 Jul 2010 13:26:50 +0000 To: kde-commits Subject: [Konversation] e080774: Applied a patch by Christian Mühlhäuser to right Message-Id: <20100701132650.445FCBB545E () projects ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=127799635913131 commit e08077431f64f2eea0b410b818a6c914c3561dba Author: Dario Abatianni Date: Thu Sep 25 15:40:50 2003 +0000 Applied a patch by Christian Mühlhäuser to right-align close widgets svn path=/trunk/kdeextragear-2/konversation/; revision=253885 diff --git a/konversation/konversationapplication.cpp b/konversation/konversationapplication.cpp index 1bd6bac..594eb8e 100644 --- a/konversation/konversationapplication.cpp +++ b/konversation/konversationapplication.cpp @@ -276,6 +276,7 @@ void KonversationApplication::readOptions() preferences.setShowQuickButtons(config->readBoolEntry("ShowQuickButtons",preferences.getShowQuickButtons())); preferences.setShowModeButtons(config->readBoolEntry("ShowModeButtons",preferences.getShowModeButtons())); preferences.setCloseButtonsOnTabs(config->readBoolEntry("CloseButtonsOnTabs",preferences.getCloseButtonsOnTabs())); + preferences.setCloseButtonsAlignRight(config->readBoolEntry("CloseButtonsAlignRight",preferences.getCloseButtonsAlignRight())); preferences.setAutoUserhost(config->readBoolEntry("AutoUserhost",preferences.getAutoUserhost())); @@ -524,6 +525,7 @@ void KonversationApplication::saveOptions(bool updateGUI) config->writeEntry("ShowQuickButtons",preferences.getShowQuickButtons()); config->writeEntry("ShowModeButtons",preferences.getShowModeButtons()); config->writeEntry("CloseButtonsOnTabs",preferences.getCloseButtonsOnTabs()); + config->writeEntry("CloseButtonsAlignRight",preferences.getCloseButtonsAlignRight()); config->writeEntry("AutoUserhost",preferences.getAutoUserhost()); @@ -779,7 +781,7 @@ bool KonversationApplication::emitDCOPSig(const QString &appId, const QString &o QByteArray replyData; QCString replyType; if (!KApplication::dcopClient()->call(appId.ascii(), objId.ascii(), signal.ascii() /*must have prototype*/, - data, replyType, replyData)) { + data, replyType, replyData)) { qDebug("there was some error using DCOP."); return true; // Keep processing filters } else { diff --git a/konversation/ledtabbar.cpp b/konversation/ledtabbar.cpp index 4f4fd73..9edf381 100644 --- a/konversation/ledtabbar.cpp +++ b/konversation/ledtabbar.cpp @@ -151,6 +151,7 @@ void LedTabBar::paint( QPainter * p, QTab * t, bool selected ) const fw += t->text().contains("&&") * fm.width('&'); int w = iw + fw + 4; int h = QMAX(fm.height() + 4, ih ); + paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, r.top() + (r.height()-h)/2, w, h ), t, t->identifier() == keyboardFocusTab() ); @@ -184,16 +185,37 @@ void LedTabBar::paintLabel( QPainter* p, const QRect& br, QTab* tab, bool has_fo // do we want close widgets on the tabs? if(KonversationApplication::preferences.getCloseButtonsOnTabs()) { - r.setLeft( r.left() + LABEL_OFFSET); - r.setRight( r.right() + LABEL_OFFSET); - // ### the pixmap shift should probably not be hardcoded.. - p->drawPixmap( br.left() + 6 + LABEL_OFFSET /* + ((selected == TRUE) ? 0 : 1) */, - br.center().y()-pixh/2 + ((selected == TRUE) ? 0 : 1), - pixmap ); - - p->drawPixmap( br.left(), - br.center().y()-close_pixh/2, - close_pixmap ); + if (!KonversationApplication::preferences.getCloseButtonsAlignRight()) + { + // Shift the text to the right + r.setLeft( r.left() + LABEL_OFFSET); + r.setRight( r.right() + LABEL_OFFSET); + + // Draw iconset on the left side + p->drawPixmap( br.left() + 6 + LABEL_OFFSET /* + ((selected == TRUE) ? 0 : 1) */, + br.center().y()-pixh/2 + ((selected == TRUE) ? 0 : 1), + pixmap ); + + // Draw close button on the left side + p->drawPixmap( br.left(), + br.center().y() - close_pixh/2, + close_pixmap ); + } + else + { + // Shift the text to the left + r.setLeft( r.left() - 6); + + // Draw iconset on the left side + p->drawPixmap( br.left() + 2, + br.center().y()-pixh/2 + ((selected == TRUE) ? 0 : 1), + pixmap ); + + // Draw close button on the right side + p->drawPixmap( br.right() - 7, + br.center().y() - close_pixh/2, + close_pixmap ); + } } else { @@ -243,6 +265,7 @@ void LedTabBar::layoutTabs() QTab* ltab=tabAt(index); QRect r=ltab->rect(); r.setWidth(r.width()+LABEL_OFFSET); + r.moveBy(offset,0); offset+=LABEL_OFFSET; @@ -262,11 +285,16 @@ void LedTabBar::mouseReleaseEvent(QMouseEvent* e) // get physical position of QTab* t QRect target(t->rect()); + + // move target area to aprop. place + if(KonversationApplication::preferences.getCloseButtonsAlignRight()) + target.moveBy(target.width() - 20,4); + else + target.moveBy(8,4); + // set size of target area target.setWidth(16); target.setHeight(16); - // move target area to final place - target.moveBy(8,4); if(target.contains(e->pos())) emit closeTab(t->identifier()); } diff --git a/konversation/main.cpp b/konversation/main.cpp index 9a0b093..bd0ca2f 100644 --- a/konversation/main.cpp +++ b/konversation/main.cpp @@ -52,6 +52,7 @@ int main(int argc, char* argv[]) aboutData.addAuthor("Stanislav Karchebny",I18N_NOOP("Non-Latin1-Encodings"),"berkus@users.sourceforge.net"); aboutData.addAuthor("Mickael Marchand",I18N_NOOP("Konsole part view"),"marchand@kde.org"); aboutData.addAuthor("Peter Simonsson",I18N_NOOP("Color picker, IRC color preferences, KNotify events"),"psn@linux.se"); + aboutData.addAuthor("Christian Mühlhäuser",I18N_NOOP("Multiple modes extension, Close widget placement"),"chris@chris.de>"); aboutData.addCredit("Frauke Oster",I18N_NOOP("System tray patch"),"frauke@frsv.de"); aboutData.addCredit("Lucijan Busch",I18N_NOOP("Bug fixes"),"lucijan@kde.org"); diff --git a/konversation/preferences.cpp b/konversation/preferences.cpp index 6293583..5001281 100644 --- a/konversation/preferences.cpp +++ b/konversation/preferences.cpp @@ -112,6 +112,7 @@ Preferences::Preferences() setTabPlacement(Bottom); setBlinkingTabs(true); setCloseButtonsOnTabs(true); + setCloseButtonsAlignRight(false); setBringToFront(true); setNotifyDelay(20); @@ -411,6 +412,9 @@ bool Preferences::getBlinkingTabs() { return blinkingTabs; } void Preferences::setCloseButtonsOnTabs(bool state) { closeButtonsOnTabs=state; } bool Preferences::getCloseButtonsOnTabs() { return closeButtonsOnTabs; } +void Preferences::setCloseButtonsAlignRight(bool state) { closeButtonsAlignRight=state; } +bool Preferences::getCloseButtonsAlignRight() { return closeButtonsAlignRight; } + void Preferences::setBringToFront(bool state) { bringToFront=state; } bool Preferences::getBringToFront() { return bringToFront; } diff --git a/konversation/preferences.h b/konversation/preferences.h index b068e51..6f74fd1 100644 --- a/konversation/preferences.h +++ b/konversation/preferences.h @@ -124,6 +124,8 @@ class Preferences : public QObject bool getBringToFront(); void setCloseButtonsOnTabs(bool state); bool getCloseButtonsOnTabs(); + void setCloseButtonsAlignRight(bool state); + bool getCloseButtonsAlignRight(); // sorting stuff bool getSortByStatus(); @@ -318,10 +320,11 @@ class Preferences : public QObject bool logFollowsNick; QString logPath; - TabPlacement tabPlacement; // where do the tabs go? - bool blinkingTabs; // Do we want the LEDs on the tabs to blink? - bool closeButtonsOnTabs; // Do we want close widgets on the tabs? - bool bringToFront; // Do we want to see newly created tabs immediately? + TabPlacement tabPlacement; // where do the tabs go? + bool blinkingTabs; // Do we want the LEDs on the tabs to blink? + bool closeButtonsOnTabs; // Do we want close widgets on the tabs? + bool closeButtonsAlignRight; // Display close widgets on the right side? + bool bringToFront; // Do we want to see newly created tabs immediately? bool fixedMOTD; bool beep; diff --git a/konversation/prefspageappearance.cpp b/konversation/prefspageappearance.cpp index cd77e5e..046a802 100644 --- a/konversation/prefspageappearance.cpp +++ b/konversation/prefspageappearance.cpp @@ -134,6 +134,13 @@ PrefsPageAppearance::PrefsPageAppearance(QFrame* newParent,Preferences* newPrefe closeButtonsCheck=new QCheckBox(i18n("Show close widgets on tabs"),parentFrame,"tab_close_widgets_check"); closeButtonsCheck->setChecked(preferences->getCloseButtonsOnTabs()); + // Take care of ghosting / unghosting close button checkboxes + closeButtonsChanged(preferences->getCloseButtonsOnTabs() ? 2 : 0); + + // Display close buttons on which side + closeButtonsAlignRight=new QCheckBox(i18n("Place close widgets on the right side"),parentFrame,"tab_close_widgets_align_right"); + closeButtonsAlignRight->setChecked(preferences->getCloseButtonsAlignRight()); + // Sorting QVGroupBox* sortOptionsGroup=new QVGroupBox(i18n("Sort Options"),parentFrame,"sort_options_group"); sortOrderGroup=new QHGroupBox(i18n("Sorting Order"),parentFrame,"sort_order_group"); @@ -193,6 +200,8 @@ PrefsPageAppearance::PrefsPageAppearance(QFrame* newParent,Preferences* newPrefe row++; appearanceLayout->addMultiCellWidget(closeButtonsCheck,row,row,0,2); row++; + appearanceLayout->addMultiCellWidget(closeButtonsAlignRight,row,row,0,2); + row++; appearanceLayout->addWidget(sortOptionsGroup,row,0); appearanceLayout->addMultiCellWidget(sortOrderGroup,row,row,1,2); row++; @@ -211,6 +220,8 @@ PrefsPageAppearance::PrefsPageAppearance(QFrame* newParent,Preferences* newPrefe connect(useParagraphSpacingCheck,SIGNAL (stateChanged(int)),this,SLOT (useParagraphSpacingChanged(int)) ); + connect(closeButtonsCheck,SIGNAL (stateChanged(int)),this,SLOT (closeButtonsChanged(int)) ); + connect(sortByStatusCheck,SIGNAL (stateChanged(int)),this,SLOT (sortByStatusChanged(int)) ); connect(sortMoveUp,SIGNAL (clicked()),this,SLOT (moveUp()) ); @@ -264,6 +275,12 @@ void PrefsPageAppearance::useParagraphSpacingChanged(int state) paragraphSpacingSpin->setEnabled(state==2); } +void PrefsPageAppearance::closeButtonsChanged(int state) +{ + closeButtonsCheck->setChecked(state); + closeButtonsAlignRight->setEnabled(state==2); +} + void PrefsPageAppearance::sortByStatusChanged(int state) { sortOrderGroup->setEnabled(state==2); @@ -304,6 +321,7 @@ void PrefsPageAppearance::applyPreferences() preferences->setMargin(marginSpin->value()); preferences->setUseParagraphSpacing(useParagraphSpacingCheck->isChecked()); preferences->setParagraphSpacing(paragraphSpacingSpin->value()); + preferences->setCloseButtonsAlignRight(closeButtonsAlignRight->isChecked()); preferences->setSortByStatus(sortByStatusCheck->isChecked()); preferences->setSortCaseInsensitive(sortCaseInsensitiveCheck->isChecked()); diff --git a/konversation/prefspageappearance.h b/konversation/prefspageappearance.h index a2c8ef4..d698d0d 100644 --- a/konversation/prefspageappearance.h +++ b/konversation/prefspageappearance.h @@ -52,6 +52,8 @@ class PrefsPageAppearance : public PrefsPage void useParagraphSpacingChanged(int state); + void closeButtonsChanged(int state); + void sortByStatusChanged(int state); void moveUp(); @@ -77,6 +79,7 @@ class PrefsPageAppearance : public PrefsPage QCheckBox* autoUserhostCheck; QCheckBox* closeButtonsCheck; + QCheckBox* closeButtonsAlignRight; QCheckBox* useSpacingCheck; QLabel* spacingLabel; diff --git a/konversation/server.cpp b/konversation/server.cpp index 314ac66..f9f1213 100644 --- a/konversation/server.cpp +++ b/konversation/server.cpp @@ -524,10 +524,9 @@ void Server::queue(const QString& buffer) void Server::queueList(const QStringList& buffer) { // Only queue lines if we are connected - const QStringList it; if(isConnected() && buffer.count()) { - for (int i=0;iappendRaw(*buffer.at(i));