![]() |
Prevent double press? [SOLVED]
There's only one bug that keeps me from promoting Wallpaeper to Extras-testing, which is the following:
It's possible to open multiple windows after pressing a button more than once. How can I make sure a button can only be pressed once? (or how can I make sure only one window is opened?) I've tried: (after button press) - Disable button before creating a new Manager window (but that seemed to go simultaneously, so the button was disabled just before or after the new window shows) - Disable the button, if(disabled) - open window (same as above, strange..) - A boolean that decides whether to open it or not (false if button pressed) - disconnect() after button press - if a Manager window is made, don't make it again (didn't work..) None of these worked :( It doesn't crash with multiple windows, there are just multiple windows without a parent window So can anyone help me with either: - Preventing double button press - Setting QListWidget icons faster Many thanks in advance! |
Re: Prevent double press?
Can you be more accurate on what language your coding ?
I'am a beginner but i found handy to use Hildon's StackableWindow. Makes you sure you won't have multiple windows opened at the same time... Hope i'am not completely wrong ! |
Re: Prevent double press?
I'm using C++ in the Nokia Qt SDK ;)
I also use .setAttribute(Qt::WA_Maemo5StackedWindow); with the right parent window, of course. When I press the button once, it stacks perfectly, however when I press it multiple times, it opens multiple windows, which then don't have a parent window, and are shown as separate windows. The window takes some time to load, that's why it can be pressed more than once. |
Re: Prevent double press?
Set a windowIsVisible etc. flag before QWidget::show() is called. Then unset the flag when QWidget is hidden (maybe you have to reimplement hideEvent()).
E: Maybe it is easier to help if you show your code... What do you mean by setting QListWidget icons faster? |
Re: Prevent double press?
Thanks for that visible-flag tip ;) I will try something with that, not that I know a lot about flags, but I'll figure it out.
This is how it adds new items to the QListWidget: - Put all .desktop files from /home/user/MyDocs/.images/ in a QStringList - Open all of them --- Check if it contains "Type=Background Image", if it does, next step: --- Take filename, X-File1=, X-File2=, X-File3=, X-File4=, Name= from the file and put it in a second QStringList, [0] to [5] --- Then add values from that second QStringList (the "clean" one) to the QListWidget, like this: Code:
itemList.append(new QListWidgetItem(QIcon(imageSetList[i][1]), QFileInfo(imageSetList[i][0]).fileName(), ui->fileList)); (A previous version didn't have the icons, it was LOTS faster..) This is the slot that creates/shows the new window: Code:
void wallPaeper::manBtnClicked() { |
Re: Prevent double press?
The updateList() function, that does the above with the QStringLists, is in the constructor of wpManager (the new window). Hence the loading time,
I've just gotten an idea, which didn't work before, but I thought of a new way to do it.. I'll remove updateList() from the contructor, make a connect() function that checks if the window is visible, and updates the list when it is. I'll make sure the slot prevents an infinite loop, since it stays visible for a while. So it will load the list after the window opens. This will greatly improve the loading time (before it shows), making double button pressing less likely. |
Re: Prevent double press?
It's solved :D it's probably not the prettiest solution, but I'm not taking my code to the catwalk ;)
It sets openManWin on true in the constructor, after the button press it's set on false, and after the window closes, it's true again. Here's the code: Code:
void wallPaeper::manBtnClicked() { |
All times are GMT. The time now is 08:17. |
vBulletin® Version 3.8.8