mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-03 03:53:56 -07:00
tab modified indicator
This commit is contained in:
parent
5d6652f5de
commit
70594387de
5 changed files with 103 additions and 7 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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<Tab *>(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<Tab *>(widget(index));
|
||||
if (tab->getContentsChanged()) {
|
||||
setTabIcon(index, QIcon());
|
||||
tab->setContentsChanged(false);
|
||||
}
|
||||
emit setMenu(static_cast<Tab *>(widget(index))->getTabMenu());
|
||||
else
|
||||
} else
|
||||
emit setMenu(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue