File indexing completed on 2024-04-21 16:33:40

0001 /*
0002  * Copyright 2010-2012 Bart Kroon <bart@tarmack.eu>
0003  * Copyright 2012, 2013 Martin Sandsmark <martin.sandsmark@kde.org>
0004  * 
0005  * Redistribution and use in source and binary forms, with or without
0006  * modification, are permitted provided that the following conditions
0007  * are met:
0008  * 
0009  * 1. Redistributions of source code must retain the above copyright
0010  *   notice, this list of conditions and the following disclaimer.
0011  * 2. Redistributions in binary form must reproduce the above copyright
0012  *   notice, this list of conditions and the following disclaimer in the
0013  *   documentation and/or other materials provided with the distribution.
0014  * 
0015  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0016  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0017  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0018  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0019  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0020  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0021  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0022  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0023  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0024  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0025  */
0026 
0027 #ifndef Mangonel_H
0028 #define Mangonel_H
0029 
0030 #include "Provider.h"
0031 
0032 #include <QAction>
0033 #include <QObject>
0034 #include <QPointer>
0035 
0036 class QGlobalShortcut;
0037 
0038 class Mangonel : public QObject
0039 {
0040     Q_OBJECT
0041     Q_PROPERTY(QStringList history READ history NOTIFY historyChanged)
0042 
0043 public:
0044     static Mangonel *instance();
0045 
0046     const QStringList &history() { return m_history; }
0047 
0048 public slots:
0049     QList<QObject*> setQuery(const QString &query);
0050     void launch(QObject *selectedObject);
0051     void showConfig();
0052     void configureNotifications();
0053     QString selectionClipboardContent();
0054     void addToHistory(const QString &text);
0055 
0056 signals:
0057     void appsChanged();
0058     void triggered();
0059     void historyChanged();
0060 
0061 private slots:
0062     void setHotkey(const QKeySequence& hotkey);
0063 private:
0064     Mangonel();
0065     void storePopularities();
0066 
0067     QAction* m_actionShow;
0068     QStringList m_history;
0069     QHash<QString, Provider*> m_providers;
0070     QPointer<QGlobalShortcut> m_shortcut;
0071 
0072     QHash<QString, Popularity> m_popularities;
0073 
0074     int m_current = -1;
0075     QString m_currentQuery;
0076 };
0077 
0078 #endif // Mangonel_H
0079 // kate: indent-mode cstyle; space-indent on; indent-width 4;