[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdetoys/fifteenapplet
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2003-08-12 10:20:19
[Download RAW message or body]
CVS commit by aseigo:
put the menu in the applet handle...
M +14 -22 fifteenapplet.cpp 1.9
M +5 -3 fifteenapplet.h 1.5
--- kdetoys/fifteenapplet/fifteenapplet.cpp #1.8:1.9
@@ -53,4 +53,5 @@ FifteenApplet::FifteenApplet(const QStri
// setup table
_table = new PiecesTable(this);
+ setCustomMenu(_table->popup());
// setup layout
@@ -88,7 +89,11 @@ void FifteenApplet::about()
PiecesTable::PiecesTable(QWidget* parent, const char* name )
- : QtTableView(parent, name), _menu(0), _activeRow(-1), _activeCol(-1), _randomized(false)
+ : QtTableView(parent, name), _activeRow(-1), _activeCol(-1), _randomized(false)
{
- // setup table view
+ _menu = new QPopupMenu(this);
+ _menu->insertItem(i18n("R&andomize Pieces"), this, SLOT(randomizeMap()));
+ _menu->insertItem(i18n("&Reset Pieces"), this, SLOT(resetMap()));
+ _menu->adjustSize(); // setup table view
+
setFrameStyle(StyledPanel | Sunken);
setBackgroundMode(NoBackground);
@@ -198,4 +203,10 @@ void PiecesTable::randomizeMap()
}
+void PiecesTable::resetMap()
+{
+ initMap();
+ repaint();
+}
+
void PiecesTable::checkwin()
{
@@ -216,25 +227,6 @@ void PiecesTable::mousePressEvent(QMouse
if (e->button() == RightButton) {
-
- // setup RMB pupup menu
- if(!_menu) {
- _menu = new QPopupMenu(this);
- _menu->insertItem(i18n("R&andomize Pieces"), mRandomize);
- _menu->insertItem(i18n("&Reset Pieces"), mReset);
- _menu->adjustSize();
- }
-
// execute RMB popup and check result
- switch(_menu->exec(mapToGlobal(e->pos()))) {
- case mRandomize:
- randomizeMap();
- break;
- case mReset:
- initMap();
- repaint();
- break;
- default:
- break;
- }
+ _menu->exec(mapToGlobal(e->pos()));
}
else {
--- kdetoys/fifteenapplet/fifteenapplet.h #1.4:1.5
@@ -39,4 +39,5 @@ class PiecesTable : public QtTableView
public:
PiecesTable(QWidget* parent = 0, const char* name = 0);
+ QPopupMenu* popup() { return _menu; }
protected:
@@ -49,7 +50,10 @@ protected:
void initMap();
void initColors();
- void randomizeMap();
void checkwin();
+protected slots:
+ void randomizeMap();
+ void resetMap();
+
private:
QMemArray<int> _map;
@@ -58,6 +62,4 @@ private:
int _activeRow, _activeCol;
bool _randomized;
-
- enum MenuOp { mRandomize = 1, mReset = 2 };
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic