Question

I have an application that is in very early development, and still consistently updates or fixing bugs. The program is designed to do a lot of my jobs auditing automatically and currently is being used by 5-7 people who heard of it through the grape vine.

I don't like constantly sending out emails asking to spread the word that an updates has rolled out, so I'd like to implement some sort of 'check for update' button. How would I go about doing something like this?

The button would simply check for a new version number in my release repository and let the user know if their version number is behind, is that the right route to go for this kind of action? Or is there a much easier path?

Was it helpful?

Solution

I would suggest to even avoid using a checkbox for this, and just fully automate the process by using QFileSystemWatcher.

You would need to add the desired path for watching first:

bool QFileSystemWatcher::addPath(const QString & path)

Adds path to the file system watcher if path exists. The path is not added if it does not exist, or if it is already being monitored by the file system watcher.

If path specifies a directory, the directoryChanged() signal will be emitted when path is modified or removed from disk; otherwise the fileChanged() signal is emitted when path is modified, renamed or removed.

If the watch was successful, true is returned.

Reasons for a watch failure are generally system-dependent, but may include the resource not existing, access failures, or the total watch count limit, if the platform has one.

Note: There may be a system dependent limit to the number of files and directories that can be monitored simultaneously. If this limit is been reached, path will not be monitored, and false is returned.

You would be connected to the following signal:

void QFileSystemWatcher::fileChanged(const QString & path) [signal]

This signal is emitted when the file at the specified path is modified, renamed or removed from disk.

The handler slot could then just bring up some notification to the user automatically, even without an explicit checkbox.

Putting all this into practice, I would write something like this:

MyClass::MyClass(QObject *parent) : QObject(parent)
{
    connect(myFileSystemWatcherPointer, SIGNAL(fileChanged(const QString &)), SLOT(handleFileChanged(const QString &)));
    myFileSystemWatcherPoiner->addPath(myFilePath);
}

MyClass::handleFileChanged(const QString &file)
{
    if (file == desiredFile)
        showUpdatePopUp();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top