From 084b6c93000fb3820330369d18a12e5143d3109c Mon Sep 17 00:00:00 2001 From: Rohil Surana Date: Wed, 1 Apr 2015 13:31:25 +0530 Subject: [PATCH] Added tool menu active button indicator. Disable active button to remove repainting of ui each time it is pressed. --- src/widget/widget.cpp | 24 ++++++++++++++++++++++-- src/widget/widget.h | 8 ++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 57a133746..c6eed46ec 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -133,7 +133,10 @@ void Widget::init() ui->mainHead->layout()->setMargin(0); ui->mainHead->layout()->setSpacing(0); - ui->tooliconsZone->setStyleSheet(Style::resolve("QPushButton{background-color:@themeDark;border:none;}QPushButton:hover{background-color:@themeMediumDark;border:none;}")); + ui->addButton->setCheckable(true); + ui->groupButton->setCheckable(false); + ui->transferButton->setCheckable(true); + ui->settingsButton->setCheckable(true); if (QStyleFactory::keys().contains(Settings::getInstance().getStyle()) && Settings::getInstance().getStyle() != "None") @@ -207,6 +210,7 @@ void Widget::init() addFriendForm->show(*ui); setWindowTitle(tr("Add friend")); + setActiveToolMenuButton(Widget::AddButton); connect(settingsWidget, &SettingsWidget::groupchatPositionToggled, contactListWidget, &FriendListWidget::onGroupchatPositionChanged); #if (AUTOUPDATE_ENABLED) @@ -434,6 +438,7 @@ void Widget::onAddClicked() hideMainForms(); addFriendForm->show(*ui); setWindowTitle(tr("Add friend")); + setActiveToolMenuButton(Widget::AddButton); activeChatroomWidget = nullptr; } @@ -447,6 +452,7 @@ void Widget::onTransferClicked() hideMainForms(); filesForm->show(*ui); setWindowTitle(tr("File transfers")); + setActiveToolMenuButton(Widget::TransferButton); activeChatroomWidget = nullptr; } @@ -527,6 +533,7 @@ void Widget::onSettingsClicked() hideMainForms(); settingsWidget->show(*ui); setWindowTitle(tr("Settings")); + setActiveToolMenuButton(Widget::SettingButton); activeChatroomWidget = nullptr; } @@ -729,6 +736,7 @@ void Widget::onFriendUsernameChanged(int friendId, const QString& username) void Widget::onChatroomWidgetClicked(GenericChatroomWidget *widget) { hideMainForms(); + setActiveToolMenuButton(Widget::None); widget->setChatForm(*ui); if (activeChatroomWidget != nullptr) activeChatroomWidget->setAsInactiveChatroom(); @@ -1277,7 +1285,7 @@ void Widget::clearAllReceipts() void Widget::reloadTheme() { QString statusPanelStyle = Style::getStylesheet(":/ui/window/statusPanel.css"); - ui->tooliconsZone->setStyleSheet(Style::resolve("QPushButton{background-color:@themeDark;border:none;}QPushButton:hover{background-color:@themeMediumDark;border:none;}")); + ui->tooliconsZone->setStyleSheet(Style::resolve("QPushButton{background-color:@themeDark;border:none;}QPushButton:hover{background-color:@themeMediumDark;border:none;}QPushButton:checked{background-color:@themeMedium;border:none;}QPushButton:pressed{background-color:@themeMediumLight;border:none;}")); ui->statusPanel->setStyleSheet(statusPanelStyle); ui->statusHead->setStyleSheet(statusPanelStyle); ui->friendList->setStyleSheet(Style::getStylesheet(":ui/friendList/friendList.css")); @@ -1358,3 +1366,15 @@ Status Widget::getStatusFromString(QString status) else return Status::Offline; } + +void Widget::setActiveToolMenuButton(ActiveToolMenuButton newActiveButton) +{ + ui->addButton->setChecked(newActiveButton == Widget::AddButton); + ui->addButton->setDisabled(newActiveButton == Widget::AddButton); + ui->groupButton->setChecked(newActiveButton == Widget::GroupButton); + ui->groupButton->setDisabled(newActiveButton == Widget::GroupButton); + ui->transferButton->setChecked(newActiveButton == Widget::TransferButton); + ui->transferButton->setDisabled(newActiveButton == Widget::TransferButton); + ui->settingsButton->setChecked(newActiveButton == Widget::SettingButton); + ui->settingsButton->setDisabled(newActiveButton == Widget::SettingButton); +} diff --git a/src/widget/widget.h b/src/widget/widget.h index a8736e1ba..7a4dcda8a 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -151,6 +151,14 @@ private slots: void processOfflineMsgs(); private: + enum ActiveToolMenuButton { + AddButton, + GroupButton, + TransferButton, + SettingButton, + None, + }; + void setActiveToolMenuButton(ActiveToolMenuButton newActiveButton); void hideMainForms(); virtual bool event(QEvent * e); Group *createGroup(int groupId);