Archive for the ‘Python’ Category

TortoiseHg Reviewboard issue when updating existing reviews

30 Mar

I recently noticed a bug introduced into the mercurial-reviewboard plugin that is preventing a list of existing reviews from being displayed in the drop down list.

Basically there was a change added to skip the login prompt if the user already has a a valid cookie. Unfortunatly, in this case the username is never set in the http client that the pending_user_requests function relies on.

A simple change to line 484 fixes this issue.

Before:

if not httpclient.has_valid_cookie():
    if not username:
        username = mercurial.ui.ui().prompt('Username: ')
    if not password:
        password = getpass.getpass('Password: ')
    httpclient.set_credentials(username, password)

After:

if not httpclient.has_valid_cookie():
    if not username:
        username = mercurial.ui.ui().prompt('Username: ')
    if not password:
        password = getpass.getpass('Password: ')

httpclient.set_credentials(username, password)

I have posted a new issue and patch to mdelgra’s BitBucket issue tracker, here, that fixes the issue.

Hopefully it will be fixed sooner rather then later, because it is affecting the dialog!

 
Comments Off

Posted in Python, TortoiseHg

 

Adding the ability to close a tab with mouse’s middle button to Qt’s QTabWidget

12 Mar

Tabs are a very important part of user interface design and the ability to close a tab with the middle mouse button has become ubiquitous.

Unfortunately Qt’s QTabWidget does not have this functionality built in, however I recently worked out that it is very easy to implement, in Python with a few lines of code, by creating a custom QTabBar.

class MyTabBar(QTabBar):   
    def mouseReleaseEvent(self, event):               
        if event.button() == Qt.MidButton:           
            self.tabCloseRequested.emit(self.tabAt(event.pos()))

    super(QTabBar, self).mouseReleaseEvent(event)

Using the class above  overwrites the mouse release event to emit a tabCloseRequested signal with the index of the tab that was middle clicked on.

Adding the custom QTabBar class to the QTabWidget  is done using the setTabBar function.

tw = QTabWidget()
tw.setTabBar(MyTabBar())

Hopefully the Qt developers will add this functionality to the QTabBar in the future, but for the time being the above code will suffice. I’m sure it can be easily converted to C++ or any other language you are using Qt with.

 
4 Comments

Posted in Python

 

TortoiseHg review board interface now uses a fork of the original extension

29 Dec

I originally wrote the TortoriseHg review board user interface to use a fork of Mdelagra’s fork of the original mercurial extension.

I have since made some changes to the UI I wrote earlier this year (goo.gl/AHKJE) to make use of a fork of the original extension instead.

I did this because the original extension that is listed on the Mercural website (goo.gl/nWMdS) has recently been update to support the Review Board API 2.0 that was shipped with Review Board 1.5. This updated API has some nicer features that I have implemented, namely, the more granular control over filtering review requests.

So I have forked the original and, among a couple of bug fixes, added some features to make it play nicer with the TortoiseHg review board dialog. This fork is now required to be used with TortoiseHg and can be downloaded here – goo.gl/cTdci

I have made contact with the developers of the original extension and hope to get my changes merged into it some time in the new year.

Hopefully before the release of TortoiseHg 2.0, however in the mean time my fork will have to suffice.