diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index 8f5f51b0..4ded1b1a 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -1,6 +1,7 @@ resources/back.svg + resources/icon_tab_changed.svg resources/icon_config_general.svg resources/icon_config_appearance.svg resources/icon_config_messages.svg diff --git a/cockatrice/resources/icon_tab_changed.svg b/cockatrice/resources/icon_tab_changed.svg new file mode 100644 index 00000000..51b66485 --- /dev/null +++ b/cockatrice/resources/icon_tab_changed.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/cockatrice/src/tab.h b/cockatrice/src/tab.h index b265867b..48e72744 100644 --- a/cockatrice/src/tab.h +++ b/cockatrice/src/tab.h @@ -11,10 +11,14 @@ signals: void userEvent(); protected: QMenu *tabMenu; +private: + bool contentsChanged; public: Tab(QWidget *parent = 0) - : QWidget(parent), tabMenu(0) { } + : QWidget(parent), tabMenu(0), contentsChanged(false) { } QMenu *getTabMenu() const { return tabMenu; } + bool getContentsChanged() const { return contentsChanged; } + void setContentsChanged(bool _contentsChanged) { contentsChanged = _contentsChanged; } virtual QString getTabText() const = 0; virtual void retranslateUi() = 0; }; diff --git a/cockatrice/src/tab_supervisor.cpp b/cockatrice/src/tab_supervisor.cpp index be8f0f17..d3c045cb 100644 --- a/cockatrice/src/tab_supervisor.cpp +++ b/cockatrice/src/tab_supervisor.cpp @@ -11,8 +11,14 @@ TabSupervisor:: TabSupervisor(QWidget *parent) : QTabWidget(parent), client(0), tabServer(0), tabDeckStorage(0) { + tabChangedIcon = new QIcon(":/resources/icon_tab_changed.svg"); setIconSize(QSize(15, 15)); - connect(this, SIGNAL(currentChanged(int)), this, SLOT(updateMenu(int))); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(updateCurrent(int))); +} + +TabSupervisor::~TabSupervisor() +{ + delete tabChangedIcon; } void TabSupervisor::retranslateUi() @@ -131,7 +137,10 @@ void TabSupervisor::chatChannelLeft(TabChatChannel *tab) void TabSupervisor::tabUserEvent() { Tab *tab = static_cast(sender()); - // XXX Mark tab as changed (exclamation mark icon?) + if (tab != currentWidget()) { + tab->setContentsChanged(true); + setTabIcon(indexOf(tab), *tabChangedIcon); + } QApplication::alert(this); } @@ -152,10 +161,15 @@ void TabSupervisor::processGameEvent(GameEvent *event) qDebug() << "gameEvent: invalid gameId"; } -void TabSupervisor::updateMenu(int index) +void TabSupervisor::updateCurrent(int index) { - if (index != -1) + if (index != -1) { + Tab *tab = static_cast(widget(index)); + if (tab->getContentsChanged()) { + setTabIcon(index, QIcon()); + tab->setContentsChanged(false); + } emit setMenu(static_cast(widget(index))->getTabMenu()); - else + } else emit setMenu(0); } diff --git a/cockatrice/src/tab_supervisor.h b/cockatrice/src/tab_supervisor.h index 4d66722d..376d2b75 100644 --- a/cockatrice/src/tab_supervisor.h +++ b/cockatrice/src/tab_supervisor.h @@ -18,6 +18,7 @@ class Event_GameJoined; class TabSupervisor : public QTabWidget { Q_OBJECT private: + QIcon *tabChangedIcon; Client *client; TabServer *tabServer; TabDeckStorage *tabDeckStorage; @@ -26,13 +27,14 @@ private: void myAddTab(Tab *tab); public: TabSupervisor(QWidget *parent = 0); + ~TabSupervisor(); void retranslateUi(); void start(Client *_client); void stop(); signals: void setMenu(QMenu *menu); private slots: - void updateMenu(int index); + void updateCurrent(int index); void updatePingTime(int value, int max); void gameJoined(Event_GameJoined *event); void gameLeft(TabGame *tab);