示例#1
0
            protected override void MouseMoveEvent(Qyoto.QGraphicsSceneMouseEvent evnt)
            {
                var app = ((QApplication)QApplication.Instance());

                if (new QLineF(evnt.ScreenPos(), evnt.ButtonDownScreenPos(Qt.MouseButton.LeftButton))
                    .Length() < app.StartDragDistance)
                {
                    return;
                }

                if (m_Grid.Model is IAvatarGridEditableModel <T> )
                {
                    QDrag     drag = new QDrag(evnt.Widget());
                    QMimeData mime = new RosterItemMimeData <T>(this, m_Grid);
                    drag.SetMimeData(mime);

                    QPixmap pixmap = new QPixmap(m_Grid.IconSize, m_Grid.IconSize);
                    pixmap.Fill(m_Grid.Palette.Color(QPalette.ColorRole.Base));
                    var painter = new QPainter(pixmap);
                    Paint(painter, null, null);
                    painter.End();
                    drag.SetPixmap(pixmap);


                    drag.Exec((uint)Qt.DropAction.MoveAction | (uint)Qt.DropAction.CopyAction | (uint)Qt.DropAction.IgnoreAction);
                }
            }
            protected override void MouseMoveEvent(Qyoto.QGraphicsSceneMouseEvent evnt)
            {
                if (m_LeftButtonDown)
                {
                    if (evnt.Pos().Y() > m_Grid.HeaderHeight)
                    {
                        return;
                    }

                    var app = ((QApplication)QApplication.Instance());
                    if (new QLineF(evnt.ScreenPos(), evnt.ButtonDownScreenPos(Qt.MouseButton.LeftButton))
                        .Length() < app.StartDragDistance)
                    {
                        return;
                    }

                    if (m_Grid.Model is IAvatarGridEditableModel <T> )
                    {
                        QDrag drag = new QDrag(evnt.Widget());
                        drag.SetHotSpot(evnt.Pos().ToPoint());

                        var mime = new RosterItemGroupMimeData(this, m_Grid);
                        drag.SetMimeData(mime);

                        var pixmap = new QPixmap((int)BoundingRect().Width(), m_Grid.HeaderHeight);
                        pixmap.Fill(m_Grid.Palette.Color(QPalette.ColorRole.Base));
                        var painter = new QPainter(pixmap);
                        Paint(painter, null, null);
                        painter.End();
                        drag.SetPixmap(pixmap);

                        drag.Exec();
                    }
                }
            }
示例#3
0
        internal static QIcon ConvertToQIcon(Image image)
        {
            QImage  ms = ConvertToQImage(image);
            QPixmap px = QPixmap.FromImage(ms);

            return(new QIcon(px));
        }
示例#4
0
        protected override void InsertFromMimeData(Qyoto.QMimeData source)
        {
            var cursor = base.TextCursor();

            if (source.HasImage())
            {
                var image     = QPixmap.FromImage((QImage)source.ImageData());
                var document  = base.Document();
                var imageName = Guid.NewGuid().ToString();
                document.AddResource((int)QTextDocument.ResourceType.ImageResource, new QUrl(imageName), image);
                cursor.InsertImage(imageName);
            }
            else if (source.HasUrls())
            {
                var magic = new Magic(true);
                foreach (var url in source.Urls())
                {
                    if (url.Scheme() == "file")
                    {
                        string fileName = url.Path();
                        if (File.Exists(fileName))
                        {
                            string mimeType = magic.Lookup(url.Path());
                            if (mimeType.StartsWith("image/"))
                            {
                                // FIXME: If image is over a certain size, send as file transfer rather
                                // than encoded inline.
                                cursor.InsertHtml(String.Format("<img src=\"{0}\" />", fileName));
                            }
                            else
                            {
                                // FIXME: Generate and insert an image representing a file.
                                Console.WriteLine("File Transfer: " + fileName);
                            }
                        }
                        else
                        {
                            // FIXME: Support "sending" directories?
                            cursor.InsertText(url.ToString());
                        }
                    }
                    else if (url.Scheme() == "http" || url.Scheme() == "https")
                    {
                        cursor.InsertHtml(String.Format("<a href=\"{0}\">{0}</a>", url.ToString()));
                    }
                    else
                    {
                        cursor.InsertText(url.ToString());
                    }
                }
            }
            else
            {
                base.InsertFromMimeData(source);
            }
        }
示例#5
0
        void HandleAvatarUpdated(string jid, string hash)
        {
            if (jid == m_Account.Jid.Bare)
            {
                QApplication.Invoke(delegate {
                    QPixmap pixmap = new QPixmap(36, 36);
                    pixmap.Fill(GlobalColor.transparent);

                    QPainter painter = new QPainter(pixmap);
                    Gui.DrawAvatar(painter, m_AvatarLabel.Width(), m_AvatarLabel.Height(), (QPixmap)AvatarManager.GetAvatar(hash));
                    painter.Dispose();

                    m_AvatarLabel.Pixmap = pixmap;
                });
            }
        }
        private void InitUI()
        {
            //StyleSheet = "QWidget { background-color : #414141 }";

            QPixmap image1 = new QPixmap ("images/periya_kovil.jpeg");
            QPixmap image2 = new QPixmap ("images/western_ghats.jpeg");

            QLabel label1 = new QLabel (this);
            label1.Pixmap = image1;
            label1.Move (20, 20);
            label1.ToolTip = "தஞ்சை பெரிய கோவில் - Tanjore Temple";

            QLabel label2 = new QLabel (this);
            label2.Pixmap = image2;
            label2.ToolTip = "மேற்கு தொடர்ச்சி மலை - Western Ghats";
            label2.Move (320, 20);
        }
示例#7
0
        public AvatarFileEngine(string uri)
        {
            // uri begins with "avatar:/"
            m_AvatarHash = uri.Substring(8);

            QPixmap pixmap = (QPixmap)Synapse.Xmpp.AvatarManager.GetAvatar(m_AvatarHash);

            // FIXME: This doesn't seem very efficient...
            QBuffer buffer = new QBuffer();

            buffer.Open((uint)QIODevice.OpenModeFlag.WriteOnly);
            pixmap.Save(buffer, "PNG");
            buffer.Close();

            m_Buffer = new byte[buffer.Size()];
            Marshal.Copy(buffer.Data().Data().ToIntPtr(), m_Buffer, 0, m_Buffer.Length);
        }
        private void InitUI()
        {
            //StyleSheet = "QWidget { background-color : #414141 }";

            QPixmap image1 = new QPixmap("images/periya_kovil.jpeg");
            QPixmap image2 = new QPixmap("images/western_ghats.jpeg");

            QLabel label1 = new QLabel(this);

            label1.Pixmap = image1;
            label1.Move(20, 20);
            label1.ToolTip = "தஞ்சை பெரிய கோவில் - Tanjore Temple";

            QLabel label2 = new QLabel(this);

            label2.Pixmap  = image2;
            label2.ToolTip = "மேற்கு தொடர்ச்சி மலை - Western Ghats";
            label2.Move(320, 20);
        }
示例#9
0
        private void InitUI()
        {
            StyleSheet = "QWidget {background-color:#414141}";

            QPixmap img1 = new QPixmap ("img1.jpg");
            QPixmap img2 = new QPixmap ("img2.jpg");
            QPixmap img3 = new QPixmap ("img3.jpg");

            QLabel label1 = new QLabel (this);
            label1.Pixmap = img1;
            label1.Move (20, 20);

            QLabel label2 = new QLabel (this);
            label2.Pixmap = img2;
            label2.Move (40	, 160);

            QLabel label3 = new QLabel (this);
            label3.Pixmap = img3;
            label3.Move (170, 50);
        }
示例#10
0
            public override void Paint(Qyoto.QPainter painter, Qyoto.QStyleOptionGraphicsItem option, Qyoto.QWidget widget)
            {
                painter.SetRenderHint(QPainter.RenderHint.Antialiasing, true);
                int iconSize = m_Grid.IconSize;

                // Parent opacity overrides item opacity.
                var parentGroup = (RosterItemGroup)base.Group();

                if (parentGroup == null)                 // This happens while the item is being removed.
                {
                    return;
                }
                if (parentGroup.Opacity != 1)
                {
                    painter.SetOpacity(parentGroup.Opacity);
                }
                else
                {
                    painter.SetOpacity(m_Opacity);
                }

                QPixmap pixmap = (QPixmap)m_Grid.Model.GetImage(m_Item);

                Gui.DrawAvatar(painter, iconSize, iconSize, pixmap);

                if (IsHover)
                {
                    // FIXME: Do something?
                }

                if (m_Grid.ListMode)
                {
                    var rect = BoundingRect();
                    var pen  = new QPen();
                    pen.SetBrush(m_Grid.Palette.Text());
                    painter.SetPen(pen);

                    int x = iconSize + m_Grid.IconPadding;
                    painter.DrawText(x, 0, (int)rect.Width() - x, (int)rect.Height(), (int)Qt.TextFlag.TextSingleLine, m_Grid.Model.GetName(m_Item));
                }
            }
示例#11
0
        public static void DrawAvatar(QPainter painter, int width, int height, QPixmap avatarPixmap)
        {
            QPainterPath path = new QPainterPath();

            // Draw a rect without corners.
            path.MoveTo(0, 1);
            path.LineTo(1, 1);
            path.LineTo(1, 0);
            path.LineTo(width - 1, 0);
            path.LineTo(width, 1);
            path.LineTo(width, height - 1);
            path.LineTo(width - 1, height - 1);
            path.LineTo(width - 1, height);
            path.LineTo(1, height);
            path.LineTo(1, height - 1);
            path.LineTo(0, height - 1);
            path.LineTo(0, 1);

            QLinearGradient g1 = new QLinearGradient(0, 0, 0, height);

            g1.SetColorAt(0, new QColor("#888781"));
            g1.SetColorAt(1, new QColor("#abaaa8"));
            QBrush b1 = new QBrush(g1);

            painter.FillPath(path, b1);
            painter.FillRect(1, 1, width - 2, height - 2, new QBrush(Qt.GlobalColor.black));

            // Darken the corners...
            var b2 = new QBrush(new QColor(61, 61, 61, 102));

            painter.FillRect(0, 0, 3, 3, b2);
            painter.FillRect(width - 3, 0, 3, 3, b2);
            painter.FillRect(0, width - 3, 3, 3, b2);
            painter.FillRect(width - 3, width - 3, 3, 3, b2);

            painter.DrawPixmap(2, 2, width - 4, height - 4, avatarPixmap);
        }
示例#12
0
        public TrayIcon(QObject parent) : base(parent)
        {
            m_ShowMainWindowAction           = new QAction("Show Synapse", this);
            m_ShowMainWindowAction.Checkable = true;
            QObject.Connect(m_ShowMainWindowAction,  Qt.SIGNAL("triggered()"), HandleShowMainWindowActionTriggered);

            m_ShowDebugWindowAction           = new QAction("Debug Window", this);
            m_ShowDebugWindowAction.Checkable = true;
            QObject.Connect(m_ShowDebugWindowAction,  Qt.SIGNAL("triggered()"), HandleShowDebugWindowActionTriggered);

            m_Menu = new QMenu();
            m_Menu.AddAction(m_ShowMainWindowAction);
            m_Menu.AddAction(m_ShowDebugWindowAction);
            m_Menu.AddSeparator();
            m_Menu.AddAction(Gui.GlobalActions.NewMessageAction);
            m_Menu.AddAction(Gui.GlobalActions.JoinConferenceAction);
            m_Menu.AddAction(Gui.GlobalActions.ShowBrowserAction);
            m_Menu.AddAction(Gui.GlobalActions.EditProfileAction);
            m_Menu.AddAction(Gui.GlobalActions.ChangeStatusAction);
            m_Menu.AddSeparator();
            m_Menu.AddAction(Gui.GlobalActions.ShowPreferencesAction);
            m_Menu.AddSeparator();
            m_Menu.AddAction(Gui.GlobalActions.AboutAction);
            m_Menu.AddAction(Gui.GlobalActions.SendFeedbackAction);
            m_Menu.AddSeparator();
            m_Menu.AddAction(Gui.GlobalActions.QuitAction);
            QObject.Connect(m_Menu, Qt.SIGNAL("aboutToShow()"), HandleMenuAboutToShow);

            QPixmap pixmap = new QPixmap("resource:/octy-22.png");
            QIcon   icon   = new QIcon(pixmap);

            m_Icon = new QSystemTrayIcon(icon);
            m_Icon.SetContextMenu(m_Menu);

            QObject.Connect <QSystemTrayIcon.ActivationReason>(m_Icon, Qt.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), HandleTrayActivated);
        }
示例#13
0
        public CoverageView(QWidget parent, String fileName) : base(parent)
        {
            SetRootIsDecorated(true);
            AddColumn("Classes");
            AddColumn("Lines Hit");
            AddColumn("Lines Missed");
            AddColumn("Coverage");

            sourceViews = new Hashtable();

            // TODO: Why the cast ?
            SetColumnAlignment(1, (int)Qt.AlignmentFlags.AlignCenter);
            SetColumnAlignment(2, (int)Qt.AlignmentFlags.AlignCenter);
            SetColumnAlignment(3, (int)Qt.AlignmentFlags.AlignCenter);

            QObject.Connect(this, SIGNAL("doubleClicked(QListViewItem)"),
                            this, SLOT("OnDoubleClick(QListViewItem)"));

            QObject.Connect(this,SIGNAL("expanded(QListViewItem)"),
                            this,SLOT("OnExpanded(QListViewItem)"));

            // TODO: This is not supported by current Qt#
            try {
                QObject.Connect(this,SIGNAL("contextMenuRequested(QListViewItem,QPoint,int)"),
                                this,SLOT("OnContextMenu(QListViewItem, QPoint, Int32)"));
            }
            catch (Exception) {
            }

            QPixmap namespaceOpenPixmap   = new QPixmap(namespace_open_xpm);
            QPixmap namespaceClosedPixmap = new QPixmap(namespace_closed_xpm);
            QPixmap classPixmap           = new QPixmap(class_xpm);

            model = new CoverageModel();
            foreach (string filter in DEFAULT_FILTERS)
            {
                model.AddFilter(filter);
            }
            model.ReadFromFile(fileName);

            QListViewItem rootItem = new TreeItem(this,"PROJECT",model);

            rootItem.SetOpen(true);

            Hashtable classes2 = model.Classes;

            namespaces = new Hashtable();

            foreach (string name in classes2.Keys)
            {
                ClassCoverageItem klass = (ClassCoverageItem)classes2 [name];

                if (klass.filtered)
                {
                    continue;
                }

                string        namespace2 = klass.name_space;
                NamespaceItem nsItem     = (NamespaceItem)namespaces [namespace2];
                if (nsItem == null)
                {
                    // Create namespaces
                    String        nsPrefix   = "";
                    QListViewItem parentItem = rootItem;
                    foreach (String nsPart in namespace2.Split('.'))
                    {
                        if (nsPrefix == "")
                        {
                            nsPrefix = nsPart;
                        }
                        else
                        {
                            nsPrefix = nsPrefix + "." + nsPart;
                        }

                        NamespaceCoverageItem nsModel = (NamespaceCoverageItem)model.Namespaces [nsPrefix];
                        if (nsModel.filtered)
                        {
                            break;
                        }

                        nsItem = (NamespaceItem)namespaces [nsPrefix];
                        if (nsItem == null)
                        {
                            nsItem = new NamespaceItem(parentItem,nsPrefix,
                                                       nsModel);
                            nsItem.SetOpen(true);
                            nsItem.SetPixmap(0,namespaceOpenPixmap);
                            namespaces [nsPrefix] = nsItem;
                        }
                        parentItem = nsItem;
                    }
                }

                if (nsItem != null)
                {
                    ClassItem classItem = new ClassItem(nsItem,klass.name,klass);
                    classItem.SetPixmap(0,classPixmap);
                    if (klass.ChildCount > 0)
                    {
                        classItem.SetExpandable(true);
                    }
                }
            }
        }
示例#14
0
        public MainWindow()
        {
            SetupUi();
            base.WindowFlags = (uint)Qt.WindowType.FramelessWindowHint;

            closeButton.icon = new QIcon(new QPixmap("resource:/stock-close_12.png"));
            menuButton.icon  = new QIcon(new QPixmap("resource:/menu-icon.png"));

            // FIXME: Add a global "Application Icon" somewhere that contains multiple sizes.
            QPixmap pixmap = new QPixmap("resource:/octy-22.png");

            base.WindowIcon = new QIcon(pixmap);

            m_NoAccountsStyleSheet = Util.ReadResource("mainwindow-noaccounts.qss");
            m_StyleSheet           = Util.ReadResource("mainwindow.qss");

            containerWidget.SetStyleSheet(m_StyleSheet);

            QVBoxLayout layout = new QVBoxLayout();

            layout.SetContentsMargins(0, 0, 0, 0);
            contentWidget.SetLayout(layout);

            m_RosterWidget = new RosterWidget(contentWidget);
            contentWidget.Layout().AddWidget(m_RosterWidget);

            m_NoAccountsWidget = new NoAccountsWidget(contentWidget);
            contentWidget.Layout().AddWidget(m_NoAccountsWidget);

            // This makes the shortcut work.
            base.AddAction(Gui.GlobalActions.QuitAction);

            m_MainMenu = new QMenu(this);
            m_MainMenu.AddAction(Gui.GlobalActions.NewMessageAction);
            m_MainMenu.AddAction(Gui.GlobalActions.JoinConferenceAction);
            m_MainMenu.AddAction(Gui.GlobalActions.ShowBrowserAction);
            m_MainMenu.AddAction(Gui.GlobalActions.EditProfileAction);
            m_MainMenu.AddAction(Gui.GlobalActions.ChangeStatusAction);
            m_MainMenu.AddSeparator();
            m_MainMenu.AddAction(Gui.GlobalActions.ShowPreferencesAction);
            m_MainMenu.AddSeparator();
            m_MainMenu.AddAction(Gui.GlobalActions.AboutAction);
            m_MainMenu.AddAction(Gui.GlobalActions.SendFeedbackAction);
            m_MainMenu.AddSeparator();
            m_MainMenu.AddAction(Gui.GlobalActions.QuitAction);

            Gui.CenterWidgetOnScreen(this);

            headerLabel.InstallEventFilter(new WindowMover(this));

            AccountService accountService = ServiceManager.Get <AccountService>();

            accountService.AccountAdded   += AddAccount;
            accountService.AccountRemoved += RemoveAccount;

            foreach (Account account in accountService.Accounts)
            {
                AddAccount(account);
            }

            var settingsService = ServiceManager.Get <SettingsService>();

            if (settingsService.Has("MainWindowGeometry"))
            {
                var geometry = settingsService.Get <byte[]>("MainWindowGeometry");
                base.RestoreGeometry(QByteArrayConverter.FromArray(geometry));
            }
        }
示例#15
0
 public ImagesWithAbsolutePositionDemo()
 {
     sky1_icon    = media.MediaGfxHelper.Sky1Pixmap;
     sky2_icon    = media.MediaGfxHelper.Sky2Pixmap;
     pancake_icon = media.MediaGfxHelper.PancakePixmap;
 }
示例#16
0
        public CoverageView(QWidget parent, String fileName)
            : base(parent)
        {
            SetRootIsDecorated (true);
            AddColumn ("Classes");
            AddColumn ("Lines Hit");
            AddColumn ("Lines Missed");
            AddColumn ("Coverage");

            sourceViews = new Hashtable ();

            // TODO: Why the cast ?
            SetColumnAlignment (1, (int)Qt.AlignmentFlags.AlignCenter);
            SetColumnAlignment (2, (int)Qt.AlignmentFlags.AlignCenter);
            SetColumnAlignment (3, (int)Qt.AlignmentFlags.AlignCenter);

            QObject.Connect (this, SIGNAL ("doubleClicked(QListViewItem)"),
                         this, SLOT ("OnDoubleClick(QListViewItem)"));

            QObject.Connect (this, SIGNAL ("expanded(QListViewItem)"),
                         this, SLOT ("OnExpanded(QListViewItem)"));

            // TODO: This is not supported by current Qt#
            try {
            QObject.Connect (this, SIGNAL ("contextMenuRequested(QListViewItem,QPoint,int)"),
                             this, SLOT ("OnContextMenu(QListViewItem, QPoint, Int32)"));
            }
            catch (Exception) {
            }

            QPixmap namespaceOpenPixmap = new QPixmap (namespace_open_xpm);
            QPixmap namespaceClosedPixmap = new QPixmap (namespace_closed_xpm);
            QPixmap classPixmap = new QPixmap (class_xpm);

            model = new CoverageModel ();
            foreach (string filter in DEFAULT_FILTERS) {
            model.AddFilter (filter);
            }
            model.ReadFromFile (fileName);

            QListViewItem rootItem = new TreeItem (this, "PROJECT", model);
            rootItem.SetOpen (true);

            Hashtable classes2 = model.Classes;

            namespaces = new Hashtable ();

            foreach (string name in classes2.Keys) {
            ClassCoverageItem klass = (ClassCoverageItem)classes2 [name];

            if (klass.filtered)
                continue;

            string namespace2 = klass.name_space;
            NamespaceItem nsItem = (NamespaceItem)namespaces [namespace2];
            if (nsItem == null) {
                // Create namespaces
                String nsPrefix = "";
                QListViewItem parentItem = rootItem;
                foreach (String nsPart in namespace2.Split ('.')) {
                    if (nsPrefix == "")
                        nsPrefix = nsPart;
                    else
                        nsPrefix = nsPrefix + "." + nsPart;

                    NamespaceCoverageItem nsModel = (NamespaceCoverageItem)model.Namespaces [nsPrefix];
                    if (nsModel.filtered)
                        break;

                    nsItem = (NamespaceItem)namespaces [nsPrefix];
                    if (nsItem == null) {
                        nsItem = new NamespaceItem (parentItem, nsPrefix,
                                                    nsModel);
                        nsItem.SetOpen (true);
                        nsItem.SetPixmap (0, namespaceOpenPixmap);
                        namespaces [nsPrefix] = nsItem;
                    }
                    parentItem = nsItem;
                }
            }

            if (nsItem != null) {
                ClassItem classItem = new ClassItem (nsItem, klass.name, klass);
                classItem.SetPixmap (0, classPixmap);
                if (klass.ChildCount > 0)
                    classItem.SetExpandable (true);
            }
            }
        }