Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed #488 Display a message if no cursor theme is found

  • Loading branch information...
commit 6bd1becdaee195732b37e7f1ecd9698b9a01e2fc 1 parent 98270b6
@pvanek pvanek authored
View
3  razorqt-config/razor-config-mouse/CMakeLists.txt
@@ -24,6 +24,7 @@ set ( razor-config-mouse_HDRS
# main.h
# crtheme.h
selectwnd.h
+ warninglabel.h
)
set ( razor-config-mouse_SRCS
@@ -39,10 +40,12 @@ set ( razor-config-mouse_SRCS
previewwidget.cpp
itemdelegate.cpp
thememodel.cpp
+ warninglabel.cpp
)
set(razor-config-mouse_UIS
ui/selectwnd.ui
+ ui/warninglabel.ui
)
find_package(ZLIB REQUIRED)
View
28 razorqt-config/razor-config-mouse/selectwnd.cpp
@@ -16,6 +16,7 @@
#include <QtCore/QTimer>
#include <QtGui/QWidget>
#include <QtGui/QPushButton>
+#include <QtGui/QToolTip>
#include "cfgfile.h"
#include "crtheme.h"
@@ -36,6 +37,8 @@ SelectWnd::SelectWnd(QWidget *parent) : QWidget(parent)
setupUi(this);
closeButton->setIcon(XdgIcon::fromTheme("dialog-close"));
+ warningLabel->hide();
+
mModel = new XCursorThemeModel(this);
int size = style()->pixelMetric(QStyle::PM_LargeIconSize);
@@ -47,6 +50,16 @@ SelectWnd::SelectWnd(QWidget *parent) : QWidget(parent)
// Make sure we find out about selection changes
connect(lbThemes->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
SLOT(currentChanged(const QModelIndex &, const QModelIndex &)));
+ // display/hide warning label
+ connect(mModel, SIGNAL(modelReset()),
+ this, SLOT(handleWarning()));
+ connect(mModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
+ this, SLOT(handleWarning()));
+ connect(mModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
+ this, SLOT(handleWarning()));
+
+ connect(warningLabel, SIGNAL(showDirInfo()),
+ this, SLOT(showDirInfo()));
// Disable the install button if we can't install new themes to ~/.icons,
// or Xcursor isn't set up to look for cursor themes there
@@ -56,6 +69,8 @@ SelectWnd::SelectWnd(QWidget *parent) : QWidget(parent)
btRemove->hide();
//QTimer::singleShot(0, this, SLOT(setCurrent()));
+
+ handleWarning();
}
@@ -156,3 +171,16 @@ void SelectWnd::on_btRemove_clicked()
mModel->removeTheme(lbThemes->currentIndex());
removeXCursorTheme(d);
}
+
+void SelectWnd::handleWarning()
+{
+ bool empty = mModel->rowCount();
+ warningLabel->setVisible(!empty);
+ preview->setVisible(empty);
+ infoLabel->setVisible(empty);
+}
+
+void SelectWnd::showDirInfo()
+{
+ QToolTip::showText(mapToGlobal(warningLabel->buttonPos()), mModel->searchPaths().join("\n"));
+}
View
3  razorqt-config/razor-config-mouse/selectwnd.h
@@ -40,10 +40,13 @@ private slots:
void on_btInstall_clicked ();
void on_btRemove_clicked ();
void on_btSet_clicked ();
+ void handleWarning();
+ void showDirInfo();
private:
XCursorThemeModel *mModel;
QPersistentModelIndex mAppliedIndex;
+
};
#endif
View
87 razorqt-config/razor-config-mouse/ui/selectwnd.ui
@@ -13,38 +13,9 @@
<property name="windowTitle">
<string>Razor Mouse Theme Configuration</string>
</property>
- <layout class="QGridLayout">
- <item row="3" column="0">
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>174</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0" colspan="5">
- <widget class="QListView" name="lbThemes">
- <property name="editTriggers">
- <set>QAbstractItemView::NoEditTriggers</set>
- </property>
- <property name="showDropIndicator" stdset="0">
- <bool>false</bool>
- </property>
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="verticalScrollMode">
- <enum>QAbstractItemView::ScrollPerPixel</enum>
- </property>
- </widget>
- </item>
+ <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="5">
- <widget class="QLabel" name="label">
+ <widget class="QLabel" name="infoLabel">
<property name="text">
<string>Select the cursor theme you want to use (hover preview to test cursor). &lt;b&gt;Razor session needs restart after this change&lt;/b&gt;:</string>
</property>
@@ -54,6 +25,9 @@
</widget>
</item>
<item row="1" column="0" colspan="5">
+ <widget class="WarningLabel" name="warningLabel" native="true"/>
+ </item>
+ <item row="2" column="0" colspan="5">
<widget class="PreviewWidget" name="preview" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -69,7 +43,36 @@
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="3" column="0" colspan="5">
+ <widget class="QListView" name="lbThemes">
+ <property name="editTriggers">
+ <set>QAbstractItemView::NoEditTriggers</set>
+ </property>
+ <property name="showDropIndicator" stdset="0">
+ <bool>false</bool>
+ </property>
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="verticalScrollMode">
+ <enum>QAbstractItemView::ScrollPerPixel</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>174</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="4" column="1">
<widget class="QPushButton" name="btInstall">
<property name="enabled">
<bool>false</bool>
@@ -79,21 +82,21 @@
</property>
</widget>
</item>
- <item row="3" column="3">
- <widget class="QPushButton" name="btSet">
+ <item row="4" column="2">
+ <widget class="QPushButton" name="btRemove">
<property name="text">
- <string>&amp;Set Theme</string>
+ <string>&amp;Remove Theme</string>
</property>
</widget>
</item>
- <item row="3" column="2">
- <widget class="QPushButton" name="btRemove">
+ <item row="4" column="3">
+ <widget class="QPushButton" name="btSet">
<property name="text">
- <string>&amp;Remove Theme</string>
+ <string>&amp;Set Theme</string>
</property>
</widget>
</item>
- <item row="3" column="4">
+ <item row="4" column="4">
<widget class="QPushButton" name="closeButton">
<property name="text">
<string>&amp;Close</string>
@@ -108,6 +111,12 @@
<extends>QWidget</extends>
<header>previewwidget.h</header>
</customwidget>
+ <customwidget>
+ <class>WarningLabel</class>
+ <extends>QWidget</extends>
+ <header>warninglabel.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<tabstops>
<tabstop>lbThemes</tabstop>
View
64 razorqt-config/razor-config-mouse/ui/warninglabel.ui
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>WarningLabel</class>
+ <widget class="QWidget" name="WarningLabel">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>334</width>
+ <height>72</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="iconLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>64</width>
+ <height>64</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="warningLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Razor could not find any cursor theme. The default X11 cursor theme will be used instead. Razor looked in the following directories:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="showDirButton">
+ <property name="text">
+ <string>Show...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
View
43 razorqt-config/razor-config-mouse/warninglabel.cpp
@@ -0,0 +1,43 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2012 Razor team
+ * Authors:
+ * Petr Vanek <petr@scribus.info>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#include <qtxdg/xdgicon.h>
+
+#include "warninglabel.h"
+
+
+
+WarningLabel::WarningLabel(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+
+ iconLabel->setPixmap(XdgIcon::fromTheme("dialog-warning").pixmap(64, 64));
+
+ connect(showDirButton, SIGNAL(pressed()),
+ this, SIGNAL(showDirInfo()));
+}
View
47 razorqt-config/razor-config-mouse/warninglabel.h
@@ -0,0 +1,47 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2012 Razor team
+ * Authors:
+ * Petr Vanek <petr@scribus.info>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#ifndef WARNINGLABEL_H
+#define WARNINGLABEL_H
+
+#include "ui_warninglabel.h"
+
+
+class WarningLabel : public QWidget, public Ui::WarningLabel
+{
+ Q_OBJECT
+
+public:
+ WarningLabel (QWidget *parent=0);
+
+ QPoint buttonPos() { return showDirButton->pos(); }
+
+signals:
+ void showDirInfo();
+};
+
+#endif
Please sign in to comment.
Something went wrong with that request. Please try again.