Initial support for system Icons (incomplete but good progress)

This commit is contained in:
Christophe Dumez
2010-12-12 19:37:59 +00:00
parent e72d9de34a
commit 052825e5c4
82 changed files with 299 additions and 433 deletions

View File

@@ -112,13 +112,11 @@
</item>
</layout>
<action name="actionEnable">
<property name="text">
<string>Enable</string>
<property name="checkable">
<bool>true</bool>
</property>
</action>
<action name="actionDisable">
<property name="text">
<string>Disable</string>
<string>Enabled</string>
</property>
</action>
<action name="actionUninstall">

View File

@@ -52,11 +52,8 @@ engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_en
pluginsTree->header()->resizeSection(0, 170);
pluginsTree->header()->resizeSection(1, 220);
pluginsTree->hideColumn(ENGINE_ID);
actionEnable->setIcon(QIcon(QString::fromUtf8(":/Icons/oxygen/button_ok.png")));
actionDisable->setIcon(QIcon(QString::fromUtf8(":/Icons/oxygen/button_cancel.png")));
actionUninstall->setIcon(QIcon(QString::fromUtf8(":/Icons/oxygen/list-remove.png")));
connect(actionEnable, SIGNAL(triggered()), this, SLOT(enableSelection()));
connect(actionDisable, SIGNAL(triggered()), this, SLOT(disableSelection()));
actionUninstall->setIcon(misc::getIcon("list-remove"));
connect(actionEnable, SIGNAL(toggled(bool)), this, SLOT(enableSelection(bool)));
connect(pluginsTree, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayContextMenu(const QPoint&)));
downloader = new downloadThread(this);
connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
@@ -132,20 +129,10 @@ void engineSelectDlg::displayContextMenu(const QPoint&) {
QMenu myContextMenu(this);
// Enable/disable pause/start action given the DL state
QList<QTreeWidgetItem *> items = pluginsTree->selectedItems();
bool has_enable = false, has_disable = false;
QTreeWidgetItem *item;
foreach(item, items) {
QString id = item->text(ENGINE_ID);
if(supported_engines->value(id)->isEnabled() && !has_disable) {
myContextMenu.addAction(actionDisable);
has_disable = true;
}
if(!supported_engines->value(id)->isEnabled() && !has_enable) {
myContextMenu.addAction(actionEnable);
has_enable = true;
}
if(has_enable && has_disable) break;
}
if(items.isEmpty()) return;
QString first_id = items.first()->text(ENGINE_ID);
actionEnable->setChecked(supported_engines->value(first_id)->isEnabled());
myContextMenu.addAction(actionEnable);
myContextMenu.addSeparator();
myContextMenu.addAction(actionUninstall);
myContextMenu.exec(QCursor::pos());
@@ -194,29 +181,21 @@ void engineSelectDlg::on_actionUninstall_triggered() {
QMessageBox::information(0, tr("Uninstall success"), tr("All selected plugins were uninstalled successfully"));
}
void engineSelectDlg::enableSelection() {
void engineSelectDlg::enableSelection(bool enable) {
QList<QTreeWidgetItem *> items = pluginsTree->selectedItems();
QTreeWidgetItem *item;
foreach(item, items) {
int index = pluginsTree->indexOfTopLevelItem(item);
Q_ASSERT(index != -1);
QString id = item->text(ENGINE_ID);
supported_engines->value(id)->setEnabled(true);
item->setText(ENGINE_STATE, tr("Yes"));
setRowColor(index, "green");
}
}
void engineSelectDlg::disableSelection() {
QList<QTreeWidgetItem *> items = pluginsTree->selectedItems();
QTreeWidgetItem *item;
foreach(item, items) {
int index = pluginsTree->indexOfTopLevelItem(item);
Q_ASSERT(index != -1);
QString id = item->text(ENGINE_ID);
supported_engines->value(id)->setEnabled(false);
item->setText(ENGINE_STATE, tr("No"));
setRowColor(index, "red");
supported_engines->value(id)->setEnabled(enable);
if(enable) {
item->setText(ENGINE_STATE, tr("Yes"));
setRowColor(index, "green");
} else {
item->setText(ENGINE_STATE, tr("No"));
setRowColor(index, "red");
}
}
}

View File

@@ -66,8 +66,7 @@ class engineSelectDlg : public QDialog, public Ui::engineSelect{
void processDownloadedFile(QString url, QString filePath);
void handleDownloadFailure(QString url, QString reason);
void displayContextMenu(const QPoint& pos);
void enableSelection();
void disableSelection();
void enableSelection(bool enable);
void on_actionUninstall_triggered();
void on_updateButton_clicked();
void on_installButton_clicked();

View File

@@ -61,16 +61,20 @@
/*SEARCH ENGINE START*/
SearchEngine::SearchEngine(MainWindow *parent) : QWidget(parent), mp_mainWindow(parent) {
setupUi(this);
// Icons
search_button->setIcon(misc::getIcon("edit-find"));
download_button->setIcon(misc::getIcon("download"));
enginesButton->setIcon(misc::getIcon("preferences-system-network"));
// new qCompleter to the search pattern
startSearchHistory();
createCompleter();
#if QT_VERSION >= 0x040500
#if (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
tabWidget->setTabsClosable(true);
connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
#else
// Add close tab button
closeTab_button = new QPushButton();
closeTab_button->setIcon(QIcon(QString::fromUtf8(":/Icons/oxygen/tab-close.png")));
closeTab_button->setIcon(misc::getIcon("tab-close"));
closeTab_button->setFlat(true);
tabWidget->setCornerWidget(closeTab_button);
connect(closeTab_button, SIGNAL(clicked()), this, SLOT(closeTab_button_clicked()));
@@ -199,11 +203,11 @@ SearchEngine::~SearchEngine(){
void SearchEngine::displayPatternContextMenu(QPoint) {
QMenu myMenu(this);
QAction cutAct(QIcon(":/Icons/oxygen/edit-cut.png"), tr("Cut"), &myMenu);
QAction copyAct(QIcon(":/Icons/oxygen/edit-copy.png"), tr("Copy"), &myMenu);
QAction pasteAct(QIcon(":/Icons/oxygen/edit-paste.png"), tr("Paste"), &myMenu);
QAction clearAct(QIcon(":/Icons/oxygen/edit_clear.png"), tr("Clear field"), &myMenu);
QAction clearHistoryAct(QIcon(":/Icons/oxygen/edit-clear.png"), tr("Clear completion history"), &myMenu);
QAction cutAct(misc::getIcon("edit-cut"), tr("Cut"), &myMenu);
QAction copyAct(misc::getIcon("edit-copy"), tr("Copy"), &myMenu);
QAction pasteAct(misc::getIcon("edit-paste"), tr("Paste"), &myMenu);
QAction clearAct(misc::getIcon("edit-clear"), tr("Clear field"), &myMenu);
QAction clearHistoryAct(misc::getIcon("edit-clear-history"), tr("Clear completion history"), &myMenu);
bool hasCopyAct = false;
if(search_pattern->hasSelectedText()) {
myMenu.addAction(&cutAct);